import React, { useCallback, useRef } from 'react'; import { UncontrolledPopover } from 'reactstrap'; import classNames from 'classnames'; import Picker from '@emoji-mart/react'; import PropTypes from 'prop-types'; import { gettext } from '../../../utils/constants'; import { data } from './../utils/emoji-utils'; const PageIcon = ({ currentPageConfig, onUpdatePage }) => { const popoverRef = useRef(null); const handleSetIcon = useCallback((emoji) => { onUpdatePage(currentPageConfig.id, { name: currentPageConfig.name, icon: emoji }); setTimeout(() => { popoverRef.current?.toggle(); }, 300); }, [currentPageConfig.id, currentPageConfig.name, onUpdatePage]); const handleIconRemove = useCallback(() => { handleSetIcon(''); }, [handleSetIcon]); return ( <>
{currentPageConfig.icon}
{gettext('Emojis')} {gettext('Remove')}
handleSetIcon(emoji.native)} previewPosition="none" skinTonePosition="none" locale={window.seafile.lang.slice(0, 2)} maxFrequentRows={2} theme="light" />
); }; PageIcon.propTypes = { currentPageConfig: PropTypes.object.isRequired, onUpdatePage: PropTypes.func.isRequired, }; export default PageIcon;