@pagopa/io-app-design-system 1.1.3 → 1.3.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/README.md +1 -0
- package/lib/commonjs/components/accordion/RawAccordion.js.map +1 -1
- package/lib/commonjs/components/alert/Alert.js.map +1 -1
- package/lib/commonjs/components/avatar/__test__/avatar.test.js.map +1 -1
- package/lib/commonjs/components/badge/Badge.js.map +1 -1
- package/lib/commonjs/components/banner/Banner.js +1 -1
- package/lib/commonjs/components/banner/Banner.js.map +1 -1
- package/lib/commonjs/components/banner/__test__/banner.test.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonExtendedOutline.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonOutline.js +3 -3
- package/lib/commonjs/components/buttons/ButtonOutline.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonSolid.js +3 -3
- package/lib/commonjs/components/buttons/ButtonSolid.js.map +1 -1
- package/lib/commonjs/components/common/AnimatedTick.js +2 -1
- package/lib/commonjs/components/common/AnimatedTick.js.map +1 -1
- package/lib/commonjs/components/contentWrapper/ContentWrapper.js.map +1 -1
- package/lib/commonjs/components/icons/Icon.js +124 -120
- package/lib/commonjs/components/icons/Icon.js.map +1 -1
- package/lib/commonjs/components/icons/svg/IconLight.js +31 -0
- package/lib/commonjs/components/icons/svg/IconLight.js.map +1 -0
- package/lib/commonjs/components/icons/svg/IconLightFilled.js +31 -0
- package/lib/commonjs/components/icons/svg/IconLightFilled.js.map +1 -0
- package/lib/commonjs/components/icons/svg/originals/IconLight.svg +3 -0
- package/lib/commonjs/components/icons/svg/originals/IconLightFilled.svg +3 -0
- package/lib/commonjs/components/index.js +11 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemAction.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemIDP.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemNavAlert.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemTransaction.js.map +1 -1
- package/lib/commonjs/components/listitems/PressableListItemsBase.js.map +1 -1
- package/lib/commonjs/components/listitems/__test__/listitem.test.js.map +1 -1
- package/lib/commonjs/components/listitems/hooks/useListItemSpringAnimation.js.map +1 -1
- package/lib/commonjs/components/pictograms/Pictogram.js +37 -31
- package/lib/commonjs/components/pictograms/Pictogram.js.map +1 -1
- package/lib/commonjs/components/pictograms/svg/PictogramFocusOn.js +56 -0
- package/lib/commonjs/components/pictograms/svg/PictogramFocusOn.js.map +1 -0
- package/lib/commonjs/components/pictograms/svg/PictogramSuccess.js +61 -0
- package/lib/commonjs/components/pictograms/svg/PictogramSuccess.js.map +1 -0
- package/lib/commonjs/components/pictograms/svg/originals/PictogramFocusOn.svg +19 -0
- package/lib/commonjs/components/pictograms/svg/originals/PictogramSuccess.svg +35 -0
- package/lib/commonjs/components/spacer/Spacer.js.map +1 -1
- package/lib/commonjs/components/tabs/TabItem.js +123 -0
- package/lib/commonjs/components/tabs/TabItem.js.map +1 -0
- package/lib/commonjs/components/tabs/TabNavigation.js +80 -0
- package/lib/commonjs/components/tabs/TabNavigation.js.map +1 -0
- package/lib/commonjs/components/tabs/index.js +20 -0
- package/lib/commonjs/components/tabs/index.js.map +1 -0
- package/lib/commonjs/components/typography/Body.js.map +1 -1
- package/lib/commonjs/components/typography/Factory.js.map +1 -1
- package/lib/commonjs/components/typography/H1.js.map +1 -1
- package/lib/commonjs/components/typography/H2.js.map +1 -1
- package/lib/commonjs/components/typography/H4.js.map +1 -1
- package/lib/commonjs/components/typography/H5.js.map +1 -1
- package/lib/commonjs/components/typography/H6.js.map +1 -1
- package/lib/commonjs/components/typography/Label.js.map +1 -1
- package/lib/commonjs/components/typography/LabelHeader.js +37 -0
- package/lib/commonjs/components/typography/LabelHeader.js.map +1 -0
- package/lib/commonjs/components/typography/LabelSmall.js.map +1 -1
- package/lib/commonjs/components/typography/Monospace.js.map +1 -1
- package/lib/commonjs/components/typography/common.js +2 -2
- package/lib/commonjs/components/typography/common.js.map +1 -1
- package/lib/commonjs/utils/hooks/useSpringPressProgressValue.js +31 -0
- package/lib/commonjs/utils/hooks/useSpringPressProgressValue.js.map +1 -0
- package/lib/commonjs/utils/image.js.map +1 -1
- package/lib/module/components/accordion/RawAccordion.js.map +1 -1
- package/lib/module/components/alert/Alert.js.map +1 -1
- package/lib/module/components/avatar/__test__/avatar.test.js.map +1 -1
- package/lib/module/components/badge/Badge.js.map +1 -1
- package/lib/module/components/banner/Banner.js +1 -1
- package/lib/module/components/banner/Banner.js.map +1 -1
- package/lib/module/components/banner/__test__/banner.test.js.map +1 -1
- package/lib/module/components/buttons/ButtonExtendedOutline.js.map +1 -1
- package/lib/module/components/buttons/ButtonOutline.js +3 -3
- package/lib/module/components/buttons/ButtonOutline.js.map +1 -1
- package/lib/module/components/buttons/ButtonSolid.js +3 -3
- package/lib/module/components/buttons/ButtonSolid.js.map +1 -1
- package/lib/module/components/buttons/IconButtonContained.js.map +1 -1
- package/lib/module/components/buttons/IconButtonSolid.js.map +1 -1
- package/lib/module/components/common/AnimatedTick.js +2 -1
- package/lib/module/components/common/AnimatedTick.js.map +1 -1
- package/lib/module/components/contentWrapper/ContentWrapper.js.map +1 -1
- package/lib/module/components/icons/Icon.js +124 -120
- package/lib/module/components/icons/Icon.js.map +1 -1
- package/lib/module/components/icons/svg/IconLight.js +23 -0
- package/lib/module/components/icons/svg/IconLight.js.map +1 -0
- package/lib/module/components/icons/svg/IconLightFilled.js +23 -0
- package/lib/module/components/icons/svg/IconLightFilled.js.map +1 -0
- package/lib/module/components/icons/svg/originals/IconLight.svg +3 -0
- package/lib/module/components/icons/svg/originals/IconLightFilled.svg +3 -0
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/listitems/ListItemAction.js.map +1 -1
- package/lib/module/components/listitems/ListItemIDP.js.map +1 -1
- package/lib/module/components/listitems/ListItemNavAlert.js.map +1 -1
- package/lib/module/components/listitems/ListItemTransaction.js.map +1 -1
- package/lib/module/components/listitems/PressableListItemsBase.js.map +1 -1
- package/lib/module/components/listitems/__test__/listitem.test.js.map +1 -1
- package/lib/module/components/listitems/hooks/useListItemSpringAnimation.js.map +1 -1
- package/lib/module/components/pictograms/Pictogram.js +37 -31
- package/lib/module/components/pictograms/Pictogram.js.map +1 -1
- package/lib/module/components/pictograms/svg/PictogramFocusOn.js +48 -0
- package/lib/module/components/pictograms/svg/PictogramFocusOn.js.map +1 -0
- package/lib/module/components/pictograms/svg/PictogramSuccess.js +51 -0
- package/lib/module/components/pictograms/svg/PictogramSuccess.js.map +1 -0
- package/lib/module/components/pictograms/svg/originals/PictogramFocusOn.svg +19 -0
- package/lib/module/components/pictograms/svg/originals/PictogramSuccess.svg +35 -0
- package/lib/module/components/spacer/Spacer.js.map +1 -1
- package/lib/module/components/tabs/TabItem.js +114 -0
- package/lib/module/components/tabs/TabItem.js.map +1 -0
- package/lib/module/components/tabs/TabNavigation.js +73 -0
- package/lib/module/components/tabs/TabNavigation.js.map +1 -0
- package/lib/module/components/tabs/index.js +3 -0
- package/lib/module/components/tabs/index.js.map +1 -0
- package/lib/module/components/typography/Body.js.map +1 -1
- package/lib/module/components/typography/Factory.js.map +1 -1
- package/lib/module/components/typography/H1.js.map +1 -1
- package/lib/module/components/typography/H2.js.map +1 -1
- package/lib/module/components/typography/H4.js.map +1 -1
- package/lib/module/components/typography/H5.js.map +1 -1
- package/lib/module/components/typography/H6.js.map +1 -1
- package/lib/module/components/typography/Label.js.map +1 -1
- package/lib/module/components/typography/LabelHeader.js +27 -0
- package/lib/module/components/typography/LabelHeader.js.map +1 -0
- package/lib/module/components/typography/LabelSmall.js.map +1 -1
- package/lib/module/components/typography/Monospace.js.map +1 -1
- package/lib/module/components/typography/common.js +2 -2
- package/lib/module/components/typography/common.js.map +1 -1
- package/lib/module/utils/hooks/useSpringPressProgressValue.js +22 -0
- package/lib/module/utils/hooks/useSpringPressProgressValue.js.map +1 -0
- package/lib/module/utils/image.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/buttons/ButtonExtendedOutline.d.ts.map +1 -1
- package/lib/typescript/components/buttons/ButtonOutline.d.ts.map +1 -1
- package/lib/typescript/components/buttons/ButtonSolid.d.ts.map +1 -1
- package/lib/typescript/components/buttons/IconButtonContained.d.ts.map +1 -1
- package/lib/typescript/components/common/AnimatedTick.d.ts.map +1 -1
- package/lib/typescript/components/contentWrapper/ContentWrapper.d.ts.map +1 -1
- package/lib/typescript/components/icons/Icon.d.ts +2 -0
- package/lib/typescript/components/icons/Icon.d.ts.map +1 -1
- package/lib/typescript/components/icons/svg/IconLight.d.ts +5 -0
- package/lib/typescript/components/icons/svg/IconLight.d.ts.map +1 -0
- package/lib/typescript/components/icons/svg/IconLightFilled.d.ts +5 -0
- package/lib/typescript/components/icons/svg/IconLightFilled.d.ts.map +1 -0
- package/lib/typescript/components/index.d.ts +1 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemAction.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemIDP.d.ts +1 -1
- package/lib/typescript/components/listitems/ListItemIDP.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemNavAlert.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemTransaction.d.ts.map +1 -1
- package/lib/typescript/components/listitems/PressableListItemsBase.d.ts.map +1 -1
- package/lib/typescript/components/listitems/hooks/useListItemSpringAnimation.d.ts.map +1 -1
- package/lib/typescript/components/pictograms/Pictogram.d.ts +3 -0
- package/lib/typescript/components/pictograms/Pictogram.d.ts.map +1 -1
- package/lib/typescript/components/pictograms/svg/PictogramFocusOn.d.ts +5 -0
- package/lib/typescript/components/pictograms/svg/PictogramFocusOn.d.ts.map +1 -0
- package/lib/typescript/components/pictograms/svg/PictogramSuccess.d.ts +5 -0
- package/lib/typescript/components/pictograms/svg/PictogramSuccess.d.ts.map +1 -0
- package/lib/typescript/components/spacer/Spacer.d.ts.map +1 -1
- package/lib/typescript/components/tabs/TabItem.d.ts +19 -0
- package/lib/typescript/components/tabs/TabItem.d.ts.map +1 -0
- package/lib/typescript/components/tabs/TabNavigation.d.ts +15 -0
- package/lib/typescript/components/tabs/TabNavigation.d.ts.map +1 -0
- package/lib/typescript/components/tabs/index.d.ts +3 -0
- package/lib/typescript/components/tabs/index.d.ts.map +1 -0
- package/lib/typescript/components/typography/Body.d.ts.map +1 -1
- package/lib/typescript/components/typography/Factory.d.ts.map +1 -1
- package/lib/typescript/components/typography/H1.d.ts.map +1 -1
- package/lib/typescript/components/typography/H2.d.ts.map +1 -1
- package/lib/typescript/components/typography/H4.d.ts.map +1 -1
- package/lib/typescript/components/typography/H5.d.ts.map +1 -1
- package/lib/typescript/components/typography/H6.d.ts.map +1 -1
- package/lib/typescript/components/typography/Label.d.ts.map +1 -1
- package/lib/typescript/components/typography/LabelHeader.d.ts +19 -0
- package/lib/typescript/components/typography/LabelHeader.d.ts.map +1 -0
- package/lib/typescript/components/typography/LabelSmall.d.ts.map +1 -1
- package/lib/typescript/components/typography/Monospace.d.ts.map +1 -1
- package/lib/typescript/components/typography/common.d.ts +2 -2
- package/lib/typescript/components/typography/common.d.ts.map +1 -1
- package/lib/typescript/utils/hooks/useSpringPressProgressValue.d.ts +11 -0
- package/lib/typescript/utils/hooks/useSpringPressProgressValue.d.ts.map +1 -0
- package/lib/typescript/utils/image.d.ts.map +1 -1
- package/package.json +6 -4
- package/src/components/Advice/index.tsx +1 -1
- package/src/components/accordion/RawAccordion.tsx +3 -3
- package/src/components/alert/Alert.tsx +4 -1
- package/src/components/avatar/Avatar.tsx +1 -1
- package/src/components/avatar/__test__/avatar.test.tsx +7 -4
- package/src/components/avatar/index.tsx +1 -1
- package/src/components/badge/Badge.tsx +16 -11
- package/src/components/banner/Banner.tsx +206 -195
- package/src/components/banner/__test__/banner.test.tsx +11 -9
- package/src/components/banner/index.tsx +1 -1
- package/src/components/buttons/ButtonExtendedOutline.tsx +80 -80
- package/src/components/buttons/ButtonOutline.tsx +278 -280
- package/src/components/buttons/ButtonSolid.tsx +142 -141
- package/src/components/buttons/IconButtonContained.tsx +17 -17
- package/src/components/buttons/IconButtonSolid.tsx +11 -11
- package/src/components/common/AnimatedTick.tsx +1 -0
- package/src/components/contentWrapper/ContentWrapper.tsx +12 -12
- package/src/components/contentWrapper/index.tsx +1 -1
- package/src/components/divider/index.tsx +1 -1
- package/src/components/icons/Icon.tsx +124 -120
- package/src/components/icons/index.tsx +1 -1
- package/src/components/icons/svg/IconLight.tsx +16 -0
- package/src/components/icons/svg/IconLightFilled.tsx +16 -0
- package/src/components/icons/svg/originals/IconLight.svg +3 -0
- package/src/components/icons/svg/originals/IconLightFilled.svg +3 -0
- package/src/components/index.tsx +1 -0
- package/src/components/listitems/ListItemAction.tsx +120 -119
- package/src/components/listitems/ListItemIDP.tsx +115 -115
- package/src/components/listitems/ListItemNavAlert.tsx +114 -110
- package/src/components/listitems/ListItemTransaction.tsx +2 -6
- package/src/components/listitems/PressableListItemsBase.tsx +29 -29
- package/src/components/listitems/__test__/listitem.test.tsx +53 -15
- package/src/components/listitems/hooks/useListItemSpringAnimation.ts +54 -52
- package/src/components/pictograms/Pictogram.tsx +36 -31
- package/src/components/pictograms/svg/PictogramFocusOn.tsx +39 -0
- package/src/components/pictograms/svg/PictogramSuccess.tsx +49 -0
- package/src/components/pictograms/svg/originals/PictogramFocusOn.svg +19 -0
- package/src/components/pictograms/svg/originals/PictogramSuccess.svg +35 -0
- package/src/components/spacer/Spacer.tsx +21 -18
- package/src/components/spacer/index.tsx +1 -1
- package/src/components/tabs/TabItem.tsx +183 -0
- package/src/components/tabs/TabNavigation.tsx +114 -0
- package/src/components/tabs/index.tsx +2 -0
- package/src/components/typography/Body.tsx +10 -10
- package/src/components/typography/Factory.tsx +38 -38
- package/src/components/typography/H1.tsx +19 -19
- package/src/components/typography/H2.tsx +19 -19
- package/src/components/typography/H4.tsx +12 -12
- package/src/components/typography/H5.tsx +24 -24
- package/src/components/typography/H6.tsx +10 -10
- package/src/components/typography/Label.tsx +16 -16
- package/src/components/typography/LabelHeader.tsx +44 -0
- package/src/components/typography/LabelSmall.tsx +27 -28
- package/src/components/typography/Monospace.tsx +14 -14
- package/src/components/typography/common.tsx +20 -20
- package/src/components/typography/index.tsx +0 -1
- package/src/index.tsx +0 -1
- package/src/json-import.d.ts +3 -4
- package/src/utils/dates.ts +1 -1
- package/src/utils/hooks/useSpringPressProgressValue.ts +28 -0
- package/src/utils/image.ts +22 -22
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { GestureResponderEvent, Pressable, StyleSheet } from "react-native";
|
|
3
|
+
import Animated, {
|
|
4
|
+
Extrapolate,
|
|
5
|
+
interpolate,
|
|
6
|
+
interpolateColor,
|
|
7
|
+
useAnimatedStyle,
|
|
8
|
+
useDerivedValue,
|
|
9
|
+
useSharedValue,
|
|
10
|
+
withSpring
|
|
11
|
+
} from "react-native-reanimated";
|
|
12
|
+
import { WithTestID } from "../../utils/types";
|
|
13
|
+
import { IOIcons, Icon } from "../icons";
|
|
14
|
+
import { HSpacer } from "../spacer";
|
|
15
|
+
import { LabelHeader } from "../typography/LabelHeader";
|
|
16
|
+
import { IOSpringValues, IOColors, hexToRgba, IOScaleValues } from "../../core";
|
|
17
|
+
import { useSpringPressProgressValue } from "../../utils/hooks/useSpringPressProgressValue";
|
|
18
|
+
|
|
19
|
+
type ColorMode = "light" | "dark";
|
|
20
|
+
|
|
21
|
+
export type TabItem = WithTestID<{
|
|
22
|
+
label: string;
|
|
23
|
+
color?: ColorMode;
|
|
24
|
+
selected?: boolean;
|
|
25
|
+
fullWidth?: boolean;
|
|
26
|
+
// Icons
|
|
27
|
+
icon?: IOIcons;
|
|
28
|
+
iconSelected?: IOIcons;
|
|
29
|
+
// Accessibility
|
|
30
|
+
accessibilityLabel: string;
|
|
31
|
+
accessibilityHint?: string;
|
|
32
|
+
// Events
|
|
33
|
+
onPress?: (event: GestureResponderEvent) => void;
|
|
34
|
+
}>;
|
|
35
|
+
|
|
36
|
+
type ColorStates = {
|
|
37
|
+
background: {
|
|
38
|
+
default: string;
|
|
39
|
+
selected: string;
|
|
40
|
+
pressed: string;
|
|
41
|
+
};
|
|
42
|
+
foreground: {
|
|
43
|
+
default: IOColors;
|
|
44
|
+
selected: IOColors;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const mapColorStates: Record<NonNullable<TabItem["color"]>, ColorStates> = {
|
|
49
|
+
light: {
|
|
50
|
+
background: {
|
|
51
|
+
default: "#ffffff00",
|
|
52
|
+
selected: IOColors["grey-50"],
|
|
53
|
+
pressed: IOColors["grey-50"]
|
|
54
|
+
},
|
|
55
|
+
foreground: {
|
|
56
|
+
default: "grey-650",
|
|
57
|
+
selected: "black"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
dark: {
|
|
61
|
+
background: {
|
|
62
|
+
default: "#ffffff00",
|
|
63
|
+
selected: IOColors.white,
|
|
64
|
+
pressed: IOColors.white
|
|
65
|
+
},
|
|
66
|
+
foreground: {
|
|
67
|
+
default: "white",
|
|
68
|
+
selected: "grey-850"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const TabItem = ({
|
|
74
|
+
label,
|
|
75
|
+
color = "light",
|
|
76
|
+
selected = false,
|
|
77
|
+
fullWidth = false,
|
|
78
|
+
accessibilityLabel,
|
|
79
|
+
accessibilityHint,
|
|
80
|
+
testID,
|
|
81
|
+
onPress,
|
|
82
|
+
icon,
|
|
83
|
+
iconSelected
|
|
84
|
+
}: TabItem) => {
|
|
85
|
+
const {
|
|
86
|
+
progress: progressPressed,
|
|
87
|
+
onPressIn,
|
|
88
|
+
onPressOut
|
|
89
|
+
} = useSpringPressProgressValue(IOSpringValues.selection);
|
|
90
|
+
|
|
91
|
+
const colors = mapColorStates[color];
|
|
92
|
+
const foregroundColor = colors.foreground[selected ? "selected" : "default"];
|
|
93
|
+
|
|
94
|
+
const opaquePressedBackgroundColor = hexToRgba(
|
|
95
|
+
colors.background.pressed,
|
|
96
|
+
0.1
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
const isSelected: Animated.SharedValue<number> = useSharedValue(0);
|
|
100
|
+
const progressSelected = useDerivedValue(() =>
|
|
101
|
+
withSpring(isSelected.value, IOSpringValues.selection)
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
React.useEffect(() => {
|
|
105
|
+
// eslint-disable-next-line functional/immutable-data
|
|
106
|
+
isSelected.value = selected ? 1 : 0;
|
|
107
|
+
}, [isSelected, selected]);
|
|
108
|
+
|
|
109
|
+
// Interpolate animation values from `pressed` values
|
|
110
|
+
const animatedStyle = useAnimatedStyle(() => {
|
|
111
|
+
// Link color states to the pressed states
|
|
112
|
+
const pressedBackgroundColor = interpolateColor(
|
|
113
|
+
progressPressed.value,
|
|
114
|
+
[0, 1],
|
|
115
|
+
[colors.background.default, opaquePressedBackgroundColor]
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
const selectedBackgroundColor = interpolateColor(
|
|
119
|
+
progressSelected.value,
|
|
120
|
+
[0, 1],
|
|
121
|
+
[opaquePressedBackgroundColor, colors.background.selected]
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
// Scale down button slightly when pressed
|
|
125
|
+
const scale = interpolate(
|
|
126
|
+
progressPressed.value,
|
|
127
|
+
[0, 1],
|
|
128
|
+
[1, IOScaleValues?.basicButton?.pressedState],
|
|
129
|
+
Extrapolate.CLAMP
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
backgroundColor: selected
|
|
134
|
+
? selectedBackgroundColor
|
|
135
|
+
: pressedBackgroundColor,
|
|
136
|
+
transform: [{ scale }]
|
|
137
|
+
};
|
|
138
|
+
}, [progressPressed, progressSelected, selected]);
|
|
139
|
+
|
|
140
|
+
const activeIcon = selected ? iconSelected ?? icon : icon;
|
|
141
|
+
|
|
142
|
+
return (
|
|
143
|
+
<Pressable
|
|
144
|
+
accessibilityLabel={accessibilityLabel}
|
|
145
|
+
accessibilityHint={accessibilityHint}
|
|
146
|
+
accessibilityRole={"button"}
|
|
147
|
+
testID={testID}
|
|
148
|
+
onPress={onPress}
|
|
149
|
+
onPressIn={onPressIn}
|
|
150
|
+
onPressOut={onPressOut}
|
|
151
|
+
accessible={true}
|
|
152
|
+
>
|
|
153
|
+
<Animated.View
|
|
154
|
+
style={[styles.container, animatedStyle, fullWidth && styles.fullWidth]}
|
|
155
|
+
>
|
|
156
|
+
{activeIcon && (
|
|
157
|
+
<>
|
|
158
|
+
<Icon name={activeIcon} color={foregroundColor} size={16} />
|
|
159
|
+
<HSpacer size={4} />
|
|
160
|
+
</>
|
|
161
|
+
)}
|
|
162
|
+
<LabelHeader color={foregroundColor}>{label}</LabelHeader>
|
|
163
|
+
</Animated.View>
|
|
164
|
+
</Pressable>
|
|
165
|
+
);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const styles = StyleSheet.create({
|
|
169
|
+
container: {
|
|
170
|
+
flexDirection: "row",
|
|
171
|
+
alignItems: "center",
|
|
172
|
+
paddingHorizontal: 16,
|
|
173
|
+
paddingVertical: 8,
|
|
174
|
+
borderRadius: 65,
|
|
175
|
+
justifyContent: "center",
|
|
176
|
+
alignSelf: "flex-start"
|
|
177
|
+
},
|
|
178
|
+
fullWidth: {
|
|
179
|
+
alignSelf: "auto"
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
export { TabItem };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FlexStyle, LayoutChangeEvent, StyleSheet, View } from "react-native";
|
|
3
|
+
import { ScrollView } from "react-native-gesture-handler";
|
|
4
|
+
import { TabItem } from "./TabItem";
|
|
5
|
+
|
|
6
|
+
export type TabNavigationItem = Omit<
|
|
7
|
+
TabItem,
|
|
8
|
+
"onPress" | "color" | "selected" | "accessibilityLabel" | "accessibilityHint"
|
|
9
|
+
>;
|
|
10
|
+
|
|
11
|
+
type TabNavigationChildren =
|
|
12
|
+
| React.ReactElement<TabItem>
|
|
13
|
+
| Array<React.ReactElement<TabItem>>;
|
|
14
|
+
|
|
15
|
+
type TabAlignment = "start" | "center" | "end" | "stretch";
|
|
16
|
+
|
|
17
|
+
type TabNavigation = {
|
|
18
|
+
// Configuration
|
|
19
|
+
color?: TabItem["color"];
|
|
20
|
+
selectedIndex?: number;
|
|
21
|
+
tabAlignment?: TabAlignment;
|
|
22
|
+
// Events
|
|
23
|
+
onItemPress?: (index: number) => void;
|
|
24
|
+
// Tabs
|
|
25
|
+
children: TabNavigationChildren;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const itemsJustify: Record<TabAlignment, FlexStyle["justifyContent"]> = {
|
|
29
|
+
start: "flex-start",
|
|
30
|
+
center: "center",
|
|
31
|
+
end: "flex-end",
|
|
32
|
+
stretch: "space-between"
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const TabNavigation = ({
|
|
36
|
+
color = "light",
|
|
37
|
+
selectedIndex: forceSelectedIndex,
|
|
38
|
+
tabAlignment = "center",
|
|
39
|
+
onItemPress,
|
|
40
|
+
children
|
|
41
|
+
}: TabNavigation) => {
|
|
42
|
+
const [itemMinWidth, setItemMinWidth] = React.useState<number>(0);
|
|
43
|
+
const [selectedIndex, setSelectedIndex] = React.useState(
|
|
44
|
+
forceSelectedIndex ?? 0
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const handleItemPress = (index: number) => {
|
|
48
|
+
setSelectedIndex(forceSelectedIndex ?? index);
|
|
49
|
+
onItemPress?.(index);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const handleItemOnLayout = (event: LayoutChangeEvent) => {
|
|
53
|
+
const { width } = event.nativeEvent.layout;
|
|
54
|
+
setItemMinWidth(current => Math.max(current, width));
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const stretchItems = tabAlignment === "stretch";
|
|
58
|
+
|
|
59
|
+
const wrapChild = (child: React.ReactElement<TabItem>, index: number = 0) => (
|
|
60
|
+
<View
|
|
61
|
+
key={index}
|
|
62
|
+
style={[
|
|
63
|
+
styles.item,
|
|
64
|
+
{
|
|
65
|
+
marginEnd: index === React.Children.count(children) - 1 ? 0 : 8
|
|
66
|
+
},
|
|
67
|
+
stretchItems && {
|
|
68
|
+
minWidth: itemMinWidth
|
|
69
|
+
}
|
|
70
|
+
]}
|
|
71
|
+
onLayout={handleItemOnLayout}
|
|
72
|
+
>
|
|
73
|
+
{React.cloneElement<TabItem>(child, {
|
|
74
|
+
onPress: event => {
|
|
75
|
+
child.props.onPress?.(event);
|
|
76
|
+
handleItemPress(index);
|
|
77
|
+
},
|
|
78
|
+
selected: selectedIndex === index,
|
|
79
|
+
color
|
|
80
|
+
})}
|
|
81
|
+
</View>
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<ScrollView
|
|
86
|
+
horizontal={true}
|
|
87
|
+
centerContent={true}
|
|
88
|
+
showsHorizontalScrollIndicator={false}
|
|
89
|
+
contentContainerStyle={[
|
|
90
|
+
styles.container,
|
|
91
|
+
{
|
|
92
|
+
justifyContent: itemsJustify[tabAlignment]
|
|
93
|
+
}
|
|
94
|
+
]}
|
|
95
|
+
>
|
|
96
|
+
{Array.isArray(children) ? children.map(wrapChild) : wrapChild(children)}
|
|
97
|
+
</ScrollView>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const styles = StyleSheet.create({
|
|
102
|
+
container: {
|
|
103
|
+
flexGrow: 1,
|
|
104
|
+
paddingHorizontal: 24
|
|
105
|
+
},
|
|
106
|
+
item: {
|
|
107
|
+
flexGrow: 0,
|
|
108
|
+
flexShrink: 1,
|
|
109
|
+
flexBasis: 100,
|
|
110
|
+
alignItems: "center"
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
export { TabNavigation };
|
|
@@ -5,14 +5,14 @@ import { useTypographyFactory } from "./Factory";
|
|
|
5
5
|
import { ExternalTypographyProps, TypographyProps } from "./common";
|
|
6
6
|
|
|
7
7
|
type PartialAllowedColors = Extract<
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
IOColors,
|
|
9
|
+
"bluegreyDark" | "white" | "blue" | "bluegrey" | "bluegreyLight"
|
|
10
10
|
>;
|
|
11
11
|
type AllowedColors = PartialAllowedColors | IOTheme["textBody-default"];
|
|
12
12
|
type AllowedWeight = IOFontWeight | "Regular" | "SemiBold";
|
|
13
13
|
|
|
14
14
|
type OwnProps = ExternalTypographyProps<
|
|
15
|
-
|
|
15
|
+
TypographyProps<AllowedWeight, AllowedColors>
|
|
16
16
|
>;
|
|
17
17
|
|
|
18
18
|
const fontName: FontFamily = "TitilliumWeb";
|
|
@@ -28,10 +28,10 @@ export const bodyDefaultWeight: AllowedWeight = "Regular";
|
|
|
28
28
|
* @constructor
|
|
29
29
|
*/
|
|
30
30
|
export const Body: React.FunctionComponent<OwnProps> = props =>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
useTypographyFactory<AllowedWeight, AllowedColors>({
|
|
32
|
+
...props,
|
|
33
|
+
defaultWeight: bodyDefaultWeight,
|
|
34
|
+
defaultColor: bodyDefaultColor,
|
|
35
|
+
font: fontName,
|
|
36
|
+
fontStyle: { fontSize: bodyFontSize, lineHeight: bodyLineHeight }
|
|
37
|
+
});
|
|
@@ -4,9 +4,9 @@ import { IOFontWeight } from "../../utils/fonts";
|
|
|
4
4
|
import { XOR } from "../../utils/types";
|
|
5
5
|
import { BaseTypography } from "./BaseTypography";
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
calculateWeightColor,
|
|
8
|
+
RequiredTypographyProps,
|
|
9
|
+
TypographyProps
|
|
10
10
|
} from "./common";
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -14,8 +14,8 @@ import {
|
|
|
14
14
|
* that will be used when the fields weight and color will be undefined.
|
|
15
15
|
*/
|
|
16
16
|
type DefaultArgumentProps<WeightPropsType, ColorsPropsType> = {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
defaultWeight: WeightPropsType;
|
|
18
|
+
defaultColor: ColorsPropsType;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -23,18 +23,18 @@ type DefaultArgumentProps<WeightPropsType, ColorsPropsType> = {
|
|
|
23
23
|
* weight and color, thus allowing to implement more sophisticated strategies.
|
|
24
24
|
*/
|
|
25
25
|
type DefaultFactoryProps<WeightPropsType, ColorsPropsType> = {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
weightColorFactory: (
|
|
27
|
+
weight?: WeightPropsType,
|
|
28
|
+
color?: ColorsPropsType
|
|
29
|
+
) => RequiredTypographyProps<WeightPropsType, ColorsPropsType>;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Only one type of default props strategy is allowed
|
|
34
34
|
*/
|
|
35
35
|
type DefaultProps<WeightPropsType, ColorsPropsType> = XOR<
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
DefaultArgumentProps<WeightPropsType, ColorsPropsType>,
|
|
37
|
+
DefaultFactoryProps<WeightPropsType, ColorsPropsType>
|
|
38
38
|
>;
|
|
39
39
|
|
|
40
40
|
/**
|
|
@@ -44,25 +44,25 @@ type DefaultProps<WeightPropsType, ColorsPropsType> = XOR<
|
|
|
44
44
|
* - The default {@link TypographyProps}
|
|
45
45
|
*/
|
|
46
46
|
type FactoryProps<WeightPropsType, ColorsPropsType> = TypographyProps<
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
WeightPropsType,
|
|
48
|
+
ColorsPropsType
|
|
49
49
|
> &
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
DefaultProps<WeightPropsType, ColorsPropsType> &
|
|
51
|
+
Omit<React.ComponentProps<typeof BaseTypography>, "weight" | "color">;
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* Calculate if the props is of type {@link DefaultFactoryProps}
|
|
55
55
|
* @param props
|
|
56
56
|
*/
|
|
57
57
|
function isDefaultFactoryProps<WeightPropsType, ColorsPropsType>(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
props:
|
|
59
|
+
| DefaultFactoryProps<WeightPropsType, ColorsPropsType>
|
|
60
|
+
| DefaultArgumentProps<WeightPropsType, ColorsPropsType>
|
|
61
61
|
): props is DefaultFactoryProps<WeightPropsType, ColorsPropsType> {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
return (
|
|
63
|
+
(props as DefaultFactoryProps<WeightPropsType, ColorsPropsType>)
|
|
64
|
+
.weightColorFactory !== undefined
|
|
65
|
+
);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
/**
|
|
@@ -72,22 +72,22 @@ function isDefaultFactoryProps<WeightPropsType, ColorsPropsType>(
|
|
|
72
72
|
* @param props
|
|
73
73
|
*/
|
|
74
74
|
export function useTypographyFactory<
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
WeightPropsType extends IOFontWeight,
|
|
76
|
+
ColorsPropsType extends IOColors
|
|
77
77
|
>(props: FactoryProps<WeightPropsType, ColorsPropsType>) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
78
|
+
// Use different strategy to calculate the default values, based on DefaultProps
|
|
79
|
+
const { weight, color } = useMemo(
|
|
80
|
+
() =>
|
|
81
|
+
isDefaultFactoryProps(props)
|
|
82
|
+
? props.weightColorFactory(props.weight, props.color)
|
|
83
|
+
: calculateWeightColor(
|
|
84
|
+
props.defaultWeight,
|
|
85
|
+
props.defaultColor,
|
|
86
|
+
props.weight,
|
|
87
|
+
props.color
|
|
88
|
+
),
|
|
89
|
+
[props]
|
|
90
|
+
);
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
return <BaseTypography weight={weight} color={color} {...props} />;
|
|
93
93
|
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
IOColors,
|
|
4
|
+
IOColorsStatusForeground,
|
|
5
|
+
IOTheme
|
|
6
6
|
} from "../../core/IOColors";
|
|
7
7
|
import { FontFamily, IOFontWeight } from "../../utils/fonts";
|
|
8
8
|
import { useTypographyFactory } from "./Factory";
|
|
9
9
|
import { ExternalTypographyProps, TypographyProps } from "./common";
|
|
10
10
|
|
|
11
11
|
type PartialAllowedColors = Extract<
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
IOColors,
|
|
13
|
+
"bluegreyDark" | "white" | "blue"
|
|
14
14
|
>;
|
|
15
15
|
type AllowedColors =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
| PartialAllowedColors
|
|
17
|
+
| IOColorsStatusForeground
|
|
18
|
+
| IOTheme["textHeading-default"];
|
|
19
19
|
type AllowedWeight = Extract<IOFontWeight, "Bold">;
|
|
20
20
|
|
|
21
21
|
type OwnProps = ExternalTypographyProps<
|
|
22
|
-
|
|
22
|
+
TypographyProps<AllowedWeight, AllowedColors>
|
|
23
23
|
>;
|
|
24
24
|
|
|
25
25
|
export const h1FontSize = 26;
|
|
@@ -33,13 +33,13 @@ export const h1DefaultWeight: AllowedWeight = "Bold";
|
|
|
33
33
|
* @param props
|
|
34
34
|
* @constructor
|
|
35
35
|
*/
|
|
36
|
-
export const H1: React.FC<OwnProps> =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
};
|
|
36
|
+
export const H1: React.FC<OwnProps> = props => {
|
|
37
|
+
const fontName: FontFamily = "TitilliumWeb";
|
|
38
|
+
return useTypographyFactory<AllowedWeight, AllowedColors>({
|
|
39
|
+
...props,
|
|
40
|
+
defaultWeight: h1DefaultWeight,
|
|
41
|
+
defaultColor: h1DefaultColor,
|
|
42
|
+
font: fontName,
|
|
43
|
+
fontStyle: { fontSize: h1FontSize, lineHeight: h1LineHeight }
|
|
44
|
+
});
|
|
45
|
+
};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
IOColors,
|
|
4
|
+
IOColorsStatusForeground,
|
|
5
|
+
IOTheme
|
|
6
6
|
} from "../../core/IOColors";
|
|
7
7
|
import { FontFamily, IOFontWeight } from "../../utils/fonts";
|
|
8
8
|
import { useTypographyFactory } from "./Factory";
|
|
9
9
|
import { ExternalTypographyProps, TypographyProps } from "./common";
|
|
10
10
|
|
|
11
11
|
type PartialAllowedColors = Extract<
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
IOColors,
|
|
13
|
+
"bluegreyDark" | "white" | "blue" | "bluegrey"
|
|
14
14
|
>;
|
|
15
15
|
type AllowedColors =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
| PartialAllowedColors
|
|
17
|
+
| IOColorsStatusForeground
|
|
18
|
+
| IOTheme["textHeading-default"];
|
|
19
19
|
type AllowedWeight = Extract<IOFontWeight, "Bold" | "SemiBold">;
|
|
20
20
|
|
|
21
21
|
type OwnProps = ExternalTypographyProps<
|
|
22
|
-
|
|
22
|
+
TypographyProps<AllowedWeight, AllowedColors>
|
|
23
23
|
>;
|
|
24
24
|
|
|
25
25
|
export const h2FontSize = 20;
|
|
@@ -33,13 +33,13 @@ export const h2DefaultWeight: AllowedWeight = "Bold";
|
|
|
33
33
|
* @param props
|
|
34
34
|
* @constructor
|
|
35
35
|
*/
|
|
36
|
-
export const H2: React.FC<OwnProps> =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
};
|
|
36
|
+
export const H2: React.FC<OwnProps> = props => {
|
|
37
|
+
const fontName: FontFamily = "TitilliumWeb";
|
|
38
|
+
return useTypographyFactory<AllowedWeight, AllowedColors>({
|
|
39
|
+
...props,
|
|
40
|
+
defaultWeight: h2DefaultWeight,
|
|
41
|
+
defaultColor: h2DefaultColor,
|
|
42
|
+
font: fontName,
|
|
43
|
+
fontStyle: { fontSize: h2FontSize, lineHeight: h2LineHeight }
|
|
44
|
+
});
|
|
45
|
+
};
|
|
@@ -8,7 +8,7 @@ type AllowedColors = IOColorsStatusForeground | IOTheme["textHeading-default"];
|
|
|
8
8
|
type AllowedWeight = Extract<IOFontWeight, "SemiBold" | "Regular">;
|
|
9
9
|
|
|
10
10
|
type OwnProps = ExternalTypographyProps<
|
|
11
|
-
|
|
11
|
+
TypographyProps<AllowedWeight, AllowedColors>
|
|
12
12
|
>;
|
|
13
13
|
|
|
14
14
|
/* Common typographic styles */
|
|
@@ -22,16 +22,16 @@ export const h4LineHeight = 24;
|
|
|
22
22
|
* @constructor
|
|
23
23
|
*/
|
|
24
24
|
export const H4: React.FC<OwnProps> = props => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
/* New typographic styles */
|
|
26
|
+
const font: FontFamily = "ReadexPro";
|
|
27
|
+
const defaultColor: AllowedColors = "black";
|
|
28
|
+
const defaultWeight: AllowedWeight = "Regular";
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
return useTypographyFactory<AllowedWeight, AllowedColors>({
|
|
31
|
+
...props,
|
|
32
|
+
defaultWeight,
|
|
33
|
+
defaultColor,
|
|
34
|
+
font,
|
|
35
|
+
fontStyle: { fontSize: h4FontSize, lineHeight: h4LineHeight }
|
|
36
|
+
});
|
|
37
37
|
};
|