From a1cfb0385ac4247dabe60f917d91b338a50338da Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Thu, 13 May 2021 18:20:47 +0200 Subject: [PATCH] Move accordion children in prop --- .../Animations/AnimatedAccordion.tsx | 9 +++---- src/components/Lists/Clubs/ClubListHeader.tsx | 17 +++++++------ .../DashboardEdit/DashboardEditAccordion.tsx | 23 +++++++++-------- .../Lists/PlanexGroups/GroupListAccordion.tsx | 25 ++++++++++--------- 4 files changed, 39 insertions(+), 35 deletions(-) diff --git a/src/components/Animations/AnimatedAccordion.tsx b/src/components/Animations/AnimatedAccordion.tsx index 3d3efa1..fae08a3 100644 --- a/src/components/Animations/AnimatedAccordion.tsx +++ b/src/components/Animations/AnimatedAccordion.tsx @@ -38,7 +38,7 @@ type PropsType = { opened?: boolean; unmountWhenCollapsed?: boolean; enabled?: boolean; - children?: React.ReactNode; + renderItem: () => React.ReactNode; }; function AnimatedAccordion(props: PropsType) { @@ -96,6 +96,8 @@ function AnimatedAccordion(props: PropsType) { const toggleAccordion = () => setExpanded(!expanded); + const renderChildren = + !props.unmountWhenCollapsed || (props.unmountWhenCollapsed && expanded); return ( {enabled ? ( - {!props.unmountWhenCollapsed || - (props.unmountWhenCollapsed && expanded) - ? props.children - : null} + {renderChildren ? props.renderItem() : null} ) : null} diff --git a/src/components/Lists/Clubs/ClubListHeader.tsx b/src/components/Lists/Clubs/ClubListHeader.tsx index f7cec65..7ef5bd6 100644 --- a/src/components/Lists/Clubs/ClubListHeader.tsx +++ b/src/components/Lists/Clubs/ClubListHeader.tsx @@ -94,13 +94,16 @@ function ClubListHeader(props: PropsType) { icon="star" /> )} - opened - > - - {i18n.t('screens.clubs.categoriesFilterMessage')} - - {getCategoriesRender()} - + opened={true} + renderItem={() => ( + + + {i18n.t('screens.clubs.categoriesFilterMessage')} + + {getCategoriesRender()} + + )} + /> ); } diff --git a/src/components/Lists/DashboardEdit/DashboardEditAccordion.tsx b/src/components/Lists/DashboardEdit/DashboardEditAccordion.tsx index 19d535a..dc04a4d 100644 --- a/src/components/Lists/DashboardEdit/DashboardEditAccordion.tsx +++ b/src/components/Lists/DashboardEdit/DashboardEditAccordion.tsx @@ -84,17 +84,18 @@ function DashboardEditAccordion(props: PropsType) { /> ) } - > - - + renderItem={() => ( + + )} + /> ); } diff --git a/src/components/Lists/PlanexGroups/GroupListAccordion.tsx b/src/components/Lists/PlanexGroups/GroupListAccordion.tsx index a6adf1b..6314ca4 100644 --- a/src/components/Lists/PlanexGroups/GroupListAccordion.tsx +++ b/src/components/Lists/PlanexGroups/GroupListAccordion.tsx @@ -105,18 +105,19 @@ function GroupListAccordion(props: PropsType) { (isFavorite && !isEmptyFavorite) } enabled={!isEmptyFavorite} - > - - + renderItem={() => ( + + )} + /> ); }