From 21b6ad1cbd3cb746f1cf1135e6cfd4519a63bf61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Wed, 26 Apr 2023 23:28:57 +0200 Subject: [PATCH] Add dismiss button instead of menu in fediverse explanation box MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- .../components/ui/accordion/accordion.tsx | 20 ++++++++++++++++++- .../features/public-timeline/index.tsx | 8 +++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/app/soapbox/components/ui/accordion/accordion.tsx b/app/soapbox/components/ui/accordion/accordion.tsx index f83a011be..842032242 100644 --- a/app/soapbox/components/ui/accordion/accordion.tsx +++ b/app/soapbox/components/ui/accordion/accordion.tsx @@ -21,13 +21,16 @@ interface IAccordion { menu?: Menu expanded?: boolean onToggle?: (value: boolean) => void + action?: () => void + actionIcon?: string + actionLabel?: string } /** * Accordion * An accordion is a vertically stacked group of collapsible sections. */ -const Accordion: React.FC = ({ headline, children, menu, expanded = false, onToggle = () => {} }) => { +const Accordion: React.FC = ({ headline, children, menu, expanded = false, onToggle = () => {}, action, actionIcon, actionLabel }) => { const intl = useIntl(); const handleToggle = (e: React.MouseEvent) => { @@ -35,6 +38,13 @@ const Accordion: React.FC = ({ headline, children, menu, expanded = e.preventDefault(); }; + const handleAction = (e: React.MouseEvent) => { + if (!action) return; + + action(); + e.preventDefault(); + }; + return (
+ )} { const explanationBoxExpanded = settings.get('explanationBox'); const showExplanationBox = settings.get('showExplanationBox'); - const explanationBoxMenu = () => { - return [{ text: intl.formatMessage(messages.dismiss), action: dismissExplanationBox }]; - }; - const dismissExplanationBox = () => { dispatch(changeSetting(['showExplanationBox'], false)); }; @@ -66,7 +62,9 @@ const CommunityTimeline = () => { {showExplanationBox &&
} - menu={explanationBoxMenu()} + action={dismissExplanationBox} + actionIcon={require('@tabler/icons/x.svg')} + actionLabel={intl.formatMessage(messages.dismiss)} expanded={explanationBoxExpanded} onToggle={toggleExplanationBox} >