@pagopa/io-app-design-system 4.5.0 → 4.5.2
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/Advice.js +1 -1
- package/lib/commonjs/components/accordion/AccordionItem.js +1 -1
- package/lib/commonjs/components/accordion/AccordionItem.js.map +1 -1
- package/lib/commonjs/components/accordion/RawAccordion.js +1 -1
- package/lib/commonjs/components/accordion/RawAccordion.js.map +1 -1
- package/lib/commonjs/components/banner/__test__/__snapshots__/banner.test.tsx.snap +0 -4
- package/lib/commonjs/components/buttons/ButtonLink.js +26 -26
- package/lib/commonjs/components/buttons/ButtonLink.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonOutline.js +45 -101
- package/lib/commonjs/components/buttons/ButtonOutline.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonSolid.js +71 -64
- package/lib/commonjs/components/buttons/ButtonSolid.js.map +1 -1
- package/lib/commonjs/components/buttons/IconButton.js +31 -30
- package/lib/commonjs/components/buttons/IconButton.js.map +1 -1
- package/lib/commonjs/components/buttons/IconButtonContained.js +11 -11
- package/lib/commonjs/components/buttons/IconButtonContained.js.map +1 -1
- package/lib/commonjs/components/buttons/IconButtonSolid.js +30 -30
- package/lib/commonjs/components/buttons/IconButtonSolid.js.map +1 -1
- package/lib/commonjs/components/buttons/__test__/__snapshots__/button.test.tsx.snap +5 -7
- package/lib/commonjs/components/icons/Icon.js +2 -2
- package/lib/commonjs/components/icons/Icon.js.map +1 -1
- package/lib/commonjs/components/icons/README.md +1 -1
- package/lib/commonjs/components/icons/svg/IconProductIOAppBlueBg.js +8 -20
- package/lib/commonjs/components/icons/svg/IconProductIOAppBlueBg.js.map +1 -1
- package/lib/commonjs/components/icons/svg/originals/IconProductIOAppBlueBg.svg +12 -9
- package/lib/commonjs/components/layout/HeaderFirstLevel.js +2 -2
- package/lib/commonjs/components/layout/HeaderFirstLevel.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemInfo.js +1 -1
- package/lib/commonjs/components/listitems/ListItemInfo.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemInfoCopy.js +1 -1
- package/lib/commonjs/components/listitems/ListItemInfoCopy.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemNav.js +4 -3
- package/lib/commonjs/components/listitems/ListItemNav.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemNavAlert.js +1 -1
- package/lib/commonjs/components/listitems/ListItemNavAlert.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemTransaction.js +1 -1
- package/lib/commonjs/components/listitems/ListItemTransaction.js.map +1 -1
- package/lib/commonjs/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +2 -2
- package/lib/commonjs/components/numberpad/NumberButton.js +1 -1
- package/lib/commonjs/components/pictograms/Pictogram.js +1 -22
- package/lib/commonjs/components/pictograms/Pictogram.js.map +1 -1
- package/lib/commonjs/components/spacer/Spacer.js +1 -1
- package/lib/commonjs/components/spacer/Spacer.js.map +1 -1
- package/lib/commonjs/components/stepper/Stepper.js +1 -1
- package/lib/commonjs/components/switch/NativeSwitch.js +2 -2
- package/lib/commonjs/components/switch/NativeSwitch.js.map +1 -1
- package/lib/commonjs/components/tabs/TabItem.js +3 -3
- package/lib/commonjs/components/tabs/TabItem.js.map +1 -1
- package/lib/commonjs/components/typography/__test__/__snapshots__/typography.test.tsx.snap +4 -4
- package/lib/commonjs/components/typography/__test__/typography.test.js +13 -13
- package/lib/commonjs/components/typography/__test__/typography.test.js.map +1 -1
- package/lib/commonjs/core/IOColors.js +31 -99
- package/lib/commonjs/core/IOColors.js.map +1 -1
- package/lib/commonjs/core/IOStyles.js +2 -2
- package/lib/module/components/Advice/Advice.js +1 -1
- package/lib/module/components/accordion/AccordionItem.js +1 -1
- package/lib/module/components/accordion/AccordionItem.js.map +1 -1
- package/lib/module/components/accordion/RawAccordion.js +1 -1
- package/lib/module/components/accordion/RawAccordion.js.map +1 -1
- package/lib/module/components/banner/__test__/__snapshots__/banner.test.tsx.snap +0 -4
- package/lib/module/components/buttons/ButtonLink.js +27 -27
- package/lib/module/components/buttons/ButtonLink.js.map +1 -1
- package/lib/module/components/buttons/ButtonOutline.js +46 -102
- package/lib/module/components/buttons/ButtonOutline.js.map +1 -1
- package/lib/module/components/buttons/ButtonSolid.js +74 -67
- package/lib/module/components/buttons/ButtonSolid.js.map +1 -1
- package/lib/module/components/buttons/IconButton.js +32 -31
- package/lib/module/components/buttons/IconButton.js.map +1 -1
- package/lib/module/components/buttons/IconButtonContained.js +11 -11
- package/lib/module/components/buttons/IconButtonContained.js.map +1 -1
- package/lib/module/components/buttons/IconButtonSolid.js +31 -31
- package/lib/module/components/buttons/IconButtonSolid.js.map +1 -1
- package/lib/module/components/buttons/__test__/__snapshots__/button.test.tsx.snap +5 -7
- package/lib/module/components/icons/Icon.js +2 -2
- package/lib/module/components/icons/Icon.js.map +1 -1
- package/lib/module/components/icons/README.md +1 -1
- package/lib/module/components/icons/svg/IconProductIOAppBlueBg.js +9 -21
- package/lib/module/components/icons/svg/IconProductIOAppBlueBg.js.map +1 -1
- package/lib/module/components/icons/svg/originals/IconProductIOAppBlueBg.svg +12 -9
- package/lib/module/components/layout/HeaderFirstLevel.js +2 -2
- package/lib/module/components/layout/HeaderFirstLevel.js.map +1 -1
- package/lib/module/components/listitems/ListItemInfo.js +1 -1
- package/lib/module/components/listitems/ListItemInfo.js.map +1 -1
- package/lib/module/components/listitems/ListItemInfoCopy.js +1 -1
- package/lib/module/components/listitems/ListItemInfoCopy.js.map +1 -1
- package/lib/module/components/listitems/ListItemNav.js +4 -3
- package/lib/module/components/listitems/ListItemNav.js.map +1 -1
- package/lib/module/components/listitems/ListItemNavAlert.js +1 -1
- package/lib/module/components/listitems/ListItemNavAlert.js.map +1 -1
- package/lib/module/components/listitems/ListItemTransaction.js +1 -1
- package/lib/module/components/listitems/ListItemTransaction.js.map +1 -1
- package/lib/module/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +2 -2
- package/lib/module/components/numberpad/NumberButton.js +1 -1
- package/lib/module/components/pictograms/Pictogram.js +0 -20
- package/lib/module/components/pictograms/Pictogram.js.map +1 -1
- package/lib/module/components/spacer/Spacer.js +1 -1
- package/lib/module/components/spacer/Spacer.js.map +1 -1
- package/lib/module/components/stepper/Stepper.js +1 -1
- package/lib/module/components/switch/NativeSwitch.js +2 -2
- package/lib/module/components/switch/NativeSwitch.js.map +1 -1
- package/lib/module/components/tabs/TabItem.js +3 -3
- package/lib/module/components/tabs/TabItem.js.map +1 -1
- package/lib/module/components/typography/__test__/__snapshots__/typography.test.tsx.snap +4 -4
- package/lib/module/components/typography/__test__/typography.test.js +13 -13
- package/lib/module/components/typography/__test__/typography.test.js.map +1 -1
- package/lib/module/core/IOColors.js +31 -99
- package/lib/module/core/IOColors.js.map +1 -1
- package/lib/module/core/IOStyles.js +2 -2
- package/lib/typescript/components/buttons/ButtonLink.d.ts +1 -1
- package/lib/typescript/components/buttons/ButtonLink.d.ts.map +1 -1
- package/lib/typescript/components/buttons/ButtonOutline.d.ts +2 -2
- package/lib/typescript/components/buttons/ButtonOutline.d.ts.map +1 -1
- package/lib/typescript/components/buttons/ButtonSolid.d.ts +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/IconButtonSolid.d.ts.map +1 -1
- package/lib/typescript/components/icons/svg/IconProductIOAppBlueBg.d.ts.map +1 -1
- package/lib/typescript/components/layout/HeaderFirstLevel.d.ts +2 -2
- package/lib/typescript/components/layout/HeaderFirstLevel.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemNav.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemNavAlert.d.ts.map +1 -1
- package/lib/typescript/components/pictograms/Pictogram.d.ts +2 -11
- package/lib/typescript/components/pictograms/Pictogram.d.ts.map +1 -1
- package/lib/typescript/components/pictograms/types.d.ts +0 -1
- package/lib/typescript/components/pictograms/types.d.ts.map +1 -1
- package/lib/typescript/components/typography/BodyMonospace.d.ts +1 -1
- package/lib/typescript/components/typography/ButtonText.d.ts +1 -1
- package/lib/typescript/components/typography/Caption.d.ts +1 -1
- package/lib/typescript/components/typography/H1.d.ts +1 -1
- package/lib/typescript/components/typography/H2.d.ts +1 -1
- package/lib/typescript/components/typography/H3.d.ts +1 -1
- package/lib/typescript/components/typography/H4.d.ts +1 -1
- package/lib/typescript/components/typography/H5.d.ts +1 -1
- package/lib/typescript/components/typography/H6.d.ts +1 -1
- package/lib/typescript/components/typography/Hero.d.ts +1 -1
- package/lib/typescript/components/typography/markdown/MdH1.d.ts +1 -1
- package/lib/typescript/components/typography/markdown/MdH2.d.ts +1 -1
- package/lib/typescript/components/typography/markdown/MdH3.d.ts +1 -1
- package/lib/typescript/core/IOColors.d.ts +5 -35
- package/lib/typescript/core/IOColors.d.ts.map +1 -1
- package/lib/typescript/core/IOStyles.d.ts +2 -2
- package/lib/typescript/utils/fonts.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/Advice/Advice.tsx +1 -1
- package/src/components/accordion/AccordionItem.tsx +1 -1
- package/src/components/accordion/RawAccordion.tsx +1 -1
- package/src/components/banner/__test__/__snapshots__/banner.test.tsx.snap +0 -4
- package/src/components/buttons/ButtonLink.tsx +38 -31
- package/src/components/buttons/ButtonOutline.tsx +55 -112
- package/src/components/buttons/ButtonSolid.tsx +95 -79
- package/src/components/buttons/IconButton.tsx +39 -32
- package/src/components/buttons/IconButtonContained.tsx +11 -11
- package/src/components/buttons/IconButtonSolid.tsx +38 -34
- package/src/components/buttons/__test__/__snapshots__/button.test.tsx.snap +5 -7
- package/src/components/icons/Icon.tsx +2 -2
- package/src/components/icons/README.md +1 -1
- package/src/components/icons/svg/IconProductIOAppBlueBg.tsx +12 -13
- package/src/components/icons/svg/originals/IconProductIOAppBlueBg.svg +12 -9
- package/src/components/layout/HeaderFirstLevel.tsx +4 -4
- package/src/components/listitems/ListItemInfo.tsx +1 -1
- package/src/components/listitems/ListItemInfoCopy.tsx +1 -1
- package/src/components/listitems/ListItemNav.tsx +5 -4
- package/src/components/listitems/ListItemNavAlert.tsx +3 -1
- package/src/components/listitems/ListItemTransaction.tsx +1 -1
- package/src/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +2 -2
- package/src/components/numberpad/NumberButton.tsx +1 -1
- package/src/components/pictograms/Pictogram.tsx +0 -22
- package/src/components/pictograms/types.ts +0 -1
- package/src/components/spacer/Spacer.tsx +1 -1
- package/src/components/stepper/Stepper.tsx +1 -1
- package/src/components/switch/NativeSwitch.tsx +2 -2
- package/src/components/tabs/TabItem.tsx +3 -3
- package/src/components/typography/__test__/__snapshots__/typography.test.tsx.snap +4 -4
- package/src/components/typography/__test__/typography.test.tsx +18 -16
- package/src/core/IOColors.ts +39 -98
- package/src/core/IOStyles.ts +2 -2
- package/lib/commonjs/components/layout/BlockButtons.js +0 -85
- package/lib/commonjs/components/layout/BlockButtons.js.map +0 -1
- package/lib/commonjs/components/pictograms/svg/PictogramCompleted.js +0 -33
- package/lib/commonjs/components/pictograms/svg/PictogramCompleted.js.map +0 -1
- package/lib/commonjs/components/pictograms/svg/PictogramProcessing.js +0 -33
- package/lib/commonjs/components/pictograms/svg/PictogramProcessing.js.map +0 -1
- package/lib/commonjs/components/pictograms/svg/originals/PictogramCompleted.svg +0 -14
- package/lib/module/components/layout/BlockButtons.js +0 -76
- package/lib/module/components/layout/BlockButtons.js.map +0 -1
- package/lib/module/components/pictograms/svg/PictogramCompleted.js +0 -25
- package/lib/module/components/pictograms/svg/PictogramCompleted.js.map +0 -1
- package/lib/module/components/pictograms/svg/PictogramProcessing.js +0 -25
- package/lib/module/components/pictograms/svg/PictogramProcessing.js.map +0 -1
- package/lib/module/components/pictograms/svg/originals/PictogramCompleted.svg +0 -14
- package/lib/typescript/components/layout/BlockButtons.d.ts +0 -54
- package/lib/typescript/components/layout/BlockButtons.d.ts.map +0 -1
- package/lib/typescript/components/pictograms/svg/PictogramCompleted.d.ts +0 -5
- package/lib/typescript/components/pictograms/svg/PictogramCompleted.d.ts.map +0 -1
- package/lib/typescript/components/pictograms/svg/PictogramProcessing.d.ts +0 -5
- package/lib/typescript/components/pictograms/svg/PictogramProcessing.d.ts.map +0 -1
- package/src/components/layout/BlockButtons.tsx +0 -143
- package/src/components/pictograms/svg/PictogramCompleted.tsx +0 -22
- package/src/components/pictograms/svg/PictogramProcessing.tsx +0 -22
- package/src/components/pictograms/svg/originals/PictogramCompleted.svg +0 -14
|
@@ -16,7 +16,8 @@ import {
|
|
|
16
16
|
IOButtonStyles,
|
|
17
17
|
IOColors,
|
|
18
18
|
hexToRgba,
|
|
19
|
-
useIOExperimentalDesign
|
|
19
|
+
useIOExperimentalDesign,
|
|
20
|
+
useIOTheme
|
|
20
21
|
} from "../../core/";
|
|
21
22
|
import { useScaleAnimation } from "../../hooks";
|
|
22
23
|
import { WithTestID } from "../../utils/types";
|
|
@@ -28,7 +29,7 @@ import {
|
|
|
28
29
|
} from "../icons";
|
|
29
30
|
import { IOText, buttonTextFontSize } from "../typography";
|
|
30
31
|
|
|
31
|
-
type ColorButtonOutline = "primary" | "contrast"
|
|
32
|
+
type ColorButtonOutline = "primary" | "contrast";
|
|
32
33
|
export type ButtonOutline = WithTestID<
|
|
33
34
|
{
|
|
34
35
|
color?: ColorButtonOutline;
|
|
@@ -46,7 +47,7 @@ export type ButtonOutline = WithTestID<
|
|
|
46
47
|
>;
|
|
47
48
|
|
|
48
49
|
type ColorStates = {
|
|
49
|
-
|
|
50
|
+
foreground: {
|
|
50
51
|
default: string;
|
|
51
52
|
pressed: string;
|
|
52
53
|
disabled: string;
|
|
@@ -56,71 +57,6 @@ type ColorStates = {
|
|
|
56
57
|
pressed: string;
|
|
57
58
|
disabled: string;
|
|
58
59
|
};
|
|
59
|
-
label: {
|
|
60
|
-
default: string;
|
|
61
|
-
pressed: string;
|
|
62
|
-
disabled: string;
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const mapColorStates: Record<
|
|
67
|
-
NonNullable<ButtonOutline["color"]>,
|
|
68
|
-
ColorStates
|
|
69
|
-
> = {
|
|
70
|
-
// Primary button
|
|
71
|
-
primary: {
|
|
72
|
-
border: {
|
|
73
|
-
default: IOColors["blueIO-500"],
|
|
74
|
-
pressed: IOColors["blueIO-600"],
|
|
75
|
-
disabled: IOColors["grey-200"]
|
|
76
|
-
},
|
|
77
|
-
background: {
|
|
78
|
-
default: hexToRgba(IOColors["blueIO-50"], 0),
|
|
79
|
-
pressed: hexToRgba(IOColors["blueIO-50"], 1),
|
|
80
|
-
disabled: "transparent"
|
|
81
|
-
},
|
|
82
|
-
label: {
|
|
83
|
-
default: IOColors["blueIO-500"],
|
|
84
|
-
pressed: IOColors["blueIO-600"],
|
|
85
|
-
disabled: IOColors["grey-700"]
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
// Contrast button
|
|
89
|
-
contrast: {
|
|
90
|
-
border: {
|
|
91
|
-
default: IOColors.white,
|
|
92
|
-
pressed: IOColors.white,
|
|
93
|
-
disabled: IOColors["blueIO-200"]
|
|
94
|
-
},
|
|
95
|
-
background: {
|
|
96
|
-
default: hexToRgba(IOColors["blueIO-600"], 0),
|
|
97
|
-
pressed: IOColors["blueIO-600"],
|
|
98
|
-
disabled: "transparent"
|
|
99
|
-
},
|
|
100
|
-
label: {
|
|
101
|
-
default: IOColors.white,
|
|
102
|
-
pressed: IOColors.white,
|
|
103
|
-
disabled: IOColors["blueIO-200"]
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
// Danger button
|
|
107
|
-
danger: {
|
|
108
|
-
border: {
|
|
109
|
-
default: IOColors.red,
|
|
110
|
-
pressed: IOColors.red,
|
|
111
|
-
disabled: IOColors.bluegreyLight
|
|
112
|
-
},
|
|
113
|
-
background: {
|
|
114
|
-
default: hexToRgba(IOColors.red, 0),
|
|
115
|
-
pressed: hexToRgba(IOColors.red, 0.15),
|
|
116
|
-
disabled: "transparent"
|
|
117
|
-
},
|
|
118
|
-
label: {
|
|
119
|
-
default: IOColors.red,
|
|
120
|
-
pressed: IOColors.red,
|
|
121
|
-
disabled: IOColors.grey
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
60
|
};
|
|
125
61
|
|
|
126
62
|
// TODO: Remove this when legacy look is deprecated https://pagopa.atlassian.net/browse/IOPLT-153
|
|
@@ -130,25 +66,20 @@ const mapLegacyColorStates: Record<
|
|
|
130
66
|
> = {
|
|
131
67
|
// Primary button
|
|
132
68
|
primary: {
|
|
133
|
-
|
|
134
|
-
default: IOColors
|
|
135
|
-
pressed: IOColors
|
|
136
|
-
disabled: IOColors
|
|
69
|
+
foreground: {
|
|
70
|
+
default: IOColors["blue-500"],
|
|
71
|
+
pressed: IOColors["blue-500"],
|
|
72
|
+
disabled: IOColors["grey-450"]
|
|
137
73
|
},
|
|
138
74
|
background: {
|
|
139
|
-
default: hexToRgba(IOColors
|
|
140
|
-
pressed: hexToRgba(IOColors
|
|
75
|
+
default: hexToRgba(IOColors["blue-500"], 0),
|
|
76
|
+
pressed: hexToRgba(IOColors["blue-500"], 0.15),
|
|
141
77
|
disabled: "transparent"
|
|
142
|
-
},
|
|
143
|
-
label: {
|
|
144
|
-
default: IOColors.blue,
|
|
145
|
-
pressed: IOColors.blue,
|
|
146
|
-
disabled: IOColors.grey
|
|
147
78
|
}
|
|
148
79
|
},
|
|
149
80
|
// Contrast button
|
|
150
81
|
contrast: {
|
|
151
|
-
|
|
82
|
+
foreground: {
|
|
152
83
|
default: IOColors.white,
|
|
153
84
|
pressed: IOColors.white,
|
|
154
85
|
disabled: hexToRgba(IOColors.white, 0.5)
|
|
@@ -157,29 +88,6 @@ const mapLegacyColorStates: Record<
|
|
|
157
88
|
default: hexToRgba(IOColors.white, 0),
|
|
158
89
|
pressed: hexToRgba(IOColors.white, 0.2),
|
|
159
90
|
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
91
|
}
|
|
184
92
|
}
|
|
185
93
|
};
|
|
@@ -219,6 +127,7 @@ export const ButtonOutline = forwardRef<View, ButtonOutline>(
|
|
|
219
127
|
},
|
|
220
128
|
ref
|
|
221
129
|
) => {
|
|
130
|
+
const theme = useIOTheme();
|
|
222
131
|
const { isExperimental } = useIOExperimentalDesign();
|
|
223
132
|
const { progress, onPressIn, onPressOut, scaleAnimatedStyle } =
|
|
224
133
|
useScaleAnimation();
|
|
@@ -226,9 +135,43 @@ export const ButtonOutline = forwardRef<View, ButtonOutline>(
|
|
|
226
135
|
|
|
227
136
|
const AnimatedIOText = Animated.createAnimatedComponent(IOText);
|
|
228
137
|
|
|
138
|
+
const mapColorStates = React.useMemo<
|
|
139
|
+
Record<NonNullable<ButtonOutline["color"]>, ColorStates>
|
|
140
|
+
>(
|
|
141
|
+
() => ({
|
|
142
|
+
// Primary button
|
|
143
|
+
primary: {
|
|
144
|
+
foreground: {
|
|
145
|
+
default: IOColors[theme["interactiveElem-default"]],
|
|
146
|
+
pressed: IOColors[theme["interactiveElem-pressed"]],
|
|
147
|
+
disabled: IOColors[theme["interactiveOutline-disabled"]]
|
|
148
|
+
},
|
|
149
|
+
background: {
|
|
150
|
+
default: hexToRgba(IOColors[theme["interactiveElem-pressed"]], 0),
|
|
151
|
+
pressed: hexToRgba(IOColors[theme["interactiveElem-pressed"]], 0.1),
|
|
152
|
+
disabled: "transparent"
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
// Contrast button
|
|
156
|
+
contrast: {
|
|
157
|
+
foreground: {
|
|
158
|
+
default: IOColors.white,
|
|
159
|
+
pressed: IOColors.white,
|
|
160
|
+
disabled: IOColors["blueIO-200"]
|
|
161
|
+
},
|
|
162
|
+
background: {
|
|
163
|
+
default: hexToRgba(IOColors["blueIO-600"], 0),
|
|
164
|
+
pressed: hexToRgba(IOColors["blueIO-600"], 0.5),
|
|
165
|
+
disabled: "transparent"
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}),
|
|
169
|
+
[theme]
|
|
170
|
+
);
|
|
171
|
+
|
|
229
172
|
const colorMap = React.useMemo(
|
|
230
173
|
() => (isExperimental ? mapColorStates : mapLegacyColorStates),
|
|
231
|
-
[isExperimental]
|
|
174
|
+
[isExperimental, mapColorStates]
|
|
232
175
|
);
|
|
233
176
|
|
|
234
177
|
const buttonStyles = React.useMemo(
|
|
@@ -253,7 +196,7 @@ export const ButtonOutline = forwardRef<View, ButtonOutline>(
|
|
|
253
196
|
const borderColor = interpolateColor(
|
|
254
197
|
progress.value,
|
|
255
198
|
[0, 1],
|
|
256
|
-
[colorMap[color].
|
|
199
|
+
[colorMap[color].foreground.default, colorMap[color].foreground.pressed]
|
|
257
200
|
);
|
|
258
201
|
|
|
259
202
|
return {
|
|
@@ -266,7 +209,7 @@ export const ButtonOutline = forwardRef<View, ButtonOutline>(
|
|
|
266
209
|
color: interpolateColor(
|
|
267
210
|
progress.value,
|
|
268
211
|
[0, 1],
|
|
269
|
-
[colorMap[color].
|
|
212
|
+
[colorMap[color].foreground.default, colorMap[color].foreground.pressed]
|
|
270
213
|
)
|
|
271
214
|
}));
|
|
272
215
|
|
|
@@ -275,7 +218,7 @@ export const ButtonOutline = forwardRef<View, ButtonOutline>(
|
|
|
275
218
|
color: interpolateColor(
|
|
276
219
|
progress.value,
|
|
277
220
|
[0, 1],
|
|
278
|
-
[colorMap[color].
|
|
221
|
+
[colorMap[color].foreground.default, colorMap[color].foreground.pressed]
|
|
279
222
|
)
|
|
280
223
|
}));
|
|
281
224
|
|
|
@@ -308,12 +251,12 @@ export const ButtonOutline = forwardRef<View, ButtonOutline>(
|
|
|
308
251
|
disabled
|
|
309
252
|
? {
|
|
310
253
|
backgroundColor: colorMap[color]?.background?.disabled,
|
|
311
|
-
borderColor: colorMap[color]?.
|
|
254
|
+
borderColor: colorMap[color]?.foreground?.disabled,
|
|
312
255
|
opacity: DISABLED_OPACITY
|
|
313
256
|
}
|
|
314
257
|
: {
|
|
315
258
|
backgroundColor: colorMap[color]?.background?.default,
|
|
316
|
-
borderColor: colorMap[color]?.
|
|
259
|
+
borderColor: colorMap[color]?.foreground.default
|
|
317
260
|
},
|
|
318
261
|
/* Prevent Reanimated from overriding background colors
|
|
319
262
|
if button is disabled */
|
|
@@ -327,14 +270,14 @@ export const ButtonOutline = forwardRef<View, ButtonOutline>(
|
|
|
327
270
|
allowFontScaling
|
|
328
271
|
name={icon}
|
|
329
272
|
animatedProps={pressedColorIconAnimationStyle}
|
|
330
|
-
color={colorMap[color]?.
|
|
273
|
+
color={colorMap[color]?.foreground?.default}
|
|
331
274
|
size={iconSize}
|
|
332
275
|
/>
|
|
333
276
|
) : (
|
|
334
277
|
<AnimatedIcon
|
|
335
278
|
allowFontScaling
|
|
336
279
|
name={icon}
|
|
337
|
-
color={colorMap[color]?.
|
|
280
|
+
color={colorMap[color]?.foreground?.disabled}
|
|
338
281
|
size={iconSize}
|
|
339
282
|
/>
|
|
340
283
|
))}
|
|
@@ -350,7 +293,7 @@ export const ButtonOutline = forwardRef<View, ButtonOutline>(
|
|
|
350
293
|
style={[
|
|
351
294
|
buttonStyles.label,
|
|
352
295
|
disabled
|
|
353
|
-
? { color: colorMap[color]?.
|
|
296
|
+
? { color: colorMap[color]?.foreground?.disabled }
|
|
354
297
|
: { ...pressedColorLabelAnimationStyle }
|
|
355
298
|
]}
|
|
356
299
|
>
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
ComponentProps,
|
|
3
|
+
forwardRef,
|
|
4
|
+
useCallback,
|
|
5
|
+
useEffect,
|
|
6
|
+
useMemo,
|
|
7
|
+
useRef
|
|
8
|
+
} from "react";
|
|
2
9
|
import {
|
|
10
|
+
ColorValue,
|
|
3
11
|
GestureResponderEvent,
|
|
4
12
|
Pressable,
|
|
5
|
-
StyleSheet,
|
|
6
13
|
View
|
|
7
14
|
} from "react-native";
|
|
8
15
|
import ReactNativeHapticFeedback from "react-native-haptic-feedback";
|
|
@@ -18,7 +25,8 @@ import {
|
|
|
18
25
|
enterTransitionInnerContent,
|
|
19
26
|
enterTransitionInnerContentSmall,
|
|
20
27
|
exitTransitionInnerContent,
|
|
21
|
-
useIOExperimentalDesign
|
|
28
|
+
useIOExperimentalDesign,
|
|
29
|
+
useIOTheme
|
|
22
30
|
} from "../../core";
|
|
23
31
|
import { useScaleAnimation } from "../../hooks";
|
|
24
32
|
import { WithTestID } from "../../utils/types";
|
|
@@ -29,37 +37,23 @@ import { ButtonText } from "../typography/ButtonText";
|
|
|
29
37
|
export type ButtonSolidColor = "primary" | "danger" | "contrast";
|
|
30
38
|
|
|
31
39
|
type ColorStates = {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
background: {
|
|
41
|
+
default: string;
|
|
42
|
+
pressed: string;
|
|
43
|
+
disabled: string;
|
|
44
|
+
};
|
|
45
|
+
foreground: {
|
|
35
46
|
default: IOColors;
|
|
36
47
|
disabled: IOColors;
|
|
37
48
|
};
|
|
38
49
|
};
|
|
39
50
|
|
|
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
|
-
const colorPrimaryButtonDisabled: IOColors = "grey-200";
|
|
50
51
|
const ICON_MARGIN = 8;
|
|
51
52
|
const DISABLED_OPACITY = 0.5;
|
|
52
53
|
|
|
53
54
|
// Icon size
|
|
54
55
|
const iconSize: IOIconSizeScale = 20;
|
|
55
56
|
|
|
56
|
-
const styles = StyleSheet.create({
|
|
57
|
-
backgroundDisabled: {
|
|
58
|
-
backgroundColor: IOColors[colorPrimaryButtonDisabled],
|
|
59
|
-
opacity: DISABLED_OPACITY
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
|
|
63
57
|
export type ButtonSolidProps = WithTestID<
|
|
64
58
|
{
|
|
65
59
|
/**
|
|
@@ -87,39 +81,6 @@ export type ButtonSolidProps = WithTestID<
|
|
|
87
81
|
>
|
|
88
82
|
>;
|
|
89
83
|
|
|
90
|
-
const mapColorStates: Record<
|
|
91
|
-
NonNullable<ButtonSolidProps["color"]>,
|
|
92
|
-
ColorStates
|
|
93
|
-
> = {
|
|
94
|
-
// Primary button
|
|
95
|
-
primary: {
|
|
96
|
-
default: IOColors["blueIO-500"],
|
|
97
|
-
pressed: IOColors["blueIO-600"],
|
|
98
|
-
label: {
|
|
99
|
-
default: "white",
|
|
100
|
-
disabled: "grey-700"
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
// Danger button
|
|
104
|
-
danger: {
|
|
105
|
-
default: IOColors["error-600"],
|
|
106
|
-
pressed: IOColors["error-500"],
|
|
107
|
-
label: {
|
|
108
|
-
default: "white",
|
|
109
|
-
disabled: "grey-700"
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
// Contrast button
|
|
113
|
-
contrast: {
|
|
114
|
-
default: IOColors.white,
|
|
115
|
-
pressed: IOColors["blueIO-50"],
|
|
116
|
-
label: {
|
|
117
|
-
default: "blueIO-500",
|
|
118
|
-
disabled: "grey-700"
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
|
|
123
84
|
// TODO: Remove this when legacy look is deprecated https://pagopa.atlassian.net/browse/IOPLT-153
|
|
124
85
|
const mapLegacyColorStates: Record<
|
|
125
86
|
NonNullable<ButtonSolidProps["color"]>,
|
|
@@ -127,34 +88,43 @@ const mapLegacyColorStates: Record<
|
|
|
127
88
|
> = {
|
|
128
89
|
// Primary button
|
|
129
90
|
primary: {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
91
|
+
background: {
|
|
92
|
+
default: IOColors["blue-500"],
|
|
93
|
+
pressed: IOColors["blue-600"],
|
|
94
|
+
disabled: IOColors["grey-200"]
|
|
95
|
+
},
|
|
96
|
+
foreground: {
|
|
133
97
|
default: "white",
|
|
134
98
|
disabled: "white"
|
|
135
99
|
}
|
|
136
100
|
},
|
|
137
101
|
// Danger button
|
|
138
102
|
danger: {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
103
|
+
background: {
|
|
104
|
+
default: IOColors["error-600"],
|
|
105
|
+
pressed: IOColors["error-500"],
|
|
106
|
+
disabled: IOColors["grey-200"]
|
|
107
|
+
},
|
|
108
|
+
foreground: {
|
|
142
109
|
default: "white",
|
|
143
110
|
disabled: "white"
|
|
144
111
|
}
|
|
145
112
|
},
|
|
146
113
|
// Contrast button
|
|
147
114
|
contrast: {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
115
|
+
background: {
|
|
116
|
+
default: IOColors.white,
|
|
117
|
+
pressed: IOColors["blue-50"],
|
|
118
|
+
disabled: IOColors["grey-200"]
|
|
119
|
+
},
|
|
120
|
+
foreground: {
|
|
121
|
+
default: "blue-500",
|
|
152
122
|
disabled: "white"
|
|
153
123
|
}
|
|
154
124
|
}
|
|
155
125
|
};
|
|
156
126
|
|
|
157
|
-
export const ButtonSolid =
|
|
127
|
+
export const ButtonSolid = forwardRef<View, ButtonSolidProps>(
|
|
158
128
|
(
|
|
159
129
|
{
|
|
160
130
|
color = "primary",
|
|
@@ -171,17 +141,62 @@ export const ButtonSolid = React.forwardRef<View, ButtonSolidProps>(
|
|
|
171
141
|
},
|
|
172
142
|
ref
|
|
173
143
|
) => {
|
|
144
|
+
const theme = useIOTheme();
|
|
174
145
|
const { isExperimental } = useIOExperimentalDesign();
|
|
175
146
|
const { progress, onPressIn, onPressOut, scaleAnimatedStyle } =
|
|
176
147
|
useScaleAnimation();
|
|
177
148
|
const reducedMotion = useReducedMotion();
|
|
178
149
|
|
|
179
|
-
const
|
|
150
|
+
const mapColorStates = useMemo<
|
|
151
|
+
Record<NonNullable<ButtonSolidProps["color"]>, ColorStates>
|
|
152
|
+
>(
|
|
153
|
+
() => ({
|
|
154
|
+
// Primary button
|
|
155
|
+
primary: {
|
|
156
|
+
background: {
|
|
157
|
+
default: IOColors[theme["interactiveElem-default"]],
|
|
158
|
+
pressed: IOColors[theme["interactiveElem-pressed"]],
|
|
159
|
+
disabled: IOColors[theme["interactiveElem-disabled"]]
|
|
160
|
+
},
|
|
161
|
+
foreground: {
|
|
162
|
+
default: theme["buttonText-default"],
|
|
163
|
+
disabled: theme["buttonText-disabled"]
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
// Danger button
|
|
167
|
+
danger: {
|
|
168
|
+
background: {
|
|
169
|
+
default: IOColors["error-600"],
|
|
170
|
+
pressed: IOColors["error-500"],
|
|
171
|
+
disabled: IOColors[theme["interactiveElem-disabled"]]
|
|
172
|
+
},
|
|
173
|
+
foreground: {
|
|
174
|
+
default: theme["buttonText-default"],
|
|
175
|
+
disabled: theme["buttonText-disabled"]
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
// Contrast button
|
|
179
|
+
contrast: {
|
|
180
|
+
background: {
|
|
181
|
+
default: IOColors.white,
|
|
182
|
+
pressed: IOColors["blueIO-50"],
|
|
183
|
+
disabled: IOColors["blueIO-50"]
|
|
184
|
+
},
|
|
185
|
+
foreground: {
|
|
186
|
+
default: "blueIO-500",
|
|
187
|
+
disabled: "blueIO-500"
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}),
|
|
191
|
+
[theme]
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
const colorMap = useMemo(
|
|
180
195
|
() => (isExperimental ? mapColorStates : mapLegacyColorStates),
|
|
181
|
-
[isExperimental]
|
|
196
|
+
[isExperimental, mapColorStates]
|
|
182
197
|
);
|
|
183
198
|
|
|
184
|
-
const buttonStyles =
|
|
199
|
+
const buttonStyles = useMemo(
|
|
185
200
|
() => (isExperimental ? IOButtonStyles : IOButtonLegacyStyles),
|
|
186
201
|
[isExperimental]
|
|
187
202
|
);
|
|
@@ -203,7 +218,7 @@ export const ButtonSolid = React.forwardRef<View, ButtonSolidProps>(
|
|
|
203
218
|
const backgroundColor = interpolateColor(
|
|
204
219
|
progress.value,
|
|
205
220
|
[0, 1],
|
|
206
|
-
[colorMap[color].default, colorMap[color].pressed]
|
|
221
|
+
[colorMap[color].background.default, colorMap[color].background.pressed]
|
|
207
222
|
);
|
|
208
223
|
|
|
209
224
|
return { backgroundColor };
|
|
@@ -222,10 +237,15 @@ export const ButtonSolid = React.forwardRef<View, ButtonSolidProps>(
|
|
|
222
237
|
[loading, onPress]
|
|
223
238
|
);
|
|
224
239
|
|
|
240
|
+
// Background
|
|
241
|
+
const backgroundColor: ColorValue = disabled
|
|
242
|
+
? colorMap[color]?.background?.disabled
|
|
243
|
+
: colorMap[color]?.background?.default;
|
|
244
|
+
|
|
225
245
|
// Label & Icons colors
|
|
226
246
|
const foregroundColor: IOColors = disabled
|
|
227
|
-
? colorMap[color]?.
|
|
228
|
-
: colorMap[color]?.
|
|
247
|
+
? colorMap[color]?.foreground?.disabled
|
|
248
|
+
: colorMap[color]?.foreground?.default;
|
|
229
249
|
|
|
230
250
|
return (
|
|
231
251
|
<Pressable
|
|
@@ -249,14 +269,10 @@ export const ButtonSolid = React.forwardRef<View, ButtonSolidProps>(
|
|
|
249
269
|
<Animated.View
|
|
250
270
|
style={[
|
|
251
271
|
buttonStyles.button,
|
|
252
|
-
{ overflow: "hidden" },
|
|
272
|
+
{ backgroundColor, overflow: "hidden" },
|
|
253
273
|
isExperimental && fullWidth && { paddingHorizontal: 16 },
|
|
254
274
|
buttonStyles.buttonSizeDefault,
|
|
255
|
-
disabled
|
|
256
|
-
? isExperimental
|
|
257
|
-
? styles.backgroundDisabled
|
|
258
|
-
: legacyStyles.backgroundDisabled
|
|
259
|
-
: { backgroundColor: colorMap[color]?.default },
|
|
275
|
+
disabled ? { opacity: DISABLED_OPACITY } : {},
|
|
260
276
|
/* Prevent Reanimated from overriding background colors
|
|
261
277
|
if button is disabled */
|
|
262
278
|
!disabled && !reducedMotion && scaleAnimatedStyle,
|
|
@@ -10,7 +10,8 @@ import {
|
|
|
10
10
|
IOIconButtonStyles,
|
|
11
11
|
IOStyles,
|
|
12
12
|
hexToRgba,
|
|
13
|
-
useIOExperimentalDesign
|
|
13
|
+
useIOExperimentalDesign,
|
|
14
|
+
useIOTheme
|
|
14
15
|
} from "../../core";
|
|
15
16
|
import { useScaleAnimation } from "../../hooks";
|
|
16
17
|
import { WithTestID } from "../../utils/types";
|
|
@@ -47,36 +48,9 @@ const mapLegacyColorStates: Record<
|
|
|
47
48
|
// Primary button
|
|
48
49
|
primary: {
|
|
49
50
|
icon: {
|
|
50
|
-
default: IOColors
|
|
51
|
+
default: IOColors["blue-500"],
|
|
51
52
|
pressed: IOColors["blue-600"],
|
|
52
|
-
disabled: hexToRgba(IOColors
|
|
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
|
-
const mapColorStates: Record<NonNullable<IconButton["color"]>, ColorStates> = {
|
|
74
|
-
// Primary button
|
|
75
|
-
primary: {
|
|
76
|
-
icon: {
|
|
77
|
-
default: IOColors["blueIO-500"],
|
|
78
|
-
pressed: IOColors["blueIO-600"],
|
|
79
|
-
disabled: hexToRgba(IOColors["blueIO-500"], 0.25)
|
|
53
|
+
disabled: hexToRgba(IOColors["blue-500"], 0.25)
|
|
80
54
|
}
|
|
81
55
|
},
|
|
82
56
|
// Neutral button
|
|
@@ -84,7 +58,7 @@ const mapColorStates: Record<NonNullable<IconButton["color"]>, ColorStates> = {
|
|
|
84
58
|
icon: {
|
|
85
59
|
default: IOColors.black,
|
|
86
60
|
pressed: IOColors["grey-850"],
|
|
87
|
-
disabled: IOColors
|
|
61
|
+
disabled: IOColors["grey-450"]
|
|
88
62
|
}
|
|
89
63
|
},
|
|
90
64
|
// Contrast button
|
|
@@ -110,15 +84,48 @@ export const IconButton = ({
|
|
|
110
84
|
accessibilityHint,
|
|
111
85
|
testID
|
|
112
86
|
}: IconButton) => {
|
|
87
|
+
const theme = useIOTheme();
|
|
113
88
|
const { progress, onPressIn, onPressOut, scaleAnimatedStyle } =
|
|
114
89
|
useScaleAnimation("exaggerated");
|
|
115
90
|
const reducedMotion = useReducedMotion();
|
|
116
91
|
|
|
117
92
|
const { isExperimental } = useIOExperimentalDesign();
|
|
118
93
|
|
|
94
|
+
const mapColorStates = useMemo<
|
|
95
|
+
Record<NonNullable<IconButton["color"]>, ColorStates>
|
|
96
|
+
>(
|
|
97
|
+
() => ({
|
|
98
|
+
// Primary button
|
|
99
|
+
primary: {
|
|
100
|
+
icon: {
|
|
101
|
+
default: IOColors[theme["interactiveElem-default"]],
|
|
102
|
+
pressed: IOColors[theme["interactiveElem-pressed"]],
|
|
103
|
+
disabled: IOColors[theme["interactiveElem-disabled"]]
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
// Neutral button
|
|
107
|
+
neutral: {
|
|
108
|
+
icon: {
|
|
109
|
+
default: IOColors[theme["neutralButton-default"]],
|
|
110
|
+
pressed: IOColors[theme["neutralButton-pressed"]],
|
|
111
|
+
disabled: IOColors[theme["neutralButton-disabled"]]
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
// Contrast button
|
|
115
|
+
contrast: {
|
|
116
|
+
icon: {
|
|
117
|
+
default: IOColors.white,
|
|
118
|
+
pressed: hexToRgba(IOColors.white, 0.85),
|
|
119
|
+
disabled: hexToRgba(IOColors.white, 0.25)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}),
|
|
123
|
+
[theme]
|
|
124
|
+
);
|
|
125
|
+
|
|
119
126
|
const colorMap = useMemo(
|
|
120
127
|
() => (isExperimental ? mapColorStates : mapLegacyColorStates),
|
|
121
|
-
[isExperimental]
|
|
128
|
+
[isExperimental, mapColorStates]
|
|
122
129
|
);
|
|
123
130
|
|
|
124
131
|
// Animate the <Icon> color prop
|