import { h } from 'preact'; import { useState } from 'preact/hooks'; import PropTypes from 'prop-types'; import { articlePropTypes } from '../../common-prop-types'; import { ButtonNew as Button } from '@crayons'; import BookmarkSVG from '@images/small-save.svg'; import BookmarkFilledSVG from '@images/small-save-filled.svg'; export const SaveButton = ({ article, isBookmarked: isBookmarkedProps, onClick, saveable = true, }) => { const [isBookmarked, setIsBookmarked] = useState(isBookmarkedProps); const handleClick = (_e) => { onClick(_e); setIsBookmarked((prevState) => !prevState); }; if (article.class_name === 'Article' && saveable) { return ( ); } return null; }; SaveButton.propTypes = { article: articlePropTypes.isRequired, isBookmarked: PropTypes.bool.isRequired, onClick: PropTypes.func.isRequired, saveable: PropTypes.bool.isRequired, }; SaveButton.displayName = 'SaveButton';