@pagopa/io-app-design-system 5.11.1 → 5.11.3
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/layout/index.js +0 -22
- package/lib/commonjs/components/layout/index.js.map +1 -1
- package/lib/commonjs/components/templates/ForceScrollDownView.js +13 -5
- package/lib/commonjs/components/templates/ForceScrollDownView.js.map +1 -1
- package/lib/commonjs/components/templates/__test__/__snapshots__/ForceScrollDownView.test.tsx.snap +1 -0
- package/lib/commonjs/components/typography/BodySmall.js +3 -1
- package/lib/commonjs/components/typography/BodySmall.js.map +1 -1
- package/lib/module/components/layout/index.js +0 -2
- package/lib/module/components/layout/index.js.map +1 -1
- package/lib/module/components/templates/ForceScrollDownView.js +15 -7
- package/lib/module/components/templates/ForceScrollDownView.js.map +1 -1
- package/lib/module/components/templates/__test__/__snapshots__/ForceScrollDownView.test.tsx.snap +1 -0
- package/lib/module/components/typography/BodySmall.js +3 -1
- package/lib/module/components/typography/BodySmall.js.map +1 -1
- package/lib/typescript/components/layout/index.d.ts +0 -2
- package/lib/typescript/components/layout/index.d.ts.map +1 -1
- package/lib/typescript/components/templates/ForceScrollDownView.d.ts +7 -1
- package/lib/typescript/components/templates/ForceScrollDownView.d.ts.map +1 -1
- package/lib/typescript/components/typography/BodySmall.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/layout/index.tsx +0 -2
- package/src/components/templates/ForceScrollDownView.tsx +23 -8
- package/src/components/templates/__test__/__snapshots__/ForceScrollDownView.test.tsx.snap +1 -0
- package/src/components/typography/BodySmall.tsx +7 -2
- package/lib/commonjs/components/layout/GradientBottomActions.js +0 -121
- package/lib/commonjs/components/layout/GradientBottomActions.js.map +0 -1
- package/lib/commonjs/components/layout/GradientScrollView.js +0 -116
- package/lib/commonjs/components/layout/GradientScrollView.js.map +0 -1
- package/lib/module/components/layout/GradientBottomActions.js +0 -114
- package/lib/module/components/layout/GradientBottomActions.js.map +0 -1
- package/lib/module/components/layout/GradientScrollView.js +0 -109
- package/lib/module/components/layout/GradientScrollView.js.map +0 -1
- package/lib/typescript/components/layout/GradientBottomActions.d.ts +0 -33
- package/lib/typescript/components/layout/GradientBottomActions.d.ts.map +0 -1
- package/lib/typescript/components/layout/GradientScrollView.d.ts +0 -19
- package/lib/typescript/components/layout/GradientScrollView.d.ts.map +0 -1
- package/src/components/layout/GradientBottomActions.tsx +0 -143
- package/src/components/layout/GradientScrollView.tsx +0 -173
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { Easing, StyleProp, StyleSheet, View, ViewStyle } from "react-native";
|
|
3
|
-
import { easeGradient } from "react-native-easing-gradient";
|
|
4
|
-
import LinearGradient from "react-native-linear-gradient";
|
|
5
|
-
import Animated, { AnimatedStyle } from "react-native-reanimated";
|
|
6
|
-
import { IOColors, IOSpacer, IOVisualCostants, hexToRgba } from "../../core";
|
|
7
|
-
import { WithTestID } from "../../utils/types";
|
|
8
|
-
import { IOButton, IOButtonProps } from "../buttons";
|
|
9
|
-
import { VSpacer } from "./Spacer";
|
|
10
|
-
|
|
11
|
-
type PrimaryActionProps = Extract<
|
|
12
|
-
IOButtonProps,
|
|
13
|
-
{ variant?: "solid" | "outline" }
|
|
14
|
-
>;
|
|
15
|
-
type SecondaryActionProps = Extract<IOButtonProps, { variant?: "link" }>;
|
|
16
|
-
|
|
17
|
-
export type GradientBottomActions = WithTestID<{
|
|
18
|
-
transitionAnimStyle: AnimatedStyle<StyleProp<ViewStyle>>;
|
|
19
|
-
dimensions: GradientBottomActionsDimensions;
|
|
20
|
-
// Button actions
|
|
21
|
-
primaryActionProps?: PrimaryActionProps;
|
|
22
|
-
secondaryActionProps?: SecondaryActionProps;
|
|
23
|
-
// Debug mode
|
|
24
|
-
debugMode?: boolean;
|
|
25
|
-
}>;
|
|
26
|
-
|
|
27
|
-
type GradientBottomActionsDimensions = {
|
|
28
|
-
bottomMargin: number;
|
|
29
|
-
extraBottomMargin: number;
|
|
30
|
-
gradientAreaHeight: number;
|
|
31
|
-
spaceBetweenActions: IOSpacer;
|
|
32
|
-
safeBackgroundHeight: number;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// Background color should be app main background (both light and dark themes)
|
|
36
|
-
const HEADER_BG_COLOR: IOColors = "white";
|
|
37
|
-
|
|
38
|
-
const { colors, locations } = easeGradient({
|
|
39
|
-
colorStops: {
|
|
40
|
-
0: { color: hexToRgba(IOColors[HEADER_BG_COLOR], 0) },
|
|
41
|
-
1: { color: IOColors[HEADER_BG_COLOR] }
|
|
42
|
-
},
|
|
43
|
-
easing: Easing.ease,
|
|
44
|
-
extraColorStopsPerTransition: 20
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const styles = StyleSheet.create({
|
|
48
|
-
buttonContainer: {
|
|
49
|
-
paddingHorizontal: IOVisualCostants.appMarginDefault,
|
|
50
|
-
width: "100%",
|
|
51
|
-
flex: 1,
|
|
52
|
-
flexShrink: 0,
|
|
53
|
-
justifyContent: "flex-end"
|
|
54
|
-
},
|
|
55
|
-
gradientContainer: {
|
|
56
|
-
...StyleSheet.absoluteFillObject
|
|
57
|
-
},
|
|
58
|
-
safeBackgroundBlock: {
|
|
59
|
-
position: "absolute",
|
|
60
|
-
bottom: 0,
|
|
61
|
-
left: 0,
|
|
62
|
-
right: 0,
|
|
63
|
-
backgroundColor: IOColors[HEADER_BG_COLOR]
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* @deprecated This component has been included in the new `IOScrollView` after a proper refactor. It will be removed in a future release.
|
|
69
|
-
* @see IOScrollView
|
|
70
|
-
*/
|
|
71
|
-
export const GradientBottomActions = ({
|
|
72
|
-
primaryActionProps,
|
|
73
|
-
secondaryActionProps,
|
|
74
|
-
dimensions,
|
|
75
|
-
transitionAnimStyle,
|
|
76
|
-
debugMode,
|
|
77
|
-
testID
|
|
78
|
-
}: GradientBottomActions) => (
|
|
79
|
-
<View
|
|
80
|
-
style={{
|
|
81
|
-
width: "100%",
|
|
82
|
-
position: "absolute",
|
|
83
|
-
bottom: 0,
|
|
84
|
-
height: dimensions.gradientAreaHeight,
|
|
85
|
-
paddingBottom: dimensions.bottomMargin
|
|
86
|
-
}}
|
|
87
|
-
testID={testID}
|
|
88
|
-
pointerEvents="box-none"
|
|
89
|
-
>
|
|
90
|
-
<Animated.View
|
|
91
|
-
style={[
|
|
92
|
-
styles.gradientContainer,
|
|
93
|
-
debugMode && {
|
|
94
|
-
borderTopColor: IOColors["error-500"],
|
|
95
|
-
borderTopWidth: 1,
|
|
96
|
-
backgroundColor: hexToRgba(IOColors["error-500"], 0.5)
|
|
97
|
-
},
|
|
98
|
-
transitionAnimStyle
|
|
99
|
-
]}
|
|
100
|
-
pointerEvents="none"
|
|
101
|
-
>
|
|
102
|
-
{/* 100% opacity bg color fills at least 45% of the area */}
|
|
103
|
-
<LinearGradient
|
|
104
|
-
style={{ height: dimensions.gradientAreaHeight * 0.55 }}
|
|
105
|
-
locations={locations}
|
|
106
|
-
colors={colors}
|
|
107
|
-
/>
|
|
108
|
-
<View
|
|
109
|
-
style={{
|
|
110
|
-
bottom: 0,
|
|
111
|
-
height: dimensions.gradientAreaHeight * 0.45,
|
|
112
|
-
backgroundColor: IOColors[HEADER_BG_COLOR]
|
|
113
|
-
}}
|
|
114
|
-
/>
|
|
115
|
-
</Animated.View>
|
|
116
|
-
|
|
117
|
-
<View
|
|
118
|
-
style={[
|
|
119
|
-
styles.safeBackgroundBlock,
|
|
120
|
-
{
|
|
121
|
-
height: dimensions.safeBackgroundHeight
|
|
122
|
-
}
|
|
123
|
-
]}
|
|
124
|
-
/>
|
|
125
|
-
<View style={styles.buttonContainer} pointerEvents="box-none">
|
|
126
|
-
{primaryActionProps && <IOButton {...primaryActionProps} fullWidth />}
|
|
127
|
-
|
|
128
|
-
{secondaryActionProps && (
|
|
129
|
-
<View
|
|
130
|
-
style={{
|
|
131
|
-
alignSelf: "center",
|
|
132
|
-
marginBottom: dimensions.extraBottomMargin
|
|
133
|
-
}}
|
|
134
|
-
>
|
|
135
|
-
<VSpacer size={dimensions.spaceBetweenActions} />
|
|
136
|
-
<IOButton {...secondaryActionProps} />
|
|
137
|
-
</View>
|
|
138
|
-
)}
|
|
139
|
-
</View>
|
|
140
|
-
</View>
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
export default GradientBottomActions;
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import Animated, {
|
|
4
|
-
Easing,
|
|
5
|
-
useAnimatedScrollHandler,
|
|
6
|
-
useAnimatedStyle,
|
|
7
|
-
useSharedValue,
|
|
8
|
-
withTiming
|
|
9
|
-
} from "react-native-reanimated";
|
|
10
|
-
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
11
|
-
import {
|
|
12
|
-
IOSpacer,
|
|
13
|
-
IOSpacingScale,
|
|
14
|
-
IOVisualCostants,
|
|
15
|
-
buttonSolidHeight
|
|
16
|
-
} from "../../core";
|
|
17
|
-
import { WithTestID } from "../../utils/types";
|
|
18
|
-
import GradientBottomActions from "./GradientBottomActions";
|
|
19
|
-
|
|
20
|
-
export type GradientScrollView = WithTestID<{
|
|
21
|
-
children: React.ReactNode;
|
|
22
|
-
excludeSafeAreaMargins?: boolean;
|
|
23
|
-
debugMode?: boolean;
|
|
24
|
-
// Accepted components: `solid` variant for the primaryAction,
|
|
25
|
-
// `link` variant for the secondaryAction.
|
|
26
|
-
// Don't use any components other than this, please.
|
|
27
|
-
primaryActionProps: GradientBottomActions["primaryActionProps"];
|
|
28
|
-
secondaryActionProps?: GradientBottomActions["secondaryActionProps"];
|
|
29
|
-
}>;
|
|
30
|
-
|
|
31
|
-
// Extended gradient area above the actions
|
|
32
|
-
export const gradientSafeArea: IOSpacingScale = 96;
|
|
33
|
-
// End content margin before the actions
|
|
34
|
-
const contentEndMargin: IOSpacingScale = 32;
|
|
35
|
-
// Margin between primary action and secondary one
|
|
36
|
-
const spaceBetweenActions: IOSpacer = 24;
|
|
37
|
-
// Estimated height of the secondary action
|
|
38
|
-
const secondaryActionEstHeight: number = 20;
|
|
39
|
-
// Extra bottom margin for iPhone bottom handle
|
|
40
|
-
const extraSafeAreaMargin: IOSpacingScale = 8;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @deprecated This component has been deprecated. It will be removed in a future release.
|
|
44
|
-
* @see IOScrollView
|
|
45
|
-
*/
|
|
46
|
-
export const GradientScrollView = ({
|
|
47
|
-
children,
|
|
48
|
-
primaryActionProps: primaryActionProps,
|
|
49
|
-
secondaryActionProps: secondaryActionProps,
|
|
50
|
-
// Don't include safe area insets
|
|
51
|
-
excludeSafeAreaMargins = false,
|
|
52
|
-
debugMode = false,
|
|
53
|
-
testID
|
|
54
|
-
}: GradientScrollView) => {
|
|
55
|
-
const gradientOpacity = useSharedValue(1);
|
|
56
|
-
const insets = useSafeAreaInsets();
|
|
57
|
-
|
|
58
|
-
/* Check if the iPhone bottom handle is present.
|
|
59
|
-
If not, or if you don't need safe area insets,
|
|
60
|
-
add a default margin to prevent the button
|
|
61
|
-
from sticking to the bottom. */
|
|
62
|
-
const bottomMargin: number = useMemo(
|
|
63
|
-
() =>
|
|
64
|
-
insets.bottom === 0 || excludeSafeAreaMargins
|
|
65
|
-
? IOVisualCostants.appMarginDefault
|
|
66
|
-
: insets.bottom,
|
|
67
|
-
[insets, excludeSafeAreaMargins]
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
/* When the secondary action is visible, add extra margin
|
|
71
|
-
to avoid little space from iPhone bottom handle */
|
|
72
|
-
const extraBottomMargin: number = useMemo(
|
|
73
|
-
() =>
|
|
74
|
-
secondaryActionProps && insets.bottom !== 0 ? extraSafeAreaMargin : 0,
|
|
75
|
-
[insets.bottom, secondaryActionProps]
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
/* Total height of actions */
|
|
79
|
-
const actionsArea: number = useMemo(
|
|
80
|
-
() =>
|
|
81
|
-
primaryActionProps && secondaryActionProps
|
|
82
|
-
? (buttonSolidHeight as number) +
|
|
83
|
-
spaceBetweenActions +
|
|
84
|
-
secondaryActionEstHeight +
|
|
85
|
-
extraBottomMargin
|
|
86
|
-
: buttonSolidHeight,
|
|
87
|
-
[extraBottomMargin, primaryActionProps, secondaryActionProps]
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
/* Total height of "Actions + Gradient" area */
|
|
91
|
-
const gradientAreaHeight: number = useMemo(
|
|
92
|
-
() => bottomMargin + actionsArea + gradientSafeArea,
|
|
93
|
-
[actionsArea, bottomMargin]
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
/* Height of the safe bottom area, applied to the ScrollView:
|
|
97
|
-
Actions + Content end margin */
|
|
98
|
-
const safeBottomAreaHeight: number = useMemo(
|
|
99
|
-
() => bottomMargin + actionsArea + contentEndMargin,
|
|
100
|
-
[actionsArea, bottomMargin]
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
{
|
|
104
|
-
/* Safe background block. It's added because when
|
|
105
|
-
you swipe up quickly, the content below is visible
|
|
106
|
-
for about 100ms. Without this block, the content
|
|
107
|
-
appears glitchy. */
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const safeBackgroundHeight = useMemo(
|
|
111
|
-
() =>
|
|
112
|
-
secondaryActionProps
|
|
113
|
-
? spaceBetweenActions +
|
|
114
|
-
secondaryActionEstHeight +
|
|
115
|
-
extraBottomMargin +
|
|
116
|
-
bottomMargin
|
|
117
|
-
: bottomMargin,
|
|
118
|
-
[bottomMargin, extraBottomMargin, secondaryActionProps]
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
const handleScroll = useAnimatedScrollHandler(
|
|
122
|
-
({ contentOffset, layoutMeasurement, contentSize }) => {
|
|
123
|
-
/* We use Math.floor because decimals used on Android
|
|
124
|
-
devices never change the `isEndReached` boolean value.
|
|
125
|
-
We have more consistent behavior across platforms
|
|
126
|
-
if we round these calculations ¯\_(ツ)_/¯ */
|
|
127
|
-
const isEndReached =
|
|
128
|
-
Math.floor(layoutMeasurement.height + contentOffset.y) >=
|
|
129
|
-
Math.floor(contentSize.height);
|
|
130
|
-
|
|
131
|
-
// eslint-disable-next-line functional/immutable-data
|
|
132
|
-
gradientOpacity.value = isEndReached ? 0 : 1;
|
|
133
|
-
}
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
const opacityTransition = useAnimatedStyle(() => ({
|
|
137
|
-
opacity: withTiming(gradientOpacity.value, {
|
|
138
|
-
duration: 200,
|
|
139
|
-
easing: Easing.ease
|
|
140
|
-
})
|
|
141
|
-
}));
|
|
142
|
-
|
|
143
|
-
return (
|
|
144
|
-
<>
|
|
145
|
-
<Animated.ScrollView
|
|
146
|
-
testID={testID}
|
|
147
|
-
onScroll={handleScroll}
|
|
148
|
-
scrollEventThrottle={16}
|
|
149
|
-
contentContainerStyle={{
|
|
150
|
-
paddingHorizontal: IOVisualCostants.appMarginDefault,
|
|
151
|
-
paddingBottom: safeBottomAreaHeight
|
|
152
|
-
}}
|
|
153
|
-
>
|
|
154
|
-
{children}
|
|
155
|
-
</Animated.ScrollView>
|
|
156
|
-
<GradientBottomActions
|
|
157
|
-
debugMode={debugMode}
|
|
158
|
-
primaryActionProps={primaryActionProps}
|
|
159
|
-
secondaryActionProps={secondaryActionProps}
|
|
160
|
-
transitionAnimStyle={opacityTransition}
|
|
161
|
-
dimensions={{
|
|
162
|
-
bottomMargin,
|
|
163
|
-
extraBottomMargin,
|
|
164
|
-
gradientAreaHeight,
|
|
165
|
-
spaceBetweenActions,
|
|
166
|
-
safeBackgroundHeight
|
|
167
|
-
}}
|
|
168
|
-
/>
|
|
169
|
-
</>
|
|
170
|
-
);
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
export default GradientScrollView;
|