From 322d4d7baee0a2c7aa390b70382f3dcc7b5690da Mon Sep 17 00:00:00 2001 From: Cristiano Tofani Date: Tue, 5 Sep 2023 14:23:06 +0200 Subject: [PATCH 01/12] Introduces context to handle the experimental features --- example/src/App.tsx | 25 +- example/src/pages/Buttons.tsx | 1122 +++++++++--------- src/components/buttons/ButtonSolid.tsx | 34 +- src/components/buttons/ButtonSolidLeg.tsx | 243 ++++ src/core/IODSExperimentalContextProvider.tsx | 32 + src/core/index.ts | 1 + 6 files changed, 885 insertions(+), 572 deletions(-) create mode 100644 src/components/buttons/ButtonSolidLeg.tsx create mode 100644 src/core/IODSExperimentalContextProvider.tsx diff --git a/example/src/App.tsx b/example/src/App.tsx index 5ec462d8..73cb3083 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -5,6 +5,7 @@ import { } from "@react-navigation/native"; import * as React from "react"; import { + IODSExperimentalContextProvider, IOStyles, IOThemeContext, IOThemeDark, @@ -40,17 +41,19 @@ export default function App() { - - - - - + + + + + + + ); } diff --git a/example/src/pages/Buttons.tsx b/example/src/pages/Buttons.tsx index b4896121..a1141ea3 100644 --- a/example/src/pages/Buttons.tsx +++ b/example/src/pages/Buttons.tsx @@ -11,7 +11,9 @@ import { IconButton, IconButtonContained, IconButtonSolid, - VSpacer + ListItemSwitch, + VSpacer, + useIOExperimentalDesign } from "@pagopa/io-app-design-system"; import React from "react"; import { Alert, StyleSheet, View } from "react-native"; @@ -31,161 +33,98 @@ const onButtonPress = () => { }; // sonarjs/cognitive-complexity -export const Buttons = () => ( - - {/* The title should be dynamic, got from the route object */} -

- ButtonSolid -

- - - - - - - - - - { + const { isExperimental, setExperimental } = useIOExperimentalDesign(); + return ( + + {/* The title should be dynamic, got from the route object */} +

+ ButtonSolid +

+ - - - - - - -
- - - - - - - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + - + - - - + + + - - + @@ -193,368 +132,403 @@ export const Buttons = () => ( - - + - + - - - - -

- ButtonOutline -

- - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - +

+ ButtonOutline +

+ -
-
- - + + + - - - - - - - - + + - - - - - - + - - + - - - - -

- ButtonLink -

- - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - +

+ ButtonLink +

+ -
-
- - + + + - - - - - -

- IconButton -

- - - - + - + + + + + + + - + - - - + + + - - - + - +

+ IconButton +

+ + + - + + + - + - - - + +
+
- - + ( ( ( /> - - - - -

- IconButtonSolid -

- - - - { - alert("Action triggered"); - }} - /> - - - { - alert("Action triggered"); - }} - /> + + + + + + + + + + + + + + - - - + +

+ IconButtonSolid +

+ + { + alert("Action triggered"); + }} /> { + alert("Action triggered"); + }} /> -
- - - -

- IconButtonContained (Icebox) -

- - - { - alert("Action triggered"); - }} - /> - { - alert("Action triggered"); - }} - /> + + + + + + + + + + - - - - { - alert("Action triggered"); - }} - /> + - { - alert("Action triggered"); - }} - /> - - - - - + IconButtonContained (Icebox) + + { + alert("Action triggered"); + }} /> { + alert("Action triggered"); + }} /> - - - - -

- ButtonExtendedOutline -

- - - { - alert("Action triggered"); - }} - /> + + + + { + alert("Action triggered"); + }} + /> + + { + alert("Action triggered"); + }} + /> + + + + + + + + + + + - - - { - alert("Action triggered"); - }} + + + +

+ ButtonExtendedOutline +

+ + + { + alert("Action triggered"); + }} + /> + + + + { + alert("Action triggered"); + }} + /> + + + + + +

+ Specific buttons +

+ + + -
-
- - - -

- Specific buttons -

- - - - + - - - - - - - - -
-); + + + + + + + + + + ); +}; diff --git a/src/components/buttons/ButtonSolid.tsx b/src/components/buttons/ButtonSolid.tsx index 02e322bb..2c6ba85a 100644 --- a/src/components/buttons/ButtonSolid.tsx +++ b/src/components/buttons/ButtonSolid.tsx @@ -9,13 +9,18 @@ import Animated, { useSharedValue, withSpring } from "react-native-reanimated"; -import { IOScaleValues, IOSpringValues } from "../../core/IOAnimations"; -import { IOColors } from "../../core/IOColors"; -import { IOButtonStyles } from "../../core/IOStyles"; import { IOIcons, Icon } from "../icons"; import { WithTestID } from "../../utils/types"; import { HSpacer } from "../spacer/Spacer"; import { BaseTypography } from "../typography/BaseTypography"; +import { + IOButtonStyles, + IOColors, + IOScaleValues, + IOSpringValues, + useIOExperimentalDesign +} from "../../core"; +import ButtonSolidLegacy from "./ButtonSolidLeg"; type ButtonSolidColor = "primary" | "danger" | "contrast"; @@ -115,7 +120,7 @@ export const ButtonSolid = React.memo( testID }: ButtonSolidProps) => { const isPressed = useSharedValue(0); - + const { isExperimental } = useIOExperimentalDesign(); // Scaling transformation applied when the button is pressed const animationScaleValue = IOScaleValues?.basicButton?.pressedState; @@ -224,7 +229,26 @@ export const ButtonSolid = React.memo( ); - return