@pagopa/io-app-design-system 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/lib/commonjs/components/banner/__test__/__snapshots__/banner.test.tsx.snap +1 -0
- package/lib/commonjs/components/buttons/ButtonLink.js +1 -0
- package/lib/commonjs/components/buttons/ButtonLink.js.map +1 -1
- package/lib/commonjs/components/buttons/IconButton.js +0 -1
- package/lib/commonjs/components/buttons/IconButton.js.map +1 -1
- package/lib/commonjs/components/buttons/__test__/__snapshots__/button.test.tsx.snap +1 -5
- package/lib/commonjs/components/checkbox/AnimatedMessageCheckbox.js +79 -0
- package/lib/commonjs/components/checkbox/AnimatedMessageCheckbox.js.map +1 -0
- package/lib/commonjs/components/checkbox/index.js +11 -0
- package/lib/commonjs/components/checkbox/index.js.map +1 -1
- package/lib/commonjs/components/icons/Icon.js +2 -0
- package/lib/commonjs/components/icons/Icon.js.map +1 -1
- package/lib/commonjs/components/icons/svg/IconArchive.js +31 -0
- package/lib/commonjs/components/icons/svg/IconArchive.js.map +1 -0
- package/lib/commonjs/components/icons/svg/originals/IconArchive.svg +4 -0
- package/lib/commonjs/components/layout/HeaderSecondLevel.js +95 -0
- package/lib/commonjs/components/layout/HeaderSecondLevel.js.map +1 -0
- package/lib/commonjs/components/layout/index.js +33 -0
- package/lib/commonjs/components/layout/index.js.map +1 -1
- package/lib/commonjs/components/typography/CTA.js +34 -0
- package/lib/commonjs/components/typography/CTA.js.map +1 -0
- package/lib/commonjs/components/typography/__test__/__snapshots__/typography.test.tsx.snap +32 -0
- package/lib/commonjs/components/typography/__test__/typography.test.js +6 -1
- package/lib/commonjs/components/typography/__test__/typography.test.js.map +1 -1
- package/lib/commonjs/components/typography/index.js +15 -4
- package/lib/commonjs/components/typography/index.js.map +1 -1
- package/lib/commonjs/core/IOStyles.js +2 -1
- package/lib/commonjs/core/IOStyles.js.map +1 -1
- package/lib/module/components/banner/__test__/__snapshots__/banner.test.tsx.snap +1 -0
- package/lib/module/components/buttons/ButtonLink.js +1 -0
- package/lib/module/components/buttons/ButtonLink.js.map +1 -1
- package/lib/module/components/buttons/IconButton.js +1 -2
- package/lib/module/components/buttons/IconButton.js.map +1 -1
- package/lib/module/components/buttons/__test__/__snapshots__/button.test.tsx.snap +1 -5
- package/lib/module/components/checkbox/AnimatedMessageCheckbox.js +70 -0
- package/lib/module/components/checkbox/AnimatedMessageCheckbox.js.map +1 -0
- package/lib/module/components/checkbox/index.js +1 -0
- package/lib/module/components/checkbox/index.js.map +1 -1
- package/lib/module/components/icons/Icon.js +2 -0
- package/lib/module/components/icons/Icon.js.map +1 -1
- package/lib/module/components/icons/svg/IconArchive.js +23 -0
- package/lib/module/components/icons/svg/IconArchive.js.map +1 -0
- package/lib/module/components/icons/svg/originals/IconArchive.svg +4 -0
- package/lib/module/components/layout/HeaderSecondLevel.js +84 -0
- package/lib/module/components/layout/HeaderSecondLevel.js.map +1 -0
- package/lib/module/components/layout/index.js +3 -0
- package/lib/module/components/layout/index.js.map +1 -1
- package/lib/module/components/typography/CTA.js +27 -0
- package/lib/module/components/typography/CTA.js.map +1 -0
- package/lib/module/components/typography/__test__/__snapshots__/typography.test.tsx.snap +32 -0
- package/lib/module/components/typography/__test__/typography.test.js +6 -1
- package/lib/module/components/typography/__test__/typography.test.js.map +1 -1
- package/lib/module/components/typography/index.js +2 -1
- package/lib/module/components/typography/index.js.map +1 -1
- package/lib/module/core/IOStyles.js +1 -1
- package/lib/module/core/IOStyles.js.map +1 -1
- package/lib/typescript/components/buttons/ButtonLink.d.ts.map +1 -1
- package/lib/typescript/components/buttons/IconButton.d.ts.map +1 -1
- package/lib/typescript/components/checkbox/AnimatedMessageCheckbox.d.ts +13 -0
- package/lib/typescript/components/checkbox/AnimatedMessageCheckbox.d.ts.map +1 -0
- package/lib/typescript/components/checkbox/index.d.ts +1 -0
- package/lib/typescript/components/checkbox/index.d.ts.map +1 -1
- package/lib/typescript/components/icons/Icon.d.ts +1 -0
- package/lib/typescript/components/icons/Icon.d.ts.map +1 -1
- package/lib/typescript/components/icons/svg/IconArchive.d.ts +5 -0
- package/lib/typescript/components/icons/svg/IconArchive.d.ts.map +1 -0
- package/lib/typescript/components/layout/HeaderSecondLevel.d.ts +20 -0
- package/lib/typescript/components/layout/HeaderSecondLevel.d.ts.map +1 -0
- package/lib/typescript/components/layout/index.d.ts +3 -0
- package/lib/typescript/components/layout/index.d.ts.map +1 -1
- package/lib/typescript/components/typography/CTA.d.ts +16 -0
- package/lib/typescript/components/typography/CTA.d.ts.map +1 -0
- package/lib/typescript/components/typography/index.d.ts +2 -1
- package/lib/typescript/components/typography/index.d.ts.map +1 -1
- package/lib/typescript/core/IOStyles.d.ts +1 -0
- package/lib/typescript/core/IOStyles.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/banner/__test__/__snapshots__/banner.test.tsx.snap +1 -0
- package/src/components/buttons/ButtonLink.tsx +1 -0
- package/src/components/buttons/IconButton.tsx +0 -2
- package/src/components/buttons/__test__/__snapshots__/button.test.tsx.snap +1 -5
- package/src/components/checkbox/AnimatedMessageCheckbox.tsx +105 -0
- package/src/components/checkbox/index.tsx +1 -0
- package/src/components/icons/Icon.tsx +2 -0
- package/src/components/icons/svg/IconArchive.tsx +16 -0
- package/src/components/icons/svg/originals/IconArchive.svg +4 -0
- package/src/components/layout/HeaderSecondLevel.tsx +153 -0
- package/src/components/layout/index.tsx +3 -0
- package/src/components/typography/CTA.tsx +35 -0
- package/src/components/typography/__test__/__snapshots__/typography.test.tsx.snap +32 -0
- package/src/components/typography/__test__/typography.test.tsx +7 -2
- package/src/components/typography/index.tsx +2 -2
- package/src/core/IOStyles.ts +1 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
|
+
import { StyleSheet, Pressable, PressableProps } from "react-native";
|
|
3
|
+
import Animated, {
|
|
4
|
+
useSharedValue,
|
|
5
|
+
useAnimatedStyle,
|
|
6
|
+
interpolate,
|
|
7
|
+
withSpring,
|
|
8
|
+
withTiming,
|
|
9
|
+
Easing
|
|
10
|
+
} from "react-native-reanimated";
|
|
11
|
+
import { IOColors } from "../../core/IOColors";
|
|
12
|
+
import { IOSpringValues } from "../../core/IOAnimations";
|
|
13
|
+
import { AnimatedTick } from "../common/AnimatedTick";
|
|
14
|
+
import {
|
|
15
|
+
IOSelectionTickVisualParams,
|
|
16
|
+
IOVisualCostants
|
|
17
|
+
} from "../../core/IOStyles";
|
|
18
|
+
import { IOSpacingScale } from "../../core/IOSpacing";
|
|
19
|
+
|
|
20
|
+
type Props = {
|
|
21
|
+
checked?: boolean;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type AnimatedMessageCheckbox = Props & Pick<PressableProps, "onPress">;
|
|
25
|
+
|
|
26
|
+
const internalSpacing: IOSpacingScale = 4;
|
|
27
|
+
|
|
28
|
+
const styles = StyleSheet.create({
|
|
29
|
+
checkBoxWrapper: {
|
|
30
|
+
width: IOVisualCostants.avatarSizeSmall,
|
|
31
|
+
height: IOVisualCostants.avatarSizeSmall,
|
|
32
|
+
padding: internalSpacing
|
|
33
|
+
},
|
|
34
|
+
checkBoxCircle: {
|
|
35
|
+
position: "absolute",
|
|
36
|
+
left: 0,
|
|
37
|
+
top: 0,
|
|
38
|
+
width: IOVisualCostants.avatarSizeSmall,
|
|
39
|
+
height: IOVisualCostants.avatarSizeSmall,
|
|
40
|
+
borderRadius: IOVisualCostants.avatarSizeSmall
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Animated message checkbox used for the specific message
|
|
46
|
+
* list item (Select mode that enables related actions)
|
|
47
|
+
*/
|
|
48
|
+
export const AnimatedMessageCheckbox = ({
|
|
49
|
+
checked,
|
|
50
|
+
onPress
|
|
51
|
+
}: AnimatedMessageCheckbox) => {
|
|
52
|
+
const isChecked = checked ?? true;
|
|
53
|
+
|
|
54
|
+
const circleAnimationProgress = useSharedValue(checked ? 1 : 0);
|
|
55
|
+
const tickAnimationProgress = useSharedValue(checked ? 1 : 0);
|
|
56
|
+
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
// eslint-disable-next-line functional/immutable-data
|
|
59
|
+
circleAnimationProgress.value = withSpring(
|
|
60
|
+
checked ? 1 : 0,
|
|
61
|
+
IOSpringValues.selection
|
|
62
|
+
);
|
|
63
|
+
// eslint-disable-next-line functional/immutable-data
|
|
64
|
+
tickAnimationProgress.value = withTiming(checked ? 1 : 0, {
|
|
65
|
+
duration: 250,
|
|
66
|
+
easing: Easing.out(Easing.cubic)
|
|
67
|
+
});
|
|
68
|
+
}, [checked, circleAnimationProgress, tickAnimationProgress]);
|
|
69
|
+
|
|
70
|
+
const animatedCheckboxCircle = useAnimatedStyle(() => {
|
|
71
|
+
const scale = interpolate(circleAnimationProgress.value, [0, 1], [0.8, 1]);
|
|
72
|
+
const opacity = circleAnimationProgress.value;
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
opacity,
|
|
76
|
+
transform: [{ scale }]
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<Pressable
|
|
82
|
+
testID="AnimatedMessageCheckboxInput"
|
|
83
|
+
onPress={onPress}
|
|
84
|
+
style={styles.checkBoxWrapper}
|
|
85
|
+
>
|
|
86
|
+
<Animated.View
|
|
87
|
+
style={[
|
|
88
|
+
styles.checkBoxCircle,
|
|
89
|
+
{
|
|
90
|
+
backgroundColor:
|
|
91
|
+
IOColors[IOSelectionTickVisualParams.bgColorOnState]
|
|
92
|
+
},
|
|
93
|
+
animatedCheckboxCircle
|
|
94
|
+
]}
|
|
95
|
+
/>
|
|
96
|
+
{isChecked && (
|
|
97
|
+
<AnimatedTick
|
|
98
|
+
progress={tickAnimationProgress}
|
|
99
|
+
strokeWidth={1.5}
|
|
100
|
+
stroke={IOColors[IOSelectionTickVisualParams.tickColor]}
|
|
101
|
+
/>
|
|
102
|
+
)}
|
|
103
|
+
</Pressable>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
@@ -144,8 +144,10 @@ import IconSystemSettingsiOS from "./svg/IconSystemSettingsiOS";
|
|
|
144
144
|
import IconSystemToggleInstructions from "./svg/IconSystemToggleInstructions";
|
|
145
145
|
import IconSystemAppsAndroid from "./svg/IconSystemAppsAndroid";
|
|
146
146
|
import IconSystemNotificationsInstructions from "./svg/IconSystemNotificationsInstructions";
|
|
147
|
+
import IconArchive from "./svg/IconArchive";
|
|
147
148
|
|
|
148
149
|
export const IOIcons = {
|
|
150
|
+
archive: IconArchive,
|
|
149
151
|
spid: IconSpid,
|
|
150
152
|
cie: IconCie /* io-cie */,
|
|
151
153
|
qrCode: IconQrCode,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Svg, Path } from "react-native-svg";
|
|
3
|
+
import { SVGIconProps } from "../Icon";
|
|
4
|
+
|
|
5
|
+
const IconArchive = ({ size, style, ...props }: SVGIconProps) => (
|
|
6
|
+
<Svg width={size} height={size} viewBox="0 0 24 24" style={style} {...props}>
|
|
7
|
+
<Path
|
|
8
|
+
fillRule="evenodd"
|
|
9
|
+
clipRule="evenodd"
|
|
10
|
+
d="M0 4c0-1.65685 1.34315-3 3-3h18c1.6569 0 3 1.34315 3 3v2c0 1.30622-.8348 2.41746-2 2.82929V18c0 2.7614-2.2386 5-5 5H7c-2.76142 0-5-2.2386-5-5V8.82929C.8348 8.41746 0 7.30622 0 6V4Zm4 5h16v9c0 1.6569-1.3431 3-3 3H7c-1.65685 0-3-1.3431-3-3V9Zm18-3c0 .55228-.4477 1-1 1H3c-.55228 0-1-.44771-1-1V4c0-.55228.44772-1 1-1h18c.5523 0 1 .44771 1 1v2ZM9 11c-.55229 0-1 .4477-1 1s.44771 1 1 1h6c.5523 0 1-.4477 1-1s-.4477-1-1-1H9Z"
|
|
11
|
+
fill="currentColor"
|
|
12
|
+
/>
|
|
13
|
+
</Svg>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export default IconArchive;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg fill="none"
|
|
2
|
+
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
3
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 4c0-1.65685 1.34315-3 3-3h18c1.6569 0 3 1.34315 3 3v2c0 1.30622-.8348 2.41746-2 2.82929V18c0 2.7614-2.2386 5-5 5H7c-2.76142 0-5-2.2386-5-5V8.82929C.8348 8.41746 0 7.30622 0 6V4Zm4 5h16v9c0 1.6569-1.3431 3-3 3H7c-1.65685 0-3-1.3431-3-3V9Zm18-3c0 .55228-.4477 1-1 1H3c-.55228 0-1-.44771-1-1V4c0-.55228.44772-1 1-1h18c.5523 0 1 .44771 1 1v2ZM9 11c-.55229 0-1 .4477-1 1s.44771 1 1 1h6c.5523 0 1-.4477 1-1s-.4477-1-1-1H9Z" fill="#0E0F13" />
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View, StyleSheet, Platform } from "react-native";
|
|
3
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
4
|
+
import Animated, {
|
|
5
|
+
interpolate,
|
|
6
|
+
interpolateColor,
|
|
7
|
+
useAnimatedStyle
|
|
8
|
+
} from "react-native-reanimated";
|
|
9
|
+
import { IOColors, hexToRgba } from "../../core/IOColors";
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
IOStyles,
|
|
13
|
+
IOVisualCostants,
|
|
14
|
+
iconBtnSizeSmall
|
|
15
|
+
} from "../../core/IOStyles";
|
|
16
|
+
import { HSpacer } from "../spacer";
|
|
17
|
+
import type { IOSpacer } from "../../core/IOSpacing";
|
|
18
|
+
import { WithTestID } from "../../utils/types";
|
|
19
|
+
import IconButton from "../buttons/IconButton";
|
|
20
|
+
import { makeFontStyleObject } from "../../utils/fonts";
|
|
21
|
+
|
|
22
|
+
export type HeaderSecondLevel = WithTestID<{
|
|
23
|
+
scrollValues: ScrollValues;
|
|
24
|
+
title: string;
|
|
25
|
+
goBack: () => void;
|
|
26
|
+
backAccessibilityLabel: string;
|
|
27
|
+
// Accepted components: IconButton
|
|
28
|
+
// Don't use any components other than this, please.
|
|
29
|
+
firstAction?: React.ReactNode;
|
|
30
|
+
secondAction?: React.ReactNode;
|
|
31
|
+
thirdAction?: React.ReactNode;
|
|
32
|
+
// Visual attributes
|
|
33
|
+
transparent?: boolean;
|
|
34
|
+
}>;
|
|
35
|
+
|
|
36
|
+
type ScrollValues = {
|
|
37
|
+
contentOffsetY: Animated.SharedValue<number>;
|
|
38
|
+
triggerOffset: number;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const HEADER_BG_COLOR: IOColors = "white";
|
|
42
|
+
const borderColorDisabled = hexToRgba(IOColors["grey-100"], 0);
|
|
43
|
+
const headerTransparent = hexToRgba(IOColors[HEADER_BG_COLOR], 0);
|
|
44
|
+
const titleHorizontalMargin: IOSpacer = 16;
|
|
45
|
+
|
|
46
|
+
const styles = StyleSheet.create({
|
|
47
|
+
headerInner: {
|
|
48
|
+
paddingHorizontal: IOVisualCostants.appMarginDefault,
|
|
49
|
+
height: IOVisualCostants.headerHeight,
|
|
50
|
+
borderBottomWidth: 1,
|
|
51
|
+
flexGrow: 1,
|
|
52
|
+
flexDirection: "row",
|
|
53
|
+
alignItems: "center",
|
|
54
|
+
justifyContent: "space-between"
|
|
55
|
+
},
|
|
56
|
+
headerTitle: {
|
|
57
|
+
...makeFontStyleObject("Regular", false, "ReadexPro"),
|
|
58
|
+
fontSize: 14,
|
|
59
|
+
textAlign: "center",
|
|
60
|
+
flexGrow: 1,
|
|
61
|
+
flexShrink: 1,
|
|
62
|
+
marginHorizontal: titleHorizontalMargin
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
export const HeaderSecondLevel = ({
|
|
67
|
+
scrollValues,
|
|
68
|
+
goBack,
|
|
69
|
+
backAccessibilityLabel,
|
|
70
|
+
title,
|
|
71
|
+
firstAction,
|
|
72
|
+
secondAction,
|
|
73
|
+
thirdAction,
|
|
74
|
+
transparent = false,
|
|
75
|
+
testID
|
|
76
|
+
}: HeaderSecondLevel) => {
|
|
77
|
+
const insets = useSafeAreaInsets();
|
|
78
|
+
|
|
79
|
+
const headerWrapperAnimatedStyle = useAnimatedStyle(() => ({
|
|
80
|
+
backgroundColor: transparent
|
|
81
|
+
? interpolateColor(
|
|
82
|
+
scrollValues.contentOffsetY.value,
|
|
83
|
+
[0, scrollValues.triggerOffset],
|
|
84
|
+
[headerTransparent, IOColors[HEADER_BG_COLOR]]
|
|
85
|
+
)
|
|
86
|
+
: undefined,
|
|
87
|
+
borderColor: interpolateColor(
|
|
88
|
+
scrollValues.contentOffsetY.value,
|
|
89
|
+
[0, scrollValues.triggerOffset],
|
|
90
|
+
[borderColorDisabled, IOColors["grey-100"]]
|
|
91
|
+
)
|
|
92
|
+
}));
|
|
93
|
+
|
|
94
|
+
const titleAnimatedStyle = useAnimatedStyle(() => ({
|
|
95
|
+
opacity: interpolate(
|
|
96
|
+
scrollValues.contentOffsetY.value,
|
|
97
|
+
[0, scrollValues.triggerOffset],
|
|
98
|
+
[0, 1]
|
|
99
|
+
)
|
|
100
|
+
}));
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<Animated.View
|
|
104
|
+
accessibilityRole="header"
|
|
105
|
+
testID={testID}
|
|
106
|
+
style={[
|
|
107
|
+
{ marginTop: insets.top },
|
|
108
|
+
styles.headerInner,
|
|
109
|
+
transparent
|
|
110
|
+
? { borderBottomWidth: 0 }
|
|
111
|
+
: { backgroundColor: IOColors[HEADER_BG_COLOR] },
|
|
112
|
+
headerWrapperAnimatedStyle
|
|
113
|
+
]}
|
|
114
|
+
>
|
|
115
|
+
<IconButton
|
|
116
|
+
icon={Platform.OS === "ios" ? "backiOS" : "backAndroid"}
|
|
117
|
+
color="neutral"
|
|
118
|
+
onPress={goBack}
|
|
119
|
+
accessibilityLabel={backAccessibilityLabel}
|
|
120
|
+
/>
|
|
121
|
+
<Animated.Text
|
|
122
|
+
numberOfLines={1}
|
|
123
|
+
style={[styles.headerTitle, titleAnimatedStyle]}
|
|
124
|
+
>
|
|
125
|
+
{title}
|
|
126
|
+
</Animated.Text>
|
|
127
|
+
<View style={[IOStyles.row, { flexShrink: 0 }]}>
|
|
128
|
+
{firstAction ? (
|
|
129
|
+
firstAction
|
|
130
|
+
) : (
|
|
131
|
+
<HSpacer size={iconBtnSizeSmall as IOSpacer} />
|
|
132
|
+
)}
|
|
133
|
+
{secondAction && (
|
|
134
|
+
<>
|
|
135
|
+
{/* Ideally, with the "gap" flex property,
|
|
136
|
+
we can get rid of these ugly constructs */}
|
|
137
|
+
<HSpacer size={16} />
|
|
138
|
+
{secondAction}
|
|
139
|
+
</>
|
|
140
|
+
)}
|
|
141
|
+
{thirdAction && (
|
|
142
|
+
<>
|
|
143
|
+
{/* Same as above */}
|
|
144
|
+
<HSpacer size={16} />
|
|
145
|
+
{thirdAction}
|
|
146
|
+
</>
|
|
147
|
+
)}
|
|
148
|
+
</View>
|
|
149
|
+
</Animated.View>
|
|
150
|
+
);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export default HeaderSecondLevel;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { IOTheme, IOThemeLight } from "../../core/IOColors";
|
|
3
|
+
import { IOFontFamily, IOFontWeight } from "../../utils/fonts";
|
|
4
|
+
import { useTypographyFactory } from "./Factory";
|
|
5
|
+
import { ExternalTypographyProps, TypographyProps } from "./common";
|
|
6
|
+
|
|
7
|
+
type AllowedColors = IOTheme["textBody-default"] | "blueIO-850";
|
|
8
|
+
type AllowedWeight = Extract<IOFontWeight, "SemiBold" | "Regular">;
|
|
9
|
+
|
|
10
|
+
type OwnProps = ExternalTypographyProps<
|
|
11
|
+
TypographyProps<AllowedWeight, AllowedColors>
|
|
12
|
+
>;
|
|
13
|
+
|
|
14
|
+
/* Common typographic styles */
|
|
15
|
+
const ctaFontSize = 16;
|
|
16
|
+
const ctaLineHeight = 20;
|
|
17
|
+
const ctaDefaultColor: AllowedColors = IOThemeLight["textBody-default"];
|
|
18
|
+
/* New typographic styles */
|
|
19
|
+
const ctaFontName: IOFontFamily = "ReadexPro";
|
|
20
|
+
const ctaDefaultWeight: AllowedWeight = "Regular";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Typography component to render `CTA` text with font size {@link ctaFontSize} and fontFamily {@link ctaFontName}.
|
|
24
|
+
* default values(if not defined) are weight: {@link ctaDefaultWeight}, color: {@link ctaDefaultColor}
|
|
25
|
+
* @param props
|
|
26
|
+
* @constructor
|
|
27
|
+
*/
|
|
28
|
+
export const CTA: React.FunctionComponent<OwnProps> = props =>
|
|
29
|
+
useTypographyFactory<AllowedWeight, AllowedColors>({
|
|
30
|
+
...props,
|
|
31
|
+
defaultWeight: ctaDefaultWeight,
|
|
32
|
+
defaultColor: ctaDefaultColor,
|
|
33
|
+
font: ctaFontName,
|
|
34
|
+
fontStyle: { fontSize: ctaFontSize, lineHeight: ctaLineHeight }
|
|
35
|
+
});
|
|
@@ -32,6 +32,38 @@ exports[`Test Typography Components Body Snapshot 1`] = `
|
|
|
32
32
|
</Text>
|
|
33
33
|
`;
|
|
34
34
|
|
|
35
|
+
exports[`Test Typography Components CTA Snapshot 1`] = `
|
|
36
|
+
<Text
|
|
37
|
+
color="black"
|
|
38
|
+
defaultColor="black"
|
|
39
|
+
defaultWeight="Regular"
|
|
40
|
+
font="ReadexPro"
|
|
41
|
+
fontStyle={
|
|
42
|
+
{
|
|
43
|
+
"fontSize": 16,
|
|
44
|
+
"lineHeight": 20,
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
style={
|
|
48
|
+
[
|
|
49
|
+
{
|
|
50
|
+
"fontSize": 16,
|
|
51
|
+
"lineHeight": 20,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"color": "#0E0F13",
|
|
55
|
+
"fontFamily": "Readex Pro",
|
|
56
|
+
"fontStyle": "normal",
|
|
57
|
+
"fontWeight": "400",
|
|
58
|
+
},
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
weight="Regular"
|
|
62
|
+
>
|
|
63
|
+
Text
|
|
64
|
+
</Text>
|
|
65
|
+
`;
|
|
66
|
+
|
|
35
67
|
exports[`Test Typography Components H1 Snapshot 1`] = `
|
|
36
68
|
<Text
|
|
37
69
|
color="bluegreyDark"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import * as TestRenderer from "react-test-renderer";
|
|
3
|
-
import { IOFontWeight } from "../../../utils/fonts";
|
|
4
3
|
import type { IOColors } from "../../../core/IOColors";
|
|
4
|
+
import { IOFontWeight } from "../../../utils/fonts";
|
|
5
5
|
import { Body } from "../Body";
|
|
6
|
-
import {
|
|
6
|
+
import { CTA } from "../CTA";
|
|
7
7
|
import { H1 } from "../H1";
|
|
8
8
|
import { H2 } from "../H2";
|
|
9
9
|
import { H3 } from "../H3";
|
|
@@ -14,6 +14,7 @@ import { Label } from "../Label";
|
|
|
14
14
|
import { LabelSmall } from "../LabelSmall";
|
|
15
15
|
import { Link } from "../Link";
|
|
16
16
|
import { Monospace } from "../Monospace";
|
|
17
|
+
import { calculateWeightColor } from "../common";
|
|
17
18
|
|
|
18
19
|
describe("Test Typography Components", () => {
|
|
19
20
|
it("H1 Snapshot", () => {
|
|
@@ -144,6 +145,10 @@ describe("Test Typography Components", () => {
|
|
|
144
145
|
const bodyDefault = TestRenderer.create(<Body>Text</Body>).toJSON();
|
|
145
146
|
expect(bodyDefault).toMatchSnapshot();
|
|
146
147
|
});
|
|
148
|
+
it("CTA Snapshot", () => {
|
|
149
|
+
const cta = TestRenderer.create(<CTA>Text</CTA>).toJSON();
|
|
150
|
+
expect(cta).toMatchSnapshot();
|
|
151
|
+
});
|
|
147
152
|
it("LabelSmall Snapshot", () => {
|
|
148
153
|
const labelSmallDefault = TestRenderer.create(
|
|
149
154
|
<LabelSmall>Text</LabelSmall>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from "./BaseTypography";
|
|
2
2
|
export * from "./Body";
|
|
3
|
-
export * from "./
|
|
3
|
+
export * from "./CTA";
|
|
4
4
|
export * from "./Factory";
|
|
5
5
|
export * from "./H1";
|
|
6
6
|
export * from "./H2";
|
|
@@ -12,5 +12,5 @@ export * from "./Label";
|
|
|
12
12
|
export * from "./LabelSmall";
|
|
13
13
|
export * from "./Link";
|
|
14
14
|
export * from "./Monospace";
|
|
15
|
-
|
|
15
|
+
export * from "./common";
|
|
16
16
|
|
package/src/core/IOStyles.ts
CHANGED
|
@@ -94,7 +94,7 @@ const btnSizeDefault = 48;
|
|
|
94
94
|
export const buttonSolidHeight: number = btnSizeDefault;
|
|
95
95
|
|
|
96
96
|
// TODO: Replace the number type with the new IOIconSizeScale
|
|
97
|
-
const iconBtnSizeSmall: number = 24;
|
|
97
|
+
export const iconBtnSizeSmall: number = 24;
|
|
98
98
|
|
|
99
99
|
export const IOButtonLegacyStyles = StyleSheet.create({
|
|
100
100
|
/* BaseButton, used in the:
|