UNPKG

@chayns-components/core

Version:

A set of beautiful React components for developing your own applications with chayns.

39 lines 1.27 kB
import React from 'react'; import SharingContextMenu from '../sharing-context-menu/SharingContextMenu'; import { StyledSharingButtonContainer } from './SharingButton.styles'; import Button from '../button/Button'; const SharingButton = ({ link, alignment, container, children, isDisabled, shouldEnableKeyboardHighlighting }) => { const contextMenuRef = React.useRef(null); const [isButtonDisabled, setIsButtonDisabled] = React.useState(false); const handleButtonClick = () => { contextMenuRef.current?.show(); }; const handleOnShow = () => { setIsButtonDisabled(true); }; const handleOnHide = () => { setIsButtonDisabled(false); }; return /*#__PURE__*/React.createElement(StyledSharingButtonContainer, null, /*#__PURE__*/React.createElement(SharingContextMenu, { link: link, alignment: alignment, container: container, ref: contextMenuRef, shouldDisableClick: true, onShow: handleOnShow, onHide: handleOnHide }, /*#__PURE__*/React.createElement(Button, { onClick: handleButtonClick, isDisabled: isButtonDisabled || isDisabled, shouldEnableKeyboardHighlighting: shouldEnableKeyboardHighlighting }, children))); }; export default SharingButton; //# sourceMappingURL=SharingButton.js.map