DocSpace-buildtools/packages/asc-web-common/components/FloatingButton/FloatingButton.js

126 lines
3.5 KiB
JavaScript
Raw Normal View History

import React from "react";
import PropTypes from "prop-types";
import styled from "styled-components";
import {
StyledFloatingButtonWrapper,
StyledFloatingButton,
StyledAlertIcon,
StyledCircleWrap,
StyledCircle,
2021-03-10 17:10:09 +00:00
IconBox,
} from "./StyledFloatingButton";
Merge branch 'develop' into feature/workspaces # Conflicts: # packages/asc-web-common/src/components/FilterInput/FilterInput.js # packages/asc-web-common/src/components/FilterInput/sub-components/SortComboBox.js # packages/asc-web-common/src/components/PageLayout/index.js # packages/asc-web-common/src/components/PageLayout/sub-components/article-body.js # packages/asc-web-common/src/components/PageLayout/sub-components/article-header.js # packages/asc-web-common/src/components/PageLayout/sub-components/article-main-button.js # packages/asc-web-common/src/components/PageLayout/sub-components/section-body.js # packages/asc-web-common/src/components/PageLayout/sub-components/section-header.js # packages/asc-web-common/src/components/PrivateRoute/PrivateRoute.js # products/ASC.Files/Client/package.json # products/ASC.Files/Client/src/components/Article/Body/TreeFolders.js # products/ASC.Files/Client/src/components/pages/DocEditor/index.js # products/ASC.Files/Client/src/components/pages/Home/Section/Filter/index.js # products/ASC.Files/Client/src/components/panels/OperationsPanel/index.js # products/ASC.Files/Client/src/components/panels/SharingPanel/SharingRow.js # products/ASC.Files/Client/src/components/panels/SharingPanel/index.js # products/ASC.Files/Client/src/index.js # products/ASC.Files/Client/src/store/files/actions.js # products/ASC.Files/Client/yarn.lock # products/ASC.People/Client/package.json # products/ASC.People/Client/src/components/pages/Home/Section/Body/index.js # products/ASC.People/Client/src/components/pages/ProfileAction/Section/Body/FormFields/ContactField.js # products/ASC.People/Client/src/components/pages/ProfileAction/Section/Body/FormFields/DateField.js # products/ASC.People/Client/src/components/pages/ProfileAction/Section/Body/FormFields/EmailField.js # products/ASC.People/Client/src/components/pages/ProfileAction/Section/Body/FormFields/RadioField.js # products/ASC.People/Client/src/components/pages/ProfileAction/Section/Body/FormFields/TextChangeField.js # products/ASC.People/Client/src/components/pages/ProfileAction/Section/Body/FormFields/TextField.js # products/ASC.People/Client/src/index.js # products/ASC.People/Client/yarn.lock # web/ASC.Web.Client/package.json # web/ASC.Web.Client/src/App.js # web/ASC.Web.Client/src/components/pages/Confirm/index.js # web/ASC.Web.Client/src/components/pages/Confirm/sub-components/activateEmail.js # web/ASC.Web.Client/src/components/pages/Confirm/sub-components/changeEmail.js # web/ASC.Web.Client/src/components/pages/Confirm/sub-components/changeOwner.js # web/ASC.Web.Client/src/helpers/confirmRoute.js # web/ASC.Web.Client/src/index.js # web/ASC.Web.Common/package.json # web/ASC.Web.Common/yarn.lock # web/ASC.Web.Components/package.json # web/ASC.Web.Components/yarn.lock # web/ASC.Web.Login/src/LoginContent.jsx # web/ASC.Web.Login/src/sub-components/register-container.js # yarn.lock
2020-12-15 15:40:27 +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";
import CloseIcon from "../../../../public/images/close-icon.react.svg";
const StyledButtonAlertIcon = styled(ButtonAlertIcon)`
${commonIconsStyles}
`;
2020-11-16 11:47:30 +00:00
const FloatingButton = ({ id, className, style, ...rest }) => {
const {
icon,
alert,
percent,
onClick,
color,
clearPrimaryProgressData,
} = rest;
const onProgressClear = () => {
clearPrimaryProgressData();
};
2020-11-16 11:47:30 +00:00
return (
<StyledFloatingButtonWrapper>
<StyledCircleWrap
color={color}
id={id}
className={`${className} not-selectable`}
style={style}
icon={icon}
onClick={onClick}
>
<StyledCircle
displayProgress={icon != "minus" && percent !== 100}
percent={percent}
>
<div className="circle__mask circle__full">
<div className="circle__fill"></div>
</div>
<div className="circle__mask">
<div className="circle__fill"></div>
</div>
<StyledFloatingButton className="circle__background" color={color}>
<IconBox>
{icon == "upload" ? (
<ButtonUploadIcon />
) : icon == "file" ? (
<ButtonFileIcon />
) : icon == "trash" ? (
<ButtonTrashIcon />
) : icon == "move" ? (
<ButtonMoveIcon />
) : icon == "plus" ? (
<ButtonPlusIcon />
) : icon == "minus" ? (
<ButtonMinusIcon />
) : (
<ButtonDuplicateIcon />
)}
</IconBox>
<StyledAlertIcon>
{alert ? <StyledButtonAlertIcon size="medium" /> : <></>}
</StyledAlertIcon>
</StyledFloatingButton>
</StyledCircle>
</StyledCircleWrap>
{percent === 100 && (
<CloseIcon
className="layout-progress-bar_close-icon"
onClick={onProgressClear}
/>
)}
</StyledFloatingButtonWrapper>
2020-11-16 11:47:30 +00:00
);
};
FloatingButton.propTypes = {
id: PropTypes.string,
className: PropTypes.string,
style: PropTypes.object,
icon: PropTypes.oneOf([
"upload",
"file",
"trash",
"move",
"duplicate",
"plus",
"minus",
]),
2020-11-16 11:47:30 +00:00
alert: PropTypes.bool,
percent: PropTypes.number,
2021-01-19 11:14:15 +00:00
onClick: PropTypes.func,
color: PropTypes.string,
2020-11-16 11:47:30 +00:00
};
FloatingButton.defaultProps = {
id: undefined,
className: undefined,
style: undefined,
icon: "upload",
2020-11-16 11:47:30 +00:00
alert: false,
percent: 0,
2020-11-16 11:47:30 +00:00
};
export default FloatingButton;