From dc91c6cb588510b7e38687698f280bdfa08e2050 Mon Sep 17 00:00:00 2001 From: Damiano Plebani Date: Mon, 24 Jun 2024 14:47:51 +0200 Subject: [PATCH 01/16] Allow font scaling to most of the typographic styles --- src/components/badge/Badge.tsx | 3 +++ src/components/buttons/ButtonSolid.tsx | 2 -- src/components/typography/ButtonText.tsx | 4 +++- src/components/typography/H1.tsx | 5 ++++- src/components/typography/H2.tsx | 5 ++++- src/components/typography/H3.tsx | 5 ++++- src/components/typography/H4.tsx | 5 ++++- src/components/typography/H5.tsx | 15 ++++++++++----- src/components/typography/H6.tsx | 10 +++++++++- src/components/typography/LabelSmall.tsx | 19 +++++++++++++++---- src/components/typography/LabelSmallAlt.tsx | 5 ++++- src/core/IOStyles.ts | 6 +++++- 12 files changed, 65 insertions(+), 19 deletions(-) diff --git a/src/components/badge/Badge.tsx b/src/components/badge/Badge.tsx index 5c509a63..b69d1c1c 100644 --- a/src/components/badge/Badge.tsx +++ b/src/components/badge/Badge.tsx @@ -5,6 +5,7 @@ import { IOBadgeRadius, IOBadgeVSpacing, IOColors, + IOVisualCostants, useIOExperimentalDesign, useIOTheme } from "../../core"; @@ -179,6 +180,8 @@ export const Badge = ({ text, outline = false, variant, testID }: Badge) => { ( style={IOButtonStyles.label} numberOfLines={1} ellipsizeMode="tail" - allowFontScaling={isExperimental} - maxFontSizeMultiplier={1.3} accessible={false} accessibilityElementsHidden importantForAccessibility="no-hide-descendants" diff --git a/src/components/typography/ButtonText.tsx b/src/components/typography/ButtonText.tsx index a09d738b..4f00582b 100644 --- a/src/components/typography/ButtonText.tsx +++ b/src/components/typography/ButtonText.tsx @@ -2,7 +2,7 @@ import React from "react"; import { View } from "react-native"; import { IOColors } from "../../core/IOColors"; import { IOFontFamily, IOFontWeight } from "../../utils/fonts"; -import { useIOExperimentalDesign } from "../../core"; +import { IOVisualCostants, useIOExperimentalDesign } from "../../core"; import { useTypographyFactory } from "./Factory"; import { ExternalTypographyProps, TypographyProps } from "./common"; @@ -34,6 +34,8 @@ export const ButtonText = React.forwardRef( return useTypographyFactory( { ...props, + allowFontScaling: isExperimental, + maxFontSizeMultiplier: IOVisualCostants.maxFontSizeMultiplier, defaultWeight: isExperimental ? buttonTextDefaultWeight : legacyTextDefaultWeight, diff --git a/src/components/typography/H1.tsx b/src/components/typography/H1.tsx index f7c5b3b2..ebb057ba 100644 --- a/src/components/typography/H1.tsx +++ b/src/components/typography/H1.tsx @@ -1,6 +1,6 @@ import React from "react"; import { View } from "react-native"; -import { IOTheme, useIOExperimentalDesign } from "../../core"; +import { IOTheme, IOVisualCostants, useIOExperimentalDesign } from "../../core"; import { FontFamily, IOFontWeight } from "../../utils/fonts"; import { useTypographyFactory } from "./Factory"; import { ExternalTypographyProps, TypographyProps } from "./common"; @@ -33,6 +33,9 @@ export const H1 = React.forwardRef((props, ref) => { return useTypographyFactory( { ...props, + allowFontScaling: isExperimental, + maxFontSizeMultiplier: IOVisualCostants.maxFontSizeMultiplier, + dynamicTypeRamp: "largeTitle" /* iOS only */, defaultWeight: isExperimental ? defaultWeight : legacyDefaultWeight, defaultColor, font: isExperimental ? fontName : legacyFont, diff --git a/src/components/typography/H2.tsx b/src/components/typography/H2.tsx index 6a3e5ec6..3015626e 100644 --- a/src/components/typography/H2.tsx +++ b/src/components/typography/H2.tsx @@ -1,6 +1,6 @@ import React from "react"; import { View } from "react-native"; -import { IOTheme, useIOExperimentalDesign } from "../../core"; +import { IOTheme, IOVisualCostants, useIOExperimentalDesign } from "../../core"; import { FontFamily, IOFontWeight } from "../../utils/fonts"; import { useTypographyFactory } from "./Factory"; import { ExternalTypographyProps, TypographyProps } from "./common"; @@ -33,6 +33,9 @@ export const H2 = React.forwardRef((props, ref) => { return useTypographyFactory( { ...props, + allowFontScaling: isExperimental, + maxFontSizeMultiplier: IOVisualCostants.maxFontSizeMultiplier, + dynamicTypeRamp: "title1" /* iOS only */, defaultWeight: isExperimental ? defaultWeight : legacyDefaultWeight, defaultColor, font: isExperimental ? fontName : legacyFont, diff --git a/src/components/typography/H3.tsx b/src/components/typography/H3.tsx index 1ded44e5..43343d4e 100644 --- a/src/components/typography/H3.tsx +++ b/src/components/typography/H3.tsx @@ -1,6 +1,6 @@ import React from "react"; import { View } from "react-native"; -import { IOTheme, useIOExperimentalDesign } from "../../core"; +import { IOTheme, IOVisualCostants, useIOExperimentalDesign } from "../../core"; import { FontFamily, IOFontWeight } from "../../utils/fonts"; import { useTypographyFactory } from "./Factory"; import { ExternalTypographyProps, TypographyProps } from "./common"; @@ -34,6 +34,9 @@ export const H3 = React.forwardRef((props, ref) => { return useTypographyFactory( { ...props, + allowFontScaling: isExperimental, + maxFontSizeMultiplier: IOVisualCostants.maxFontSizeMultiplier, + dynamicTypeRamp: "title2" /* iOS only */, defaultWeight: isExperimental ? defaultWeight : legacyDefaultWeight, defaultColor: isExperimental ? defaultColor : legacyDefaultColor, font: isExperimental ? fontName : legacyFontName, diff --git a/src/components/typography/H4.tsx b/src/components/typography/H4.tsx index b34eb2c3..7571ceeb 100644 --- a/src/components/typography/H4.tsx +++ b/src/components/typography/H4.tsx @@ -1,6 +1,6 @@ import React from "react"; import { View } from "react-native"; -import { IOTheme, useIOExperimentalDesign } from "../../core"; +import { IOTheme, IOVisualCostants, useIOExperimentalDesign } from "../../core"; import { FontFamily, IOFontWeight } from "../../utils/fonts"; import { useTypographyFactory } from "./Factory"; import { ExternalTypographyProps, TypographyProps } from "./common"; @@ -32,6 +32,9 @@ export const H4 = React.forwardRef((props, ref) => { return useTypographyFactory( { ...props, + allowFontScaling: isExperimental, + maxFontSizeMultiplier: IOVisualCostants.maxFontSizeMultiplier, + dynamicTypeRamp: "title3" /* iOS only */, defaultWeight: isExperimental ? defaultWeight : legacyDefaultWeight, defaultColor: isExperimental ? defaultColor : legacyDefaultColor, font: isExperimental ? font : legacyFontName, diff --git a/src/components/typography/H5.tsx b/src/components/typography/H5.tsx index f061dfda..947f5102 100644 --- a/src/components/typography/H5.tsx +++ b/src/components/typography/H5.tsx @@ -1,6 +1,6 @@ import React from "react"; import { View } from "react-native"; -import { IOTheme } from "../../core"; +import { IOTheme, IOVisualCostants, useIOExperimentalDesign } from "../../core"; import { FontFamily, IOFontWeight } from "../../utils/fonts"; import { useTypographyFactory } from "./Factory"; import { ExternalTypographyProps, TypographyProps } from "./common"; @@ -21,10 +21,15 @@ const defaultWeight: AllowedWeight = "Semibold"; /** * `H5` typographic style */ -export const H5 = React.forwardRef((props, ref) => - useTypographyFactory( +export const H5 = React.forwardRef((props, ref) => { + const { isExperimental } = useIOExperimentalDesign(); + + return useTypographyFactory( { ...props, + allowFontScaling: isExperimental, + maxFontSizeMultiplier: IOVisualCostants.maxFontSizeMultiplier, + dynamicTypeRamp: "subheadline" /* iOS only */, defaultWeight, defaultColor, font, @@ -36,5 +41,5 @@ export const H5 = React.forwardRef((props, ref) => } }, ref - ) -); + ); +}); diff --git a/src/components/typography/H6.tsx b/src/components/typography/H6.tsx index bd6d6b56..e4fb7b3d 100644 --- a/src/components/typography/H6.tsx +++ b/src/components/typography/H6.tsx @@ -1,6 +1,11 @@ import React from "react"; import { View } from "react-native"; -import { IOTheme, IOThemeLight, useIOExperimentalDesign } from "../../core"; +import { + IOTheme, + IOThemeLight, + IOVisualCostants, + useIOExperimentalDesign +} from "../../core"; import { FontFamily, IOFontWeight } from "../../utils/fonts"; import { useTypographyFactory } from "./Factory"; import { ExternalTypographyProps, TypographyProps } from "./common"; @@ -34,6 +39,9 @@ export const H6 = React.forwardRef((props, ref) => { return useTypographyFactory( { ...props, + allowFontScaling: isExperimental, + maxFontSizeMultiplier: IOVisualCostants.maxFontSizeMultiplier, + dynamicTypeRamp: "headline" /* iOS only */, defaultWeight: isExperimental ? h6DefaultWeight : legacyDefaultWeight, defaultColor: h6DefaultColor, font: isExperimental ? fontName : legacyFontName, diff --git a/src/components/typography/LabelSmall.tsx b/src/components/typography/LabelSmall.tsx index c414f107..37022e28 100644 --- a/src/components/typography/LabelSmall.tsx +++ b/src/components/typography/LabelSmall.tsx @@ -1,6 +1,11 @@ import React from "react"; import { View } from "react-native"; -import { IOColors, IOTheme } from "../../core"; +import { + IOColors, + IOTheme, + IOVisualCostants, + useIOExperimentalDesign +} from "../../core"; import { FontFamily, IOFontWeight } from "../../utils/fonts"; import { useTypographyFactory } from "./Factory"; import { ExternalTypographyProps, TypographyProps } from "./common"; @@ -42,10 +47,15 @@ const labelDefaultcolor = "blue"; * `LabelSmall` typographic style */ export const LabelSmall = React.forwardRef( - (props, ref) => - useTypographyFactory( + (props, ref) => { + const { isExperimental } = useIOExperimentalDesign(); + + return useTypographyFactory( { ...props, + allowFontScaling: isExperimental, + maxFontSizeMultiplier: IOVisualCostants.maxFontSizeMultiplier, + dynamicTypeRamp: "footnote" /* iOS only */, defaultWeight: labelDefaultWeight, defaultColor: labelDefaultcolor, font, @@ -59,5 +69,6 @@ export const LabelSmall = React.forwardRef( } }, ref - ) + ); + } ); diff --git a/src/components/typography/LabelSmallAlt.tsx b/src/components/typography/LabelSmallAlt.tsx index 4f0aee93..b21a378e 100644 --- a/src/components/typography/LabelSmallAlt.tsx +++ b/src/components/typography/LabelSmallAlt.tsx @@ -1,6 +1,6 @@ import React from "react"; import { View } from "react-native"; -import { useIOExperimentalDesign } from "../../core"; +import { IOVisualCostants, useIOExperimentalDesign } from "../../core"; import type { IOColors, IOTheme } from "../../core/IOColors"; import { FontFamily, IOFontWeight } from "../../utils/fonts"; import { useTypographyFactory } from "./Factory"; @@ -44,6 +44,9 @@ export const LabelSmallAlt = React.forwardRef( return useTypographyFactory( { ...props, + allowFontScaling: isExperimental, + maxFontSizeMultiplier: IOVisualCostants.maxFontSizeMultiplier, + dynamicTypeRamp: "footnote" /* iOS only */, defaultWeight: isExperimental ? defaultWeight : legacyDefaultWeight, defaultColor, font: isExperimental ? fontName : legacyFontName, diff --git a/src/core/IOStyles.ts b/src/core/IOStyles.ts index 59d2d222..4370a4c7 100644 --- a/src/core/IOStyles.ts +++ b/src/core/IOStyles.ts @@ -1,4 +1,5 @@ -import { Platform, StyleSheet } from "react-native"; +import { Platform, StyleSheet, Text } from "react-native"; +import { ComponentProps } from "react"; import { IOIconSizeScale } from "../components/icons"; import { IOColors } from "./IOColors"; import { IOModuleIDPRadius } from "./IOShapes"; @@ -18,6 +19,8 @@ interface IOVisualCostants { appMarginDefault: IOAppMargin; // Header headerHeight: number; + // Typography + maxFontSizeMultiplier: ComponentProps["maxFontSizeMultiplier"]; // Dimensions avatarSizeSmall: number; avatarSizeMedium: number; @@ -32,6 +35,7 @@ interface IOVisualCostants { export const IOVisualCostants: IOVisualCostants = { appMarginDefault: 24, headerHeight: 56, + maxFontSizeMultiplier: 1.25, avatarSizeSmall: 44, avatarSizeMedium: 66, avatarRadiusSizeSmall: 8, From 8874abc7ea03e3ef3c7a7cb4379667827dbf451e Mon Sep 17 00:00:00 2001 From: Damiano Plebani Date: Mon, 24 Jun 2024 15:43:45 +0200 Subject: [PATCH 02/16] Fix criminal code without appropriate flexbox property --- src/components/modules/ModuleAttachment.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/modules/ModuleAttachment.tsx b/src/components/modules/ModuleAttachment.tsx index 29fc316b..5d6b1d96 100644 --- a/src/components/modules/ModuleAttachment.tsx +++ b/src/components/modules/ModuleAttachment.tsx @@ -62,6 +62,7 @@ const styles = StyleSheet.create({ borderWidth: 1 }, innerContent: { + alignItems: "flex-start", flex: 1, flexDirection: "column" }, @@ -115,9 +116,7 @@ const ModuleAttachmentContent = ({ {title} - - - + From f98365349e7506f2b16a89ba9e5f8b0da625d0a1 Mon Sep 17 00:00:00 2001 From: Damiano Plebani Date: Mon, 24 Jun 2024 15:53:36 +0200 Subject: [PATCH 03/16] Add space between content and action in `ModuleCheckout` --- src/components/modules/ModuleCheckout.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/modules/ModuleCheckout.tsx b/src/components/modules/ModuleCheckout.tsx index b105784c..e85556c4 100644 --- a/src/components/modules/ModuleCheckout.tsx +++ b/src/components/modules/ModuleCheckout.tsx @@ -85,7 +85,12 @@ export const ModuleCheckout = (props: ModuleCheckoutProps) => { return ( - {props.ctaText && } + {props.ctaText && ( + <> + + + + )} ); } From 0e7a970901c120ea28aabc4b07ea7c236a553262 Mon Sep 17 00:00:00 2001 From: Damiano Plebani Date: Mon, 24 Jun 2024 15:57:34 +0200 Subject: [PATCH 04/16] Add theme key to module border in the `PressableModuleBase` --- src/components/modules/PressableModuleBase.tsx | 10 +++++++++- src/core/IOStyles.ts | 1 - 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/modules/PressableModuleBase.tsx b/src/components/modules/PressableModuleBase.tsx index 0b25d243..8830f828 100644 --- a/src/components/modules/PressableModuleBase.tsx +++ b/src/components/modules/PressableModuleBase.tsx @@ -2,7 +2,12 @@ import * as React from "react"; import { PropsWithChildren } from "react"; import { Pressable } from "react-native"; import Animated from "react-native-reanimated"; -import { IOModuleIDPSavedVSpacing, IOModuleStyles } from "../../core"; +import { + IOColors, + IOModuleIDPSavedVSpacing, + IOModuleStyles, + useIOTheme +} from "../../core"; import { WithTestID } from "../../utils/types"; import { useModuleSpringAnimation } from "./hooks/useModuleSpringAnimation"; @@ -23,8 +28,10 @@ export const PressableModuleBase = ({ testID, children }: PropsWithChildren) => { + const theme = useIOTheme(); const { handlePressIn, handlePressOut, animatedStyle } = useModuleSpringAnimation(); + return ( Date: Mon, 24 Jun 2024 16:15:25 +0200 Subject: [PATCH 05/16] Allow font scaling to the remaining typographic styles --- src/components/typography/Body.tsx | 20 +++++++++++++++----- src/components/typography/BodyMonospace.tsx | 18 ++++++++++++++---- src/components/typography/Caption.tsx | 5 ++++- src/components/typography/Chip.tsx | 9 ++++++++- src/components/typography/Label.tsx | 19 +++++++++++++++---- src/components/typography/LabelLink.tsx | 9 ++++++++- 6 files changed, 64 insertions(+), 16 deletions(-) diff --git a/src/components/typography/Body.tsx b/src/components/typography/Body.tsx index 9c08f5fd..e88fdf84 100644 --- a/src/components/typography/Body.tsx +++ b/src/components/typography/Body.tsx @@ -1,6 +1,11 @@ import React from "react"; import { View } from "react-native"; -import { IOColors, IOTheme } from "../../core"; +import { + IOColors, + IOTheme, + IOVisualCostants, + useIOExperimentalDesign +} from "../../core"; import { FontFamily, IOFontWeight } from "../../utils/fonts"; import { useTypographyFactory } from "./Factory"; import { ExternalTypographyProps, TypographyProps } from "./common"; @@ -26,15 +31,20 @@ export const bodyDefaultWeight: AllowedWeight = "Regular"; /** * `Body` typographic style */ -export const Body = React.forwardRef((props, ref) => - useTypographyFactory( +export const Body = React.forwardRef((props, ref) => { + const { isExperimental } = useIOExperimentalDesign(); + + return useTypographyFactory( { ...props, + allowFontScaling: isExperimental, + maxFontSizeMultiplier: IOVisualCostants.maxFontSizeMultiplier, + dynamicTypeRamp: "body" /* iOS only */, defaultWeight: bodyDefaultWeight, defaultColor: bodyDefaultColor, font: fontName, fontStyle: { fontSize: bodyFontSize, lineHeight: bodyLineHeight } }, ref - ) -); + ); +}); diff --git a/src/components/typography/BodyMonospace.tsx b/src/components/typography/BodyMonospace.tsx index 13e97ac1..caffc0d7 100644 --- a/src/components/typography/BodyMonospace.tsx +++ b/src/components/typography/BodyMonospace.tsx @@ -1,6 +1,10 @@ import React from "react"; import { View } from "react-native"; -import type { IOColors } from "../../core/IOColors"; +import { + IOVisualCostants, + useIOExperimentalDesign, + type IOColors +} from "../../core"; import { FontFamily, IOFontWeight } from "../../utils/fonts"; import { useTypographyFactory } from "./Factory"; import { ExternalTypographyProps, TypographyProps } from "./common"; @@ -22,15 +26,21 @@ const monospaceDefaultcolor = "bluegrey"; * `BodyMonospace` typographic style */ export const BodyMonospace = React.forwardRef( - (props, ref) => - useTypographyFactory( + (props, ref) => { + const { isExperimental } = useIOExperimentalDesign(); + + return useTypographyFactory( { ...props, + allowFontScaling: isExperimental, + maxFontSizeMultiplier: IOVisualCostants.maxFontSizeMultiplier, + dynamicTypeRamp: "body" /* iOS only */, defaultWeight: monospaceDefaultWeight, defaultColor: monospaceDefaultcolor, font: fontName, fontStyle: { fontSize, lineHeight } }, ref - ) + ); + } ); diff --git a/src/components/typography/Caption.tsx b/src/components/typography/Caption.tsx index 84e7081a..6fcc7767 100644 --- a/src/components/typography/Caption.tsx +++ b/src/components/typography/Caption.tsx @@ -1,6 +1,6 @@ import React from "react"; import { View } from "react-native"; -import { IOTheme, useIOExperimentalDesign } from "../../core"; +import { IOTheme, IOVisualCostants, useIOExperimentalDesign } from "../../core"; import { FontFamily, IOFontWeight } from "../../utils/fonts"; import { useTypographyFactory } from "./Factory"; import { ExternalTypographyProps, TypographyProps } from "./common"; @@ -29,6 +29,9 @@ export const Caption = React.forwardRef((props, ref) => { return useTypographyFactory( { ...props, + allowFontScaling: isExperimental, + maxFontSizeMultiplier: IOVisualCostants.maxFontSizeMultiplier, + dynamicTypeRamp: "caption1" /* iOS only */, defaultWeight, defaultColor, font: isExperimental ? font : legacyFont, diff --git a/src/components/typography/Chip.tsx b/src/components/typography/Chip.tsx index a24d5990..e6f7180d 100644 --- a/src/components/typography/Chip.tsx +++ b/src/components/typography/Chip.tsx @@ -1,6 +1,10 @@ import React from "react"; import { View } from "react-native"; -import { IOColors, useIOExperimentalDesign } from "../../core"; +import { + IOColors, + IOVisualCostants, + useIOExperimentalDesign +} from "../../core"; import { FontFamily, IOFontWeight } from "../../utils/fonts"; import { useTypographyFactory } from "./Factory"; import { ExternalTypographyProps, TypographyProps } from "./common"; @@ -28,6 +32,9 @@ export const Chip = React.forwardRef((props, ref) => { return useTypographyFactory( { ...props, + allowFontScaling: isExperimental, + maxFontSizeMultiplier: IOVisualCostants.maxFontSizeMultiplier, + dynamicTypeRamp: "caption2" /* iOS only */, defaultWeight, defaultColor, font: isExperimental ? font : legacyFont, diff --git a/src/components/typography/Label.tsx b/src/components/typography/Label.tsx index 98c9c63a..5f4fd47d 100644 --- a/src/components/typography/Label.tsx +++ b/src/components/typography/Label.tsx @@ -1,6 +1,11 @@ import React from "react"; import { View } from "react-native"; -import { IOColors, IOColorsStatusForeground } from "../../core"; +import { + IOColors, + IOColorsStatusForeground, + IOVisualCostants, + useIOExperimentalDesign +} from "../../core"; import { FontFamily, IOFontWeight } from "../../utils/fonts"; import { useTypographyFactory } from "./Factory"; import { @@ -26,10 +31,15 @@ const labelDefaultcolor = "black"; * `Label` typographic style */ export const Label = React.forwardRef( - ({ fontSize, ...props }, ref) => - useTypographyFactory( + ({ fontSize, ...props }, ref) => { + const { isExperimental } = useIOExperimentalDesign(); + + return useTypographyFactory( { ...props, + allowFontScaling: isExperimental, + maxFontSizeMultiplier: IOVisualCostants.maxFontSizeMultiplier, + dynamicTypeRamp: "footnote" /* iOS only */, defaultWeight: labelDefaultWeight, defaultColor: labelDefaultcolor, font, @@ -43,5 +53,6 @@ export const Label = React.forwardRef( } }, ref - ) + ); + } ); diff --git a/src/components/typography/LabelLink.tsx b/src/components/typography/LabelLink.tsx index c8421a6f..29e337b5 100644 --- a/src/components/typography/LabelLink.tsx +++ b/src/components/typography/LabelLink.tsx @@ -1,6 +1,10 @@ import React from "react"; import { View } from "react-native"; -import { useIOExperimentalDesign, type IOColors } from "../../core"; +import { + IOVisualCostants, + useIOExperimentalDesign, + type IOColors +} from "../../core"; import { IOFontFamily, IOFontWeight } from "../../utils/fonts"; import { useTypographyFactory } from "./Factory"; import { @@ -36,6 +40,9 @@ export const LabelLink = React.forwardRef((props, ref) => { { accessibilityRole: props.onPress ? "link" : undefined, ...props, + allowFontScaling: isExperimental, + maxFontSizeMultiplier: IOVisualCostants.maxFontSizeMultiplier, + dynamicTypeRamp: "footnote" /* iOS only */, defaultWeight: linkDefaultWeight, defaultColor: isExperimental ? linkDefaultColor : linkLegacyDefaultColor, font, From ded1a0c44b83d93f77702cf61b46842adced09de Mon Sep 17 00:00:00 2001 From: Damiano Plebani Date: Mon, 24 Jun 2024 17:14:29 +0200 Subject: [PATCH 06/16] Allow font scaling to `ModuleIDP` --- src/components/modules/ModuleIDP.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/modules/ModuleIDP.tsx b/src/components/modules/ModuleIDP.tsx index cbcda514..0851b68e 100644 --- a/src/components/modules/ModuleIDP.tsx +++ b/src/components/modules/ModuleIDP.tsx @@ -9,7 +9,9 @@ import { import { IOColors, IOListItemLogoMargin, - useIOExperimentalDesign + IOVisualCostants, + useIOExperimentalDesign, + useIOTheme } from "../../core"; import { toAndroidCacheTimestamp } from "../../utils/dates"; import { makeFontStyleObject } from "../../utils/fonts"; @@ -27,7 +29,6 @@ interface ModuleIDP extends PressableModuleBaseProps { const styles = StyleSheet.create({ idpName: { - color: IOColors["grey-700"], fontSize: 12, lineHeight: 16, alignSelf: "center", @@ -63,6 +64,7 @@ export const ModuleIDP = ({ testID, accessibilityLabel }: ModuleIDP) => { + const theme = useIOTheme(); const { isExperimental } = useIOExperimentalDesign(); // eslint-disable-next-line no-console @@ -78,8 +80,11 @@ export const ModuleIDP = ({ withLooseSpacing={withLooseSpacing} > Date: Mon, 24 Jun 2024 17:40:13 +0200 Subject: [PATCH 07/16] Update jest snapshots --- .../__snapshots__/advice.test.tsx.snap | 6 +- .../__snapshots__/badge.test.tsx.snap | 4 + .../__snapshots__/banner.test.tsx.snap | 6 +- .../__snapshots__/button.test.tsx.snap | 10 ++- .../__snapshots__/listitem.test.tsx.snap | 86 +++++++++++++++---- .../__snapshots__/NumberPad.test.tsx.snap | 20 +++++ .../ToastNotification.test.tsx.snap | 24 ++++-- .../__snapshots__/typography.test.tsx.snap | 61 +++++++++++++ 8 files changed, 191 insertions(+), 26 deletions(-) diff --git a/src/components/Advice/__test__/__snapshots__/advice.test.tsx.snap b/src/components/Advice/__test__/__snapshots__/advice.test.tsx.snap index 0d2ecdf9..678d98b6 100644 --- a/src/components/Advice/__test__/__snapshots__/advice.test.tsx.snap +++ b/src/components/Advice/__test__/__snapshots__/advice.test.tsx.snap @@ -84,10 +84,11 @@ exports[`Test Advice Components - Experimental Enabled Advice Snapshot 1`] = ` } /> Date: Mon, 24 Jun 2024 17:46:11 +0200 Subject: [PATCH 08/16] Trim text box in the `Alert`, based on dynamic font size --- src/components/alert/Alert.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/alert/Alert.tsx b/src/components/alert/Alert.tsx index f01f6cd3..d2e28e16 100644 --- a/src/components/alert/Alert.tsx +++ b/src/components/alert/Alert.tsx @@ -1,6 +1,7 @@ import React, { useCallback } from "react"; import { GestureResponderEvent, + PixelRatio, Pressable, StyleSheet, Text, @@ -174,7 +175,10 @@ export const Alert = ({ have to put these magic numbers after manual adjustments. Tested on both Android and iOS. */} {title && ( <> From 65f07480283fe611f8aaaedf85e646f93d9cc21f Mon Sep 17 00:00:00 2001 From: Damiano Plebani Date: Tue, 25 Jun 2024 10:27:56 +0200 Subject: [PATCH 09/16] Add space between title and amount in the `ListItemAmount` --- example/src/pages/ListItem.tsx | 2 +- src/components/listitems/ListItemAmount.tsx | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/example/src/pages/ListItem.tsx b/example/src/pages/ListItem.tsx index 2611b089..049758be 100644 --- a/example/src/pages/ListItem.tsx +++ b/example/src/pages/ListItem.tsx @@ -526,7 +526,7 @@ const renderListItemAmount = () => ( diff --git a/src/components/listitems/ListItemAmount.tsx b/src/components/listitems/ListItemAmount.tsx index ca798295..e3e5ea9c 100644 --- a/src/components/listitems/ListItemAmount.tsx +++ b/src/components/listitems/ListItemAmount.tsx @@ -9,6 +9,7 @@ import { } from "../../core"; import { WithTestID } from "../../utils/types"; import { IOIcons, Icon } from "../icons"; +import { HSpacer } from "../spacer"; import { H3, H6 } from "../typography"; type ValueProps = ComponentProps; @@ -77,6 +78,7 @@ export const ListItemAmount = ({ )} {itemInfoTextComponent} +

Date: Tue, 25 Jun 2024 11:31:59 +0200 Subject: [PATCH 10/16] Add loading example of `ModulePaymentNotice` --- example/src/pages/Modules.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/example/src/pages/Modules.tsx b/example/src/pages/Modules.tsx index dc0c0cd6..c30b7297 100644 --- a/example/src/pages/Modules.tsx +++ b/example/src/pages/Modules.tsx @@ -102,6 +102,18 @@ const renderModulePaymentNotice = () => ( /> + + + + + ); From 24a231c9bbc925545fcfd75207c780b9f231e619 Mon Sep 17 00:00:00 2001 From: Damiano Plebani Date: Tue, 25 Jun 2024 12:00:53 +0200 Subject: [PATCH 11/16] Add the new `ModuleSkeleton`, add it to two modules --- src/components/modules/ModuleCredential.tsx | 30 ++++++++---- .../modules/ModulePaymentNotice.tsx | 49 ++++++++++++------- src/components/modules/ModuleSkeleton.tsx | 30 ++++++++++++ 3 files changed, 80 insertions(+), 29 deletions(-) create mode 100644 src/components/modules/ModuleSkeleton.tsx diff --git a/src/components/modules/ModuleCredential.tsx b/src/components/modules/ModuleCredential.tsx index bc878621..01316b66 100644 --- a/src/components/modules/ModuleCredential.tsx +++ b/src/components/modules/ModuleCredential.tsx @@ -9,7 +9,6 @@ import { import Placeholder from "rn-placeholder"; import { IOListItemVisualParams, - IOModuleStyles, IOSelectionListItemVisualParams, IOStyles, IOVisualCostants, @@ -19,6 +18,7 @@ import { WithTestID } from "../../utils/types"; import { Badge } from "../badge"; import { IOIcons, Icon } from "../icons"; import { LabelSmallAlt } from "../typography"; +import { ModuleSkeleton } from "./ModuleSkeleton"; import { PressableModuleBase, PressableModuleBaseProps @@ -90,15 +90,25 @@ const ModuleCredential = (props: WithTestID) => { }; const ModuleCredentialSkeleton = () => ( - - - - - - - - - + + {/* Rewrite it using HStack and VStack, when 0.72 will be used in the main app: + + + + + */} + + + + + + } + endBlock={ + + } + /> ); const styles = StyleSheet.create({ diff --git a/src/components/modules/ModulePaymentNotice.tsx b/src/components/modules/ModulePaymentNotice.tsx index 22e9cda3..0b208182 100644 --- a/src/components/modules/ModulePaymentNotice.tsx +++ b/src/components/modules/ModulePaymentNotice.tsx @@ -5,7 +5,8 @@ import { IOListItemVisualParams, IOModuleStyles, IOStyles, - useIOExperimentalDesign + useIOExperimentalDesign, + useIOTheme } from "../../core"; import { getAccessibleAmountText } from "../../utils/accessibility"; import { WithTestID } from "../../utils/types"; @@ -14,6 +15,7 @@ import { Icon } from "../icons"; import { VSpacer } from "../spacer"; import { H6, LabelSmall, LabelSmallAlt } from "../typography"; import { PressableModuleBase } from "./PressableModuleBase"; +import { ModuleSkeleton } from "./ModuleSkeleton"; export type PaymentNoticeStatus = | "default" @@ -61,6 +63,7 @@ const ModulePaymentNoticeContent = ({ paymentNoticeAmount, badgeText = "" }: Omit) => { + const theme = useIOTheme(); const { isExperimental } = useIOExperimentalDesign(); const AmountOrBadgeComponent = () => { @@ -94,18 +97,21 @@ const ModulePaymentNoticeContent = ({ <> {title && ( - + {title} )} - {isExperimental ? ( - + {subtitle && ( + {subtitle} - ) : ( - - {subtitle} - )} @@ -140,7 +146,7 @@ export const ModulePaymentNotice = ({ ...rest }: ModulePaymentNoticeProps) => { if (isLoading) { - return ; + return ; } return ( @@ -154,15 +160,20 @@ export const ModulePaymentNotice = ({ ); }; -const SkeletonComponent = () => ( - - - - - - - +const ModulePaymentNoticeSkeleton = () => ( + + {/* Rewrite it using HStack and VStack */} + + + + + + + } + endBlock={ - - + } + /> ); diff --git a/src/components/modules/ModuleSkeleton.tsx b/src/components/modules/ModuleSkeleton.tsx new file mode 100644 index 00000000..b744c8e3 --- /dev/null +++ b/src/components/modules/ModuleSkeleton.tsx @@ -0,0 +1,30 @@ +import * as React from "react"; +import { View } from "react-native"; +import { IOColors, IOModuleStyles, useIOTheme } from "../../core"; + +type ModuleSkeletonProps = { + startBlock: React.ReactNode; + endBlock?: React.ReactNode; +}; + +export const ModuleSkeleton = ({ + startBlock, + endBlock +}: ModuleSkeletonProps) => { + const theme = useIOTheme(); + + return ( + + + {startBlock} + + {endBlock} + + ); +}; From 148422c9d46eb3fc92aab0719b18dc79c101589e Mon Sep 17 00:00:00 2001 From: Damiano Plebani Date: Tue, 25 Jun 2024 12:10:46 +0200 Subject: [PATCH 12/16] Rename `ModuleSkeleton` into `ModuleStatic` --- example/src/pages/Modules.tsx | 10 +++++ src/components/modules/ModuleCheckout.tsx | 44 +++++++++---------- src/components/modules/ModuleCredential.tsx | 4 +- .../modules/ModulePaymentNotice.tsx | 6 +-- .../{ModuleSkeleton.tsx => ModuleStatic.tsx} | 7 +-- 5 files changed, 38 insertions(+), 33 deletions(-) rename src/components/modules/{ModuleSkeleton.tsx => ModuleStatic.tsx} (82%) diff --git a/example/src/pages/Modules.tsx b/example/src/pages/Modules.tsx index c30b7297..e99d7b9e 100644 --- a/example/src/pages/Modules.tsx +++ b/example/src/pages/Modules.tsx @@ -163,6 +163,16 @@ const renderModuleCheckout = () => ( onPress={modulePress} /> + + + diff --git a/src/components/modules/ModuleCheckout.tsx b/src/components/modules/ModuleCheckout.tsx index e85556c4..87b634bc 100644 --- a/src/components/modules/ModuleCheckout.tsx +++ b/src/components/modules/ModuleCheckout.tsx @@ -8,16 +8,15 @@ import { } from "react-native"; import Placeholder from "rn-placeholder"; import { - IOModuleStyles, IOSelectionListItemVisualParams, IOSpacingScale, - IOStyles, useIOTheme } from "../../core"; import { ButtonLink } from "../buttons"; import { IOLogoPaymentType, LogoPayment } from "../logos"; import { HSpacer, VSpacer } from "../spacer"; import { H6, LabelSmall } from "../typography"; +import { ModuleStatic } from "./ModuleStatic"; import { PressableModuleBase } from "./PressableModuleBase"; type LoadingProps = { @@ -45,7 +44,7 @@ export const ModuleCheckout = (props: ModuleCheckoutProps) => { const theme = useIOTheme(); if (props.isLoading) { - return ; + return ; } const { paymentLogo, image } = props; @@ -71,7 +70,7 @@ export const ModuleCheckout = (props: ModuleCheckoutProps) => { <> {imageComponent} -
{props.title}
+
{props.title}
{props.subtitle && ( {props.subtitle} @@ -95,11 +94,7 @@ export const ModuleCheckout = (props: ModuleCheckoutProps) => { ); } - return ( - - - - ); + return } />; }; const ModuleAction = ({ ctaText }: Pick) => ( @@ -112,19 +107,24 @@ const ModuleAction = ({ ctaText }: Pick) => (
); -const LoadingVersion = ({ ctaText }: LoadingProps) => ( - - - - - - - - - - - - +const ModuleCheckoutSkeleton = () => ( + + {/* Rewrite it using HStack and VStack */} + + + + + + + + + } + endBlock={ + + } + /> ); const imageMarginRight: IOSpacingScale = 12; diff --git a/src/components/modules/ModuleCredential.tsx b/src/components/modules/ModuleCredential.tsx index 01316b66..cf1ddb67 100644 --- a/src/components/modules/ModuleCredential.tsx +++ b/src/components/modules/ModuleCredential.tsx @@ -18,7 +18,7 @@ import { WithTestID } from "../../utils/types"; import { Badge } from "../badge"; import { IOIcons, Icon } from "../icons"; import { LabelSmallAlt } from "../typography"; -import { ModuleSkeleton } from "./ModuleSkeleton"; +import { ModuleStatic } from "./ModuleStatic"; import { PressableModuleBase, PressableModuleBaseProps @@ -90,7 +90,7 @@ const ModuleCredential = (props: WithTestID) => { }; const ModuleCredentialSkeleton = () => ( - {/* Rewrite it using HStack and VStack, when 0.72 will be used in the main app: diff --git a/src/components/modules/ModulePaymentNotice.tsx b/src/components/modules/ModulePaymentNotice.tsx index 0b208182..6e6a4406 100644 --- a/src/components/modules/ModulePaymentNotice.tsx +++ b/src/components/modules/ModulePaymentNotice.tsx @@ -3,8 +3,6 @@ import { GestureResponderEvent, StyleSheet, View } from "react-native"; import Placeholder from "rn-placeholder"; import { IOListItemVisualParams, - IOModuleStyles, - IOStyles, useIOExperimentalDesign, useIOTheme } from "../../core"; @@ -14,8 +12,8 @@ import { Badge } from "../badge"; import { Icon } from "../icons"; import { VSpacer } from "../spacer"; import { H6, LabelSmall, LabelSmallAlt } from "../typography"; +import { ModuleStatic } from "./ModuleStatic"; import { PressableModuleBase } from "./PressableModuleBase"; -import { ModuleSkeleton } from "./ModuleSkeleton"; export type PaymentNoticeStatus = | "default" @@ -161,7 +159,7 @@ export const ModulePaymentNotice = ({ }; const ModulePaymentNoticeSkeleton = () => ( - {/* Rewrite it using HStack and VStack */} diff --git a/src/components/modules/ModuleSkeleton.tsx b/src/components/modules/ModuleStatic.tsx similarity index 82% rename from src/components/modules/ModuleSkeleton.tsx rename to src/components/modules/ModuleStatic.tsx index b744c8e3..8d76ccea 100644 --- a/src/components/modules/ModuleSkeleton.tsx +++ b/src/components/modules/ModuleStatic.tsx @@ -2,15 +2,12 @@ import * as React from "react"; import { View } from "react-native"; import { IOColors, IOModuleStyles, useIOTheme } from "../../core"; -type ModuleSkeletonProps = { +type ModuleStaticProps = { startBlock: React.ReactNode; endBlock?: React.ReactNode; }; -export const ModuleSkeleton = ({ - startBlock, - endBlock -}: ModuleSkeletonProps) => { +export const ModuleStatic = ({ startBlock, endBlock }: ModuleStaticProps) => { const theme = useIOTheme(); return ( From 7e94aa742c5eefd247a602c7a6e3e263fa9229da Mon Sep 17 00:00:00 2001 From: Damiano Plebani Date: Tue, 25 Jun 2024 13:42:13 +0200 Subject: [PATCH 13/16] Replace legacy code with `ModuleStatic` in the `ModuleNavigation` --- src/components/modules/ModuleCredential.tsx | 2 +- src/components/modules/ModuleNavigation.tsx | 35 ++++++++++--------- .../modules/ModulePaymentNotice.tsx | 2 +- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/components/modules/ModuleCredential.tsx b/src/components/modules/ModuleCredential.tsx index cf1ddb67..19df1283 100644 --- a/src/components/modules/ModuleCredential.tsx +++ b/src/components/modules/ModuleCredential.tsx @@ -106,7 +106,7 @@ const ModuleCredentialSkeleton = () => ( } endBlock={ - + } /> ); diff --git a/src/components/modules/ModuleNavigation.tsx b/src/components/modules/ModuleNavigation.tsx index 034ba085..53ef8801 100644 --- a/src/components/modules/ModuleNavigation.tsx +++ b/src/components/modules/ModuleNavigation.tsx @@ -9,9 +9,7 @@ import { import Placeholder from "rn-placeholder"; import { IOListItemVisualParams, - IOModuleStyles, IOSelectionListItemVisualParams, - IOStyles, IOVisualCostants, useIOTheme } from "../../core"; @@ -20,6 +18,7 @@ import { Badge } from "../badge"; import { IOIcons, Icon } from "../icons"; import { VSpacer } from "../spacer"; import { Chip, LabelSmallAlt } from "../typography"; +import { ModuleStatic } from "./ModuleStatic"; import { PressableModuleBase, PressableModuleBaseProps @@ -77,7 +76,7 @@ export const ModuleNavigation = (props: WithTestID) => { > {title} - {subtitle && {subtitle}} + {subtitle && {subtitle}}
{badge ? ( @@ -95,19 +94,23 @@ export const ModuleNavigation = (props: WithTestID) => { }; const ModuleNavigationSkeleton = () => ( - - - - - - - - - - - - - + + + + + + + + + + + } + endBlock={ + + } + /> ); const styles = StyleSheet.create({ diff --git a/src/components/modules/ModulePaymentNotice.tsx b/src/components/modules/ModulePaymentNotice.tsx index 6e6a4406..22d825df 100644 --- a/src/components/modules/ModulePaymentNotice.tsx +++ b/src/components/modules/ModulePaymentNotice.tsx @@ -171,7 +171,7 @@ const ModulePaymentNoticeSkeleton = () => ( } endBlock={ - + } /> ); From 779b8a9685f0ccc935bb24b892606e674197f7ce Mon Sep 17 00:00:00 2001 From: Damiano Plebani Date: Tue, 25 Jun 2024 15:10:25 +0200 Subject: [PATCH 14/16] =?UTF-8?q?Refactor=20`ModuleAttachment`=20to=20use?= =?UTF-8?q?=C2=A0`PressableModuleBase`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/modules/ModuleAttachment.tsx | 170 +++++--------------- src/components/modules/ModuleStatic.tsx | 45 +++++- 2 files changed, 74 insertions(+), 141 deletions(-) diff --git a/src/components/modules/ModuleAttachment.tsx b/src/components/modules/ModuleAttachment.tsx index 5d6b1d96..4c2b315d 100644 --- a/src/components/modules/ModuleAttachment.tsx +++ b/src/components/modules/ModuleAttachment.tsx @@ -1,39 +1,20 @@ import React, { useCallback } from "react"; -import { - GestureResponderEvent, - Pressable, - PressableProps, - StyleSheet, - View -} from "react-native"; -import Animated, { - Extrapolate, - interpolate, - useAnimatedStyle, - useDerivedValue, - useSharedValue, - withSpring -} from "react-native-reanimated"; +import { GestureResponderEvent, PressableProps, View } from "react-native"; import Placeholder from "rn-placeholder"; -import { - IOColors, - IOListItemVisualParams, - IOScaleValues, - IOSpringValues, - useIOTheme -} from "../../core"; +import { IOListItemVisualParams, useIOTheme } from "../../core"; import { WithTestID } from "../../utils/types"; import { Badge } from "../badge"; import { Icon } from "../icons"; import { LoadingSpinner } from "../loadingSpinner"; import { VSpacer } from "../spacer"; import { LabelSmallAlt } from "../typography"; +import { ModuleStatic } from "./ModuleStatic"; +import { PressableModuleBase } from "./PressableModuleBase"; type PartialProps = WithTestID<{ title: string; format: "doc" | "pdf"; isLoading?: boolean; - loadingAccessibilityLabel?: string; isFetching?: boolean; fetchingAccessibilityLabel?: string; onPress: (event: GestureResponderEvent) => void; @@ -45,35 +26,6 @@ export type ModuleAttachmentProps = PartialProps & "onPress" | "accessibilityLabel" | "disabled" | "testID" >; -type SkeletonComponentProps = { - loadingAccessibilityLabel?: string; -}; - -const styles = StyleSheet.create({ - button: { - flexDirection: "row", - alignItems: "center", - paddingHorizontal: 16, - paddingVertical: 16, - borderRadius: 8, - borderColor: IOColors.bluegreyLight, - backgroundColor: IOColors.white, - borderStyle: "solid", - borderWidth: 1 - }, - innerContent: { - alignItems: "flex-start", - flex: 1, - flexDirection: "column" - }, - rightSection: { - marginLeft: IOListItemVisualParams.iconMargin, - alignItems: "center" - } -}); - -const DISABLED_OPACITY = 0.5; - const ModuleAttachmentContent = ({ isFetching, format, @@ -84,11 +36,13 @@ const ModuleAttachmentContent = ({ "isFetching" | "format" | "title" | "testID" >) => { const theme = useIOTheme(); + const IconOrActivityIndicatorComponent = () => { if (isFetching) { const activityIndicatorTestId = testID ? `${testID}_activityIndicator` : undefined; + return ( - + {title} @@ -118,7 +72,7 @@ const ModuleAttachmentContent = ({ - + @@ -135,7 +89,6 @@ const ModuleAttachmentContent = ({ * @param {string} format - Badge content. PDF or DOC. * @param {boolean} isLoading - If true, displays a skeleton loading component. * @param {boolean} isFetching - If true, displays an activity indicator. - * @param {string} loadingAccessibilityLabel - Optional accessibility label to use during loading. * @param {function} onPress - The function to be executed when the item is pressed. * @param {string} testID - The test ID for testing purposes. * @param {string} title - The title text to display. @@ -148,44 +101,10 @@ export const ModuleAttachment = ({ format, isLoading = false, isFetching = false, - loadingAccessibilityLabel, onPress, testID, title }: ModuleAttachmentProps) => { - const isPressed: Animated.SharedValue = useSharedValue(0); - - // Scaling transformation applied when the button is pressed - const animationScaleValue = IOScaleValues?.magnifiedButton?.pressedState; - - const scaleTraversed = useDerivedValue(() => - withSpring(isPressed.value, IOSpringValues.button) - ); - - // Interpolate animation values from `isPressed` values - const animatedStyle = useAnimatedStyle(() => { - const scale = interpolate( - scaleTraversed.value, - [0, 1], - [1, animationScaleValue], - Extrapolate.CLAMP - ); - - return { - transform: [{ scale }] - }; - }); - - const onPressIn = useCallback(() => { - // eslint-disable-next-line functional/immutable-data - isPressed.value = 1; - }, [isPressed]); - - const onPressOut = useCallback(() => { - // eslint-disable-next-line functional/immutable-data - isPressed.value = 0; - }, [isPressed]); - const handleOnPress = useCallback( (event: GestureResponderEvent) => { if (isFetching) { @@ -197,61 +116,46 @@ export const ModuleAttachment = ({ ); if (isLoading) { - return ( - - ); + return ; } const pressableAccessibilityLabel = (isFetching && !!fetchingAccessibilityLabel ? fetchingAccessibilityLabel : accessibilityLabel) ?? title; - return ( - + + + ) : ( + - - - - + + ); }; -const SkeletonComponent = ({ - loadingAccessibilityLabel -}: SkeletonComponentProps) => ( - - - - - - - +const ModuleAttachmentSkeleton = () => ( + + + + + + } + /> ); diff --git a/src/components/modules/ModuleStatic.tsx b/src/components/modules/ModuleStatic.tsx index 8d76ccea..52ce32a3 100644 --- a/src/components/modules/ModuleStatic.tsx +++ b/src/components/modules/ModuleStatic.tsx @@ -1,27 +1,56 @@ import * as React from "react"; -import { View } from "react-native"; +import { PressableProps, View } from "react-native"; import { IOColors, IOModuleStyles, useIOTheme } from "../../core"; -type ModuleStaticProps = { +type ModuleStaticProps = + | ModuleStaticSingleBlockProps + | ModuleStaticMultipleBlockProps; + +type ModuleStaticMultipleBlockProps = { startBlock: React.ReactNode; endBlock?: React.ReactNode; + children?: never; + disabled?: PressableProps["disabled"]; +}; + +type ModuleStaticSingleBlockProps = { + startBlock?: never; + endBlock?: never; + children: React.ReactNode; + disabled?: PressableProps["disabled"]; }; -export const ModuleStatic = ({ startBlock, endBlock }: ModuleStaticProps) => { +const DISABLED_OPACITY = 0.5; + +export const ModuleStatic = ({ + disabled = false, + startBlock, + endBlock, + children +}: ModuleStaticProps) => { const theme = useIOTheme(); return ( - - {startBlock} - - {endBlock} + {startBlock && ( + + + {startBlock} + + {endBlock} + + )} + + {children} ); }; From 30a869f02341c8c439331ac2221c4eda77669a78 Mon Sep 17 00:00:00 2001 From: Damiano Plebani Date: Tue, 25 Jun 2024 15:11:13 +0200 Subject: [PATCH 15/16] Improve `ModuleCheckout` code --- example/src/pages/Modules.tsx | 4 +- src/components/modules/ModuleCheckout.tsx | 47 ++++++++--------------- 2 files changed, 19 insertions(+), 32 deletions(-) diff --git a/example/src/pages/Modules.tsx b/example/src/pages/Modules.tsx index e99d7b9e..2b6c9f71 100644 --- a/example/src/pages/Modules.tsx +++ b/example/src/pages/Modules.tsx @@ -174,7 +174,7 @@ const renderModuleCheckout = () => ( /> - + ); @@ -183,7 +183,7 @@ const renderModuleAttachment = () => ( <> diff --git a/src/components/modules/ModuleCheckout.tsx b/src/components/modules/ModuleCheckout.tsx index 87b634bc..bf7e5858 100644 --- a/src/components/modules/ModuleCheckout.tsx +++ b/src/components/modules/ModuleCheckout.tsx @@ -21,7 +21,6 @@ import { PressableModuleBase } from "./PressableModuleBase"; type LoadingProps = { isLoading: true; - ctaText?: string; }; type ImageProps = @@ -47,7 +46,7 @@ export const ModuleCheckout = (props: ModuleCheckoutProps) => { return ; } - const { paymentLogo, image } = props; + const { paymentLogo, image, title, subtitle, ctaText, onPress } = props; const imageComponent = ( <> @@ -70,43 +69,31 @@ export const ModuleCheckout = (props: ModuleCheckoutProps) => { <> {imageComponent} -
{props.title}
- {props.subtitle && ( +
{title}
+ {subtitle && ( - {props.subtitle} + {subtitle} )}
); - if (props.ctaText) { - return ( - - - {props.ctaText && ( - <> - - - - )} - - ); - } - - return } />; + return ctaText ? ( + + + + + null} /> + + + ) : ( + + + + ); }; -const ModuleAction = ({ ctaText }: Pick) => ( - - null} - /> - -); - const ModuleCheckoutSkeleton = () => ( Date: Tue, 25 Jun 2024 15:41:28 +0200 Subject: [PATCH 16/16] Remove `loadingAccessibilityLabel` from `ModuleAttachment` story --- stories/components/modules/ModuleAttachment.stories.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/stories/components/modules/ModuleAttachment.stories.ts b/stories/components/modules/ModuleAttachment.stories.ts index 1fd44a11..2e01bc70 100644 --- a/stories/components/modules/ModuleAttachment.stories.ts +++ b/stories/components/modules/ModuleAttachment.stories.ts @@ -27,7 +27,6 @@ export const Primary: Story = { title: "Title", format: "pdf", accessibilityLabel: "accessibilityLabel", - loadingAccessibilityLabel: "loadingAccessibilityLabel", isFetching: false, fetchingAccessibilityLabel: "fetchingAccessibilityLabel", disabled: false,