@pagopa/io-app-design-system 7.0.2 → 7.1.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/alert/Alert.js +6 -5
- package/lib/commonjs/components/alert/Alert.js.map +1 -1
- package/lib/commonjs/components/banner/Banner.js +7 -6
- package/lib/commonjs/components/banner/Banner.js.map +1 -1
- package/lib/commonjs/components/buttons/IOButton/IOButton.js +10 -8
- package/lib/commonjs/components/buttons/IOButton/IOButton.js.map +1 -1
- package/lib/commonjs/components/layout/ContentWrapper.js +5 -4
- package/lib/commonjs/components/layout/ContentWrapper.js.map +1 -1
- package/lib/commonjs/components/otpInput/OTPInput.js +6 -4
- package/lib/commonjs/components/otpInput/OTPInput.js.map +1 -1
- package/lib/commonjs/components/searchInput/SearchInput.js +8 -6
- package/lib/commonjs/components/searchInput/SearchInput.js.map +1 -1
- package/lib/commonjs/components/tabs/TabItem.js +6 -4
- package/lib/commonjs/components/tabs/TabItem.js.map +1 -1
- package/lib/commonjs/components/textInput/TextInputBase.js +8 -4
- package/lib/commonjs/components/textInput/TextInputBase.js.map +1 -1
- package/lib/commonjs/components/textInput/TextInputValidation.js +5 -3
- package/lib/commonjs/components/textInput/TextInputValidation.js.map +1 -1
- package/lib/commonjs/components/typography/Body.js +8 -5
- package/lib/commonjs/components/typography/Body.js.map +1 -1
- package/lib/commonjs/components/typography/BodyMonospace.js +4 -5
- package/lib/commonjs/components/typography/BodyMonospace.js.map +1 -1
- package/lib/commonjs/components/typography/BodySmall.js +8 -5
- package/lib/commonjs/components/typography/BodySmall.js.map +1 -1
- package/lib/commonjs/components/typography/ButtonText.js +4 -5
- package/lib/commonjs/components/typography/ButtonText.js.map +1 -1
- package/lib/commonjs/components/typography/Caption.js +4 -5
- package/lib/commonjs/components/typography/Caption.js.map +1 -1
- package/lib/commonjs/components/typography/H1.js +4 -5
- package/lib/commonjs/components/typography/H1.js.map +1 -1
- package/lib/commonjs/components/typography/H2.js +4 -5
- package/lib/commonjs/components/typography/H2.js.map +1 -1
- package/lib/commonjs/components/typography/H3.js +4 -5
- package/lib/commonjs/components/typography/H3.js.map +1 -1
- package/lib/commonjs/components/typography/H4.js +4 -5
- package/lib/commonjs/components/typography/H4.js.map +1 -1
- package/lib/commonjs/components/typography/H5.js +4 -5
- package/lib/commonjs/components/typography/H5.js.map +1 -1
- package/lib/commonjs/components/typography/H6.js +4 -5
- package/lib/commonjs/components/typography/H6.js.map +1 -1
- package/lib/commonjs/components/typography/Hero.js +4 -5
- package/lib/commonjs/components/typography/Hero.js.map +1 -1
- package/lib/commonjs/components/typography/IOText.js +16 -14
- package/lib/commonjs/components/typography/IOText.js.map +1 -1
- package/lib/commonjs/components/typography/LabelMini.js +8 -5
- package/lib/commonjs/components/typography/LabelMini.js.map +1 -1
- package/lib/commonjs/components/typography/markdown/MdH1.js +4 -5
- package/lib/commonjs/components/typography/markdown/MdH1.js.map +1 -1
- package/lib/commonjs/components/typography/markdown/MdH2.js +4 -5
- package/lib/commonjs/components/typography/markdown/MdH2.js.map +1 -1
- package/lib/commonjs/components/typography/markdown/MdH3.js +4 -5
- package/lib/commonjs/components/typography/markdown/MdH3.js.map +1 -1
- package/lib/commonjs/context/IOThemeContextProvider.js +3 -4
- package/lib/commonjs/context/IOThemeContextProvider.js.map +1 -1
- package/lib/module/components/alert/Alert.js +5 -5
- package/lib/module/components/alert/Alert.js.map +1 -1
- package/lib/module/components/banner/Banner.js +6 -6
- package/lib/module/components/banner/Banner.js.map +1 -1
- package/lib/module/components/buttons/IOButton/IOButton.js +10 -9
- package/lib/module/components/buttons/IOButton/IOButton.js.map +1 -1
- package/lib/module/components/layout/ContentWrapper.js +4 -4
- package/lib/module/components/layout/ContentWrapper.js.map +1 -1
- package/lib/module/components/otpInput/OTPInput.js +6 -5
- package/lib/module/components/otpInput/OTPInput.js.map +1 -1
- package/lib/module/components/searchInput/SearchInput.js +8 -7
- package/lib/module/components/searchInput/SearchInput.js.map +1 -1
- package/lib/module/components/tabs/TabItem.js +6 -5
- package/lib/module/components/tabs/TabItem.js.map +1 -1
- package/lib/module/components/textInput/TextInputBase.js +8 -4
- package/lib/module/components/textInput/TextInputBase.js.map +1 -1
- package/lib/module/components/textInput/TextInputValidation.js +5 -4
- package/lib/module/components/textInput/TextInputValidation.js.map +1 -1
- package/lib/module/components/typography/Body.js +7 -5
- package/lib/module/components/typography/Body.js.map +1 -1
- package/lib/module/components/typography/BodyMonospace.js +3 -5
- package/lib/module/components/typography/BodyMonospace.js.map +1 -1
- package/lib/module/components/typography/BodySmall.js +7 -5
- package/lib/module/components/typography/BodySmall.js.map +1 -1
- package/lib/module/components/typography/ButtonText.js +3 -5
- package/lib/module/components/typography/ButtonText.js.map +1 -1
- package/lib/module/components/typography/Caption.js +3 -5
- package/lib/module/components/typography/Caption.js.map +1 -1
- package/lib/module/components/typography/H1.js +3 -5
- package/lib/module/components/typography/H1.js.map +1 -1
- package/lib/module/components/typography/H2.js +3 -5
- package/lib/module/components/typography/H2.js.map +1 -1
- package/lib/module/components/typography/H3.js +3 -5
- package/lib/module/components/typography/H3.js.map +1 -1
- package/lib/module/components/typography/H4.js +3 -5
- package/lib/module/components/typography/H4.js.map +1 -1
- package/lib/module/components/typography/H5.js +3 -5
- package/lib/module/components/typography/H5.js.map +1 -1
- package/lib/module/components/typography/H6.js +3 -5
- package/lib/module/components/typography/H6.js.map +1 -1
- package/lib/module/components/typography/Hero.js +3 -5
- package/lib/module/components/typography/Hero.js.map +1 -1
- package/lib/module/components/typography/IOText.js +16 -15
- package/lib/module/components/typography/IOText.js.map +1 -1
- package/lib/module/components/typography/LabelMini.js +7 -5
- package/lib/module/components/typography/LabelMini.js.map +1 -1
- package/lib/module/components/typography/markdown/MdH1.js +3 -5
- package/lib/module/components/typography/markdown/MdH1.js.map +1 -1
- package/lib/module/components/typography/markdown/MdH2.js +3 -5
- package/lib/module/components/typography/markdown/MdH2.js.map +1 -1
- package/lib/module/components/typography/markdown/MdH3.js +3 -5
- package/lib/module/components/typography/markdown/MdH3.js.map +1 -1
- package/lib/module/context/IOThemeContextProvider.js +3 -4
- package/lib/module/context/IOThemeContextProvider.js.map +1 -1
- package/lib/typescript/components/alert/Alert.d.ts +3 -1
- package/lib/typescript/components/alert/Alert.d.ts.map +1 -1
- package/lib/typescript/components/banner/Banner.d.ts +3 -1
- package/lib/typescript/components/banner/Banner.d.ts.map +1 -1
- package/lib/typescript/components/buttons/IOButton/IOButton.d.ts +3 -2
- package/lib/typescript/components/buttons/IOButton/IOButton.d.ts.map +1 -1
- package/lib/typescript/components/layout/ContentWrapper.d.ts +10 -6
- package/lib/typescript/components/layout/ContentWrapper.d.ts.map +1 -1
- package/lib/typescript/components/otpInput/OTPInput.d.ts +3 -1
- package/lib/typescript/components/otpInput/OTPInput.d.ts.map +1 -1
- package/lib/typescript/components/searchInput/SearchInput.d.ts +3 -1
- package/lib/typescript/components/searchInput/SearchInput.d.ts.map +1 -1
- package/lib/typescript/components/tabs/TabItem.d.ts +3 -11
- package/lib/typescript/components/tabs/TabItem.d.ts.map +1 -1
- package/lib/typescript/components/textInput/TextInputBase.d.ts +2 -1
- package/lib/typescript/components/textInput/TextInputBase.d.ts.map +1 -1
- package/lib/typescript/components/textInput/TextInputValidation.d.ts +13 -24
- package/lib/typescript/components/textInput/TextInputValidation.d.ts.map +1 -1
- package/lib/typescript/components/typography/Body.d.ts +4 -2
- package/lib/typescript/components/typography/Body.d.ts.map +1 -1
- package/lib/typescript/components/typography/BodyMonospace.d.ts +2 -8
- package/lib/typescript/components/typography/BodyMonospace.d.ts.map +1 -1
- package/lib/typescript/components/typography/BodySmall.d.ts +4 -2
- package/lib/typescript/components/typography/BodySmall.d.ts.map +1 -1
- package/lib/typescript/components/typography/ButtonText.d.ts +2 -8
- package/lib/typescript/components/typography/ButtonText.d.ts.map +1 -1
- package/lib/typescript/components/typography/Caption.d.ts +2 -8
- package/lib/typescript/components/typography/Caption.d.ts.map +1 -1
- package/lib/typescript/components/typography/H1.d.ts +2 -8
- package/lib/typescript/components/typography/H1.d.ts.map +1 -1
- package/lib/typescript/components/typography/H2.d.ts +6 -10
- package/lib/typescript/components/typography/H2.d.ts.map +1 -1
- package/lib/typescript/components/typography/H3.d.ts +2 -8
- package/lib/typescript/components/typography/H3.d.ts.map +1 -1
- package/lib/typescript/components/typography/H4.d.ts +2 -8
- package/lib/typescript/components/typography/H4.d.ts.map +1 -1
- package/lib/typescript/components/typography/H5.d.ts +2 -8
- package/lib/typescript/components/typography/H5.d.ts.map +1 -1
- package/lib/typescript/components/typography/H6.d.ts +2 -8
- package/lib/typescript/components/typography/H6.d.ts.map +1 -1
- package/lib/typescript/components/typography/Hero.d.ts +2 -8
- package/lib/typescript/components/typography/Hero.d.ts.map +1 -1
- package/lib/typescript/components/typography/IOText.d.ts +5 -5
- package/lib/typescript/components/typography/IOText.d.ts.map +1 -1
- package/lib/typescript/components/typography/LabelMini.d.ts +4 -2
- package/lib/typescript/components/typography/LabelMini.d.ts.map +1 -1
- package/lib/typescript/components/typography/markdown/MdH1.d.ts +2 -8
- package/lib/typescript/components/typography/markdown/MdH1.d.ts.map +1 -1
- package/lib/typescript/components/typography/markdown/MdH2.d.ts +2 -8
- package/lib/typescript/components/typography/markdown/MdH2.d.ts.map +1 -1
- package/lib/typescript/components/typography/markdown/MdH3.d.ts +2 -8
- package/lib/typescript/components/typography/markdown/MdH3.d.ts.map +1 -1
- package/lib/typescript/context/IOThemeContextProvider.d.ts.map +1 -1
- package/package.json +6 -7
- package/src/components/alert/Alert.tsx +108 -112
- package/src/components/banner/Banner.tsx +121 -125
- package/src/components/buttons/IOButton/IOButton.tsx +204 -216
- package/src/components/layout/ContentWrapper.tsx +21 -24
- package/src/components/otpInput/OTPInput.tsx +156 -167
- package/src/components/searchInput/SearchInput.tsx +208 -217
- package/src/components/tabs/TabItem.tsx +143 -146
- package/src/components/textInput/TextInputBase.tsx +13 -4
- package/src/components/textInput/TextInputValidation.tsx +122 -122
- package/src/components/typography/Body.tsx +51 -52
- package/src/components/typography/BodyMonospace.tsx +19 -24
- package/src/components/typography/BodySmall.tsx +51 -52
- package/src/components/typography/ButtonText.tsx +14 -20
- package/src/components/typography/Caption.tsx +18 -23
- package/src/components/typography/H1.tsx +12 -20
- package/src/components/typography/H2.tsx +16 -23
- package/src/components/typography/H3.tsx +12 -20
- package/src/components/typography/H4.tsx +12 -20
- package/src/components/typography/H5.tsx +16 -24
- package/src/components/typography/H6.tsx +13 -21
- package/src/components/typography/Hero.tsx +14 -19
- package/src/components/typography/IOText.tsx +54 -59
- package/src/components/typography/LabelMini.tsx +45 -49
- package/src/components/typography/markdown/MdH1.tsx +14 -19
- package/src/components/typography/markdown/MdH2.tsx +14 -19
- package/src/components/typography/markdown/MdH3.tsx +14 -19
- package/src/context/IOThemeContextProvider.tsx +4 -12
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JSX,
|
|
1
|
+
import { JSX, Ref } from "react";
|
|
2
2
|
import {
|
|
3
3
|
ColorValue,
|
|
4
4
|
GestureResponderEvent,
|
|
@@ -24,6 +24,7 @@ const ICON_SIZE: IOIconSizeScale = 24;
|
|
|
24
24
|
const [padding, paddingFullWidth] = IOAlertSpacing;
|
|
25
25
|
|
|
26
26
|
type AlertProps = WithTestID<{
|
|
27
|
+
ref?: Ref<View>;
|
|
27
28
|
variant: "error" | "warning" | "info" | "success";
|
|
28
29
|
content: string;
|
|
29
30
|
fullWidth?: boolean;
|
|
@@ -105,123 +106,118 @@ const mapVariantStatesDarkMode: Record<
|
|
|
105
106
|
}
|
|
106
107
|
};
|
|
107
108
|
|
|
108
|
-
export const Alert =
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
size={ICON_SIZE}
|
|
148
|
-
color={mapVariantStates[variant].foreground}
|
|
149
|
-
/>
|
|
150
|
-
{/* Sadly we don't have specific alignments style for text
|
|
109
|
+
export const Alert = ({
|
|
110
|
+
variant,
|
|
111
|
+
content,
|
|
112
|
+
action,
|
|
113
|
+
onPress,
|
|
114
|
+
fullWidth = false,
|
|
115
|
+
accessibilityHint,
|
|
116
|
+
ref: viewRef,
|
|
117
|
+
testID
|
|
118
|
+
}: AlertType): JSX.Element => {
|
|
119
|
+
const { onPressIn, onPressOut, scaleAnimatedStyle } =
|
|
120
|
+
useScaleAnimation("medium");
|
|
121
|
+
const { dynamicFontScale, spacingScaleMultiplier } = useIOFontDynamicScale();
|
|
122
|
+
const { themeType } = useIOThemeContext();
|
|
123
|
+
|
|
124
|
+
const paddingDefaultVariant: ViewStyle = {
|
|
125
|
+
padding,
|
|
126
|
+
borderRadius: IOAlertRadius * dynamicFontScale * spacingScaleMultiplier,
|
|
127
|
+
borderCurve: "continuous"
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const mapVariantStates =
|
|
131
|
+
themeType === "light"
|
|
132
|
+
? mapVariantStatesLightMode
|
|
133
|
+
: mapVariantStatesDarkMode;
|
|
134
|
+
|
|
135
|
+
const renderMainBlock = () => (
|
|
136
|
+
<HStack
|
|
137
|
+
space={IOVisualCostants.iconMargin as IOSpacer}
|
|
138
|
+
allowScaleSpacing
|
|
139
|
+
style={{ alignItems: "center" }}
|
|
140
|
+
>
|
|
141
|
+
<Icon
|
|
142
|
+
allowFontScaling
|
|
143
|
+
name={mapVariantStates[variant].icon}
|
|
144
|
+
size={ICON_SIZE}
|
|
145
|
+
color={mapVariantStates[variant].foreground}
|
|
146
|
+
/>
|
|
147
|
+
{/* Sadly we don't have specific alignments style for text
|
|
151
148
|
in React Native, like `text-box-trim` for CSS. So we
|
|
152
149
|
have to put these magic numbers after manual adjustments.
|
|
153
150
|
Tested on both Android and iOS. */}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
151
|
+
<View
|
|
152
|
+
style={{
|
|
153
|
+
marginTop: -4 * dynamicFontScale,
|
|
154
|
+
marginBottom: -4 * dynamicFontScale,
|
|
155
|
+
flex: 1
|
|
156
|
+
}}
|
|
157
|
+
>
|
|
158
|
+
<VStack space={8} allowScaleSpacing>
|
|
159
|
+
<Body
|
|
160
|
+
color={mapVariantStates[variant].foreground}
|
|
161
|
+
weight={"Regular"}
|
|
162
|
+
accessibilityRole="text"
|
|
163
|
+
>
|
|
164
|
+
{content}
|
|
165
|
+
</Body>
|
|
166
|
+
{action && (
|
|
167
|
+
<ButtonText
|
|
163
168
|
color={mapVariantStates[variant].foreground}
|
|
164
|
-
|
|
165
|
-
|
|
169
|
+
numberOfLines={1}
|
|
170
|
+
ellipsizeMode="tail"
|
|
166
171
|
>
|
|
167
|
-
{
|
|
168
|
-
</
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
172
|
+
{action}
|
|
173
|
+
</ButtonText>
|
|
174
|
+
)}
|
|
175
|
+
</VStack>
|
|
176
|
+
</View>
|
|
177
|
+
</HStack>
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
const StaticComponent = () => (
|
|
181
|
+
<View
|
|
182
|
+
ref={viewRef}
|
|
183
|
+
style={[
|
|
184
|
+
fullWidth ? { padding: paddingFullWidth } : paddingDefaultVariant,
|
|
185
|
+
{ backgroundColor: mapVariantStates[variant].background }
|
|
186
|
+
]}
|
|
187
|
+
testID={testID}
|
|
188
|
+
accessible={false}
|
|
189
|
+
accessibilityRole="alert"
|
|
190
|
+
accessibilityHint={accessibilityHint}
|
|
191
|
+
>
|
|
192
|
+
{renderMainBlock()}
|
|
193
|
+
</View>
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
const PressableButton = () => (
|
|
197
|
+
<Pressable
|
|
198
|
+
ref={viewRef}
|
|
199
|
+
testID={testID}
|
|
200
|
+
onPress={onPress}
|
|
201
|
+
onPressIn={onPressIn}
|
|
202
|
+
onPressOut={onPressOut}
|
|
203
|
+
onTouchEnd={onPressOut}
|
|
204
|
+
// A11y related props
|
|
205
|
+
accessible={true}
|
|
206
|
+
accessibilityHint={accessibilityHint}
|
|
207
|
+
accessibilityRole={"button"}
|
|
208
|
+
>
|
|
209
|
+
<Animated.View
|
|
186
210
|
style={[
|
|
187
|
-
fullWidth ? { padding } : paddingDefaultVariant,
|
|
188
|
-
{ backgroundColor: mapVariantStates[variant].background }
|
|
211
|
+
fullWidth ? { padding: paddingFullWidth } : paddingDefaultVariant,
|
|
212
|
+
{ backgroundColor: mapVariantStates[variant].background },
|
|
213
|
+
// Disable pressed animation when component is full width
|
|
214
|
+
!fullWidth && scaleAnimatedStyle
|
|
189
215
|
]}
|
|
190
|
-
testID={testID}
|
|
191
|
-
accessible={false}
|
|
192
|
-
accessibilityRole="alert"
|
|
193
|
-
accessibilityHint={accessibilityHint}
|
|
194
216
|
>
|
|
195
217
|
{renderMainBlock()}
|
|
196
|
-
</View>
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
testID={testID}
|
|
203
|
-
onPress={onPress}
|
|
204
|
-
onPressIn={onPressIn}
|
|
205
|
-
onPressOut={onPressOut}
|
|
206
|
-
onTouchEnd={onPressOut}
|
|
207
|
-
// A11y related props
|
|
208
|
-
accessible={true}
|
|
209
|
-
accessibilityHint={accessibilityHint}
|
|
210
|
-
accessibilityRole={"button"}
|
|
211
|
-
>
|
|
212
|
-
<Animated.View
|
|
213
|
-
style={[
|
|
214
|
-
fullWidth ? { padding: paddingFullWidth } : paddingDefaultVariant,
|
|
215
|
-
{ backgroundColor: mapVariantStates[variant].background },
|
|
216
|
-
// Disable pressed animation when component is full width
|
|
217
|
-
!fullWidth && scaleAnimatedStyle
|
|
218
|
-
]}
|
|
219
|
-
>
|
|
220
|
-
{renderMainBlock()}
|
|
221
|
-
</Animated.View>
|
|
222
|
-
</Pressable>
|
|
223
|
-
);
|
|
224
|
-
|
|
225
|
-
return action ? <PressableButton /> : <StaticComponent />;
|
|
226
|
-
}
|
|
227
|
-
);
|
|
218
|
+
</Animated.View>
|
|
219
|
+
</Pressable>
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
return action ? <PressableButton /> : <StaticComponent />;
|
|
223
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ref } from "react";
|
|
2
2
|
import {
|
|
3
3
|
AccessibilityRole,
|
|
4
4
|
GestureResponderEvent,
|
|
@@ -51,6 +51,7 @@ const styles = StyleSheet.create({
|
|
|
51
51
|
/* Component Types */
|
|
52
52
|
|
|
53
53
|
type BaseBannerProps = WithTestID<{
|
|
54
|
+
ref?: Ref<View>;
|
|
54
55
|
color: "neutral" | "turquoise";
|
|
55
56
|
pictogramName: IOPictogramsBleed;
|
|
56
57
|
// A11y related props
|
|
@@ -123,140 +124,135 @@ const mapBackgroundColorDarkMode: Record<
|
|
|
123
124
|
turquoise: "turquoise-300"
|
|
124
125
|
};
|
|
125
126
|
|
|
126
|
-
export const Banner =
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
useScaleAnimation("medium");
|
|
146
|
-
const { themeType } = useIOThemeContext();
|
|
147
|
-
const theme = useIOTheme();
|
|
127
|
+
export const Banner = ({
|
|
128
|
+
color,
|
|
129
|
+
pictogramName,
|
|
130
|
+
title,
|
|
131
|
+
content,
|
|
132
|
+
action,
|
|
133
|
+
labelClose,
|
|
134
|
+
onPress,
|
|
135
|
+
onClose,
|
|
136
|
+
accessibilityHint,
|
|
137
|
+
accessibilityLabel,
|
|
138
|
+
accessibilityRole = "button",
|
|
139
|
+
ref: viewRef,
|
|
140
|
+
testID
|
|
141
|
+
}: Banner) => {
|
|
142
|
+
const { onPressIn, onPressOut, scaleAnimatedStyle } =
|
|
143
|
+
useScaleAnimation("medium");
|
|
144
|
+
const { themeType } = useIOThemeContext();
|
|
145
|
+
const theme = useIOTheme();
|
|
148
146
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
themeType === "dark" ? "blueIO-200" : theme["interactiveElem-default"];
|
|
147
|
+
// Dynamic colors
|
|
148
|
+
const colorTitle: IOColors = themeType === "dark" ? "grey-50" : "blueIO-850";
|
|
149
|
+
const colorCloseButton: IconButton["color"] =
|
|
150
|
+
themeType === "dark" ? "contrast" : "neutral";
|
|
151
|
+
const colorMainButton =
|
|
152
|
+
themeType === "dark" ? "blueIO-200" : theme["interactiveElem-default"];
|
|
156
153
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
154
|
+
const dynamicContainerStyles: ViewStyle = {
|
|
155
|
+
backgroundColor:
|
|
156
|
+
themeType === "dark"
|
|
157
|
+
? hexToRgba(IOColors[mapBackgroundColorDarkMode[color]], 0.1)
|
|
158
|
+
: IOColors[mapBackgroundColorLightMode[color]]
|
|
159
|
+
};
|
|
163
160
|
|
|
164
|
-
|
|
161
|
+
/* Generates a complete fallbackAccessibilityLabel by concatenating the title, content, and action
|
|
165
162
|
if they are present. */
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
163
|
+
const fallbackAccessibilityLabel = [title, content, action]
|
|
164
|
+
.filter(Boolean)
|
|
165
|
+
.join(" ");
|
|
169
166
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
167
|
+
const renderMainBlock = () => (
|
|
168
|
+
<>
|
|
169
|
+
<View
|
|
170
|
+
style={{ flex: 1, alignSelf: "center", gap: 4 }}
|
|
171
|
+
accessible={true}
|
|
172
|
+
// A11y related props
|
|
173
|
+
accessibilityLabel={accessibilityLabel ?? fallbackAccessibilityLabel}
|
|
174
|
+
accessibilityHint={accessibilityHint}
|
|
175
|
+
accessibilityRole={action !== undefined ? accessibilityRole : "text"}
|
|
176
|
+
>
|
|
177
|
+
{title && <H6 color={colorTitle}>{title}</H6>}
|
|
178
|
+
{content && (
|
|
179
|
+
<BodySmall color={theme["textBody-tertiary"]} weight={"Regular"}>
|
|
180
|
+
{content}
|
|
181
|
+
</BodySmall>
|
|
182
|
+
)}
|
|
183
|
+
{action && (
|
|
184
|
+
/* Disable pointer events to avoid
|
|
188
185
|
pressed state on the button */
|
|
189
|
-
|
|
190
|
-
|
|
186
|
+
<Pressable
|
|
187
|
+
pointerEvents="none"
|
|
188
|
+
importantForAccessibility="no-hide-descendants"
|
|
189
|
+
accessible={true}
|
|
190
|
+
accessibilityElementsHidden
|
|
191
|
+
accessibilityLabel={action}
|
|
192
|
+
accessibilityRole="button"
|
|
193
|
+
onPress={onPress}
|
|
194
|
+
>
|
|
195
|
+
<VSpacer size={8} />
|
|
196
|
+
<IOText
|
|
197
|
+
weight="Semibold"
|
|
198
|
+
color={colorMainButton}
|
|
199
|
+
size={buttonTextFontSize}
|
|
200
|
+
numberOfLines={1}
|
|
201
|
+
ellipsizeMode="tail"
|
|
202
|
+
// A11y
|
|
203
|
+
accessible={false}
|
|
191
204
|
importantForAccessibility="no-hide-descendants"
|
|
192
|
-
|
|
193
|
-
accessibilityElementsHidden
|
|
194
|
-
accessibilityLabel={action}
|
|
195
|
-
accessibilityRole="button"
|
|
196
|
-
onPress={onPress}
|
|
205
|
+
accessibilityElementsHidden={true}
|
|
197
206
|
>
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
color={colorMainButton}
|
|
202
|
-
size={buttonTextFontSize}
|
|
203
|
-
numberOfLines={1}
|
|
204
|
-
ellipsizeMode="tail"
|
|
205
|
-
// A11y
|
|
206
|
-
accessible={false}
|
|
207
|
-
importantForAccessibility="no-hide-descendants"
|
|
208
|
-
accessibilityElementsHidden={true}
|
|
209
|
-
>
|
|
210
|
-
{action}
|
|
211
|
-
</IOText>
|
|
212
|
-
</Pressable>
|
|
213
|
-
)}
|
|
214
|
-
</View>
|
|
215
|
-
<View style={[styles.bleedPictogram, { alignSelf: "center" }]}>
|
|
216
|
-
<PictogramBleed name={pictogramName} size={sizePictogram} />
|
|
217
|
-
</View>
|
|
218
|
-
{onClose && labelClose && (
|
|
219
|
-
<View style={styles.closeIconButton}>
|
|
220
|
-
<IconButton
|
|
221
|
-
icon="closeSmall"
|
|
222
|
-
color={colorCloseButton}
|
|
223
|
-
onPress={onClose}
|
|
224
|
-
accessibilityLabel={labelClose}
|
|
225
|
-
/>
|
|
226
|
-
</View>
|
|
207
|
+
{action}
|
|
208
|
+
</IOText>
|
|
209
|
+
</Pressable>
|
|
227
210
|
)}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
</Animated.View>
|
|
245
|
-
</Pressable>
|
|
246
|
-
);
|
|
211
|
+
</View>
|
|
212
|
+
<View style={[styles.bleedPictogram, { alignSelf: "center" }]}>
|
|
213
|
+
<PictogramBleed name={pictogramName} size={sizePictogram} />
|
|
214
|
+
</View>
|
|
215
|
+
{onClose && labelClose && (
|
|
216
|
+
<View style={styles.closeIconButton}>
|
|
217
|
+
<IconButton
|
|
218
|
+
icon="closeSmall"
|
|
219
|
+
color={colorCloseButton}
|
|
220
|
+
onPress={onClose}
|
|
221
|
+
accessibilityLabel={labelClose}
|
|
222
|
+
/>
|
|
223
|
+
</View>
|
|
224
|
+
)}
|
|
225
|
+
</>
|
|
226
|
+
);
|
|
247
227
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
228
|
+
const PressableButton = () => (
|
|
229
|
+
<Pressable
|
|
230
|
+
ref={viewRef}
|
|
231
|
+
testID={testID}
|
|
232
|
+
onPress={onPress}
|
|
233
|
+
onPressIn={onPressIn}
|
|
234
|
+
onPressOut={onPressOut}
|
|
235
|
+
accessible={false}
|
|
236
|
+
>
|
|
237
|
+
<Animated.View
|
|
238
|
+
style={[styles.container, dynamicContainerStyles, scaleAnimatedStyle]}
|
|
255
239
|
>
|
|
256
240
|
{renderMainBlock()}
|
|
257
|
-
</View>
|
|
258
|
-
|
|
241
|
+
</Animated.View>
|
|
242
|
+
</Pressable>
|
|
243
|
+
);
|
|
259
244
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
245
|
+
const StaticComponent = () => (
|
|
246
|
+
<View
|
|
247
|
+
ref={viewRef}
|
|
248
|
+
testID={testID}
|
|
249
|
+
style={[styles.container, dynamicContainerStyles]}
|
|
250
|
+
// A11y related props
|
|
251
|
+
accessible={false}
|
|
252
|
+
>
|
|
253
|
+
{renderMainBlock()}
|
|
254
|
+
</View>
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
return action ? <PressableButton /> : <StaticComponent />;
|
|
258
|
+
};
|