From a16deeac53c65c267b4cef2f1680bb071c5226b7 Mon Sep 17 00:00:00 2001 From: lukewalczak Date: Wed, 23 Apr 2025 09:48:19 +0200 Subject: [PATCH 1/2] feat: add container style prop --- src/components/List/ListItem.tsx | 11 ++- src/components/Menu/MenuItem.tsx | 14 ++- .../__snapshots__/ListAccordion.test.tsx.snap | 13 ++- .../__snapshots__/ListItem.test.tsx.snap | 91 ++++++++++++------- .../__snapshots__/ListSection.test.tsx.snap | 78 ++++++++++------ .../__snapshots__/Menu.test.tsx.snap | 36 +++++--- .../__snapshots__/MenuItem.test.tsx.snap | 45 ++++++--- 7 files changed, 187 insertions(+), 101 deletions(-) diff --git a/src/components/List/ListItem.tsx b/src/components/List/ListItem.tsx index 4fbfcc0cb2..c6d9b64853 100644 --- a/src/components/List/ListItem.tsx +++ b/src/components/List/ListItem.tsx @@ -63,11 +63,15 @@ export type Props = $RemoveChildren & { */ theme?: ThemeProp; /** - * Style that is passed to the wrapping TouchableRipple element. + * Style that is passed to the root TouchableRipple container. */ style?: StyleProp; /** - * Style that is passed to the container wrapping title and descripton. + * Style that is passed to the outermost container that wraps the entire content, including icons and text. + */ + containerStyle?: StyleProp; + /** + * Style that is passed to the content container, which wraps the title and description. */ contentStyle?: StyleProp; /** @@ -144,6 +148,7 @@ const ListItem = ( onPress, theme: themeOverrides, style, + containerStyle, contentStyle, titleStyle, titleNumberOfLines = 1, @@ -238,7 +243,7 @@ const ListItem = ( theme={theme} testID={testID} > - + {left ? left({ color: descriptionColor, diff --git a/src/components/Menu/MenuItem.tsx b/src/components/Menu/MenuItem.tsx index 08efb22808..89b962d637 100644 --- a/src/components/Menu/MenuItem.tsx +++ b/src/components/Menu/MenuItem.tsx @@ -64,10 +64,21 @@ export type Props = { */ titleMaxFontSizeMultiplier?: number; /** + * Style that is passed to the root TouchableRipple container. * @optional */ style?: StyleProp; + /** + * Style that is passed to the outermost container that wraps the entire content, including icons and text. + */ + containerStyle?: StyleProp; + /** + * Style that is passed to the content container, which wraps the title text. + */ contentStyle?: StyleProp; + /** + * Style that is passed to the Title element. + */ titleStyle?: StyleProp; /** * Color of the ripple effect. @@ -122,6 +133,7 @@ const MenuItem = ({ background, onPress, style, + containerStyle, contentStyle, titleStyle, rippleColor: customRippleColor, @@ -176,7 +188,7 @@ const MenuItem = ({ accessibilityState={newAccessibilityState} rippleColor={rippleColor} > - + {leadingIcon ? ( @@ -710,11 +719,14 @@ exports[`renders list item with left item 1`] = ` > Date: Wed, 30 Apr 2025 10:20:59 +0200 Subject: [PATCH 2/2] feat: add container style prop to list accordion --- src/components/List/ListAccordion.tsx | 20 ++++++- src/components/List/ListItem.tsx | 2 +- src/components/Menu/MenuItem.tsx | 2 +- .../__snapshots__/ListAccordion.test.tsx.snap | 60 ++++++++++++------- 4 files changed, 59 insertions(+), 25 deletions(-) diff --git a/src/components/List/ListAccordion.tsx b/src/components/List/ListAccordion.tsx index 7c85098898..56deb81dcd 100644 --- a/src/components/List/ListAccordion.tsx +++ b/src/components/List/ListAccordion.tsx @@ -72,9 +72,17 @@ export type Props = { */ background?: PressableAndroidRippleConfig; /** - * Style that is passed to the wrapping TouchableRipple element. + * Style that is passed to the root TouchableRipple container. */ style?: StyleProp; + /** + * Style that is passed to the outermost container that wraps the entire content, including left and right items and both title and description. + */ + containerStyle?: StyleProp; + /** + * Style that is passed to the content container, which wraps the title and description. + */ + contentStyle?: StyleProp; /** * Style that is passed to Title element. */ @@ -173,6 +181,8 @@ const ListAccordion = ({ descriptionNumberOfLines = 2, rippleColor: customRippleColor, style, + containerStyle, + contentStyle, id, testID, background, @@ -252,7 +262,7 @@ const ListAccordion = ({ borderless > {left @@ -262,7 +272,11 @@ const ListAccordion = ({ }) : null} & { */ style?: StyleProp; /** - * Style that is passed to the outermost container that wraps the entire content, including icons and text. + * Style that is passed to the outermost container that wraps the entire content, including left and right items and both title and description. */ containerStyle?: StyleProp; /** diff --git a/src/components/Menu/MenuItem.tsx b/src/components/Menu/MenuItem.tsx index 89b962d637..5e5bf05bc5 100644 --- a/src/components/Menu/MenuItem.tsx +++ b/src/components/Menu/MenuItem.tsx @@ -69,7 +69,7 @@ export type Props = { */ style?: StyleProp; /** - * Style that is passed to the outermost container that wraps the entire content, including icons and text. + * Style that is passed to the outermost container that wraps the entire content, including leading and trailing icons and title text. */ containerStyle?: StyleProp; /** diff --git a/src/components/__tests__/__snapshots__/ListAccordion.test.tsx.snap b/src/components/__tests__/__snapshots__/ListAccordion.test.tsx.snap index 198b0774fd..12d8d5cbb9 100644 --- a/src/components/__tests__/__snapshots__/ListAccordion.test.tsx.snap +++ b/src/components/__tests__/__snapshots__/ListAccordion.test.tsx.snap @@ -58,10 +58,13 @@ exports[`renders expanded accordion 1`] = ` @@ -326,10 +330,13 @@ exports[`renders list accordion with children 1`] = ` @@ -543,10 +551,13 @@ exports[`renders list accordion with custom title and description styles 1`] = ` @@ -746,10 +758,13 @@ exports[`renders list accordion with left items 1`] = ` @@ -963,10 +979,13 @@ exports[`renders multiline list accordion 1`] = `