From 5f27be0e846043412d3fc60de6a19b5e1ba5bb22 Mon Sep 17 00:00:00 2001 From: clesausse-pass <187269096+clesausse-pass@users.noreply.github.com> Date: Mon, 3 Feb 2025 11:38:05 +0100 Subject: [PATCH] (PC-33638) refactor(chronicle): use children in ChronicleCard --- .../ChronicleCard/ChronicleCard.stories.tsx | 19 +++++----- .../ChronicleCard/ChronicleCard.tsx | 35 +++---------------- 2 files changed, 14 insertions(+), 40 deletions(-) diff --git a/src/features/chronicle/components/ChronicleCard/ChronicleCard.stories.tsx b/src/features/chronicle/components/ChronicleCard/ChronicleCard.stories.tsx index c6b0b3b663e..9e306d8ef45 100644 --- a/src/features/chronicle/components/ChronicleCard/ChronicleCard.stories.tsx +++ b/src/features/chronicle/components/ChronicleCard/ChronicleCard.stories.tsx @@ -1,20 +1,14 @@ -import { NavigationContainer } from '@react-navigation/native' import { ComponentMeta } from '@storybook/react' import React from 'react' +import { View } from 'react-native' import { ChronicleCard } from 'features/chronicle/components/ChronicleCard/ChronicleCard' +import { ButtonTertiaryBlack } from 'ui/components/buttons/ButtonTertiaryBlack' import { VariantsTemplate, type Variants, type VariantsStory } from 'ui/storybook/VariantsTemplate' const meta: ComponentMeta = { title: 'ui/ChronicleCard', component: ChronicleCard, - decorators: [ - (Story) => ( - - - - ), - ], } export default meta @@ -34,7 +28,14 @@ const variantConfig: Variants = [ }, { label: 'ChronicleCard with see more button', - props: { ...baseProps, shouldShowSeeMoreButton: true, navigateTo: { screen: 'Chronicles' } }, + props: { + ...baseProps, + children: ( + + + + ), + }, }, ] diff --git a/src/features/chronicle/components/ChronicleCard/ChronicleCard.tsx b/src/features/chronicle/components/ChronicleCard/ChronicleCard.tsx index 577c7cf663c..1992fe36043 100644 --- a/src/features/chronicle/components/ChronicleCard/ChronicleCard.tsx +++ b/src/features/chronicle/components/ChronicleCard/ChronicleCard.tsx @@ -1,26 +1,18 @@ -import React, { FunctionComponent } from 'react' -import { View } from 'react-native' +import React, { FunctionComponent, PropsWithChildren } from 'react' import styled from 'styled-components/native' import { ChronicleCardData } from 'features/chronicle/type' -import { ButtonTertiaryBlack } from 'ui/components/buttons/ButtonTertiaryBlack' -import { styledButton } from 'ui/components/buttons/styledButton' import { InfoHeader } from 'ui/components/InfoHeader/InfoHeader' import { Separator } from 'ui/components/Separator' -import { InternalTouchableLink } from 'ui/components/touchableLink/InternalTouchableLink' -import { InternalNavigationProps } from 'ui/components/touchableLink/types' import { ViewGap } from 'ui/components/ViewGap/ViewGap' import { BookClubCertification } from 'ui/svg/BookClubCertification' -import { PlainMore } from 'ui/svg/icons/PlainMore' import { TypoDS, getShadow, getSpacing } from 'ui/theme' const CHRONICLE_THUMBNAIL_SIZE = getSpacing(14) type Props = ChronicleCardData & { cardWidth?: number - shouldShowSeeMoreButton?: boolean - navigateTo?: InternalNavigationProps['navigateTo'] -} +} & PropsWithChildren export const ChronicleCard: FunctionComponent = ({ id, @@ -29,8 +21,7 @@ export const ChronicleCard: FunctionComponent = ({ description, date, cardWidth, - shouldShowSeeMoreButton, - navigateTo, + children, }) => { return ( @@ -44,15 +35,7 @@ export const ChronicleCard: FunctionComponent = ({ {description} {date} - {shouldShowSeeMoreButton && navigateTo ? ( - - - - ) : null} + {children} ) @@ -88,13 +71,3 @@ const PublicationDate = styled(TypoDS.BodyAccentXs)(({ theme }) => ({ color: theme.colors.greyDark, alignSelf: 'center', })) - -const StyledPlainMore = styled(PlainMore).attrs(({ theme }) => ({ - size: theme.icons.sizes.extraSmall, -}))`` - -const StyledButtonTertiaryBlack = styledButton(ButtonTertiaryBlack).attrs({ - icon: StyledPlainMore, - iconPosition: 'right', - buttonHeight: 'extraSmall', -})``