/* eslint-disable jsx-a11y/no-static-element-interactions */ import React from 'react'; import { cssClasses } from '@douyinfe/semi-foundation/floatButton/constants'; import '@douyinfe/semi-foundation/floatButton/floatButton.scss'; import BaseComponent from '../_base/baseComponent'; import Badge from '../badge'; import cls from 'classnames'; import { FloatButtonProps } from './interface'; const prefixCls = cssClasses.PREFIX; interface FloatButtonState { } export default class FloatButton extends BaseComponent { static defaultProps = { shape: 'round', colorful: false, size: 'default', }; constructor(props: FloatButtonProps) { super(props); } handleClick = (e: React.MouseEvent) => { const { href, target, onClick, disabled } = this.props; if (disabled) { return; } // 如果有 href,执行跳转 if (href) { if (target === '_blank') { window.open(href, '_blank'); } else { window.location.href = href; } } // 如果有 onClick 回调,执行它 if (onClick) { onClick(e); } }; render(): JSX.Element { const { className, style, colorful, size, icon, badge, shape, disabled } = this.props; const body =
{icon}
; return ( // eslint-disable-next-line jsx-a11y/click-events-have-key-events
{badge ? {body} : body}
); } }