import { Editor } from '@tiptap/react' import React, { FC, useMemo, PropsWithChildren } from 'react' import { styled } from '@styled-components' import { Text, TextProps } from '../../../atoms/text/index.js' import * as EditorIcons from '../icons/index.js' interface MenuButtonProps { editor: Editor name: string onClick: () => void icon?: string attributes?: Record children?: any } const StyledText: any = styled(Text)>` cursor: pointer; color: ${({ theme }) => theme.colors.grey80}; & svg path { fill: ${({ theme }) => theme.colors.grey80}; } ` const MenuButton: FC = (props) => { const { name, editor, onClick, icon, attributes, children } = props const isActive = useMemo( () => (editor.isActive(attributes || name) ? 'active' : ''), [name, attributes], ) // Using icons from: https://github.com/Keyamoon/IcoMoon-Free const Icon = icon ? EditorIcons[icon] : null return ( {Icon ? : name} {children} ) } export default MenuButton