@pagopa/io-app-design-system 5.0.0-3 → 5.0.0-5
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/accordion/AccordionItem.js +1 -1
- package/lib/commonjs/components/accordion/AccordionItem.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonLink.js +23 -22
- package/lib/commonjs/components/buttons/ButtonLink.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonOutline.js +37 -65
- package/lib/commonjs/components/buttons/ButtonOutline.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonSolid.js +50 -43
- package/lib/commonjs/components/buttons/ButtonSolid.js.map +1 -1
- package/lib/commonjs/components/buttons/IconButton.js +28 -26
- package/lib/commonjs/components/buttons/IconButton.js.map +1 -1
- package/lib/commonjs/components/buttons/IconButtonSolid.js +26 -25
- package/lib/commonjs/components/buttons/IconButtonSolid.js.map +1 -1
- package/lib/commonjs/components/buttons/__test__/__snapshots__/button.test.tsx.snap +6 -8
- 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 +7 -9
- package/lib/commonjs/components/layout/HeaderFirstLevel.js.map +1 -1
- package/lib/commonjs/components/layout/HeaderSecondLevel.js +24 -14
- package/lib/commonjs/components/layout/HeaderSecondLevel.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/core/IOColors.js +17 -3
- package/lib/commonjs/core/IOColors.js.map +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/buttons/ButtonLink.js +24 -23
- package/lib/module/components/buttons/ButtonLink.js.map +1 -1
- package/lib/module/components/buttons/ButtonOutline.js +38 -66
- package/lib/module/components/buttons/ButtonOutline.js.map +1 -1
- package/lib/module/components/buttons/ButtonSolid.js +53 -46
- package/lib/module/components/buttons/ButtonSolid.js.map +1 -1
- package/lib/module/components/buttons/IconButton.js +29 -27
- package/lib/module/components/buttons/IconButton.js.map +1 -1
- package/lib/module/components/buttons/IconButtonSolid.js +27 -26
- package/lib/module/components/buttons/IconButtonSolid.js.map +1 -1
- package/lib/module/components/buttons/__test__/__snapshots__/button.test.tsx.snap +6 -8
- 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 +8 -9
- package/lib/module/components/layout/HeaderFirstLevel.js.map +1 -1
- package/lib/module/components/layout/HeaderSecondLevel.js +26 -16
- package/lib/module/components/layout/HeaderSecondLevel.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/core/IOColors.js +17 -3
- package/lib/module/core/IOColors.js.map +1 -1
- 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 +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 +2 -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 +3 -4
- package/lib/typescript/components/layout/HeaderFirstLevel.d.ts.map +1 -1
- package/lib/typescript/components/layout/HeaderSecondLevel.d.ts +1 -1
- package/lib/typescript/components/layout/HeaderSecondLevel.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemNav.d.ts.map +1 -1
- package/lib/typescript/core/IOColors.d.ts +1 -1
- package/lib/typescript/core/IOColors.d.ts.map +1 -1
- package/lib/typescript/utils/fonts.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/accordion/AccordionItem.tsx +1 -1
- package/src/components/buttons/ButtonLink.tsx +34 -32
- package/src/components/buttons/ButtonOutline.tsx +48 -79
- package/src/components/buttons/ButtonSolid.tsx +73 -55
- package/src/components/buttons/IconButton.tsx +47 -28
- package/src/components/buttons/IconButtonSolid.tsx +33 -36
- package/src/components/buttons/__test__/__snapshots__/button.test.tsx.snap +6 -8
- 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 +19 -9
- package/src/components/layout/HeaderSecondLevel.tsx +45 -23
- 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/core/IOColors.ts +23 -2
- package/lib/commonjs/components/layout/BlockButtons.js +0 -85
- package/lib/commonjs/components/layout/BlockButtons.js.map +0 -1
- package/lib/module/components/layout/BlockButtons.js +0 -76
- package/lib/module/components/layout/BlockButtons.js.map +0 -1
- package/lib/typescript/components/layout/BlockButtons.d.ts +0 -54
- package/lib/typescript/components/layout/BlockButtons.d.ts.map +0 -1
- package/src/components/layout/BlockButtons.tsx +0 -143
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
ComponentProps,
|
|
3
|
+
forwardRef,
|
|
4
|
+
useCallback,
|
|
5
|
+
useEffect,
|
|
6
|
+
useRef
|
|
7
|
+
} from "react";
|
|
2
8
|
import {
|
|
9
|
+
ColorValue,
|
|
3
10
|
GestureResponderEvent,
|
|
4
11
|
Pressable,
|
|
5
|
-
StyleSheet,
|
|
6
12
|
View
|
|
7
13
|
} from "react-native";
|
|
8
14
|
import ReactNativeHapticFeedback from "react-native-haptic-feedback";
|
|
@@ -16,7 +22,8 @@ import {
|
|
|
16
22
|
IOColors,
|
|
17
23
|
enterTransitionInnerContent,
|
|
18
24
|
enterTransitionInnerContentSmall,
|
|
19
|
-
exitTransitionInnerContent
|
|
25
|
+
exitTransitionInnerContent,
|
|
26
|
+
useIOTheme
|
|
20
27
|
} from "../../core";
|
|
21
28
|
import { useScaleAnimation } from "../../hooks";
|
|
22
29
|
import { WithTestID } from "../../utils/types";
|
|
@@ -27,28 +34,23 @@ import { ButtonText } from "../typography/ButtonText";
|
|
|
27
34
|
export type ButtonSolidColor = "primary" | "danger" | "contrast";
|
|
28
35
|
|
|
29
36
|
type ColorStates = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
37
|
+
background: {
|
|
38
|
+
default: string;
|
|
39
|
+
pressed: string;
|
|
40
|
+
disabled: string;
|
|
41
|
+
};
|
|
42
|
+
foreground: {
|
|
33
43
|
default: IOColors;
|
|
34
44
|
disabled: IOColors;
|
|
35
45
|
};
|
|
36
46
|
};
|
|
37
47
|
|
|
38
|
-
const colorPrimaryButtonDisabled: IOColors = "grey-200";
|
|
39
48
|
const ICON_MARGIN = 8;
|
|
40
49
|
const DISABLED_OPACITY = 0.5;
|
|
41
50
|
|
|
42
51
|
// Icon size
|
|
43
52
|
const iconSize: IOIconSizeScale = 20;
|
|
44
53
|
|
|
45
|
-
const styles = StyleSheet.create({
|
|
46
|
-
backgroundDisabled: {
|
|
47
|
-
backgroundColor: IOColors[colorPrimaryButtonDisabled],
|
|
48
|
-
opacity: DISABLED_OPACITY
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
54
|
export type ButtonSolidProps = WithTestID<
|
|
53
55
|
{
|
|
54
56
|
/**
|
|
@@ -76,40 +78,7 @@ export type ButtonSolidProps = WithTestID<
|
|
|
76
78
|
>
|
|
77
79
|
>;
|
|
78
80
|
|
|
79
|
-
const
|
|
80
|
-
NonNullable<ButtonSolidProps["color"]>,
|
|
81
|
-
ColorStates
|
|
82
|
-
> = {
|
|
83
|
-
// Primary button
|
|
84
|
-
primary: {
|
|
85
|
-
default: IOColors["blueIO-500"],
|
|
86
|
-
pressed: IOColors["blueIO-600"],
|
|
87
|
-
label: {
|
|
88
|
-
default: "white",
|
|
89
|
-
disabled: "grey-700"
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
// Danger button
|
|
93
|
-
danger: {
|
|
94
|
-
default: IOColors["error-600"],
|
|
95
|
-
pressed: IOColors["error-500"],
|
|
96
|
-
label: {
|
|
97
|
-
default: "white",
|
|
98
|
-
disabled: "grey-700"
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
// Contrast button
|
|
102
|
-
contrast: {
|
|
103
|
-
default: IOColors.white,
|
|
104
|
-
pressed: IOColors["blueIO-50"],
|
|
105
|
-
label: {
|
|
106
|
-
default: "blueIO-500",
|
|
107
|
-
disabled: "grey-700"
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
export const ButtonSolid = React.forwardRef<View, ButtonSolidProps>(
|
|
81
|
+
export const ButtonSolid = forwardRef<View, ButtonSolidProps>(
|
|
113
82
|
(
|
|
114
83
|
{
|
|
115
84
|
color = "primary",
|
|
@@ -126,10 +95,53 @@ export const ButtonSolid = React.forwardRef<View, ButtonSolidProps>(
|
|
|
126
95
|
},
|
|
127
96
|
ref
|
|
128
97
|
) => {
|
|
98
|
+
const theme = useIOTheme();
|
|
129
99
|
const { progress, onPressIn, onPressOut, scaleAnimatedStyle } =
|
|
130
100
|
useScaleAnimation();
|
|
131
101
|
const reducedMotion = useReducedMotion();
|
|
132
102
|
|
|
103
|
+
const mapColorStates: Record<
|
|
104
|
+
NonNullable<ButtonSolidProps["color"]>,
|
|
105
|
+
ColorStates
|
|
106
|
+
> = {
|
|
107
|
+
// Primary button
|
|
108
|
+
primary: {
|
|
109
|
+
background: {
|
|
110
|
+
default: IOColors[theme["interactiveElem-default"]],
|
|
111
|
+
pressed: IOColors[theme["interactiveElem-pressed"]],
|
|
112
|
+
disabled: IOColors[theme["interactiveElem-disabled"]]
|
|
113
|
+
},
|
|
114
|
+
foreground: {
|
|
115
|
+
default: theme["buttonText-default"],
|
|
116
|
+
disabled: theme["buttonText-disabled"]
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
// Danger button
|
|
120
|
+
danger: {
|
|
121
|
+
background: {
|
|
122
|
+
default: IOColors["error-600"],
|
|
123
|
+
pressed: IOColors["error-500"],
|
|
124
|
+
disabled: IOColors[theme["interactiveElem-disabled"]]
|
|
125
|
+
},
|
|
126
|
+
foreground: {
|
|
127
|
+
default: theme["buttonText-default"],
|
|
128
|
+
disabled: theme["buttonText-disabled"]
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
// Contrast button
|
|
132
|
+
contrast: {
|
|
133
|
+
background: {
|
|
134
|
+
default: IOColors.white,
|
|
135
|
+
pressed: IOColors["blueIO-50"],
|
|
136
|
+
disabled: IOColors["blueIO-50"]
|
|
137
|
+
},
|
|
138
|
+
foreground: {
|
|
139
|
+
default: "blueIO-500",
|
|
140
|
+
disabled: "blueIO-500"
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
133
145
|
/* Prevent the component from triggering the `isEntering' transition
|
|
134
146
|
on the on the first render. Solution from this discussion:
|
|
135
147
|
https://github.com/software-mansion/react-native-reanimated/discussions/2513
|
|
@@ -147,7 +159,10 @@ export const ButtonSolid = React.forwardRef<View, ButtonSolidProps>(
|
|
|
147
159
|
const backgroundColor = interpolateColor(
|
|
148
160
|
progress.value,
|
|
149
161
|
[0, 1],
|
|
150
|
-
[
|
|
162
|
+
[
|
|
163
|
+
mapColorStates[color].background.default,
|
|
164
|
+
mapColorStates[color].background.pressed
|
|
165
|
+
]
|
|
151
166
|
);
|
|
152
167
|
|
|
153
168
|
return { backgroundColor };
|
|
@@ -166,10 +181,15 @@ export const ButtonSolid = React.forwardRef<View, ButtonSolidProps>(
|
|
|
166
181
|
[loading, onPress]
|
|
167
182
|
);
|
|
168
183
|
|
|
184
|
+
// Background
|
|
185
|
+
const backgroundColor: ColorValue = disabled
|
|
186
|
+
? mapColorStates[color]?.background?.disabled
|
|
187
|
+
: mapColorStates[color]?.background?.default;
|
|
188
|
+
|
|
169
189
|
// Label & Icons colors
|
|
170
190
|
const foregroundColor: IOColors = disabled
|
|
171
|
-
? mapColorStates[color]?.
|
|
172
|
-
: mapColorStates[color]?.
|
|
191
|
+
? mapColorStates[color]?.foreground?.disabled
|
|
192
|
+
: mapColorStates[color]?.foreground?.default;
|
|
173
193
|
|
|
174
194
|
return (
|
|
175
195
|
<Pressable
|
|
@@ -194,11 +214,9 @@ export const ButtonSolid = React.forwardRef<View, ButtonSolidProps>(
|
|
|
194
214
|
style={[
|
|
195
215
|
IOButtonStyles.button,
|
|
196
216
|
IOButtonStyles.buttonSizeDefault,
|
|
197
|
-
{ overflow: "hidden" },
|
|
217
|
+
{ backgroundColor, overflow: "hidden" },
|
|
198
218
|
fullWidth && { paddingHorizontal: 16 },
|
|
199
|
-
disabled
|
|
200
|
-
? styles.backgroundDisabled
|
|
201
|
-
: { backgroundColor: mapColorStates[color]?.default },
|
|
219
|
+
disabled ? { opacity: DISABLED_OPACITY } : {},
|
|
202
220
|
/* Prevent Reanimated from overriding background colors
|
|
203
221
|
if button is disabled */
|
|
204
222
|
!disabled && !reducedMotion && scaleAnimatedStyle,
|
|
@@ -5,7 +5,14 @@ import Animated, {
|
|
|
5
5
|
useAnimatedProps,
|
|
6
6
|
useReducedMotion
|
|
7
7
|
} from "react-native-reanimated";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
IOColors,
|
|
10
|
+
IOIconButtonStyles,
|
|
11
|
+
IOStyles,
|
|
12
|
+
IOThemeLight,
|
|
13
|
+
hexToRgba,
|
|
14
|
+
useIOTheme
|
|
15
|
+
} from "../../core";
|
|
9
16
|
import { useScaleAnimation } from "../../hooks";
|
|
10
17
|
import { WithTestID } from "../../utils/types";
|
|
11
18
|
import {
|
|
@@ -23,6 +30,7 @@ export type IconButton = WithTestID<{
|
|
|
23
30
|
accessibilityLabel: string;
|
|
24
31
|
accessibilityHint?: string;
|
|
25
32
|
onPress: (event: GestureResponderEvent) => void;
|
|
33
|
+
persistentColorMode?: boolean;
|
|
26
34
|
}>;
|
|
27
35
|
|
|
28
36
|
type ColorStates = {
|
|
@@ -33,38 +41,12 @@ type ColorStates = {
|
|
|
33
41
|
};
|
|
34
42
|
};
|
|
35
43
|
|
|
36
|
-
const mapColorStates: Record<NonNullable<IconButton["color"]>, ColorStates> = {
|
|
37
|
-
// Primary button
|
|
38
|
-
primary: {
|
|
39
|
-
icon: {
|
|
40
|
-
default: IOColors["blueIO-500"],
|
|
41
|
-
pressed: IOColors["blueIO-600"],
|
|
42
|
-
disabled: hexToRgba(IOColors["blueIO-500"], 0.25)
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
// Neutral button
|
|
46
|
-
neutral: {
|
|
47
|
-
icon: {
|
|
48
|
-
default: IOColors.black,
|
|
49
|
-
pressed: IOColors["grey-850"],
|
|
50
|
-
disabled: IOColors["grey-450"]
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
// Contrast button
|
|
54
|
-
contrast: {
|
|
55
|
-
icon: {
|
|
56
|
-
default: IOColors.white,
|
|
57
|
-
pressed: hexToRgba(IOColors.white, 0.85),
|
|
58
|
-
disabled: hexToRgba(IOColors.white, 0.25)
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
44
|
const AnimatedIconClassComponent =
|
|
64
45
|
Animated.createAnimatedComponent(IconClassComponent);
|
|
65
46
|
|
|
66
47
|
export const IconButton = ({
|
|
67
48
|
color = "primary",
|
|
49
|
+
persistentColorMode = false,
|
|
68
50
|
icon,
|
|
69
51
|
iconSize = 24,
|
|
70
52
|
disabled = false,
|
|
@@ -73,10 +55,47 @@ export const IconButton = ({
|
|
|
73
55
|
accessibilityHint,
|
|
74
56
|
testID
|
|
75
57
|
}: IconButton) => {
|
|
58
|
+
const theme = useIOTheme();
|
|
76
59
|
const { progress, onPressIn, onPressOut, scaleAnimatedStyle } =
|
|
77
60
|
useScaleAnimation("exaggerated");
|
|
78
61
|
const reducedMotion = useReducedMotion();
|
|
79
62
|
|
|
63
|
+
const mapColorStates: Record<
|
|
64
|
+
NonNullable<IconButton["color"]>,
|
|
65
|
+
ColorStates
|
|
66
|
+
> = {
|
|
67
|
+
// Primary button
|
|
68
|
+
primary: {
|
|
69
|
+
icon: {
|
|
70
|
+
default: IOColors[theme["interactiveElem-default"]],
|
|
71
|
+
pressed: IOColors[theme["interactiveElem-pressed"]],
|
|
72
|
+
disabled: IOColors[theme["interactiveElem-disabled"]]
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
// Neutral button
|
|
76
|
+
neutral: {
|
|
77
|
+
icon: {
|
|
78
|
+
default: persistentColorMode
|
|
79
|
+
? IOColors[IOThemeLight["neutralButton-default"]]
|
|
80
|
+
: IOColors[theme["neutralButton-default"]],
|
|
81
|
+
pressed: persistentColorMode
|
|
82
|
+
? IOColors[IOThemeLight["neutralButton-pressed"]]
|
|
83
|
+
: IOColors[theme["neutralButton-pressed"]],
|
|
84
|
+
disabled: persistentColorMode
|
|
85
|
+
? IOColors[IOThemeLight["neutralButton-disabled"]]
|
|
86
|
+
: IOColors[theme["neutralButton-disabled"]]
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
// Contrast button
|
|
90
|
+
contrast: {
|
|
91
|
+
icon: {
|
|
92
|
+
default: IOColors.white,
|
|
93
|
+
pressed: hexToRgba(IOColors.white, 0.85),
|
|
94
|
+
disabled: hexToRgba(IOColors.white, 0.25)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
80
99
|
// Animate the <Icon> color prop
|
|
81
100
|
const animatedColor = useAnimatedProps(() => {
|
|
82
101
|
const iconColor = interpolateColor(
|
|
@@ -5,7 +5,7 @@ import Animated, {
|
|
|
5
5
|
useAnimatedStyle,
|
|
6
6
|
useReducedMotion
|
|
7
7
|
} from "react-native-reanimated";
|
|
8
|
-
import { IOButtonStyles, IOIconButtonStyles } from "../../core";
|
|
8
|
+
import { IOButtonStyles, IOIconButtonStyles, useIOTheme } from "../../core";
|
|
9
9
|
import { IOColors, hexToRgba } from "../../core/IOColors";
|
|
10
10
|
import { useScaleAnimation } from "../../hooks";
|
|
11
11
|
import { WithTestID } from "../../utils/types";
|
|
@@ -32,35 +32,6 @@ type ColorStates = {
|
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
const mapColorStates: Record<
|
|
36
|
-
NonNullable<IconButtonSolid["color"]>,
|
|
37
|
-
ColorStates
|
|
38
|
-
> = {
|
|
39
|
-
// Primary button
|
|
40
|
-
primary: {
|
|
41
|
-
background: {
|
|
42
|
-
default: IOColors["blueIO-500"],
|
|
43
|
-
pressed: IOColors["blueIO-600"],
|
|
44
|
-
disabled: IOColors["grey-100"]
|
|
45
|
-
},
|
|
46
|
-
icon: {
|
|
47
|
-
default: IOColors.white,
|
|
48
|
-
disabled: IOColors["grey-450"]
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
contrast: {
|
|
52
|
-
background: {
|
|
53
|
-
default: IOColors.white,
|
|
54
|
-
pressed: IOColors["blueIO-50"],
|
|
55
|
-
disabled: hexToRgba(IOColors.white, 0.25)
|
|
56
|
-
},
|
|
57
|
-
icon: {
|
|
58
|
-
default: IOColors["blueIO-500"],
|
|
59
|
-
disabled: IOColors["blueIO-500"]
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
35
|
export const IconButtonSolid = ({
|
|
65
36
|
icon,
|
|
66
37
|
color = "primary",
|
|
@@ -70,10 +41,40 @@ export const IconButtonSolid = ({
|
|
|
70
41
|
accessibilityHint,
|
|
71
42
|
testID
|
|
72
43
|
}: IconButtonSolid) => {
|
|
44
|
+
const theme = useIOTheme();
|
|
73
45
|
const { progress, onPressIn, onPressOut, scaleAnimatedStyle } =
|
|
74
46
|
useScaleAnimation("exaggerated");
|
|
75
47
|
const reducedMotion = useReducedMotion();
|
|
76
48
|
|
|
49
|
+
const mapColorStates: Record<
|
|
50
|
+
NonNullable<IconButtonSolid["color"]>,
|
|
51
|
+
ColorStates
|
|
52
|
+
> = {
|
|
53
|
+
// Primary button
|
|
54
|
+
primary: {
|
|
55
|
+
background: {
|
|
56
|
+
default: IOColors[theme["interactiveElem-default"]],
|
|
57
|
+
pressed: IOColors[theme["interactiveElem-pressed"]],
|
|
58
|
+
disabled: IOColors[theme["interactiveElem-disabled"]]
|
|
59
|
+
},
|
|
60
|
+
icon: {
|
|
61
|
+
default: IOColors[theme["buttonText-default"]],
|
|
62
|
+
disabled: IOColors[theme["buttonText-disabled"]]
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
contrast: {
|
|
66
|
+
background: {
|
|
67
|
+
default: IOColors.white,
|
|
68
|
+
pressed: IOColors["blueIO-50"],
|
|
69
|
+
disabled: hexToRgba(IOColors.white, 0.25)
|
|
70
|
+
},
|
|
71
|
+
icon: {
|
|
72
|
+
default: IOColors["blueIO-500"],
|
|
73
|
+
disabled: IOColors["blueIO-500"]
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
77
78
|
const backgroundColorAnimationStyle = useAnimatedStyle(() => ({
|
|
78
79
|
backgroundColor: interpolateColor(
|
|
79
80
|
progress.value,
|
|
@@ -106,12 +107,8 @@ export const IconButtonSolid = ({
|
|
|
106
107
|
!disabled && !reducedMotion && scaleAnimatedStyle,
|
|
107
108
|
!disabled && backgroundColorAnimationStyle,
|
|
108
109
|
disabled
|
|
109
|
-
? {
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
: {
|
|
113
|
-
backgroundColor: mapColorStates[color]?.background?.default
|
|
114
|
-
}
|
|
110
|
+
? { backgroundColor: mapColorStates[color]?.background?.disabled }
|
|
111
|
+
: { backgroundColor: mapColorStates[color]?.background?.default }
|
|
115
112
|
]}
|
|
116
113
|
>
|
|
117
114
|
<AnimatedIcon
|
|
@@ -176,7 +176,7 @@ exports[`Test Buttons Components - Experimental Enabled ButtonOutline Snapshot 1
|
|
|
176
176
|
},
|
|
177
177
|
false,
|
|
178
178
|
{
|
|
179
|
-
"backgroundColor": "rgba(
|
|
179
|
+
"backgroundColor": "rgba(9,50,182,0)",
|
|
180
180
|
"borderColor": "#0B3EE3",
|
|
181
181
|
},
|
|
182
182
|
{
|
|
@@ -285,12 +285,11 @@ exports[`Test Buttons Components - Experimental Enabled ButtonSolid Snapshot 1`]
|
|
|
285
285
|
"height": 48,
|
|
286
286
|
},
|
|
287
287
|
{
|
|
288
|
+
"backgroundColor": "#0B3EE3",
|
|
288
289
|
"overflow": "hidden",
|
|
289
290
|
},
|
|
290
291
|
false,
|
|
291
|
-
{
|
|
292
|
-
"backgroundColor": "#0B3EE3",
|
|
293
|
-
},
|
|
292
|
+
{},
|
|
294
293
|
{
|
|
295
294
|
"transform": [
|
|
296
295
|
{
|
|
@@ -920,7 +919,7 @@ exports[`Test Buttons Components ButtonOutline Snapshot 1`] = `
|
|
|
920
919
|
},
|
|
921
920
|
false,
|
|
922
921
|
{
|
|
923
|
-
"backgroundColor": "rgba(
|
|
922
|
+
"backgroundColor": "rgba(9,50,182,0)",
|
|
924
923
|
"borderColor": "#0B3EE3",
|
|
925
924
|
},
|
|
926
925
|
{
|
|
@@ -1029,12 +1028,11 @@ exports[`Test Buttons Components ButtonSolid Snapshot 1`] = `
|
|
|
1029
1028
|
"height": 48,
|
|
1030
1029
|
},
|
|
1031
1030
|
{
|
|
1031
|
+
"backgroundColor": "#0B3EE3",
|
|
1032
1032
|
"overflow": "hidden",
|
|
1033
1033
|
},
|
|
1034
1034
|
false,
|
|
1035
|
-
{
|
|
1036
|
-
"backgroundColor": "#0B3EE3",
|
|
1037
|
-
},
|
|
1035
|
+
{},
|
|
1038
1036
|
{
|
|
1039
1037
|
"transform": [
|
|
1040
1038
|
{
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { Path, Svg } from "react-native-svg";
|
|
3
|
+
import { IOColors } from "../../../core";
|
|
3
4
|
import { SVGIconProps } from "../types";
|
|
4
5
|
|
|
5
6
|
const IconProductIOAppBlueBg = ({ size, style, ...props }: SVGIconProps) => (
|
|
6
7
|
<Svg width={size} height={size} viewBox="0 0 24 24" style={style} {...props}>
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
<Path fill="#fff" d="M-13-13h50v50h-50z" />
|
|
18
|
-
</G>
|
|
8
|
+
<Path
|
|
9
|
+
d="M0 9.6c0-3.36 0-5.04.654-6.324A6 6 0 0 1 3.276.654C4.56 0 6.24 0 9.6 0h4.8c3.36 0 5.04 0 6.324.654a6 6 0 0 1 2.622 2.622C24 4.56 24 6.24 24 9.6v4.8c0 3.36 0 5.04-.654 6.324a6 6 0 0 1-2.622 2.622C19.44 24 17.76 24 14.4 24H9.6c-3.36 0-5.04 0-6.324-.654a6 6 0 0 1-2.622-2.622C0 19.44 0 17.76 0 14.4V9.6Z"
|
|
10
|
+
fill={IOColors["blueIO-500"]}
|
|
11
|
+
/>
|
|
12
|
+
<Path
|
|
13
|
+
fillRule="evenodd"
|
|
14
|
+
clipRule="evenodd"
|
|
15
|
+
d="M7.21 6.4a1.35 1.35 0 1 1 0 2.7 1.35 1.35 0 0 1 0-2.7Zm11.34 6.48c0 2.386-1.934 4.32-4.114 4.32-2.592 0-4.526-1.934-4.526-4.32s1.934-4.32 4.526-4.32c2.18 0 4.114 1.934 4.114 4.32ZM8.29 11.53a1.08 1.08 0 1 0-2.16 0v4.59a1.08 1.08 0 0 0 2.16 0v-4.59Zm7.001.897h.576v-.566h-.571v-.685h-.625v2.277c0 .36.05.606.153.737.1.136.29.202.57.202.108 0 .27-.026.477-.075l-.03-.526-.355.009c-.062 0-.108-.013-.137-.044a.177.177 0 0 1-.05-.105 2.24 2.24 0 0 1-.008-.211v-1.013Zm-1.882-.562v2.47h.624v-2.47h-.624Zm-.938-.062a.366.366 0 0 1 .378.385c0 .11-.034.196-.105.27a.37.37 0 0 1-.269.101.375.375 0 0 1-.382-.38c0-.106.038-.196.105-.27a.363.363 0 0 1 .273-.106Z"
|
|
16
|
+
fill={IOColors.white}
|
|
17
|
+
/>
|
|
19
18
|
</Svg>
|
|
20
19
|
);
|
|
21
20
|
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
2
|
+
<path
|
|
3
|
+
d="M0 9.6c0-3.36 0-5.04.654-6.324A6 6 0 0 1 3.276.654C4.56 0 6.24 0 9.6 0h4.8c3.36 0 5.04 0 6.324.654a6 6 0 0 1 2.622 2.622C24 4.56 24 6.24 24 9.6v4.8c0 3.36 0 5.04-.654 6.324a6 6 0 0 1-2.622 2.622C19.44 24 17.76 24 14.4 24H9.6c-3.36 0-5.04 0-6.324-.654a6 6 0 0 1-2.622-2.622C0 19.44 0 17.76 0 14.4V9.6Z"
|
|
4
|
+
fill="#0B3EE3"
|
|
5
|
+
/>
|
|
6
|
+
<path
|
|
7
|
+
fill-rule="evenodd"
|
|
8
|
+
clip-rule="evenodd"
|
|
9
|
+
d="M7.21 6.4a1.35 1.35 0 1 1 0 2.7 1.35 1.35 0 0 1 0-2.7Zm11.34 6.48c0 2.386-1.934 4.32-4.114 4.32-2.592 0-4.526-1.934-4.526-4.32s1.934-4.32 4.526-4.32c2.18 0 4.114 1.934 4.114 4.32ZM8.29 11.53a1.08 1.08 0 1 0-2.16 0v4.59a1.08 1.08 0 0 0 2.16 0v-4.59Zm7.001.897h.576v-.566h-.571v-.685h-.625v2.277c0 .36.05.606.153.737.1.136.29.202.57.202.108 0 .27-.026.477-.075l-.03-.526-.355.009c-.062 0-.108-.013-.137-.044a.177.177 0 0 1-.05-.105 2.24 2.24 0 0 1-.008-.211v-1.013Zm-1.882-.562v2.47h.624v-2.47h-.624Zm-.938-.062a.366.366 0 0 1 .378.385c0 .11-.034.196-.105.27a.37.37 0 0 1-.269.101.375.375 0 0 1-.382-.38c0-.106.038-.196.105-.27a.363.363 0 0 1 .273-.106Z"
|
|
10
|
+
fill="#fff"
|
|
11
|
+
/>
|
|
12
|
+
</svg>
|
|
@@ -26,11 +26,15 @@ import { HStack } from "../stack";
|
|
|
26
26
|
import { H3 } from "../typography";
|
|
27
27
|
import { HeaderActionProps } from "./common";
|
|
28
28
|
|
|
29
|
+
type HeaderActionsProp =
|
|
30
|
+
| readonly [] // No actions
|
|
31
|
+
| readonly [HeaderActionProps] // Single action
|
|
32
|
+
| readonly [HeaderActionProps, HeaderActionProps] // Two actions
|
|
33
|
+
| readonly [HeaderActionProps, HeaderActionProps, HeaderActionProps]; // Three actions
|
|
34
|
+
|
|
29
35
|
export type HeaderFirstLevel = WithTestID<{
|
|
30
36
|
title: string;
|
|
31
|
-
|
|
32
|
-
secondAction: HeaderActionProps;
|
|
33
|
-
thirdAction?: HeaderActionProps;
|
|
37
|
+
actions: HeaderActionsProp;
|
|
34
38
|
animatedRef?: AnimatedRef<Animated.ScrollView>;
|
|
35
39
|
animatedFlatListRef?: AnimatedRef<Animated.FlatList<any>>;
|
|
36
40
|
ignoreSafeAreaMargin?: boolean;
|
|
@@ -58,9 +62,7 @@ const styles = StyleSheet.create({
|
|
|
58
62
|
export const HeaderFirstLevel = ({
|
|
59
63
|
title,
|
|
60
64
|
testID,
|
|
61
|
-
|
|
62
|
-
secondAction,
|
|
63
|
-
thirdAction,
|
|
65
|
+
actions = [],
|
|
64
66
|
ignoreSafeAreaMargin = false,
|
|
65
67
|
animatedRef,
|
|
66
68
|
animatedFlatListRef
|
|
@@ -133,9 +135,17 @@ export const HeaderFirstLevel = ({
|
|
|
133
135
|
</H3>
|
|
134
136
|
</View>
|
|
135
137
|
<HStack space={16} style={{ flexShrink: 0 }}>
|
|
136
|
-
{
|
|
137
|
-
|
|
138
|
-
|
|
138
|
+
{actions
|
|
139
|
+
.filter(
|
|
140
|
+
(action): action is HeaderActionProps => action !== undefined
|
|
141
|
+
)
|
|
142
|
+
.map((action, index) => (
|
|
143
|
+
<IconButton
|
|
144
|
+
key={`header-first-level-action-${index}`}
|
|
145
|
+
{...action}
|
|
146
|
+
color={"primary"}
|
|
147
|
+
/>
|
|
148
|
+
))}
|
|
139
149
|
</HStack>
|
|
140
150
|
</View>
|
|
141
151
|
</Animated.View>
|