@pagopa/io-app-design-system 4.4.2 → 5.0.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/Advice/__test__/__snapshots__/advice.test.tsx.snap +1 -1
- package/lib/commonjs/components/accordion/index.js +0 -11
- package/lib/commonjs/components/accordion/index.js.map +1 -1
- package/lib/commonjs/components/badge/Badge.js +4 -4
- package/lib/commonjs/components/badge/Badge.js.map +1 -1
- package/lib/commonjs/components/badge/__test__/__snapshots__/badge.test.tsx.snap +1 -1
- package/lib/commonjs/components/banner/Banner.js +4 -4
- package/lib/commonjs/components/banner/Banner.js.map +1 -1
- package/lib/commonjs/components/banner/__test__/__snapshots__/banner.test.tsx.snap +3 -3
- package/lib/commonjs/components/buttons/ButtonLink.js +25 -32
- package/lib/commonjs/components/buttons/ButtonLink.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonOutline.js +18 -86
- package/lib/commonjs/components/buttons/ButtonOutline.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonSolid.js +9 -53
- package/lib/commonjs/components/buttons/ButtonSolid.js.map +1 -1
- package/lib/commonjs/components/buttons/IconButton.js +6 -36
- package/lib/commonjs/components/buttons/IconButton.js.map +1 -1
- package/lib/commonjs/components/buttons/IconButtonContained.js +5 -50
- package/lib/commonjs/components/buttons/IconButtonContained.js.map +1 -1
- package/lib/commonjs/components/buttons/IconButtonSolid.js +5 -36
- package/lib/commonjs/components/buttons/IconButtonSolid.js.map +1 -1
- package/lib/commonjs/components/buttons/__test__/__snapshots__/button.test.tsx.snap +29 -27
- package/lib/commonjs/components/checkbox/AnimatedCheckbox.js +5 -15
- package/lib/commonjs/components/checkbox/AnimatedCheckbox.js.map +1 -1
- package/lib/commonjs/components/checkbox/AnimatedMessageCheckbox.js +2 -9
- package/lib/commonjs/components/checkbox/AnimatedMessageCheckbox.js.map +1 -1
- package/lib/commonjs/components/layout/FooterActions.js +1 -5
- package/lib/commonjs/components/layout/FooterActions.js.map +1 -1
- package/lib/commonjs/components/layout/HeaderSecondLevel.js +3 -3
- package/lib/commonjs/components/layout/HeaderSecondLevel.js.map +1 -1
- package/lib/commonjs/components/layout/ModalBSHeader.js +3 -15
- package/lib/commonjs/components/layout/ModalBSHeader.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemNavAlert.js +1 -4
- package/lib/commonjs/components/listitems/ListItemNavAlert.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemTransaction.js +1 -4
- package/lib/commonjs/components/listitems/ListItemTransaction.js.map +1 -1
- package/lib/commonjs/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +27 -27
- package/lib/commonjs/components/modules/ModuleIDP.js +4 -5
- package/lib/commonjs/components/modules/ModuleIDP.js.map +1 -1
- package/lib/commonjs/components/numberpad/NumberButton.js +3 -18
- package/lib/commonjs/components/numberpad/NumberButton.js.map +1 -1
- package/lib/commonjs/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +10 -10
- package/lib/commonjs/components/radio/AnimatedRadio.js +4 -14
- package/lib/commonjs/components/radio/AnimatedRadio.js.map +1 -1
- package/lib/commonjs/components/searchInput/SearchInput.js +6 -10
- package/lib/commonjs/components/searchInput/SearchInput.js.map +1 -1
- package/lib/commonjs/components/stepper/Stepper.js +1 -10
- package/lib/commonjs/components/stepper/Stepper.js.map +1 -1
- package/lib/commonjs/components/switch/NativeSwitch.js +2 -15
- package/lib/commonjs/components/switch/NativeSwitch.js.map +1 -1
- package/lib/commonjs/components/tabs/TabItem.js +6 -46
- package/lib/commonjs/components/tabs/TabItem.js.map +1 -1
- package/lib/commonjs/components/tag/Tag.js +4 -4
- package/lib/commonjs/components/tag/Tag.js.map +1 -1
- package/lib/commonjs/components/textInput/TextInputBase.js +10 -20
- package/lib/commonjs/components/textInput/TextInputBase.js.map +1 -1
- package/lib/commonjs/components/typography/Body.js +4 -6
- package/lib/commonjs/components/typography/Body.js.map +1 -1
- package/lib/commonjs/components/typography/BodySmall.js +3 -3
- package/lib/commonjs/components/typography/BodySmall.js.map +1 -1
- package/lib/commonjs/components/typography/ButtonText.js +6 -7
- package/lib/commonjs/components/typography/ButtonText.js.map +1 -1
- package/lib/commonjs/components/typography/Caption.js +6 -12
- package/lib/commonjs/components/typography/Caption.js.map +1 -1
- package/lib/commonjs/components/typography/H1.js +6 -13
- package/lib/commonjs/components/typography/H1.js.map +1 -1
- package/lib/commonjs/components/typography/H2.js +8 -17
- package/lib/commonjs/components/typography/H2.js.map +1 -1
- package/lib/commonjs/components/typography/H3.js +4 -8
- package/lib/commonjs/components/typography/H3.js.map +1 -1
- package/lib/commonjs/components/typography/H4.js +7 -14
- package/lib/commonjs/components/typography/H4.js.map +1 -1
- package/lib/commonjs/components/typography/H5.js +5 -10
- package/lib/commonjs/components/typography/H5.js.map +1 -1
- package/lib/commonjs/components/typography/H6.js +7 -10
- package/lib/commonjs/components/typography/H6.js.map +1 -1
- package/lib/commonjs/components/typography/Hero.js +8 -17
- package/lib/commonjs/components/typography/Hero.js.map +1 -1
- package/lib/commonjs/components/typography/LabelMini.js +4 -6
- package/lib/commonjs/components/typography/LabelMini.js.map +1 -1
- package/lib/commonjs/components/typography/__test__/__snapshots__/ComposedBodyFromArray.test.tsx.snap +42 -42
- package/lib/commonjs/components/typography/__test__/__snapshots__/typography.test.tsx.snap +26 -26
- package/lib/commonjs/components/typography/markdown/MdH1.js +3 -3
- package/lib/commonjs/components/typography/markdown/MdH1.js.map +1 -1
- package/lib/commonjs/components/typography/markdown/MdH2.js +3 -3
- package/lib/commonjs/components/typography/markdown/MdH2.js.map +1 -1
- package/lib/commonjs/components/typography/markdown/MdH3.js +3 -3
- package/lib/commonjs/components/typography/markdown/MdH3.js.map +1 -1
- package/lib/commonjs/core/IOColors.js +1 -8
- package/lib/commonjs/core/IOColors.js.map +1 -1
- package/lib/commonjs/core/IODSExperimentalContextProvider.js +4 -3
- package/lib/commonjs/core/IODSExperimentalContextProvider.js.map +1 -1
- package/lib/commonjs/core/IONewTypefaceContextProvider.js +33 -0
- package/lib/commonjs/core/IONewTypefaceContextProvider.js.map +1 -0
- package/lib/commonjs/core/IOStyles.js +1 -49
- package/lib/commonjs/core/IOStyles.js.map +1 -1
- package/lib/commonjs/core/IOThemeContextProvider.js +4 -15
- package/lib/commonjs/core/IOThemeContextProvider.js.map +1 -1
- package/lib/commonjs/core/index.js +11 -0
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/module/components/Advice/__test__/__snapshots__/advice.test.tsx.snap +1 -1
- package/lib/module/components/accordion/index.js +0 -1
- package/lib/module/components/accordion/index.js.map +1 -1
- package/lib/module/components/badge/Badge.js +5 -5
- package/lib/module/components/badge/Badge.js.map +1 -1
- package/lib/module/components/badge/__test__/__snapshots__/badge.test.tsx.snap +1 -1
- package/lib/module/components/banner/Banner.js +5 -5
- package/lib/module/components/banner/Banner.js.map +1 -1
- package/lib/module/components/banner/__test__/__snapshots__/banner.test.tsx.snap +3 -3
- package/lib/module/components/buttons/ButtonLink.js +28 -35
- package/lib/module/components/buttons/ButtonLink.js.map +1 -1
- package/lib/module/components/buttons/ButtonOutline.js +19 -87
- package/lib/module/components/buttons/ButtonOutline.js.map +1 -1
- package/lib/module/components/buttons/ButtonSolid.js +10 -54
- package/lib/module/components/buttons/ButtonSolid.js.map +1 -1
- package/lib/module/components/buttons/IconButton.js +6 -37
- package/lib/module/components/buttons/IconButton.js.map +1 -1
- package/lib/module/components/buttons/IconButtonContained.js +6 -51
- package/lib/module/components/buttons/IconButtonContained.js.map +1 -1
- package/lib/module/components/buttons/IconButtonSolid.js +6 -37
- package/lib/module/components/buttons/IconButtonSolid.js.map +1 -1
- package/lib/module/components/buttons/__test__/__snapshots__/button.test.tsx.snap +29 -27
- package/lib/module/components/checkbox/AnimatedCheckbox.js +6 -16
- package/lib/module/components/checkbox/AnimatedCheckbox.js.map +1 -1
- package/lib/module/components/checkbox/AnimatedMessageCheckbox.js +3 -10
- package/lib/module/components/checkbox/AnimatedMessageCheckbox.js.map +1 -1
- package/lib/module/components/layout/FooterActions.js +2 -6
- package/lib/module/components/layout/FooterActions.js.map +1 -1
- package/lib/module/components/layout/HeaderSecondLevel.js +4 -4
- package/lib/module/components/layout/HeaderSecondLevel.js.map +1 -1
- package/lib/module/components/layout/ModalBSHeader.js +5 -17
- package/lib/module/components/layout/ModalBSHeader.js.map +1 -1
- package/lib/module/components/listitems/ListItemNavAlert.js +2 -5
- package/lib/module/components/listitems/ListItemNavAlert.js.map +1 -1
- package/lib/module/components/listitems/ListItemTransaction.js +2 -5
- package/lib/module/components/listitems/ListItemTransaction.js.map +1 -1
- package/lib/module/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +27 -27
- package/lib/module/components/modules/ModuleIDP.js +4 -5
- package/lib/module/components/modules/ModuleIDP.js.map +1 -1
- package/lib/module/components/numberpad/NumberButton.js +5 -20
- package/lib/module/components/numberpad/NumberButton.js.map +1 -1
- package/lib/module/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +10 -10
- package/lib/module/components/radio/AnimatedRadio.js +5 -15
- package/lib/module/components/radio/AnimatedRadio.js.map +1 -1
- package/lib/module/components/searchInput/SearchInput.js +7 -11
- package/lib/module/components/searchInput/SearchInput.js.map +1 -1
- package/lib/module/components/stepper/Stepper.js +2 -11
- package/lib/module/components/stepper/Stepper.js.map +1 -1
- package/lib/module/components/switch/NativeSwitch.js +3 -16
- package/lib/module/components/switch/NativeSwitch.js.map +1 -1
- package/lib/module/components/tabs/TabItem.js +7 -47
- package/lib/module/components/tabs/TabItem.js.map +1 -1
- package/lib/module/components/tag/Tag.js +5 -5
- package/lib/module/components/tag/Tag.js.map +1 -1
- package/lib/module/components/textInput/TextInputBase.js +11 -21
- package/lib/module/components/textInput/TextInputBase.js.map +1 -1
- package/lib/module/components/typography/Body.js +5 -7
- package/lib/module/components/typography/Body.js.map +1 -1
- package/lib/module/components/typography/BodySmall.js +4 -4
- package/lib/module/components/typography/BodySmall.js.map +1 -1
- package/lib/module/components/typography/ButtonText.js +7 -8
- package/lib/module/components/typography/ButtonText.js.map +1 -1
- package/lib/module/components/typography/Caption.js +6 -12
- package/lib/module/components/typography/Caption.js.map +1 -1
- package/lib/module/components/typography/H1.js +6 -13
- package/lib/module/components/typography/H1.js.map +1 -1
- package/lib/module/components/typography/H2.js +8 -17
- package/lib/module/components/typography/H2.js.map +1 -1
- package/lib/module/components/typography/H3.js +4 -8
- package/lib/module/components/typography/H3.js.map +1 -1
- package/lib/module/components/typography/H4.js +7 -14
- package/lib/module/components/typography/H4.js.map +1 -1
- package/lib/module/components/typography/H5.js +6 -11
- package/lib/module/components/typography/H5.js.map +1 -1
- package/lib/module/components/typography/H6.js +7 -10
- package/lib/module/components/typography/H6.js.map +1 -1
- package/lib/module/components/typography/Hero.js +8 -17
- package/lib/module/components/typography/Hero.js.map +1 -1
- package/lib/module/components/typography/LabelMini.js +5 -7
- package/lib/module/components/typography/LabelMini.js.map +1 -1
- package/lib/module/components/typography/__test__/__snapshots__/ComposedBodyFromArray.test.tsx.snap +42 -42
- package/lib/module/components/typography/__test__/__snapshots__/typography.test.tsx.snap +26 -26
- package/lib/module/components/typography/markdown/MdH1.js +4 -4
- package/lib/module/components/typography/markdown/MdH1.js.map +1 -1
- package/lib/module/components/typography/markdown/MdH2.js +4 -4
- package/lib/module/components/typography/markdown/MdH2.js.map +1 -1
- package/lib/module/components/typography/markdown/MdH3.js +4 -4
- package/lib/module/components/typography/markdown/MdH3.js.map +1 -1
- package/lib/module/core/IOColors.js +0 -6
- package/lib/module/core/IOColors.js.map +1 -1
- package/lib/module/core/IODSExperimentalContextProvider.js +2 -2
- package/lib/module/core/IODSExperimentalContextProvider.js.map +1 -1
- package/lib/module/core/IONewTypefaceContextProvider.js +22 -0
- package/lib/module/core/IONewTypefaceContextProvider.js.map +1 -0
- package/lib/module/core/IOStyles.js +0 -46
- package/lib/module/core/IOStyles.js.map +1 -1
- package/lib/module/core/IOThemeContextProvider.js +3 -12
- package/lib/module/core/IOThemeContextProvider.js.map +1 -1
- package/lib/module/core/index.js +1 -0
- package/lib/module/core/index.js.map +1 -1
- package/lib/typescript/components/accordion/index.d.ts +0 -1
- package/lib/typescript/components/accordion/index.d.ts.map +1 -1
- package/lib/typescript/components/banner/Banner.d.ts.map +1 -1
- package/lib/typescript/components/buttons/ButtonLink.d.ts.map +1 -1
- package/lib/typescript/components/buttons/ButtonOutline.d.ts.map +1 -1
- package/lib/typescript/components/buttons/ButtonSolid.d.ts.map +1 -1
- package/lib/typescript/components/buttons/IconButton.d.ts.map +1 -1
- package/lib/typescript/components/buttons/IconButtonContained.d.ts.map +1 -1
- package/lib/typescript/components/buttons/IconButtonSolid.d.ts.map +1 -1
- package/lib/typescript/components/checkbox/AnimatedCheckbox.d.ts.map +1 -1
- package/lib/typescript/components/checkbox/AnimatedMessageCheckbox.d.ts.map +1 -1
- package/lib/typescript/components/layout/FooterActions.d.ts.map +1 -1
- package/lib/typescript/components/layout/HeaderSecondLevel.d.ts.map +1 -1
- package/lib/typescript/components/layout/ModalBSHeader.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemNavAlert.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemTransaction.d.ts.map +1 -1
- package/lib/typescript/components/modules/ModuleIDP.d.ts.map +1 -1
- package/lib/typescript/components/numberpad/NumberButton.d.ts.map +1 -1
- package/lib/typescript/components/radio/AnimatedRadio.d.ts.map +1 -1
- package/lib/typescript/components/searchInput/SearchInput.d.ts.map +1 -1
- package/lib/typescript/components/stepper/Stepper.d.ts.map +1 -1
- package/lib/typescript/components/switch/NativeSwitch.d.ts.map +1 -1
- package/lib/typescript/components/tabs/TabItem.d.ts.map +1 -1
- package/lib/typescript/components/textInput/TextInputBase.d.ts.map +1 -1
- package/lib/typescript/components/typography/Body.d.ts.map +1 -1
- package/lib/typescript/components/typography/ButtonText.d.ts.map +1 -1
- package/lib/typescript/components/typography/Caption.d.ts.map +1 -1
- package/lib/typescript/components/typography/H1.d.ts.map +1 -1
- package/lib/typescript/components/typography/H2.d.ts +0 -3
- package/lib/typescript/components/typography/H2.d.ts.map +1 -1
- package/lib/typescript/components/typography/H3.d.ts.map +1 -1
- package/lib/typescript/components/typography/H4.d.ts.map +1 -1
- package/lib/typescript/components/typography/H5.d.ts.map +1 -1
- package/lib/typescript/components/typography/H6.d.ts.map +1 -1
- package/lib/typescript/components/typography/Hero.d.ts.map +1 -1
- package/lib/typescript/components/typography/LabelMini.d.ts.map +1 -1
- package/lib/typescript/core/IOColors.d.ts +0 -1
- package/lib/typescript/core/IOColors.d.ts.map +1 -1
- package/lib/typescript/core/IODSExperimentalContextProvider.d.ts.map +1 -1
- package/lib/typescript/core/IONewTypefaceContextProvider.d.ts +16 -0
- package/lib/typescript/core/IONewTypefaceContextProvider.d.ts.map +1 -0
- package/lib/typescript/core/IOStyles.d.ts +2 -32
- package/lib/typescript/core/IOStyles.d.ts.map +1 -1
- package/lib/typescript/core/IOThemeContextProvider.d.ts +0 -4
- package/lib/typescript/core/IOThemeContextProvider.d.ts.map +1 -1
- package/lib/typescript/core/index.d.ts +1 -0
- package/lib/typescript/core/index.d.ts.map +1 -1
- package/lib/typescript/utils/fonts.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/Advice/__test__/__snapshots__/advice.test.tsx.snap +1 -1
- package/src/components/accordion/index.tsx +0 -1
- package/src/components/badge/Badge.tsx +3 -3
- package/src/components/badge/__test__/__snapshots__/badge.test.tsx.snap +1 -1
- package/src/components/banner/Banner.tsx +3 -4
- package/src/components/banner/__test__/__snapshots__/banner.test.tsx.snap +3 -3
- package/src/components/buttons/ButtonLink.tsx +38 -41
- package/src/components/buttons/ButtonOutline.tsx +31 -103
- package/src/components/buttons/ButtonSolid.tsx +11 -69
- package/src/components/buttons/IconButton.tsx +5 -49
- package/src/components/buttons/IconButtonContained.tsx +11 -58
- package/src/components/buttons/IconButtonSolid.tsx +9 -47
- package/src/components/buttons/__test__/__snapshots__/button.test.tsx.snap +29 -27
- package/src/components/checkbox/AnimatedCheckbox.tsx +6 -34
- package/src/components/checkbox/AnimatedMessageCheckbox.tsx +3 -14
- package/src/components/layout/FooterActions.tsx +1 -4
- package/src/components/layout/HeaderSecondLevel.tsx +4 -3
- package/src/components/layout/ModalBSHeader.tsx +11 -29
- package/src/components/listitems/ListItemNavAlert.tsx +1 -4
- package/src/components/listitems/ListItemTransaction.tsx +1 -5
- package/src/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +27 -27
- package/src/components/modules/ModuleIDP.tsx +3 -8
- package/src/components/numberpad/NumberButton.tsx +4 -27
- package/src/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +10 -10
- package/src/components/radio/AnimatedRadio.tsx +5 -33
- package/src/components/searchInput/SearchInput.tsx +11 -20
- package/src/components/stepper/Stepper.tsx +2 -20
- package/src/components/switch/NativeSwitch.tsx +3 -21
- package/src/components/tabs/TabItem.tsx +14 -61
- package/src/components/tag/Tag.tsx +3 -3
- package/src/components/textInput/TextInputBase.tsx +19 -34
- package/src/components/typography/Body.tsx +4 -11
- package/src/components/typography/BodySmall.tsx +3 -3
- package/src/components/typography/ButtonText.tsx +6 -8
- package/src/components/typography/Caption.tsx +6 -13
- package/src/components/typography/H1.tsx +6 -14
- package/src/components/typography/H2.tsx +8 -18
- package/src/components/typography/H3.tsx +4 -8
- package/src/components/typography/H4.tsx +7 -15
- package/src/components/typography/H5.tsx +6 -14
- package/src/components/typography/H6.tsx +7 -11
- package/src/components/typography/Hero.tsx +8 -18
- package/src/components/typography/LabelMini.tsx +4 -11
- package/src/components/typography/__test__/__snapshots__/ComposedBodyFromArray.test.tsx.snap +42 -42
- package/src/components/typography/__test__/__snapshots__/typography.test.tsx.snap +26 -26
- package/src/components/typography/markdown/MdH1.tsx +3 -3
- package/src/components/typography/markdown/MdH2.tsx +3 -3
- package/src/components/typography/markdown/MdH3.tsx +3 -3
- package/src/core/IOColors.ts +0 -7
- package/src/core/IODSExperimentalContextProvider.tsx +2 -2
- package/src/core/IONewTypefaceContextProvider.tsx +37 -0
- package/src/core/IOStyles.ts +0 -52
- package/src/core/IOThemeContextProvider.tsx +3 -16
- package/src/core/index.ts +1 -0
- package/lib/commonjs/components/accordion/RawAccordion.js +0 -93
- package/lib/commonjs/components/accordion/RawAccordion.js.map +0 -1
- package/lib/module/components/accordion/RawAccordion.js +0 -86
- package/lib/module/components/accordion/RawAccordion.js.map +0 -1
- package/lib/typescript/components/accordion/RawAccordion.d.ts +0 -17
- package/lib/typescript/components/accordion/RawAccordion.d.ts.map +0 -1
- package/src/components/accordion/RawAccordion.tsx +0 -116
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React, { forwardRef
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
2
|
import { GestureResponderEvent, Pressable, View } from "react-native";
|
|
3
3
|
import Animated, {
|
|
4
4
|
interpolateColor,
|
|
5
|
+
useAnimatedProps,
|
|
5
6
|
useAnimatedStyle,
|
|
6
7
|
useReducedMotion
|
|
7
8
|
} from "react-native-reanimated";
|
|
@@ -10,7 +11,7 @@ import {
|
|
|
10
11
|
IOColors,
|
|
11
12
|
IOSpacingScale,
|
|
12
13
|
hexToRgba,
|
|
13
|
-
|
|
14
|
+
useIONewTypeface
|
|
14
15
|
} from "../../core";
|
|
15
16
|
import { useScaleAnimation } from "../../hooks";
|
|
16
17
|
import { WithTestID } from "../../utils/types";
|
|
@@ -67,28 +68,6 @@ const mapColorStates: Record<
|
|
|
67
68
|
}
|
|
68
69
|
};
|
|
69
70
|
|
|
70
|
-
// TODO: Remove this when legacy look is deprecated https://pagopa.atlassian.net/browse/IOPLT-153
|
|
71
|
-
const mapLegacyColorStates: Record<
|
|
72
|
-
NonNullable<ButtonLinkProps["color"]>,
|
|
73
|
-
ColorStates
|
|
74
|
-
> = {
|
|
75
|
-
// Primary button
|
|
76
|
-
primary: {
|
|
77
|
-
label: {
|
|
78
|
-
default: IOColors.blue,
|
|
79
|
-
pressed: IOColors["blue-600"],
|
|
80
|
-
disabled: IOColors["grey-700"]
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
contrast: {
|
|
84
|
-
label: {
|
|
85
|
-
default: IOColors.white,
|
|
86
|
-
pressed: hexToRgba(IOColors.white, 0.85),
|
|
87
|
-
disabled: hexToRgba(IOColors.white, 0.5)
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
71
|
const DISABLED_OPACITY = 0.5;
|
|
93
72
|
const ICON_MARGIN = 8;
|
|
94
73
|
|
|
@@ -107,25 +86,43 @@ export const ButtonLink = forwardRef<View, ButtonLinkProps>(
|
|
|
107
86
|
},
|
|
108
87
|
ref
|
|
109
88
|
) => {
|
|
110
|
-
const {
|
|
89
|
+
const { newTypefaceEnabled } = useIONewTypeface();
|
|
111
90
|
const { progress, onPressIn, onPressOut, scaleAnimatedStyle } =
|
|
112
91
|
useScaleAnimation();
|
|
113
92
|
const reducedMotion = useReducedMotion();
|
|
114
93
|
|
|
115
|
-
const colorMap = useMemo(
|
|
116
|
-
() => (isExperimental ? mapColorStates : mapLegacyColorStates),
|
|
117
|
-
[isExperimental]
|
|
118
|
-
);
|
|
119
|
-
|
|
120
94
|
const AnimatedIOText = Animated.createAnimatedComponent(IOText);
|
|
121
95
|
|
|
122
|
-
const
|
|
123
|
-
color
|
|
96
|
+
const pressedColorLabelAnimationStyle = useAnimatedStyle(() => {
|
|
97
|
+
// Link color states to the pressed states
|
|
98
|
+
|
|
99
|
+
const labelColor = interpolateColor(
|
|
100
|
+
progress.value,
|
|
101
|
+
[0, 1],
|
|
102
|
+
[
|
|
103
|
+
mapColorStates[color].label.default,
|
|
104
|
+
mapColorStates[color].label.pressed
|
|
105
|
+
]
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
color: labelColor
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// Animate the <Icon> color prop
|
|
114
|
+
const pressedColorIconAnimationStyle = useAnimatedProps(() => {
|
|
115
|
+
const iconColor = interpolateColor(
|
|
124
116
|
progress.value,
|
|
125
117
|
[0, 1],
|
|
126
|
-
[
|
|
127
|
-
|
|
128
|
-
|
|
118
|
+
[
|
|
119
|
+
mapColorStates[color].label.default,
|
|
120
|
+
mapColorStates[color].label.pressed
|
|
121
|
+
]
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
return { color: iconColor };
|
|
125
|
+
});
|
|
129
126
|
|
|
130
127
|
const AnimatedIconClassComponent =
|
|
131
128
|
Animated.createAnimatedComponent(IconClassComponent);
|
|
@@ -168,15 +165,15 @@ export const ButtonLink = forwardRef<View, ButtonLinkProps>(
|
|
|
168
165
|
<AnimatedIconClassComponent
|
|
169
166
|
allowFontScaling
|
|
170
167
|
name={icon}
|
|
171
|
-
animatedProps={
|
|
172
|
-
color={
|
|
168
|
+
animatedProps={pressedColorIconAnimationStyle}
|
|
169
|
+
color={mapColorStates[color]?.label?.default}
|
|
173
170
|
size={iconSize}
|
|
174
171
|
/>
|
|
175
172
|
) : (
|
|
176
173
|
<AnimatedIcon
|
|
177
174
|
allowFontScaling
|
|
178
175
|
name={icon}
|
|
179
|
-
color={
|
|
176
|
+
color={mapColorStates[color]?.label?.disabled}
|
|
180
177
|
size={iconSize}
|
|
181
178
|
/>
|
|
182
179
|
))}
|
|
@@ -184,13 +181,13 @@ export const ButtonLink = forwardRef<View, ButtonLinkProps>(
|
|
|
184
181
|
accessible={false}
|
|
185
182
|
accessibilityElementsHidden
|
|
186
183
|
importantForAccessibility="no-hide-descendants"
|
|
187
|
-
font={
|
|
184
|
+
font={newTypefaceEnabled ? "Titillio" : "TitilliumSansPro"}
|
|
188
185
|
weight={"Semibold"}
|
|
189
186
|
size={buttonTextFontSize}
|
|
190
187
|
style={
|
|
191
188
|
disabled
|
|
192
|
-
? { color:
|
|
193
|
-
: { ...
|
|
189
|
+
? { color: mapColorStates[color]?.label?.disabled }
|
|
190
|
+
: { ...pressedColorLabelAnimationStyle }
|
|
194
191
|
}
|
|
195
192
|
numberOfLines={1}
|
|
196
193
|
ellipsizeMode="tail"
|
|
@@ -12,11 +12,10 @@ import Animated, {
|
|
|
12
12
|
useReducedMotion
|
|
13
13
|
} from "react-native-reanimated";
|
|
14
14
|
import {
|
|
15
|
-
IOButtonLegacyStyles,
|
|
16
15
|
IOButtonStyles,
|
|
17
16
|
IOColors,
|
|
18
17
|
hexToRgba,
|
|
19
|
-
|
|
18
|
+
useIONewTypeface
|
|
20
19
|
} from "../../core/";
|
|
21
20
|
import { useScaleAnimation } from "../../hooks";
|
|
22
21
|
import { WithTestID } from "../../utils/types";
|
|
@@ -123,74 +122,6 @@ const mapColorStates: Record<
|
|
|
123
122
|
}
|
|
124
123
|
};
|
|
125
124
|
|
|
126
|
-
// TODO: Remove this when legacy look is deprecated https://pagopa.atlassian.net/browse/IOPLT-153
|
|
127
|
-
const mapLegacyColorStates: Record<
|
|
128
|
-
NonNullable<ButtonOutline["color"]>,
|
|
129
|
-
ColorStates
|
|
130
|
-
> = {
|
|
131
|
-
// Primary button
|
|
132
|
-
primary: {
|
|
133
|
-
border: {
|
|
134
|
-
default: IOColors.blue,
|
|
135
|
-
pressed: IOColors.blue,
|
|
136
|
-
disabled: IOColors.bluegreyLight
|
|
137
|
-
},
|
|
138
|
-
background: {
|
|
139
|
-
default: hexToRgba(IOColors.blue, 0),
|
|
140
|
-
pressed: hexToRgba(IOColors.blue, 0.15),
|
|
141
|
-
disabled: "transparent"
|
|
142
|
-
},
|
|
143
|
-
label: {
|
|
144
|
-
default: IOColors.blue,
|
|
145
|
-
pressed: IOColors.blue,
|
|
146
|
-
disabled: IOColors.grey
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
// Contrast button
|
|
150
|
-
contrast: {
|
|
151
|
-
border: {
|
|
152
|
-
default: IOColors.white,
|
|
153
|
-
pressed: IOColors.white,
|
|
154
|
-
disabled: hexToRgba(IOColors.white, 0.5)
|
|
155
|
-
},
|
|
156
|
-
background: {
|
|
157
|
-
default: hexToRgba(IOColors.white, 0),
|
|
158
|
-
pressed: hexToRgba(IOColors.white, 0.2),
|
|
159
|
-
disabled: "transparent"
|
|
160
|
-
},
|
|
161
|
-
label: {
|
|
162
|
-
default: IOColors.white,
|
|
163
|
-
pressed: IOColors.white,
|
|
164
|
-
disabled: hexToRgba(IOColors.white, 0.5)
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
// Danger button
|
|
168
|
-
danger: {
|
|
169
|
-
border: {
|
|
170
|
-
default: IOColors.red,
|
|
171
|
-
pressed: IOColors.red,
|
|
172
|
-
disabled: IOColors.bluegreyLight
|
|
173
|
-
},
|
|
174
|
-
background: {
|
|
175
|
-
default: hexToRgba(IOColors.red, 0),
|
|
176
|
-
pressed: hexToRgba(IOColors.red, 0.15),
|
|
177
|
-
disabled: "transparent"
|
|
178
|
-
},
|
|
179
|
-
label: {
|
|
180
|
-
default: IOColors.red,
|
|
181
|
-
pressed: IOColors.red,
|
|
182
|
-
disabled: IOColors.grey
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
// TODO: Remove this when legacy look is deprecated https://pagopa.atlassian.net/browse/IOPLT-153
|
|
188
|
-
const IOButtonLegacyStylesLocal = StyleSheet.create({
|
|
189
|
-
buttonWithBorder: {
|
|
190
|
-
borderWidth: 1
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
|
|
194
125
|
// Icon size
|
|
195
126
|
const iconSize: IOIconSizeScale = 20;
|
|
196
127
|
|
|
@@ -219,41 +150,32 @@ export const ButtonOutline = forwardRef<View, ButtonOutline>(
|
|
|
219
150
|
},
|
|
220
151
|
ref
|
|
221
152
|
) => {
|
|
222
|
-
const {
|
|
153
|
+
const { newTypefaceEnabled } = useIONewTypeface();
|
|
223
154
|
const { progress, onPressIn, onPressOut, scaleAnimatedStyle } =
|
|
224
155
|
useScaleAnimation();
|
|
225
156
|
const reducedMotion = useReducedMotion();
|
|
226
157
|
|
|
227
158
|
const AnimatedIOText = Animated.createAnimatedComponent(IOText);
|
|
228
159
|
|
|
229
|
-
const colorMap = React.useMemo(
|
|
230
|
-
() => (isExperimental ? mapColorStates : mapLegacyColorStates),
|
|
231
|
-
[isExperimental]
|
|
232
|
-
);
|
|
233
|
-
|
|
234
|
-
const buttonStyles = React.useMemo(
|
|
235
|
-
() => (isExperimental ? IOButtonStyles : IOButtonLegacyStyles),
|
|
236
|
-
[isExperimental]
|
|
237
|
-
);
|
|
238
|
-
|
|
239
|
-
const buttonStylesLocal = React.useMemo(
|
|
240
|
-
() => (isExperimental ? IOButtonStylesLocal : IOButtonLegacyStylesLocal),
|
|
241
|
-
[isExperimental]
|
|
242
|
-
);
|
|
243
|
-
|
|
244
160
|
// Interpolate animation values from `isPressed` values
|
|
245
161
|
const pressedAnimationStyle = useAnimatedStyle(() => {
|
|
246
162
|
// Link color states to the pressed states
|
|
247
163
|
const backgroundColor = interpolateColor(
|
|
248
164
|
progress.value,
|
|
249
165
|
[0, 1],
|
|
250
|
-
[
|
|
166
|
+
[
|
|
167
|
+
mapColorStates[color].background.default,
|
|
168
|
+
mapColorStates[color].background.pressed
|
|
169
|
+
]
|
|
251
170
|
);
|
|
252
171
|
|
|
253
172
|
const borderColor = interpolateColor(
|
|
254
173
|
progress.value,
|
|
255
174
|
[0, 1],
|
|
256
|
-
[
|
|
175
|
+
[
|
|
176
|
+
mapColorStates[color].border.default,
|
|
177
|
+
mapColorStates[color].border.pressed
|
|
178
|
+
]
|
|
257
179
|
);
|
|
258
180
|
|
|
259
181
|
return {
|
|
@@ -266,7 +188,10 @@ export const ButtonOutline = forwardRef<View, ButtonOutline>(
|
|
|
266
188
|
color: interpolateColor(
|
|
267
189
|
progress.value,
|
|
268
190
|
[0, 1],
|
|
269
|
-
[
|
|
191
|
+
[
|
|
192
|
+
mapColorStates[color].border.default,
|
|
193
|
+
mapColorStates[color].border.pressed
|
|
194
|
+
]
|
|
270
195
|
)
|
|
271
196
|
}));
|
|
272
197
|
|
|
@@ -275,7 +200,10 @@ export const ButtonOutline = forwardRef<View, ButtonOutline>(
|
|
|
275
200
|
color: interpolateColor(
|
|
276
201
|
progress.value,
|
|
277
202
|
[0, 1],
|
|
278
|
-
[
|
|
203
|
+
[
|
|
204
|
+
mapColorStates[color].label.default,
|
|
205
|
+
mapColorStates[color].label.pressed
|
|
206
|
+
]
|
|
279
207
|
)
|
|
280
208
|
}));
|
|
281
209
|
|
|
@@ -299,21 +227,21 @@ export const ButtonOutline = forwardRef<View, ButtonOutline>(
|
|
|
299
227
|
>
|
|
300
228
|
<Animated.View
|
|
301
229
|
style={[
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
230
|
+
IOButtonStyles.button,
|
|
231
|
+
IOButtonStyles.buttonSizeDefault,
|
|
232
|
+
IOButtonStylesLocal.buttonWithBorder,
|
|
233
|
+
fullWidth && { paddingHorizontal: 16 },
|
|
306
234
|
{ columnGap: ICON_MARGIN },
|
|
307
235
|
iconPosition === "end" && { flexDirection: "row-reverse" },
|
|
308
236
|
disabled
|
|
309
237
|
? {
|
|
310
|
-
backgroundColor:
|
|
311
|
-
borderColor:
|
|
238
|
+
backgroundColor: mapColorStates[color]?.background?.disabled,
|
|
239
|
+
borderColor: mapColorStates[color]?.border?.disabled,
|
|
312
240
|
opacity: DISABLED_OPACITY
|
|
313
241
|
}
|
|
314
242
|
: {
|
|
315
|
-
backgroundColor:
|
|
316
|
-
borderColor:
|
|
243
|
+
backgroundColor: mapColorStates[color]?.background?.default,
|
|
244
|
+
borderColor: mapColorStates[color]?.border.default
|
|
317
245
|
},
|
|
318
246
|
/* Prevent Reanimated from overriding background colors
|
|
319
247
|
if button is disabled */
|
|
@@ -327,19 +255,19 @@ export const ButtonOutline = forwardRef<View, ButtonOutline>(
|
|
|
327
255
|
allowFontScaling
|
|
328
256
|
name={icon}
|
|
329
257
|
animatedProps={pressedColorIconAnimationStyle}
|
|
330
|
-
color={
|
|
258
|
+
color={mapColorStates[color]?.label?.default}
|
|
331
259
|
size={iconSize}
|
|
332
260
|
/>
|
|
333
261
|
) : (
|
|
334
262
|
<AnimatedIcon
|
|
335
263
|
allowFontScaling
|
|
336
264
|
name={icon}
|
|
337
|
-
color={
|
|
265
|
+
color={mapColorStates[color]?.label?.disabled}
|
|
338
266
|
size={iconSize}
|
|
339
267
|
/>
|
|
340
268
|
))}
|
|
341
269
|
<AnimatedIOText
|
|
342
|
-
font={
|
|
270
|
+
font={newTypefaceEnabled ? "Titillio" : "TitilliumSansPro"}
|
|
343
271
|
weight={"Semibold"}
|
|
344
272
|
size={buttonTextFontSize}
|
|
345
273
|
accessible={false}
|
|
@@ -348,9 +276,9 @@ export const ButtonOutline = forwardRef<View, ButtonOutline>(
|
|
|
348
276
|
numberOfLines={1}
|
|
349
277
|
ellipsizeMode="tail"
|
|
350
278
|
style={[
|
|
351
|
-
|
|
279
|
+
IOButtonStyles.label,
|
|
352
280
|
disabled
|
|
353
|
-
? { color:
|
|
281
|
+
? { color: mapColorStates[color]?.label?.disabled }
|
|
354
282
|
: { ...pressedColorLabelAnimationStyle }
|
|
355
283
|
]}
|
|
356
284
|
>
|
|
@@ -12,13 +12,11 @@ import Animated, {
|
|
|
12
12
|
useReducedMotion
|
|
13
13
|
} from "react-native-reanimated";
|
|
14
14
|
import {
|
|
15
|
-
IOButtonLegacyStyles,
|
|
16
15
|
IOButtonStyles,
|
|
17
16
|
IOColors,
|
|
18
17
|
enterTransitionInnerContent,
|
|
19
18
|
enterTransitionInnerContentSmall,
|
|
20
|
-
exitTransitionInnerContent
|
|
21
|
-
useIOExperimentalDesign
|
|
19
|
+
exitTransitionInnerContent
|
|
22
20
|
} from "../../core";
|
|
23
21
|
import { useScaleAnimation } from "../../hooks";
|
|
24
22
|
import { WithTestID } from "../../utils/types";
|
|
@@ -37,15 +35,6 @@ type ColorStates = {
|
|
|
37
35
|
};
|
|
38
36
|
};
|
|
39
37
|
|
|
40
|
-
// Disabled state
|
|
41
|
-
// TODO: Remove this when legacy look is deprecated https://pagopa.atlassian.net/browse/IOPLT-153
|
|
42
|
-
const colorPrimaryLegacyButtonDisabled: IOColors = "bluegreyLight";
|
|
43
|
-
const legacyStyles = StyleSheet.create({
|
|
44
|
-
backgroundDisabled: {
|
|
45
|
-
backgroundColor: IOColors[colorPrimaryLegacyButtonDisabled]
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
38
|
const colorPrimaryButtonDisabled: IOColors = "grey-200";
|
|
50
39
|
const ICON_MARGIN = 8;
|
|
51
40
|
const DISABLED_OPACITY = 0.5;
|
|
@@ -120,40 +109,6 @@ const mapColorStates: Record<
|
|
|
120
109
|
}
|
|
121
110
|
};
|
|
122
111
|
|
|
123
|
-
// TODO: Remove this when legacy look is deprecated https://pagopa.atlassian.net/browse/IOPLT-153
|
|
124
|
-
const mapLegacyColorStates: Record<
|
|
125
|
-
NonNullable<ButtonSolidProps["color"]>,
|
|
126
|
-
ColorStates
|
|
127
|
-
> = {
|
|
128
|
-
// Primary button
|
|
129
|
-
primary: {
|
|
130
|
-
default: IOColors.blue,
|
|
131
|
-
pressed: IOColors["blue-600"],
|
|
132
|
-
label: {
|
|
133
|
-
default: "white",
|
|
134
|
-
disabled: "white"
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
// Danger button
|
|
138
|
-
danger: {
|
|
139
|
-
default: IOColors["error-600"],
|
|
140
|
-
pressed: IOColors["error-500"],
|
|
141
|
-
label: {
|
|
142
|
-
default: "white",
|
|
143
|
-
disabled: "white"
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
// Contrast button
|
|
147
|
-
contrast: {
|
|
148
|
-
default: IOColors.white,
|
|
149
|
-
pressed: IOColors["blue-50"],
|
|
150
|
-
label: {
|
|
151
|
-
default: "blue",
|
|
152
|
-
disabled: "white"
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
|
|
157
112
|
export const ButtonSolid = React.forwardRef<View, ButtonSolidProps>(
|
|
158
113
|
(
|
|
159
114
|
{
|
|
@@ -171,28 +126,17 @@ export const ButtonSolid = React.forwardRef<View, ButtonSolidProps>(
|
|
|
171
126
|
},
|
|
172
127
|
ref
|
|
173
128
|
) => {
|
|
174
|
-
const { isExperimental } = useIOExperimentalDesign();
|
|
175
129
|
const { progress, onPressIn, onPressOut, scaleAnimatedStyle } =
|
|
176
130
|
useScaleAnimation();
|
|
177
131
|
const reducedMotion = useReducedMotion();
|
|
178
132
|
|
|
179
|
-
const colorMap = React.useMemo(
|
|
180
|
-
() => (isExperimental ? mapColorStates : mapLegacyColorStates),
|
|
181
|
-
[isExperimental]
|
|
182
|
-
);
|
|
183
|
-
|
|
184
|
-
const buttonStyles = React.useMemo(
|
|
185
|
-
() => (isExperimental ? IOButtonStyles : IOButtonLegacyStyles),
|
|
186
|
-
[isExperimental]
|
|
187
|
-
);
|
|
188
|
-
|
|
189
133
|
// Interpolate animation values from `isPressed` values
|
|
190
134
|
const pressedAnimationStyle = useAnimatedStyle(() => {
|
|
191
135
|
// Link color states to the pressed states
|
|
192
136
|
const backgroundColor = interpolateColor(
|
|
193
137
|
progress.value,
|
|
194
138
|
[0, 1],
|
|
195
|
-
[
|
|
139
|
+
[mapColorStates[color].default, mapColorStates[color].pressed]
|
|
196
140
|
);
|
|
197
141
|
|
|
198
142
|
return { backgroundColor };
|
|
@@ -213,8 +157,8 @@ export const ButtonSolid = React.forwardRef<View, ButtonSolidProps>(
|
|
|
213
157
|
|
|
214
158
|
// Label & Icons colors
|
|
215
159
|
const foregroundColor: IOColors = disabled
|
|
216
|
-
?
|
|
217
|
-
:
|
|
160
|
+
? mapColorStates[color]?.label?.disabled
|
|
161
|
+
: mapColorStates[color]?.label?.default;
|
|
218
162
|
|
|
219
163
|
return (
|
|
220
164
|
<Pressable
|
|
@@ -237,15 +181,13 @@ export const ButtonSolid = React.forwardRef<View, ButtonSolidProps>(
|
|
|
237
181
|
>
|
|
238
182
|
<Animated.View
|
|
239
183
|
style={[
|
|
240
|
-
|
|
184
|
+
IOButtonStyles.button,
|
|
185
|
+
IOButtonStyles.buttonSizeDefault,
|
|
241
186
|
{ overflow: "hidden" },
|
|
242
|
-
|
|
243
|
-
buttonStyles.buttonSizeDefault,
|
|
187
|
+
fullWidth && { paddingHorizontal: 16 },
|
|
244
188
|
disabled
|
|
245
|
-
?
|
|
246
|
-
|
|
247
|
-
: legacyStyles.backgroundDisabled
|
|
248
|
-
: { backgroundColor: colorMap[color]?.default },
|
|
189
|
+
? styles.backgroundDisabled
|
|
190
|
+
: { backgroundColor: mapColorStates[color]?.default },
|
|
249
191
|
/* Prevent Reanimated from overriding background colors
|
|
250
192
|
if button is disabled */
|
|
251
193
|
!disabled && !reducedMotion && scaleAnimatedStyle,
|
|
@@ -254,7 +196,7 @@ export const ButtonSolid = React.forwardRef<View, ButtonSolidProps>(
|
|
|
254
196
|
>
|
|
255
197
|
{loading && (
|
|
256
198
|
<Animated.View
|
|
257
|
-
style={
|
|
199
|
+
style={IOButtonStyles.buttonInner}
|
|
258
200
|
entering={enterTransitionInnerContentSmall}
|
|
259
201
|
exiting={exitTransitionInnerContent}
|
|
260
202
|
>
|
|
@@ -265,7 +207,7 @@ export const ButtonSolid = React.forwardRef<View, ButtonSolidProps>(
|
|
|
265
207
|
{!loading && (
|
|
266
208
|
<Animated.View
|
|
267
209
|
style={[
|
|
268
|
-
|
|
210
|
+
IOButtonStyles.buttonInner,
|
|
269
211
|
{ columnGap: ICON_MARGIN },
|
|
270
212
|
/* If 'iconPosition' is set to 'end', we use
|
|
271
213
|
reverse flex property to invert the position */
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { GestureResponderEvent, Pressable } from "react-native";
|
|
3
3
|
import Animated, {
|
|
4
4
|
interpolateColor,
|
|
5
5
|
useAnimatedProps,
|
|
6
6
|
useReducedMotion
|
|
7
7
|
} from "react-native-reanimated";
|
|
8
|
-
import {
|
|
9
|
-
IOColors,
|
|
10
|
-
IOIconButtonStyles,
|
|
11
|
-
IOStyles,
|
|
12
|
-
hexToRgba,
|
|
13
|
-
useIOExperimentalDesign
|
|
14
|
-
} from "../../core";
|
|
8
|
+
import { IOColors, IOIconButtonStyles, IOStyles, hexToRgba } from "../../core";
|
|
15
9
|
import { useScaleAnimation } from "../../hooks";
|
|
16
10
|
import { WithTestID } from "../../utils/types";
|
|
17
11
|
import {
|
|
@@ -39,37 +33,6 @@ type ColorStates = {
|
|
|
39
33
|
};
|
|
40
34
|
};
|
|
41
35
|
|
|
42
|
-
// TODO: Remove this when legacy look is deprecated https://pagopa.atlassian.net/browse/IOPLT-153
|
|
43
|
-
const mapLegacyColorStates: Record<
|
|
44
|
-
NonNullable<IconButton["color"]>,
|
|
45
|
-
ColorStates
|
|
46
|
-
> = {
|
|
47
|
-
// Primary button
|
|
48
|
-
primary: {
|
|
49
|
-
icon: {
|
|
50
|
-
default: IOColors.blue,
|
|
51
|
-
pressed: IOColors["blue-600"],
|
|
52
|
-
disabled: hexToRgba(IOColors.blue, 0.25)
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
// Neutral button
|
|
56
|
-
neutral: {
|
|
57
|
-
icon: {
|
|
58
|
-
default: IOColors.black,
|
|
59
|
-
pressed: IOColors.bluegreyDark,
|
|
60
|
-
disabled: IOColors.grey
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
// Contrast button
|
|
64
|
-
contrast: {
|
|
65
|
-
icon: {
|
|
66
|
-
default: IOColors.white,
|
|
67
|
-
pressed: hexToRgba(IOColors.white, 0.85),
|
|
68
|
-
disabled: hexToRgba(IOColors.white, 0.25)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
36
|
const mapColorStates: Record<NonNullable<IconButton["color"]>, ColorStates> = {
|
|
74
37
|
// Primary button
|
|
75
38
|
primary: {
|
|
@@ -114,19 +77,12 @@ export const IconButton = ({
|
|
|
114
77
|
useScaleAnimation("exaggerated");
|
|
115
78
|
const reducedMotion = useReducedMotion();
|
|
116
79
|
|
|
117
|
-
const { isExperimental } = useIOExperimentalDesign();
|
|
118
|
-
|
|
119
|
-
const colorMap = useMemo(
|
|
120
|
-
() => (isExperimental ? mapColorStates : mapLegacyColorStates),
|
|
121
|
-
[isExperimental]
|
|
122
|
-
);
|
|
123
|
-
|
|
124
80
|
// Animate the <Icon> color prop
|
|
125
81
|
const animatedColor = useAnimatedProps(() => {
|
|
126
82
|
const iconColor = interpolateColor(
|
|
127
83
|
progress.value,
|
|
128
84
|
[0, 1],
|
|
129
|
-
[
|
|
85
|
+
[mapColorStates[color].icon.default, mapColorStates[color].icon.pressed]
|
|
130
86
|
);
|
|
131
87
|
return { color: iconColor };
|
|
132
88
|
});
|
|
@@ -164,14 +120,14 @@ export const IconButton = ({
|
|
|
164
120
|
name={icon}
|
|
165
121
|
size={iconSize}
|
|
166
122
|
animatedProps={animatedColor}
|
|
167
|
-
color={
|
|
123
|
+
color={mapColorStates[color]?.icon?.default}
|
|
168
124
|
/>
|
|
169
125
|
) : (
|
|
170
126
|
<AnimatedIcon
|
|
171
127
|
allowFontScaling
|
|
172
128
|
name={icon}
|
|
173
129
|
size={iconSize}
|
|
174
|
-
color={
|
|
130
|
+
color={mapColorStates[color]?.icon?.disabled}
|
|
175
131
|
/>
|
|
176
132
|
)}
|
|
177
133
|
</Animated.View>
|