2022-01-20 15:29:09 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import styled from 'styled-components';
|
2021-02-20 14:54:12 +00:00
|
|
|
|
2020-11-18 14:09:48 +00:00
|
|
|
import {
|
|
|
|
StyledFloatingButton,
|
|
|
|
StyledAlertIcon,
|
|
|
|
StyledCircleWrap,
|
|
|
|
StyledCircle,
|
2021-03-10 17:10:09 +00:00
|
|
|
IconBox,
|
2022-01-20 15:29:09 +00:00
|
|
|
} from './StyledFloatingButton';
|
2020-12-15 15:40:27 +00:00
|
|
|
|
2022-01-20 15:29:09 +00:00
|
|
|
import ButtonUploadIcon from '../../../../public/images/button.upload.react.svg';
|
|
|
|
import ButtonFileIcon from '../../../../public/images/button.file.react.svg';
|
|
|
|
import ButtonTrashIcon from '../../../../public/images/button.trash.react.svg';
|
|
|
|
import ButtonMoveIcon from '../../../../public/images/button.move.react.svg';
|
|
|
|
import ButtonDuplicateIcon from '../../../../public/images/button.duplicate.react.svg';
|
|
|
|
import ButtonAlertIcon from '../../../../public/images/button.alert.react.svg';
|
|
|
|
import commonIconsStyles from '@appserver/components/utils/common-icons-style';
|
|
|
|
import ButtonPlusIcon from '../../../../public/images/actions.button.plus.react.svg';
|
|
|
|
import ButtonMinusIcon from '../../../../public/images/actions.button.minus.react.svg';
|
2021-02-20 14:54:12 +00:00
|
|
|
|
|
|
|
const StyledButtonAlertIcon = styled(ButtonAlertIcon)`
|
|
|
|
${commonIconsStyles}
|
|
|
|
`;
|
2020-11-16 11:47:30 +00:00
|
|
|
const FloatingButton = ({ id, className, style, ...rest }) => {
|
2021-11-17 12:37:01 +00:00
|
|
|
const { icon, alert, percent, onClick, color } = rest;
|
2020-11-16 11:47:30 +00:00
|
|
|
|
|
|
|
return (
|
2021-01-19 11:14:15 +00:00
|
|
|
<StyledCircleWrap
|
|
|
|
id={id}
|
2021-06-09 10:28:22 +00:00
|
|
|
className={`${className} not-selectable`}
|
2021-01-19 11:14:15 +00:00
|
|
|
style={style}
|
|
|
|
icon={icon}
|
2022-01-20 15:29:09 +00:00
|
|
|
onClick={onClick}>
|
2021-06-11 13:56:43 +00:00
|
|
|
<StyledCircle percent={percent}>
|
2020-11-18 14:14:47 +00:00
|
|
|
<div className="circle__mask circle__full">
|
|
|
|
<div className="circle__fill"></div>
|
2020-11-16 15:49:54 +00:00
|
|
|
</div>
|
2020-11-18 14:14:47 +00:00
|
|
|
<div className="circle__mask">
|
|
|
|
<div className="circle__fill"></div>
|
2020-11-18 14:09:48 +00:00
|
|
|
</div>
|
|
|
|
|
2022-01-20 15:29:09 +00:00
|
|
|
<StyledFloatingButton className="circle__background" color={color}>
|
2021-03-10 17:10:09 +00:00
|
|
|
<IconBox>
|
2022-01-20 15:29:09 +00:00
|
|
|
{icon == 'upload' ? (
|
2021-03-10 17:10:09 +00:00
|
|
|
<ButtonUploadIcon />
|
2022-01-20 15:29:09 +00:00
|
|
|
) : icon == 'file' ? (
|
2021-03-10 17:10:09 +00:00
|
|
|
<ButtonFileIcon />
|
2022-01-20 15:29:09 +00:00
|
|
|
) : icon == 'trash' ? (
|
2021-03-10 17:10:09 +00:00
|
|
|
<ButtonTrashIcon />
|
2022-01-20 15:29:09 +00:00
|
|
|
) : icon == 'move' ? (
|
2021-03-10 17:10:09 +00:00
|
|
|
<ButtonMoveIcon />
|
2022-01-20 15:29:09 +00:00
|
|
|
) : icon == 'plus' ? (
|
2021-11-02 08:30:33 +00:00
|
|
|
<ButtonPlusIcon />
|
2022-01-20 15:29:09 +00:00
|
|
|
) : icon == 'minus' ? (
|
2021-11-02 08:30:33 +00:00
|
|
|
<ButtonMinusIcon />
|
2021-03-10 17:10:09 +00:00
|
|
|
) : (
|
|
|
|
<ButtonDuplicateIcon />
|
|
|
|
)}
|
|
|
|
</IconBox>
|
2020-11-18 14:09:48 +00:00
|
|
|
<StyledAlertIcon>
|
2021-02-20 14:54:12 +00:00
|
|
|
{alert ? <StyledButtonAlertIcon size="medium" /> : <></>}
|
2020-11-18 14:09:48 +00:00
|
|
|
</StyledAlertIcon>
|
|
|
|
</StyledFloatingButton>
|
|
|
|
</StyledCircle>
|
|
|
|
</StyledCircleWrap>
|
2020-11-16 11:47:30 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
FloatingButton.propTypes = {
|
|
|
|
id: PropTypes.string,
|
|
|
|
className: PropTypes.string,
|
|
|
|
style: PropTypes.object,
|
2022-01-20 15:29:09 +00:00
|
|
|
icon: PropTypes.oneOf(['upload', 'file', 'trash', 'move', 'duplicate', 'plus', 'minus']),
|
2020-11-16 11:47:30 +00:00
|
|
|
alert: PropTypes.bool,
|
2020-11-16 15:49:54 +00:00
|
|
|
percent: PropTypes.number,
|
2021-01-19 11:14:15 +00:00
|
|
|
onClick: PropTypes.func,
|
2021-11-17 12:37:01 +00:00
|
|
|
color: PropTypes.string,
|
2020-11-16 11:47:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
FloatingButton.defaultProps = {
|
|
|
|
id: undefined,
|
|
|
|
className: undefined,
|
|
|
|
style: undefined,
|
2022-01-20 15:29:09 +00:00
|
|
|
icon: 'upload',
|
2020-11-16 11:47:30 +00:00
|
|
|
alert: false,
|
2020-11-16 15:49:54 +00:00
|
|
|
percent: 0,
|
2020-11-16 11:47:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default FloatingButton;
|