@pagopa/io-app-design-system 4.4.4 → 5.0.0-1
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 -5
- 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 -6
- 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 -6
- 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,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
2
|
import {
|
|
3
3
|
GestureResponderEvent,
|
|
4
4
|
Pressable,
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from "react-native";
|
|
8
8
|
import Animated, {
|
|
9
9
|
interpolateColor,
|
|
10
|
+
useAnimatedProps,
|
|
10
11
|
useAnimatedStyle,
|
|
11
12
|
useReducedMotion
|
|
12
13
|
} from "react-native-reanimated";
|
|
@@ -15,7 +16,7 @@ import {
|
|
|
15
16
|
IOColors,
|
|
16
17
|
IOSpacingScale,
|
|
17
18
|
hexToRgba,
|
|
18
|
-
|
|
19
|
+
useIONewTypeface
|
|
19
20
|
} from "../../core";
|
|
20
21
|
import { useScaleAnimation } from "../../hooks";
|
|
21
22
|
import { WithTestID } from "../../utils/types";
|
|
@@ -78,28 +79,6 @@ const mapColorStates: Record<
|
|
|
78
79
|
}
|
|
79
80
|
};
|
|
80
81
|
|
|
81
|
-
// TODO: Remove this when legacy look is deprecated https://pagopa.atlassian.net/browse/IOPLT-153
|
|
82
|
-
const mapLegacyColorStates: Record<
|
|
83
|
-
NonNullable<ButtonLinkProps["color"]>,
|
|
84
|
-
ColorStates
|
|
85
|
-
> = {
|
|
86
|
-
// Primary button
|
|
87
|
-
primary: {
|
|
88
|
-
label: {
|
|
89
|
-
default: IOColors.blue,
|
|
90
|
-
pressed: IOColors["blue-600"],
|
|
91
|
-
disabled: IOColors["grey-700"]
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
contrast: {
|
|
95
|
-
label: {
|
|
96
|
-
default: IOColors.white,
|
|
97
|
-
pressed: hexToRgba(IOColors.white, 0.85),
|
|
98
|
-
disabled: hexToRgba(IOColors.white, 0.5)
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
82
|
const DISABLED_OPACITY = 0.5;
|
|
104
83
|
const ICON_MARGIN = 8;
|
|
105
84
|
|
|
@@ -120,25 +99,43 @@ export const ButtonLink = forwardRef<View, ButtonLinkProps>(
|
|
|
120
99
|
},
|
|
121
100
|
ref
|
|
122
101
|
) => {
|
|
123
|
-
const {
|
|
102
|
+
const { newTypefaceEnabled } = useIONewTypeface();
|
|
124
103
|
const { progress, onPressIn, onPressOut, scaleAnimatedStyle } =
|
|
125
104
|
useScaleAnimation();
|
|
126
105
|
const reducedMotion = useReducedMotion();
|
|
127
106
|
|
|
128
|
-
const colorMap = useMemo(
|
|
129
|
-
() => (isExperimental ? mapColorStates : mapLegacyColorStates),
|
|
130
|
-
[isExperimental]
|
|
131
|
-
);
|
|
132
|
-
|
|
133
107
|
const AnimatedIOText = Animated.createAnimatedComponent(IOText);
|
|
134
108
|
|
|
135
|
-
const
|
|
136
|
-
color
|
|
109
|
+
const pressedColorLabelAnimationStyle = useAnimatedStyle(() => {
|
|
110
|
+
// Link color states to the pressed states
|
|
111
|
+
|
|
112
|
+
const labelColor = interpolateColor(
|
|
113
|
+
progress.value,
|
|
114
|
+
[0, 1],
|
|
115
|
+
[
|
|
116
|
+
mapColorStates[color].label.default,
|
|
117
|
+
mapColorStates[color].label.pressed
|
|
118
|
+
]
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
return {
|
|
122
|
+
color: labelColor
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// Animate the <Icon> color prop
|
|
127
|
+
const pressedColorIconAnimationStyle = useAnimatedProps(() => {
|
|
128
|
+
const iconColor = interpolateColor(
|
|
137
129
|
progress.value,
|
|
138
130
|
[0, 1],
|
|
139
|
-
[
|
|
140
|
-
|
|
141
|
-
|
|
131
|
+
[
|
|
132
|
+
mapColorStates[color].label.default,
|
|
133
|
+
mapColorStates[color].label.pressed
|
|
134
|
+
]
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
return { color: iconColor };
|
|
138
|
+
});
|
|
142
139
|
|
|
143
140
|
const AnimatedIconClassComponent =
|
|
144
141
|
Animated.createAnimatedComponent(IconClassComponent);
|
|
@@ -181,15 +178,15 @@ export const ButtonLink = forwardRef<View, ButtonLinkProps>(
|
|
|
181
178
|
<AnimatedIconClassComponent
|
|
182
179
|
allowFontScaling
|
|
183
180
|
name={icon}
|
|
184
|
-
animatedProps={
|
|
185
|
-
color={
|
|
181
|
+
animatedProps={pressedColorIconAnimationStyle}
|
|
182
|
+
color={mapColorStates[color]?.label?.default}
|
|
186
183
|
size={iconSize}
|
|
187
184
|
/>
|
|
188
185
|
) : (
|
|
189
186
|
<AnimatedIcon
|
|
190
187
|
allowFontScaling
|
|
191
188
|
name={icon}
|
|
192
|
-
color={
|
|
189
|
+
color={mapColorStates[color]?.label?.disabled}
|
|
193
190
|
size={iconSize}
|
|
194
191
|
/>
|
|
195
192
|
))}
|
|
@@ -197,14 +194,14 @@ export const ButtonLink = forwardRef<View, ButtonLinkProps>(
|
|
|
197
194
|
accessible={false}
|
|
198
195
|
accessibilityElementsHidden
|
|
199
196
|
importantForAccessibility="no-hide-descendants"
|
|
200
|
-
font={
|
|
197
|
+
font={newTypefaceEnabled ? "Titillio" : "TitilliumSansPro"}
|
|
201
198
|
weight={"Semibold"}
|
|
202
199
|
size={buttonTextFontSize}
|
|
203
200
|
lineHeight={buttonTextLineHeight}
|
|
204
201
|
style={[
|
|
205
202
|
disabled
|
|
206
|
-
? { color:
|
|
207
|
-
: { ...
|
|
203
|
+
? { color: mapColorStates[color]?.label?.disabled }
|
|
204
|
+
: { ...pressedColorLabelAnimationStyle },
|
|
208
205
|
{ textAlign }
|
|
209
206
|
]}
|
|
210
207
|
numberOfLines={numberOfLines}
|
|
@@ -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,21 +126,10 @@ 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
|
/* Prevent the component from triggering the `isEntering' transition
|
|
190
134
|
on the on the first render. Solution from this discussion:
|
|
191
135
|
https://github.com/software-mansion/react-native-reanimated/discussions/2513
|
|
@@ -203,7 +147,7 @@ export const ButtonSolid = React.forwardRef<View, ButtonSolidProps>(
|
|
|
203
147
|
const backgroundColor = interpolateColor(
|
|
204
148
|
progress.value,
|
|
205
149
|
[0, 1],
|
|
206
|
-
[
|
|
150
|
+
[mapColorStates[color].default, mapColorStates[color].pressed]
|
|
207
151
|
);
|
|
208
152
|
|
|
209
153
|
return { backgroundColor };
|
|
@@ -224,8 +168,8 @@ export const ButtonSolid = React.forwardRef<View, ButtonSolidProps>(
|
|
|
224
168
|
|
|
225
169
|
// Label & Icons colors
|
|
226
170
|
const foregroundColor: IOColors = disabled
|
|
227
|
-
?
|
|
228
|
-
:
|
|
171
|
+
? mapColorStates[color]?.label?.disabled
|
|
172
|
+
: mapColorStates[color]?.label?.default;
|
|
229
173
|
|
|
230
174
|
return (
|
|
231
175
|
<Pressable
|
|
@@ -248,15 +192,13 @@ export const ButtonSolid = React.forwardRef<View, ButtonSolidProps>(
|
|
|
248
192
|
>
|
|
249
193
|
<Animated.View
|
|
250
194
|
style={[
|
|
251
|
-
|
|
195
|
+
IOButtonStyles.button,
|
|
196
|
+
IOButtonStyles.buttonSizeDefault,
|
|
252
197
|
{ overflow: "hidden" },
|
|
253
|
-
|
|
254
|
-
buttonStyles.buttonSizeDefault,
|
|
198
|
+
fullWidth && { paddingHorizontal: 16 },
|
|
255
199
|
disabled
|
|
256
|
-
?
|
|
257
|
-
|
|
258
|
-
: legacyStyles.backgroundDisabled
|
|
259
|
-
: { backgroundColor: colorMap[color]?.default },
|
|
200
|
+
? styles.backgroundDisabled
|
|
201
|
+
: { backgroundColor: mapColorStates[color]?.default },
|
|
260
202
|
/* Prevent Reanimated from overriding background colors
|
|
261
203
|
if button is disabled */
|
|
262
204
|
!disabled && !reducedMotion && scaleAnimatedStyle,
|
|
@@ -265,7 +207,7 @@ export const ButtonSolid = React.forwardRef<View, ButtonSolidProps>(
|
|
|
265
207
|
>
|
|
266
208
|
{loading && (
|
|
267
209
|
<Animated.View
|
|
268
|
-
style={
|
|
210
|
+
style={IOButtonStyles.buttonInner}
|
|
269
211
|
entering={
|
|
270
212
|
isMounted.current ? enterTransitionInnerContentSmall : undefined
|
|
271
213
|
}
|
|
@@ -278,7 +220,7 @@ export const ButtonSolid = React.forwardRef<View, ButtonSolidProps>(
|
|
|
278
220
|
{!loading && (
|
|
279
221
|
<Animated.View
|
|
280
222
|
style={[
|
|
281
|
-
|
|
223
|
+
IOButtonStyles.buttonInner,
|
|
282
224
|
{ columnGap: ICON_MARGIN },
|
|
283
225
|
/* If 'iconPosition' is set to 'end', we use
|
|
284
226
|
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>
|