@pagopa/io-app-design-system 4.0.0 → 4.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/badge/Badge.js +95 -14
- package/lib/commonjs/components/badge/Badge.js.map +1 -1
- package/lib/commonjs/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +1 -1
- package/lib/commonjs/components/stack/Stack.js +2 -2
- 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/badge/Badge.js +96 -15
- package/lib/module/components/badge/Badge.js.map +1 -1
- package/lib/module/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +1 -1
- package/lib/module/components/stack/Stack.js +2 -2
- 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/badge/Badge.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/badge/Badge.tsx +109 -19
- package/src/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +1 -1
- package/src/components/stack/Stack.tsx +2 -2
- package/src/components/tag/Tag.tsx +66 -33
- package/src/components/typography/IOText.tsx +1 -2
- package/src/core/IOColors.ts +11 -0
- package/src/utils/fonts.ts +2 -2
|
@@ -3,6 +3,8 @@ import { Platform, StyleSheet, View } from "react-native";
|
|
|
3
3
|
import {
|
|
4
4
|
IOColors,
|
|
5
5
|
IOTagRadius,
|
|
6
|
+
IOTheme,
|
|
7
|
+
IOThemeLight,
|
|
6
8
|
useIOExperimentalDesign,
|
|
7
9
|
useIOTheme
|
|
8
10
|
} from "../../core";
|
|
@@ -15,9 +17,21 @@ import { WithTestID } from "../../utils/types";
|
|
|
15
17
|
import { IOIconSizeScale, IOIcons, Icon } from "../icons";
|
|
16
18
|
import { IOText } from "../typography";
|
|
17
19
|
|
|
20
|
+
const IconColorsMap: Record<string, keyof IOTheme> = {
|
|
21
|
+
primary: "interactiveElem-default",
|
|
22
|
+
warning: "warningIcon",
|
|
23
|
+
error: "errorIcon",
|
|
24
|
+
success: "successIcon",
|
|
25
|
+
info: "infoIcon",
|
|
26
|
+
grey: "icon-default",
|
|
27
|
+
lightGrey: "icon-decorative"
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type IconColorVariant = keyof typeof IconColorsMap;
|
|
31
|
+
|
|
18
32
|
type VariantProps = {
|
|
19
|
-
|
|
20
|
-
|
|
33
|
+
color: IconColorVariant;
|
|
34
|
+
name: IOIcons;
|
|
21
35
|
};
|
|
22
36
|
|
|
23
37
|
type TextProps =
|
|
@@ -30,8 +44,7 @@ type TextProps =
|
|
|
30
44
|
iconAccessibilityLabel: string;
|
|
31
45
|
};
|
|
32
46
|
|
|
33
|
-
export type Tag = TextProps &
|
|
34
|
-
WithTestID<
|
|
47
|
+
export type Tag = TextProps & { forceLightMode?: boolean } & WithTestID<
|
|
35
48
|
| {
|
|
36
49
|
variant:
|
|
37
50
|
| "qrCode"
|
|
@@ -42,11 +55,12 @@ export type Tag = TextProps &
|
|
|
42
55
|
| "success"
|
|
43
56
|
| "attachment"
|
|
44
57
|
| "noIcon";
|
|
45
|
-
|
|
58
|
+
iconName?: never;
|
|
59
|
+
icon?: never;
|
|
46
60
|
}
|
|
47
61
|
| {
|
|
48
|
-
variant: "
|
|
49
|
-
|
|
62
|
+
variant: "custom";
|
|
63
|
+
icon: VariantProps;
|
|
50
64
|
}
|
|
51
65
|
>;
|
|
52
66
|
|
|
@@ -64,9 +78,7 @@ const styles = StyleSheet.create({
|
|
|
64
78
|
textAlignVertical: "center"
|
|
65
79
|
}
|
|
66
80
|
}),
|
|
67
|
-
backgroundColor: IOColors.white,
|
|
68
81
|
borderWidth: 1,
|
|
69
|
-
borderColor: IOColors["grey-100"],
|
|
70
82
|
borderRadius: IOTagRadius,
|
|
71
83
|
borderCurve: "continuous",
|
|
72
84
|
paddingHorizontal: IOTagHSpacing,
|
|
@@ -82,45 +94,46 @@ const styles = StyleSheet.create({
|
|
|
82
94
|
|
|
83
95
|
const getVariantProps = (
|
|
84
96
|
variant: NonNullable<Tag["variant"]>,
|
|
85
|
-
|
|
97
|
+
customIcon?: VariantProps
|
|
86
98
|
): VariantProps | undefined => {
|
|
99
|
+
if (variant === "custom" && customIcon) {
|
|
100
|
+
return customIcon;
|
|
101
|
+
}
|
|
87
102
|
switch (variant) {
|
|
88
|
-
case "customIcon":
|
|
89
|
-
return customIconProps;
|
|
90
103
|
case "qrCode":
|
|
91
104
|
return {
|
|
92
|
-
|
|
93
|
-
|
|
105
|
+
color: "primary",
|
|
106
|
+
name: "qrCode"
|
|
94
107
|
};
|
|
95
108
|
case "attachment":
|
|
96
109
|
return {
|
|
97
|
-
|
|
98
|
-
|
|
110
|
+
color: "grey",
|
|
111
|
+
name: "attachment"
|
|
99
112
|
};
|
|
100
113
|
case "legalMessage":
|
|
101
114
|
return {
|
|
102
|
-
|
|
103
|
-
|
|
115
|
+
color: "primary",
|
|
116
|
+
name: "legalValue"
|
|
104
117
|
};
|
|
105
118
|
case "info":
|
|
106
119
|
return {
|
|
107
|
-
|
|
108
|
-
|
|
120
|
+
color: "info",
|
|
121
|
+
name: "infoFilled"
|
|
109
122
|
};
|
|
110
123
|
case "warning":
|
|
111
124
|
return {
|
|
112
|
-
|
|
113
|
-
|
|
125
|
+
color: "warning",
|
|
126
|
+
name: "warningFilled"
|
|
114
127
|
};
|
|
115
128
|
case "error":
|
|
116
129
|
return {
|
|
117
|
-
|
|
118
|
-
|
|
130
|
+
color: "error",
|
|
131
|
+
name: "errorFilled"
|
|
119
132
|
};
|
|
120
133
|
case "success":
|
|
121
134
|
return {
|
|
122
|
-
|
|
123
|
-
|
|
135
|
+
color: "success",
|
|
136
|
+
name: "success"
|
|
124
137
|
};
|
|
125
138
|
case "noIcon":
|
|
126
139
|
return undefined;
|
|
@@ -136,21 +149,37 @@ export const Tag = ({
|
|
|
136
149
|
text,
|
|
137
150
|
variant,
|
|
138
151
|
testID,
|
|
139
|
-
|
|
140
|
-
iconAccessibilityLabel
|
|
152
|
+
icon,
|
|
153
|
+
iconAccessibilityLabel,
|
|
154
|
+
forceLightMode = false
|
|
141
155
|
}: Tag) => {
|
|
142
156
|
const theme = useIOTheme();
|
|
143
157
|
const { isExperimental } = useIOExperimentalDesign();
|
|
144
158
|
|
|
145
|
-
const variantProps = getVariantProps(variant,
|
|
159
|
+
const variantProps = getVariantProps(variant, icon);
|
|
160
|
+
|
|
161
|
+
const borderColor = forceLightMode
|
|
162
|
+
? IOColors[IOThemeLight["cardBorder-default"]]
|
|
163
|
+
: IOColors[theme["cardBorder-default"]];
|
|
164
|
+
|
|
165
|
+
const backgroundColor = forceLightMode
|
|
166
|
+
? IOColors[IOThemeLight["appBackground-primary"]]
|
|
167
|
+
: IOColors[theme["appBackground-primary"]];
|
|
146
168
|
|
|
147
169
|
return (
|
|
148
|
-
<View
|
|
170
|
+
<View
|
|
171
|
+
testID={testID}
|
|
172
|
+
style={[styles.tag, { borderColor, backgroundColor }]}
|
|
173
|
+
>
|
|
149
174
|
{variantProps && (
|
|
150
175
|
<View style={styles.iconWrapper}>
|
|
151
176
|
<Icon
|
|
152
|
-
name={variantProps.
|
|
153
|
-
color={
|
|
177
|
+
name={variantProps.name}
|
|
178
|
+
color={
|
|
179
|
+
forceLightMode
|
|
180
|
+
? IOThemeLight[IconColorsMap[variantProps.color]]
|
|
181
|
+
: theme[IconColorsMap[variantProps.color]]
|
|
182
|
+
}
|
|
154
183
|
size={IOTagIconSize}
|
|
155
184
|
accessible={!!iconAccessibilityLabel}
|
|
156
185
|
accessibilityLabel={iconAccessibilityLabel}
|
|
@@ -164,7 +193,11 @@ export const Tag = ({
|
|
|
164
193
|
weight={"Semibold"}
|
|
165
194
|
size={12}
|
|
166
195
|
lineHeight={16}
|
|
167
|
-
color={
|
|
196
|
+
color={
|
|
197
|
+
forceLightMode
|
|
198
|
+
? IOThemeLight["textBody-tertiary"]
|
|
199
|
+
: theme["textBody-tertiary"]
|
|
200
|
+
}
|
|
168
201
|
numberOfLines={1}
|
|
169
202
|
ellipsizeMode="tail"
|
|
170
203
|
style={{
|
|
@@ -10,7 +10,6 @@ import { IOColors, useIOExperimentalDesign, useIOTheme } from "../../core";
|
|
|
10
10
|
import { useBoldTextEnabled } from "../../utils/accessibility";
|
|
11
11
|
import {
|
|
12
12
|
IOFontFamily,
|
|
13
|
-
IOFontSize,
|
|
14
13
|
IOFontWeight,
|
|
15
14
|
makeFontStyleObject
|
|
16
15
|
} from "../../utils/fonts";
|
|
@@ -37,7 +36,7 @@ export type TypographicStyleProps = Omit<
|
|
|
37
36
|
* cannot be included in the default StyleProp<TextStyle>
|
|
38
37
|
*/
|
|
39
38
|
type IOTextBaseProps = {
|
|
40
|
-
size?:
|
|
39
|
+
size?: number;
|
|
41
40
|
weight?: IOFontWeight;
|
|
42
41
|
color?: IOColors;
|
|
43
42
|
font?: IOFontFamily;
|
package/src/core/IOColors.ts
CHANGED
|
@@ -53,6 +53,7 @@ export const IOColors = asIOColors({
|
|
|
53
53
|
"turquoise-850": "#003B3D",
|
|
54
54
|
"turquoise-500": "#00C5CA",
|
|
55
55
|
"turquoise-450": "#19CBCF" /* Dark mode */,
|
|
56
|
+
"turquoise-300": "#61DCDF",
|
|
56
57
|
"turquoise-150": "#AAEEEF",
|
|
57
58
|
"turquoise-100": "#C2F3F4",
|
|
58
59
|
"turquoise-50": "#DBF9FA",
|
|
@@ -283,7 +284,10 @@ const themeKeys = [
|
|
|
283
284
|
// Status
|
|
284
285
|
"errorIcon",
|
|
285
286
|
"errorText",
|
|
287
|
+
"successIcon",
|
|
286
288
|
"successText",
|
|
289
|
+
"warningIcon",
|
|
290
|
+
"infoIcon",
|
|
287
291
|
// Pictograms
|
|
288
292
|
"pictogram-hands",
|
|
289
293
|
"pictogram-tint-main",
|
|
@@ -322,7 +326,10 @@ export const IOThemeLight: IOTheme = {
|
|
|
322
326
|
// Status
|
|
323
327
|
errorIcon: "error-600",
|
|
324
328
|
errorText: "error-600",
|
|
329
|
+
successIcon: "success-700",
|
|
325
330
|
successText: "success-700",
|
|
331
|
+
warningIcon: "warning-700",
|
|
332
|
+
infoIcon: "info-700",
|
|
326
333
|
// Pictograms
|
|
327
334
|
"pictogram-hands": "blueIO-500",
|
|
328
335
|
"pictogram-tint-main": "turquoise-150",
|
|
@@ -356,6 +363,7 @@ export const IOThemeDark: IOTheme = {
|
|
|
356
363
|
// Design System related
|
|
357
364
|
"cardBorder-default": "grey-850",
|
|
358
365
|
"icon-default": "grey-450",
|
|
366
|
+
"icon-decorative": "grey-650",
|
|
359
367
|
// Layout
|
|
360
368
|
"divider-header": "grey-850",
|
|
361
369
|
"divider-default": "grey-850",
|
|
@@ -364,6 +372,9 @@ export const IOThemeDark: IOTheme = {
|
|
|
364
372
|
errorIcon: "error-400",
|
|
365
373
|
errorText: "error-400",
|
|
366
374
|
successText: "success-400",
|
|
375
|
+
successIcon: "success-500",
|
|
376
|
+
warningIcon: "warning-500",
|
|
377
|
+
infoIcon: "info-500",
|
|
367
378
|
// Pictograms
|
|
368
379
|
"pictogram-hands": "white",
|
|
369
380
|
"pictogram-tint-main": "turquoise-150",
|
package/src/utils/fonts.ts
CHANGED
|
@@ -73,7 +73,7 @@ export const fontWeights: Record<IOFontWeight, IOFontWeightNumeric> = {
|
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
type FontStyleObject = {
|
|
76
|
-
fontSize: IOFontSize;
|
|
76
|
+
fontSize: IOFontSize | number;
|
|
77
77
|
/* We also accept `string` because Android needs a composed
|
|
78
78
|
fontFamily name, like `TitilliumSansPro-Regular` */
|
|
79
79
|
fontFamily: string | IOFontFamily;
|
|
@@ -132,7 +132,7 @@ const defaultFontSize: IOFontSize = 16;
|
|
|
132
132
|
*/
|
|
133
133
|
|
|
134
134
|
export const makeFontStyleObject = (
|
|
135
|
-
size:
|
|
135
|
+
size: number = defaultFontSize,
|
|
136
136
|
font: IOFontFamily = defaultFont,
|
|
137
137
|
lineHeight: TextStyle["lineHeight"],
|
|
138
138
|
weight: IOFontWeight = defaultWeight,
|