@pagopa/io-app-design-system 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/alert/Alert.js +34 -7
- package/lib/commonjs/components/alert/Alert.js.map +1 -1
- package/lib/commonjs/components/badge/Badge.js +95 -14
- package/lib/commonjs/components/badge/Badge.js.map +1 -1
- package/lib/commonjs/components/banner/Banner.js +35 -20
- package/lib/commonjs/components/banner/Banner.js.map +1 -1
- package/lib/commonjs/components/banner/__test__/__snapshots__/banner.test.tsx.snap +36 -190
- package/lib/commonjs/components/featureInfo/FeatureInfo.js +27 -26
- package/lib/commonjs/components/featureInfo/FeatureInfo.js.map +1 -1
- package/lib/commonjs/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +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/stack/Stack.js +18 -15
- package/lib/commonjs/components/stack/Stack.js.map +1 -1
- package/lib/commonjs/components/tag/Tag.js +40 -26
- package/lib/commonjs/components/tag/Tag.js.map +1 -1
- package/lib/commonjs/components/typography/IOText.js.map +1 -1
- package/lib/commonjs/core/IOColors.js +9 -1
- package/lib/commonjs/core/IOColors.js.map +1 -1
- package/lib/commonjs/utils/fonts.js.map +1 -1
- package/lib/module/components/alert/Alert.js +36 -9
- package/lib/module/components/alert/Alert.js.map +1 -1
- package/lib/module/components/badge/Badge.js +96 -15
- package/lib/module/components/badge/Badge.js.map +1 -1
- package/lib/module/components/banner/Banner.js +40 -25
- package/lib/module/components/banner/Banner.js.map +1 -1
- package/lib/module/components/banner/__test__/__snapshots__/banner.test.tsx.snap +36 -190
- package/lib/module/components/featureInfo/FeatureInfo.js +29 -28
- package/lib/module/components/featureInfo/FeatureInfo.js.map +1 -1
- package/lib/module/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +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/stack/Stack.js +18 -15
- package/lib/module/components/stack/Stack.js.map +1 -1
- package/lib/module/components/tag/Tag.js +41 -27
- package/lib/module/components/tag/Tag.js.map +1 -1
- package/lib/module/components/typography/IOText.js.map +1 -1
- package/lib/module/core/IOColors.js +9 -1
- package/lib/module/core/IOColors.js.map +1 -1
- package/lib/module/utils/fonts.js.map +1 -1
- package/lib/typescript/components/alert/Alert.d.ts.map +1 -1
- package/lib/typescript/components/badge/Badge.d.ts.map +1 -1
- package/lib/typescript/components/banner/Banner.d.ts.map +1 -1
- package/lib/typescript/components/featureInfo/FeatureInfo.d.ts.map +1 -1
- package/lib/typescript/components/spacer/Spacer.d.ts +0 -1
- package/lib/typescript/components/spacer/Spacer.d.ts.map +1 -1
- package/lib/typescript/components/stack/Stack.d.ts +9 -6
- package/lib/typescript/components/stack/Stack.d.ts.map +1 -1
- package/lib/typescript/components/tag/Tag.d.ts +13 -8
- package/lib/typescript/components/tag/Tag.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/IOText.d.ts +2 -2
- package/lib/typescript/components/typography/IOText.d.ts.map +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 +2 -1
- package/lib/typescript/core/IOColors.d.ts.map +1 -1
- package/lib/typescript/utils/fonts.d.ts +3 -3
- package/lib/typescript/utils/fonts.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/alert/Alert.tsx +46 -15
- package/src/components/badge/Badge.tsx +109 -19
- package/src/components/banner/Banner.tsx +55 -27
- package/src/components/banner/__test__/__snapshots__/banner.test.tsx.snap +36 -190
- package/src/components/featureInfo/FeatureInfo.tsx +26 -28
- package/src/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +1 -1
- package/src/components/spacer/Spacer.tsx +2 -4
- package/src/components/stack/Stack.tsx +25 -17
- package/src/components/tag/Tag.tsx +66 -33
- package/src/components/typography/IOText.tsx +1 -2
- package/src/core/IOColors.ts +12 -0
- package/src/utils/fonts.ts +2 -2
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useState } from "react";
|
|
2
2
|
import {
|
|
3
|
+
ColorValue,
|
|
3
4
|
GestureResponderEvent,
|
|
4
5
|
NativeSyntheticEvent,
|
|
5
6
|
PixelRatio,
|
|
@@ -17,13 +18,9 @@ import Animated, {
|
|
|
17
18
|
useSharedValue,
|
|
18
19
|
withSpring
|
|
19
20
|
} from "react-native-reanimated";
|
|
20
|
-
import { IOVisualCostants } from "../../core";
|
|
21
|
+
import { IOVisualCostants, useIOThemeContext } from "../../core";
|
|
21
22
|
import { IOScaleValues, IOSpringValues } from "../../core/IOAnimations";
|
|
22
|
-
import {
|
|
23
|
-
IOColors,
|
|
24
|
-
IOColorsStatusBackground,
|
|
25
|
-
IOColorsStatusForeground
|
|
26
|
-
} from "../../core/IOColors";
|
|
23
|
+
import { IOColors, hexToRgba } from "../../core/IOColors";
|
|
27
24
|
import { IOAlertRadius } from "../../core/IOShapes";
|
|
28
25
|
import { IOAlertSpacing } from "../../core/IOSpacing";
|
|
29
26
|
import { WithTestID } from "../../utils/types";
|
|
@@ -75,38 +72,66 @@ type AlertType = AlertProps & AlertActionProps;
|
|
|
75
72
|
|
|
76
73
|
type VariantStates = {
|
|
77
74
|
icon: IOIcons;
|
|
78
|
-
background:
|
|
79
|
-
foreground:
|
|
75
|
+
background: ColorValue;
|
|
76
|
+
foreground: IOColors;
|
|
80
77
|
};
|
|
81
78
|
|
|
82
79
|
// COMPONENT CONFIGURATION
|
|
83
80
|
|
|
84
|
-
const
|
|
81
|
+
const mapVariantStatesLightMode: Record<
|
|
85
82
|
NonNullable<AlertType["variant"]>,
|
|
86
83
|
VariantStates
|
|
87
84
|
> = {
|
|
88
85
|
error: {
|
|
89
86
|
icon: "errorFilled",
|
|
90
|
-
background: "error-100",
|
|
87
|
+
background: IOColors["error-100"],
|
|
91
88
|
foreground: "error-850"
|
|
92
89
|
},
|
|
93
90
|
warning: {
|
|
94
91
|
icon: "warningFilled",
|
|
95
|
-
background: "warning-100",
|
|
92
|
+
background: IOColors["warning-100"],
|
|
96
93
|
foreground: "warning-850"
|
|
97
94
|
},
|
|
98
95
|
info: {
|
|
99
96
|
icon: "infoFilled",
|
|
100
|
-
background: "info-100",
|
|
97
|
+
background: IOColors["info-100"],
|
|
101
98
|
foreground: "info-850"
|
|
102
99
|
},
|
|
103
100
|
success: {
|
|
104
101
|
icon: "success",
|
|
105
|
-
background: "success-100",
|
|
102
|
+
background: IOColors["success-100"],
|
|
106
103
|
foreground: "success-850"
|
|
107
104
|
}
|
|
108
105
|
};
|
|
109
106
|
|
|
107
|
+
const bgOpacityDarkMode = 0.2;
|
|
108
|
+
|
|
109
|
+
const mapVariantStatesDarkMode: Record<
|
|
110
|
+
NonNullable<AlertType["variant"]>,
|
|
111
|
+
VariantStates
|
|
112
|
+
> = {
|
|
113
|
+
error: {
|
|
114
|
+
icon: "errorFilled",
|
|
115
|
+
background: hexToRgba(IOColors["error-400"], bgOpacityDarkMode),
|
|
116
|
+
foreground: "error-100"
|
|
117
|
+
},
|
|
118
|
+
warning: {
|
|
119
|
+
icon: "warningFilled",
|
|
120
|
+
background: hexToRgba(IOColors["warning-400"], bgOpacityDarkMode),
|
|
121
|
+
foreground: "warning-100"
|
|
122
|
+
},
|
|
123
|
+
info: {
|
|
124
|
+
icon: "infoFilled",
|
|
125
|
+
background: hexToRgba(IOColors["info-400"], bgOpacityDarkMode),
|
|
126
|
+
foreground: "info-100"
|
|
127
|
+
},
|
|
128
|
+
success: {
|
|
129
|
+
icon: "success",
|
|
130
|
+
background: hexToRgba(IOColors["success-400"], bgOpacityDarkMode),
|
|
131
|
+
foreground: "success-100"
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
110
135
|
export const Alert = React.forwardRef<View, AlertType>(
|
|
111
136
|
(
|
|
112
137
|
{
|
|
@@ -121,6 +146,7 @@ export const Alert = React.forwardRef<View, AlertType>(
|
|
|
121
146
|
}: AlertType,
|
|
122
147
|
viewRef
|
|
123
148
|
): JSX.Element => {
|
|
149
|
+
const { themeType } = useIOThemeContext();
|
|
124
150
|
const isPressed: SharedValue<number> = useSharedValue(0);
|
|
125
151
|
|
|
126
152
|
const [isMultiline, setIsMultiline] = useState(false);
|
|
@@ -164,6 +190,11 @@ export const Alert = React.forwardRef<View, AlertType>(
|
|
|
164
190
|
isPressed.value = 0;
|
|
165
191
|
}, [isPressed]);
|
|
166
192
|
|
|
193
|
+
const mapVariantStates =
|
|
194
|
+
themeType === "light"
|
|
195
|
+
? mapVariantStatesLightMode
|
|
196
|
+
: mapVariantStatesDarkMode;
|
|
197
|
+
|
|
167
198
|
const renderMainBlock = () => (
|
|
168
199
|
<>
|
|
169
200
|
<View
|
|
@@ -226,7 +257,7 @@ export const Alert = React.forwardRef<View, AlertType>(
|
|
|
226
257
|
style={[
|
|
227
258
|
styles.container,
|
|
228
259
|
fullWidth ? styles.spacingFullWidth : styles.spacingDefault,
|
|
229
|
-
{ backgroundColor:
|
|
260
|
+
{ backgroundColor: mapVariantStates[variant].background }
|
|
230
261
|
]}
|
|
231
262
|
testID={testID}
|
|
232
263
|
accessible={false}
|
|
@@ -254,7 +285,7 @@ export const Alert = React.forwardRef<View, AlertType>(
|
|
|
254
285
|
style={[
|
|
255
286
|
styles.container,
|
|
256
287
|
fullWidth ? styles.spacingFullWidth : styles.spacingDefault,
|
|
257
|
-
{ backgroundColor:
|
|
288
|
+
{ backgroundColor: mapVariantStates[variant].background },
|
|
258
289
|
// Disable pressed animation when component is full width
|
|
259
290
|
!fullWidth && pressedAnimationStyle
|
|
260
291
|
]}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Platform, StyleSheet, View } from "react-native";
|
|
2
|
+
import { ColorValue, Platform, StyleSheet, View } from "react-native";
|
|
3
3
|
import {
|
|
4
|
+
hexToRgba,
|
|
4
5
|
IOBadgeHSpacing,
|
|
5
6
|
IOBadgeRadius,
|
|
6
7
|
IOBadgeVSpacing,
|
|
7
8
|
IOColors,
|
|
8
9
|
useIOExperimentalDesign,
|
|
9
|
-
useIOTheme
|
|
10
|
+
useIOTheme,
|
|
11
|
+
useIOThemeContext
|
|
10
12
|
} from "../../core";
|
|
11
13
|
import { WithTestID } from "../../utils/types";
|
|
12
14
|
import { IOText } from "../typography";
|
|
@@ -28,7 +30,7 @@ export type Badge = WithTestID<{
|
|
|
28
30
|
}>;
|
|
29
31
|
|
|
30
32
|
type SolidVariantProps = {
|
|
31
|
-
background:
|
|
33
|
+
background: ColorValue;
|
|
32
34
|
foreground: IOColors;
|
|
33
35
|
};
|
|
34
36
|
|
|
@@ -60,54 +62,103 @@ const styles = StyleSheet.create({
|
|
|
60
62
|
export const Badge = ({ text, outline = false, variant, testID }: Badge) => {
|
|
61
63
|
const { isExperimental } = useIOExperimentalDesign();
|
|
62
64
|
const theme = useIOTheme();
|
|
65
|
+
const { themeType } = useIOThemeContext();
|
|
63
66
|
|
|
64
|
-
const
|
|
67
|
+
const bgOpacityDarkMode = 0.2;
|
|
68
|
+
|
|
69
|
+
const mapVariantsLightMode: Record<
|
|
65
70
|
NonNullable<Badge["variant"]>,
|
|
66
71
|
SolidVariantProps
|
|
67
72
|
> = {
|
|
68
73
|
default: {
|
|
69
74
|
foreground: "grey-700",
|
|
70
|
-
background: "grey-50"
|
|
75
|
+
background: IOColors["grey-50"]
|
|
71
76
|
},
|
|
72
77
|
info: {
|
|
73
78
|
foreground: "info-850",
|
|
74
|
-
background: "info-100"
|
|
79
|
+
background: IOColors["info-100"]
|
|
75
80
|
},
|
|
76
81
|
warning: {
|
|
77
82
|
foreground: "warning-850",
|
|
78
|
-
background: "warning-100"
|
|
83
|
+
background: IOColors["warning-100"]
|
|
79
84
|
},
|
|
80
85
|
success: {
|
|
81
86
|
foreground: "success-850",
|
|
82
|
-
background: "success-100"
|
|
87
|
+
background: IOColors["success-100"]
|
|
83
88
|
},
|
|
84
89
|
error: {
|
|
85
90
|
foreground: "error-850",
|
|
86
|
-
background: "error-100"
|
|
91
|
+
background: IOColors["error-100"]
|
|
87
92
|
},
|
|
88
93
|
purple: {
|
|
89
94
|
foreground: "hanPurple-500",
|
|
90
|
-
background: "hanPurple-100"
|
|
95
|
+
background: IOColors["hanPurple-100"]
|
|
91
96
|
},
|
|
92
97
|
lightBlue: {
|
|
93
98
|
foreground: "blueIO-850",
|
|
94
|
-
background: "blueIO-50"
|
|
99
|
+
background: IOColors["blueIO-50"]
|
|
95
100
|
},
|
|
96
101
|
blue: {
|
|
97
102
|
foreground: "white",
|
|
98
|
-
background: theme["interactiveElem-default"]
|
|
103
|
+
background: IOColors[theme["interactiveElem-default"]]
|
|
99
104
|
},
|
|
100
105
|
turquoise: {
|
|
101
106
|
foreground: "turquoise-850",
|
|
102
|
-
background: "turquoise-50"
|
|
107
|
+
background: IOColors["turquoise-50"]
|
|
108
|
+
},
|
|
109
|
+
contrast: {
|
|
110
|
+
foreground: "grey-700",
|
|
111
|
+
background: IOColors.white
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const mapVariantsDarkMode: Record<
|
|
116
|
+
NonNullable<Badge["variant"]>,
|
|
117
|
+
SolidVariantProps
|
|
118
|
+
> = {
|
|
119
|
+
default: {
|
|
120
|
+
foreground: "grey-50",
|
|
121
|
+
background: hexToRgba(IOColors["grey-50"], bgOpacityDarkMode)
|
|
122
|
+
},
|
|
123
|
+
info: {
|
|
124
|
+
foreground: "info-400",
|
|
125
|
+
background: hexToRgba(IOColors["info-400"], bgOpacityDarkMode)
|
|
126
|
+
},
|
|
127
|
+
warning: {
|
|
128
|
+
foreground: "warning-400",
|
|
129
|
+
background: hexToRgba(IOColors["warning-400"], bgOpacityDarkMode)
|
|
130
|
+
},
|
|
131
|
+
success: {
|
|
132
|
+
foreground: "success-400",
|
|
133
|
+
background: hexToRgba(IOColors["success-400"], bgOpacityDarkMode)
|
|
134
|
+
},
|
|
135
|
+
error: {
|
|
136
|
+
foreground: "error-400",
|
|
137
|
+
background: hexToRgba(IOColors["error-400"], bgOpacityDarkMode)
|
|
138
|
+
},
|
|
139
|
+
purple: {
|
|
140
|
+
foreground: "hanPurple-250",
|
|
141
|
+
background: hexToRgba(IOColors["hanPurple-250"], bgOpacityDarkMode)
|
|
142
|
+
},
|
|
143
|
+
lightBlue: {
|
|
144
|
+
foreground: "blueIO-200",
|
|
145
|
+
background: hexToRgba(IOColors["blueIO-600"], bgOpacityDarkMode)
|
|
146
|
+
},
|
|
147
|
+
blue: {
|
|
148
|
+
foreground: "white",
|
|
149
|
+
background: IOColors[theme["interactiveElem-default"]]
|
|
150
|
+
},
|
|
151
|
+
turquoise: {
|
|
152
|
+
foreground: "turquoise-300",
|
|
153
|
+
background: hexToRgba(IOColors["turquoise-300"], bgOpacityDarkMode)
|
|
103
154
|
},
|
|
104
155
|
contrast: {
|
|
105
156
|
foreground: "grey-700",
|
|
106
|
-
background:
|
|
157
|
+
background: IOColors.white
|
|
107
158
|
}
|
|
108
159
|
};
|
|
109
160
|
|
|
110
|
-
const
|
|
161
|
+
const mapOutlineVariantsLightMode: Record<
|
|
111
162
|
NonNullable<Badge["variant"]>,
|
|
112
163
|
OutlinedVariantProps
|
|
113
164
|
> = {
|
|
@@ -143,9 +194,48 @@ export const Badge = ({ text, outline = false, variant, testID }: Badge) => {
|
|
|
143
194
|
}
|
|
144
195
|
};
|
|
145
196
|
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
197
|
+
const mapOutlineVariantsDarkMode: Record<
|
|
198
|
+
NonNullable<Badge["variant"]>,
|
|
199
|
+
OutlinedVariantProps
|
|
200
|
+
> = {
|
|
201
|
+
default: {
|
|
202
|
+
foreground: "grey-100"
|
|
203
|
+
},
|
|
204
|
+
info: {
|
|
205
|
+
foreground: "info-400"
|
|
206
|
+
},
|
|
207
|
+
warning: {
|
|
208
|
+
foreground: "warning-400"
|
|
209
|
+
},
|
|
210
|
+
success: {
|
|
211
|
+
foreground: "success-400"
|
|
212
|
+
},
|
|
213
|
+
error: {
|
|
214
|
+
foreground: "error-400"
|
|
215
|
+
},
|
|
216
|
+
purple: {
|
|
217
|
+
foreground: "hanPurple-250"
|
|
218
|
+
},
|
|
219
|
+
lightBlue: {
|
|
220
|
+
foreground: "blueIO-150"
|
|
221
|
+
},
|
|
222
|
+
blue: {
|
|
223
|
+
foreground: theme["interactiveElem-default"]
|
|
224
|
+
},
|
|
225
|
+
turquoise: {
|
|
226
|
+
foreground: "turquoise-300"
|
|
227
|
+
},
|
|
228
|
+
contrast: {
|
|
229
|
+
foreground: "grey-100"
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
// prettier-ignore
|
|
234
|
+
const variantMap = themeType === "light"
|
|
235
|
+
? (outline ? mapOutlineVariantsLightMode : mapVariantsLightMode)
|
|
236
|
+
: (outline ? mapOutlineVariantsDarkMode : mapVariantsDarkMode);
|
|
237
|
+
|
|
238
|
+
const { background, foreground } = variantMap[variant];
|
|
149
239
|
|
|
150
240
|
return (
|
|
151
241
|
<View
|
|
@@ -159,7 +249,7 @@ export const Badge = ({ text, outline = false, variant, testID }: Badge) => {
|
|
|
159
249
|
borderColor: IOColors[foreground]
|
|
160
250
|
}
|
|
161
251
|
: {
|
|
162
|
-
backgroundColor: background
|
|
252
|
+
backgroundColor: background ?? undefined
|
|
163
253
|
}
|
|
164
254
|
]}
|
|
165
255
|
>
|
|
@@ -8,8 +8,9 @@ import {
|
|
|
8
8
|
ViewStyle
|
|
9
9
|
} from "react-native";
|
|
10
10
|
import Animated, {
|
|
11
|
-
|
|
11
|
+
Extrapolation,
|
|
12
12
|
interpolate,
|
|
13
|
+
SharedValue,
|
|
13
14
|
useAnimatedStyle,
|
|
14
15
|
useDerivedValue,
|
|
15
16
|
useSharedValue,
|
|
@@ -22,26 +23,26 @@ import {
|
|
|
22
23
|
IOBannerSmallVSpacing,
|
|
23
24
|
IOScaleValues,
|
|
24
25
|
IOSpringValues,
|
|
25
|
-
IOStyles
|
|
26
|
+
IOStyles,
|
|
27
|
+
useIOExperimentalDesign,
|
|
28
|
+
useIOTheme,
|
|
29
|
+
useIOThemeContext
|
|
26
30
|
} from "../../core";
|
|
27
|
-
import { IOColors } from "../../core/IOColors";
|
|
31
|
+
import { hexToRgba, IOColors } from "../../core/IOColors";
|
|
28
32
|
import { WithTestID } from "../../utils/types";
|
|
29
|
-
import {
|
|
33
|
+
import { IconButton } from "../buttons";
|
|
30
34
|
import {
|
|
31
|
-
IOPictogramSizeScale,
|
|
32
35
|
IOPictogramsBleed,
|
|
36
|
+
IOPictogramSizeScale,
|
|
33
37
|
PictogramBleed
|
|
34
38
|
} from "../pictograms";
|
|
35
39
|
import { VSpacer } from "../spacer";
|
|
36
|
-
import { H6, BodySmall } from "../typography";
|
|
40
|
+
import { buttonTextFontSize, H6, IOText, BodySmall } from "../typography";
|
|
37
41
|
|
|
38
42
|
/* Styles */
|
|
39
|
-
const colorTitle: IOColors = "blueIO-850";
|
|
40
|
-
const colorContent: IOColors = "grey-700";
|
|
41
|
-
const colorCloseButton: IconButton["color"] = "neutral";
|
|
42
43
|
const sizePictogramBig: IOPictogramSizeScale = 80;
|
|
43
44
|
const sizePictogramSmall: IOPictogramSizeScale = 64;
|
|
44
|
-
const closeButtonDistanceFromEdge: number =
|
|
45
|
+
const closeButtonDistanceFromEdge: number = 6;
|
|
45
46
|
const closeButtonOpacity = 0.6;
|
|
46
47
|
const sizeBigPadding = IOBannerBigSpacing;
|
|
47
48
|
const sizeSmallHPadding = IOBannerSmallHSpacing;
|
|
@@ -66,15 +67,6 @@ const styles = StyleSheet.create({
|
|
|
66
67
|
}
|
|
67
68
|
});
|
|
68
69
|
|
|
69
|
-
const dynamicContainerStyles = (
|
|
70
|
-
size: BaseBannerProps["size"],
|
|
71
|
-
color: BaseBannerProps["color"]
|
|
72
|
-
): ViewStyle => ({
|
|
73
|
-
backgroundColor: IOColors[mapBackgroundColor[color]],
|
|
74
|
-
paddingVertical: size === "big" ? sizeBigPadding : sizeSmallVPadding,
|
|
75
|
-
paddingHorizontal: size === "big" ? sizeBigPadding : sizeSmallHPadding
|
|
76
|
-
});
|
|
77
|
-
|
|
78
70
|
/* Component Types */
|
|
79
71
|
|
|
80
72
|
type BaseBannerProps = WithTestID<{
|
|
@@ -136,7 +128,7 @@ export const bannerBackgroundColours: Array<BaseBannerProps["color"]> = [
|
|
|
136
128
|
"turquoise"
|
|
137
129
|
];
|
|
138
130
|
|
|
139
|
-
const
|
|
131
|
+
const mapBackgroundColorLightMode: Record<
|
|
140
132
|
NonNullable<BaseBannerProps["color"]>,
|
|
141
133
|
IOColors
|
|
142
134
|
> = {
|
|
@@ -144,6 +136,14 @@ const mapBackgroundColor: Record<
|
|
|
144
136
|
turquoise: "turquoise-50"
|
|
145
137
|
};
|
|
146
138
|
|
|
139
|
+
const mapBackgroundColorDarkMode: Record<
|
|
140
|
+
NonNullable<BaseBannerProps["color"]>,
|
|
141
|
+
IOColors
|
|
142
|
+
> = {
|
|
143
|
+
neutral: "grey-50",
|
|
144
|
+
turquoise: "turquoise-300"
|
|
145
|
+
};
|
|
146
|
+
|
|
147
147
|
export const Banner = ({
|
|
148
148
|
viewRef,
|
|
149
149
|
size,
|
|
@@ -159,7 +159,27 @@ export const Banner = ({
|
|
|
159
159
|
accessibilityLabel,
|
|
160
160
|
testID
|
|
161
161
|
}: Banner) => {
|
|
162
|
-
const isPressed:
|
|
162
|
+
const isPressed: SharedValue<number> = useSharedValue(0);
|
|
163
|
+
|
|
164
|
+
const { isExperimental } = useIOExperimentalDesign();
|
|
165
|
+
const { themeType } = useIOThemeContext();
|
|
166
|
+
const theme = useIOTheme();
|
|
167
|
+
|
|
168
|
+
// Dynamic colors
|
|
169
|
+
const colorTitle: IOColors = themeType === "dark" ? "grey-50" : "blueIO-850";
|
|
170
|
+
const colorCloseButton: IconButton["color"] =
|
|
171
|
+
themeType === "dark" ? "contrast" : "neutral";
|
|
172
|
+
const colorMainButton =
|
|
173
|
+
themeType === "dark" ? "blueIO-200" : theme["interactiveElem-default"];
|
|
174
|
+
|
|
175
|
+
const dynamicContainerStyles: ViewStyle = {
|
|
176
|
+
backgroundColor:
|
|
177
|
+
themeType === "dark"
|
|
178
|
+
? hexToRgba(IOColors[mapBackgroundColorDarkMode[color]], 0.1)
|
|
179
|
+
: IOColors[mapBackgroundColorLightMode[color]],
|
|
180
|
+
paddingVertical: size === "big" ? sizeBigPadding : sizeSmallVPadding,
|
|
181
|
+
paddingHorizontal: size === "big" ? sizeBigPadding : sizeSmallHPadding
|
|
182
|
+
};
|
|
163
183
|
|
|
164
184
|
// Scaling transformation applied when the button is pressed
|
|
165
185
|
const animationScaleValue = IOScaleValues?.magnifiedButton?.pressedState;
|
|
@@ -178,7 +198,7 @@ export const Banner = ({
|
|
|
178
198
|
progressPressed.value,
|
|
179
199
|
[0, 1],
|
|
180
200
|
[1, animationScaleValue],
|
|
181
|
-
|
|
201
|
+
Extrapolation.CLAMP
|
|
182
202
|
);
|
|
183
203
|
|
|
184
204
|
return {
|
|
@@ -221,7 +241,7 @@ export const Banner = ({
|
|
|
221
241
|
)}
|
|
222
242
|
{content && (
|
|
223
243
|
<>
|
|
224
|
-
<BodySmall color={
|
|
244
|
+
<BodySmall color={theme["textBody-tertiary"]} weight={"Regular"}>
|
|
225
245
|
{content}
|
|
226
246
|
</BodySmall>
|
|
227
247
|
{action && <VSpacer size={8} />}
|
|
@@ -236,13 +256,21 @@ export const Banner = ({
|
|
|
236
256
|
importantForAccessibility="no-hide-descendants"
|
|
237
257
|
>
|
|
238
258
|
<VSpacer size={4} />
|
|
239
|
-
<
|
|
259
|
+
<IOText
|
|
260
|
+
font={isExperimental ? "Titillio" : "TitilliumSansPro"}
|
|
261
|
+
weight={isExperimental ? "Regular" : "Bold"}
|
|
262
|
+
color={colorMainButton}
|
|
263
|
+
size={buttonTextFontSize}
|
|
264
|
+
numberOfLines={1}
|
|
265
|
+
ellipsizeMode="tail"
|
|
266
|
+
>
|
|
267
|
+
{action}
|
|
268
|
+
</IOText>
|
|
240
269
|
</View>
|
|
241
270
|
)}
|
|
242
271
|
</View>
|
|
243
272
|
<View style={[styles.bleedPictogram, IOStyles.selfCenter]}>
|
|
244
273
|
<PictogramBleed
|
|
245
|
-
pictogramStyle="dark-content"
|
|
246
274
|
name={pictogramName}
|
|
247
275
|
size={size === "big" ? sizePictogramBig : sizePictogramSmall}
|
|
248
276
|
/>
|
|
@@ -272,7 +300,7 @@ export const Banner = ({
|
|
|
272
300
|
<Animated.View
|
|
273
301
|
style={[
|
|
274
302
|
styles.container,
|
|
275
|
-
dynamicContainerStyles
|
|
303
|
+
dynamicContainerStyles,
|
|
276
304
|
pressedAnimationStyle
|
|
277
305
|
]}
|
|
278
306
|
>
|
|
@@ -285,7 +313,7 @@ export const Banner = ({
|
|
|
285
313
|
<View
|
|
286
314
|
ref={viewRef}
|
|
287
315
|
testID={testID}
|
|
288
|
-
style={[styles.container, dynamicContainerStyles
|
|
316
|
+
style={[styles.container, dynamicContainerStyles]}
|
|
289
317
|
// A11y related props
|
|
290
318
|
accessible={false}
|
|
291
319
|
accessibilityHint={accessibilityHint}
|