From e7658cbbb58f1b48e52684c65a4eecfb038b0de9 Mon Sep 17 00:00:00 2001 From: Chibuotu Amadi Date: Tue, 2 May 2023 12:54:51 +0100 Subject: [PATCH] feat(app): collapse credentials of unselected stamp in 1-click modal (#1202) * feat(1-click): hide credentials on disabled stamp * feat(1-click): track accordion expansion Co-authored-by: Tim Schultz --------- Co-authored-by: Tim Schultz --- .../RefreshMyStampsModalContentCard.tsx | 44 ++++++++++++++----- app/components/RefreshMyStampsSelector.tsx | 2 +- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/app/components/RefreshMyStampsModalContentCard.tsx b/app/components/RefreshMyStampsModalContentCard.tsx index 546d2e40de..d4cb1acb01 100644 --- a/app/components/RefreshMyStampsModalContentCard.tsx +++ b/app/components/RefreshMyStampsModalContentCard.tsx @@ -1,5 +1,5 @@ // --- React hooks -import { useMemo } from "react"; +import { useMemo, useState, useRef } from "react"; // --- Types import { ValidatedProviderGroup } from "../signer/utils"; @@ -26,6 +26,10 @@ export const RefreshMyStampsModalContentCard = ({ selectedProviders, setSelectedProviders, }: RefreshMyStampsModalCardProps): JSX.Element => { + const [disableExpand, setDisableExpand] = useState(false); + const [accordionExpanded, setAccordionExpanded] = useState(false); + + const accordionButton = useRef(null); const platformProviders = useMemo( () => platformGroups.map(({ providers }) => providers?.map(({ name }) => name)).flat(2), [platformGroups] @@ -39,22 +43,31 @@ export const RefreshMyStampsModalContentCard = ({ return (
- - -
- {currentPlatform?.name} -

{currentPlatform?.name}

+ +
+
+ setAccordionExpanded(!accordionExpanded)} + > + {currentPlatform?.name} +

{currentPlatform?.name}

+
-
+
{ + if (!e.target.checked && accordionExpanded) { + // collapse before disabling accordion + accordionButton.current?.click(); + setAccordionExpanded(false); + } + setDisableExpand(!disableExpand); if (e.target.checked) { setSelectedProviders((selectedProviders || []).concat(platformProviders)); } else { @@ -64,9 +77,16 @@ export const RefreshMyStampsModalContentCard = ({ } }} /> - + { + accordionButton.current?.click(); + }} + />
- +
{provider.title}
-
+