@pagopa/io-app-design-system 1.0.0-9 → 1.0.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 +39 -4
- package/lib/commonjs/components/Advice/Advice.js +5 -7
- package/lib/commonjs/components/Advice/Advice.js.map +1 -1
- package/lib/commonjs/components/Advice/__test__/advice.test.js +2 -2
- package/lib/commonjs/components/Advice/__test__/advice.test.js.map +1 -1
- package/lib/commonjs/components/accordion/RawAccordion.js.map +1 -1
- package/lib/commonjs/components/badge/__test__/badge.test.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonLink.js +4 -5
- package/lib/commonjs/components/buttons/ButtonLink.js.map +1 -1
- package/lib/commonjs/components/buttons/IconButton.js +0 -2
- package/lib/commonjs/components/buttons/IconButton.js.map +1 -1
- package/lib/commonjs/components/buttons/IconButtonContained.js +131 -0
- package/lib/commonjs/components/buttons/IconButtonContained.js.map +1 -0
- package/lib/commonjs/components/buttons/IconButtonSolid.js +109 -0
- package/lib/commonjs/components/buttons/IconButtonSolid.js.map +1 -0
- package/lib/commonjs/components/buttons/__test__/__snapshots__/button.test.tsx.snap +370 -0
- package/lib/commonjs/components/buttons/__test__/button.test.js +27 -0
- package/lib/commonjs/components/buttons/__test__/button.test.js.map +1 -1
- package/lib/commonjs/components/buttons/index.js +30 -8
- package/lib/commonjs/components/buttons/index.js.map +1 -1
- package/lib/commonjs/components/checkbox/AnimatedCheckbox.js +1 -1
- package/lib/commonjs/components/checkbox/AnimatedCheckbox.js.map +1 -1
- package/lib/commonjs/components/icons/index.js +0 -18
- package/lib/commonjs/components/icons/index.js.map +1 -1
- package/lib/commonjs/components/index.js +72 -72
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/components/layout/GradientBottomActions.js +90 -0
- package/lib/commonjs/components/layout/GradientBottomActions.js.map +1 -0
- package/lib/commonjs/components/layout/GradientScrollView.js +111 -0
- package/lib/commonjs/components/layout/GradientScrollView.js.map +1 -0
- package/lib/commonjs/components/layout/HeaderFirstLevel.js +62 -0
- package/lib/commonjs/components/layout/HeaderFirstLevel.js.map +1 -0
- package/lib/commonjs/components/layout/index.js +17 -0
- package/lib/commonjs/components/layout/index.js.map +1 -0
- package/lib/commonjs/components/listitems/ListItemCheckbox.js +135 -0
- package/lib/commonjs/components/listitems/ListItemCheckbox.js.map +1 -0
- package/lib/commonjs/components/listitems/ListItemInfo.js +3 -6
- package/lib/commonjs/components/listitems/ListItemInfo.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemInfoCopy.js +1 -4
- package/lib/commonjs/components/listitems/ListItemInfoCopy.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemRadio.js +136 -0
- package/lib/commonjs/components/listitems/ListItemRadio.js.map +1 -0
- package/lib/commonjs/components/listitems/ListItemSwitch.js +82 -0
- package/lib/commonjs/components/listitems/ListItemSwitch.js.map +1 -0
- package/lib/commonjs/components/listitems/ListItemTransaction.js.map +1 -1
- package/lib/commonjs/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +0 -14
- package/lib/commonjs/components/listitems/index.js +33 -0
- package/lib/commonjs/components/listitems/index.js.map +1 -1
- package/lib/commonjs/components/logos/svg/LogoPaymentExtMaestro.js +3 -19
- package/lib/commonjs/components/logos/svg/LogoPaymentExtMaestro.js.map +1 -1
- package/lib/commonjs/components/logos/svg/LogoPaymentExtMastercard.js +5 -21
- package/lib/commonjs/components/logos/svg/LogoPaymentExtMastercard.js.map +1 -1
- package/lib/commonjs/components/logos/svg/LogoPaymentExtPayPal.js +9 -28
- package/lib/commonjs/components/logos/svg/LogoPaymentExtPayPal.js.map +1 -1
- package/lib/commonjs/components/logos/svg/LogoPaymentMaestro.js +8 -18
- package/lib/commonjs/components/logos/svg/LogoPaymentMaestro.js.map +1 -1
- package/lib/commonjs/components/logos/svg/LogoPaymentMastercard.js +7 -17
- package/lib/commonjs/components/logos/svg/LogoPaymentMastercard.js.map +1 -1
- package/lib/commonjs/components/logos/svg/LogoPaymentPayPal.js +5 -5
- package/lib/commonjs/components/logos/svg/LogoPaymentPayPal.js.map +1 -1
- package/lib/commonjs/components/radio/AnimatedRadio.js +1 -1
- package/lib/commonjs/components/radio/AnimatedRadio.js.map +1 -1
- package/lib/commonjs/components/radio/RadioGroup.js +36 -0
- package/lib/commonjs/components/radio/RadioGroup.js.map +1 -0
- package/lib/commonjs/components/radio/index.js +11 -0
- package/lib/commonjs/components/radio/index.js.map +1 -1
- package/lib/commonjs/components/typography/H3.js +20 -49
- package/lib/commonjs/components/typography/H3.js.map +1 -1
- package/lib/commonjs/components/typography/Link.js +17 -23
- package/lib/commonjs/components/typography/Link.js.map +1 -1
- package/lib/commonjs/components/typography/__test__/__snapshots__/typography.test.tsx.snap +50 -45
- package/lib/commonjs/core/IOColors.js +1 -1
- package/lib/commonjs/core/IOColors.js.map +1 -1
- package/lib/commonjs/core/IOSpacing.js +1 -1
- package/lib/commonjs/core/IOSpacing.js.map +1 -1
- package/lib/commonjs/core/IOStyles.js +7 -1
- package/lib/commonjs/core/IOStyles.js.map +1 -1
- package/lib/commonjs/index.js +11 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/json-import.d.js +2 -0
- package/lib/commonjs/json-import.d.js.map +1 -0
- package/lib/module/components/Advice/Advice.js +4 -6
- package/lib/module/components/Advice/Advice.js.map +1 -1
- package/lib/module/components/Advice/__test__/advice.test.js +1 -1
- package/lib/module/components/Advice/__test__/advice.test.js.map +1 -1
- package/lib/module/components/accordion/RawAccordion.js +1 -1
- package/lib/module/components/accordion/RawAccordion.js.map +1 -1
- package/lib/module/components/badge/__test__/badge.test.js.map +1 -1
- package/lib/module/components/buttons/ButtonLink.js +4 -5
- package/lib/module/components/buttons/ButtonLink.js.map +1 -1
- package/lib/module/components/buttons/IconButton.js +0 -2
- package/lib/module/components/buttons/IconButton.js.map +1 -1
- package/lib/module/components/buttons/IconButtonContained.js +122 -0
- package/lib/module/components/buttons/IconButtonContained.js.map +1 -0
- package/lib/module/components/buttons/IconButtonSolid.js +100 -0
- package/lib/module/components/buttons/IconButtonSolid.js.map +1 -0
- package/lib/module/components/buttons/__test__/__snapshots__/button.test.tsx.snap +370 -0
- package/lib/module/components/buttons/__test__/button.test.js +27 -0
- package/lib/module/components/buttons/__test__/button.test.js.map +1 -1
- package/lib/module/components/buttons/index.js +4 -2
- package/lib/module/components/buttons/index.js.map +1 -1
- package/lib/module/components/checkbox/AnimatedCheckbox.js +3 -3
- package/lib/module/components/checkbox/AnimatedCheckbox.js.map +1 -1
- package/lib/module/components/icons/index.js +0 -1
- package/lib/module/components/icons/index.js.map +1 -1
- package/lib/module/components/index.js +13 -13
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/layout/GradientBottomActions.js +79 -0
- package/lib/module/components/layout/GradientBottomActions.js.map +1 -0
- package/lib/module/components/layout/GradientScrollView.js +100 -0
- package/lib/module/components/layout/GradientScrollView.js.map +1 -0
- package/lib/module/components/layout/HeaderFirstLevel.js +52 -0
- package/lib/module/components/layout/HeaderFirstLevel.js.map +1 -0
- package/lib/module/components/layout/index.js +2 -0
- package/lib/module/components/layout/index.js.map +1 -0
- package/lib/module/components/listitems/ListItemCheckbox.js +126 -0
- package/lib/module/components/listitems/ListItemCheckbox.js.map +1 -0
- package/lib/module/components/listitems/ListItemInfo.js +3 -6
- package/lib/module/components/listitems/ListItemInfo.js.map +1 -1
- package/lib/module/components/listitems/ListItemInfoCopy.js +1 -4
- package/lib/module/components/listitems/ListItemInfoCopy.js.map +1 -1
- package/lib/module/components/listitems/ListItemRadio.js +127 -0
- package/lib/module/components/listitems/ListItemRadio.js.map +1 -0
- package/lib/module/components/listitems/ListItemSwitch.js +74 -0
- package/lib/module/components/listitems/ListItemSwitch.js.map +1 -0
- package/lib/module/components/listitems/ListItemTransaction.js.map +1 -1
- package/lib/module/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +0 -14
- package/lib/module/components/listitems/index.js +3 -0
- package/lib/module/components/listitems/index.js.map +1 -1
- package/lib/module/components/logos/svg/LogoPaymentExtMaestro.js +3 -19
- package/lib/module/components/logos/svg/LogoPaymentExtMaestro.js.map +1 -1
- package/lib/module/components/logos/svg/LogoPaymentExtMastercard.js +5 -21
- package/lib/module/components/logos/svg/LogoPaymentExtMastercard.js.map +1 -1
- package/lib/module/components/logos/svg/LogoPaymentExtPayPal.js +10 -29
- package/lib/module/components/logos/svg/LogoPaymentExtPayPal.js.map +1 -1
- package/lib/module/components/logos/svg/LogoPaymentMaestro.js +9 -19
- package/lib/module/components/logos/svg/LogoPaymentMaestro.js.map +1 -1
- package/lib/module/components/logos/svg/LogoPaymentMastercard.js +8 -18
- package/lib/module/components/logos/svg/LogoPaymentMastercard.js.map +1 -1
- package/lib/module/components/logos/svg/LogoPaymentPayPal.js +5 -5
- package/lib/module/components/logos/svg/LogoPaymentPayPal.js.map +1 -1
- package/lib/module/components/radio/AnimatedRadio.js +3 -3
- package/lib/module/components/radio/AnimatedRadio.js.map +1 -1
- package/lib/module/components/radio/RadioGroup.js +28 -0
- package/lib/module/components/radio/RadioGroup.js.map +1 -0
- package/lib/module/components/radio/index.js +1 -0
- package/lib/module/components/radio/index.js.map +1 -1
- package/lib/module/components/typography/H3.js +19 -47
- package/lib/module/components/typography/H3.js.map +1 -1
- package/lib/module/components/typography/Link.js +17 -23
- package/lib/module/components/typography/Link.js.map +1 -1
- package/lib/module/components/typography/__test__/__snapshots__/typography.test.tsx.snap +50 -45
- package/lib/module/core/IOColors.js +1 -1
- package/lib/module/core/IOColors.js.map +1 -1
- package/lib/module/core/IOSpacing.js +1 -1
- package/lib/module/core/IOSpacing.js.map +1 -1
- package/lib/module/core/IOStyles.js +5 -0
- package/lib/module/core/IOStyles.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/json-import.d.js +2 -0
- package/lib/module/json-import.d.js.map +1 -0
- package/lib/typescript/components/Advice/Advice.d.ts +7 -3
- package/lib/typescript/components/Advice/Advice.d.ts.map +1 -1
- package/lib/typescript/components/accordion/RawAccordion.d.ts +2 -2
- package/lib/typescript/components/accordion/RawAccordion.d.ts.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/buttons/IconButtonContained.d.ts +15 -0
- package/lib/typescript/components/buttons/IconButtonContained.d.ts.map +1 -0
- package/lib/typescript/components/buttons/IconButtonSolid.d.ts +15 -0
- package/lib/typescript/components/buttons/IconButtonSolid.d.ts.map +1 -0
- package/lib/typescript/components/buttons/index.d.ts +4 -2
- package/lib/typescript/components/buttons/index.d.ts.map +1 -1
- package/lib/typescript/components/checkbox/AnimatedCheckbox.d.ts.map +1 -1
- package/lib/typescript/components/icons/index.d.ts +0 -1
- package/lib/typescript/components/icons/index.d.ts.map +1 -1
- package/lib/typescript/components/index.d.ts +13 -13
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/components/layout/GradientBottomActions.d.ts +22 -0
- package/lib/typescript/components/layout/GradientBottomActions.d.ts.map +1 -0
- package/lib/typescript/components/layout/GradientScrollView.d.ts +14 -0
- package/lib/typescript/components/layout/GradientScrollView.d.ts.map +1 -0
- package/lib/typescript/components/layout/HeaderFirstLevel.d.ts +11 -0
- package/lib/typescript/components/layout/HeaderFirstLevel.d.ts.map +1 -0
- package/lib/typescript/components/layout/index.d.ts +2 -0
- package/lib/typescript/components/layout/index.d.ts.map +1 -0
- package/lib/typescript/components/listitems/ListItemCheckbox.d.ts +21 -0
- package/lib/typescript/components/listitems/ListItemCheckbox.d.ts.map +1 -0
- package/lib/typescript/components/listitems/ListItemInfo.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemInfoCopy.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemRadio.d.ts +22 -0
- package/lib/typescript/components/listitems/ListItemRadio.d.ts.map +1 -0
- package/lib/typescript/components/listitems/ListItemSwitch.d.ts +18 -0
- package/lib/typescript/components/listitems/ListItemSwitch.d.ts.map +1 -0
- package/lib/typescript/components/listitems/ListItemTransaction.d.ts.map +1 -1
- package/lib/typescript/components/listitems/index.d.ts +3 -0
- package/lib/typescript/components/listitems/index.d.ts.map +1 -1
- package/lib/typescript/components/logos/svg/LogoPaymentExtMaestro.d.ts.map +1 -1
- package/lib/typescript/components/logos/svg/LogoPaymentExtMastercard.d.ts +2 -2
- package/lib/typescript/components/logos/svg/LogoPaymentExtMastercard.d.ts.map +1 -1
- package/lib/typescript/components/logos/svg/LogoPaymentExtPayPal.d.ts.map +1 -1
- package/lib/typescript/components/logos/svg/LogoPaymentMaestro.d.ts.map +1 -1
- package/lib/typescript/components/logos/svg/LogoPaymentMastercard.d.ts.map +1 -1
- package/lib/typescript/components/radio/AnimatedRadio.d.ts.map +1 -1
- package/lib/typescript/components/radio/RadioGroup.d.ts +22 -0
- package/lib/typescript/components/radio/RadioGroup.d.ts.map +1 -0
- package/lib/typescript/components/radio/index.d.ts +1 -0
- package/lib/typescript/components/radio/index.d.ts.map +1 -1
- package/lib/typescript/components/typography/H3.d.ts +11 -30
- package/lib/typescript/components/typography/H3.d.ts.map +1 -1
- package/lib/typescript/components/typography/Link.d.ts +4 -4
- package/lib/typescript/components/typography/Link.d.ts.map +1 -1
- package/lib/typescript/core/IOColors.d.ts +2 -1
- package/lib/typescript/core/IOColors.d.ts.map +1 -1
- package/lib/typescript/core/IOSpacing.d.ts +1 -1
- package/lib/typescript/core/IOSpacing.d.ts.map +1 -1
- package/lib/typescript/core/IOStyles.d.ts +6 -2
- package/lib/typescript/core/IOStyles.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +9 -5
- package/src/components/Advice/Advice.tsx +19 -23
- package/src/components/Advice/__test__/advice.test.tsx +4 -2
- package/src/components/accordion/RawAccordion.tsx +6 -6
- package/src/components/badge/__test__/badge.test.tsx +4 -2
- package/src/components/buttons/ButtonLink.tsx +177 -177
- package/src/components/buttons/IconButton.tsx +9 -6
- package/src/components/buttons/IconButtonContained.tsx +201 -0
- package/src/components/buttons/IconButtonSolid.tsx +168 -0
- package/src/components/buttons/__test__/__snapshots__/button.test.tsx.snap +370 -0
- package/src/components/buttons/__test__/button.test.tsx +59 -4
- package/src/components/buttons/index.tsx +5 -3
- package/src/components/checkbox/AnimatedCheckbox.tsx +6 -8
- package/src/components/icons/index.tsx +1 -2
- package/src/components/index.tsx +13 -13
- package/src/components/layout/GradientBottomActions.tsx +119 -0
- package/src/components/layout/GradientScrollView.tsx +167 -0
- package/src/components/layout/HeaderFirstLevel.tsx +76 -0
- package/src/components/layout/index.tsx +1 -0
- package/src/components/listitems/ListItemCheckbox.tsx +182 -0
- package/src/components/listitems/ListItemInfo.tsx +53 -58
- package/src/components/listitems/ListItemInfoCopy.tsx +122 -127
- package/src/components/listitems/ListItemRadio.tsx +185 -0
- package/src/components/listitems/ListItemSwitch.tsx +109 -0
- package/src/components/listitems/ListItemTransaction.tsx +154 -150
- package/src/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +0 -14
- package/src/components/listitems/index.tsx +3 -0
- package/src/components/logos/svg/LogoPaymentExtMaestro.tsx +3 -20
- package/src/components/logos/svg/LogoPaymentExtMastercard.tsx +5 -22
- package/src/components/logos/svg/LogoPaymentExtPayPal.tsx +9 -31
- package/src/components/logos/svg/LogoPaymentMaestro.tsx +8 -6
- package/src/components/logos/svg/LogoPaymentMastercard.tsx +8 -6
- package/src/components/logos/svg/LogoPaymentPayPal.tsx +5 -5
- package/src/components/radio/AnimatedRadio.tsx +6 -8
- package/src/components/radio/RadioGroup.tsx +43 -0
- package/src/components/radio/index.tsx +1 -0
- package/src/components/typography/H3.tsx +25 -91
- package/src/components/typography/Link.tsx +23 -30
- package/src/components/typography/__test__/__snapshots__/typography.test.tsx.snap +50 -45
- package/src/core/IOColors.ts +2 -2
- package/src/core/IOSpacing.ts +2 -2
- package/src/core/IOStyles.ts +9 -0
- package/src/index.tsx +1 -0
- package/src/json-import.d.ts +13 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import {
|
|
4
|
-
View,
|
|
5
4
|
AccessibilityProps,
|
|
6
5
|
Animated,
|
|
7
6
|
Easing,
|
|
8
7
|
LayoutAnimation,
|
|
8
|
+
Platform,
|
|
9
9
|
StyleSheet,
|
|
10
10
|
TouchableWithoutFeedback,
|
|
11
11
|
UIManager,
|
|
12
|
-
|
|
12
|
+
View
|
|
13
13
|
} from "react-native";
|
|
14
14
|
import { IOStyles, IOVisualCostants } from "../../core/IOStyles";
|
|
15
15
|
import { Icon } from "../icons/Icon";
|
|
@@ -51,7 +51,7 @@ const getDegree = (isOpen: boolean) => (isOpen ? "-90deg" : "-270deg");
|
|
|
51
51
|
* @param props
|
|
52
52
|
* @constructor
|
|
53
53
|
*/
|
|
54
|
-
export const RawAccordion: React.
|
|
54
|
+
export const RawAccordion: React.FC<Props> = props => {
|
|
55
55
|
const [isOpen, setOpen] = useState<boolean>(false);
|
|
56
56
|
const animatedController = useRef(new Animated.Value(1)).current;
|
|
57
57
|
const shouldAnimate = props.animated ?? true;
|
|
@@ -62,9 +62,9 @@ export const RawAccordion: React.FunctionComponent<Props> = props => {
|
|
|
62
62
|
|
|
63
63
|
const arrowAngle = shouldAnimate
|
|
64
64
|
? animatedController.interpolate({
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
inputRange: [0, 1],
|
|
66
|
+
outputRange: ["0deg", "-180deg"]
|
|
67
|
+
})
|
|
68
68
|
: getDegree(isOpen);
|
|
69
69
|
|
|
70
70
|
useEffect(() => {
|
|
@@ -4,7 +4,9 @@ import { Badge } from "../Badge";
|
|
|
4
4
|
|
|
5
5
|
describe("Test Badge Components", () => {
|
|
6
6
|
it("Badge Snapshot", () => {
|
|
7
|
-
const badge = TestRenderer.create(
|
|
7
|
+
const badge = TestRenderer.create(
|
|
8
|
+
<Badge text={"text"} variant={"default"}></Badge>
|
|
9
|
+
).toJSON();
|
|
8
10
|
expect(badge).toMatchSnapshot();
|
|
9
11
|
});
|
|
10
|
-
});
|
|
12
|
+
});
|
|
@@ -1,96 +1,98 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
|
-
import {
|
|
3
|
-
GestureResponderEvent,
|
|
4
|
-
Pressable,
|
|
5
|
-
StyleSheet
|
|
6
|
-
} from "react-native";
|
|
2
|
+
import { GestureResponderEvent, Pressable, StyleSheet } from "react-native";
|
|
7
3
|
import Animated, {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
Extrapolate,
|
|
5
|
+
interpolate,
|
|
6
|
+
interpolateColor,
|
|
7
|
+
useAnimatedProps,
|
|
8
|
+
useAnimatedStyle,
|
|
9
|
+
useDerivedValue,
|
|
10
|
+
useSharedValue,
|
|
11
|
+
withSpring
|
|
16
12
|
} from "react-native-reanimated";
|
|
17
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
IOButtonStyles,
|
|
15
|
+
IOColors,
|
|
16
|
+
IOScaleValues,
|
|
17
|
+
IOSpringValues
|
|
18
|
+
} from "../../core";
|
|
18
19
|
import { makeFontStyleObject } from "../../utils/fonts";
|
|
20
|
+
import { WithTestID } from "../../utils/types";
|
|
19
21
|
import { AnimatedIcon, IOIcons, IconClassComponent } from "../icons/Icon";
|
|
20
22
|
import { HSpacer } from "../spacer/Spacer";
|
|
21
|
-
import { IOScaleValues, IOSpringValues, IOColors, IOButtonStyles } from "../../core";
|
|
22
23
|
|
|
23
24
|
type ColorButtonLink = "primary" | "error" | "warning" | "success" | "info";
|
|
24
25
|
export type ButtonLink = WithTestID<{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
color?: ColorButtonLink;
|
|
27
|
+
label: string;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
// Icons
|
|
30
|
+
icon?: IOIcons;
|
|
31
|
+
iconPosition?: "start" | "end";
|
|
32
|
+
// Accessibility
|
|
33
|
+
accessibilityLabel?: string;
|
|
34
|
+
accessibilityHint?: string;
|
|
35
|
+
// Events
|
|
36
|
+
onPress: (event: GestureResponderEvent) => void;
|
|
36
37
|
}>;
|
|
37
38
|
|
|
38
39
|
type ColorStates = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
label: {
|
|
41
|
+
default: string;
|
|
42
|
+
pressed: string;
|
|
43
|
+
disabled: string;
|
|
44
|
+
};
|
|
44
45
|
};
|
|
45
46
|
|
|
46
47
|
const mapColorStates: Record<NonNullable<ButtonLink["color"]>, ColorStates> = {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
success: {
|
|
70
|
-
label: {
|
|
71
|
-
default: IOColors["success-850"],
|
|
72
|
-
pressed: IOColors["success-850"],
|
|
73
|
-
disabled: IOColors["grey-700"]
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
info: {
|
|
77
|
-
label: {
|
|
78
|
-
default: IOColors["info-850"],
|
|
79
|
-
pressed: IOColors["info-850"],
|
|
80
|
-
disabled: IOColors["grey-700"]
|
|
81
|
-
}
|
|
48
|
+
// Primary button
|
|
49
|
+
primary: {
|
|
50
|
+
label: {
|
|
51
|
+
default: IOColors["blueIO-500"],
|
|
52
|
+
pressed: IOColors["blueIO-600"],
|
|
53
|
+
disabled: IOColors["grey-700"]
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
error: {
|
|
57
|
+
label: {
|
|
58
|
+
default: IOColors["error-850"],
|
|
59
|
+
pressed: IOColors["error-850"],
|
|
60
|
+
disabled: IOColors["grey-700"]
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
warning: {
|
|
64
|
+
label: {
|
|
65
|
+
default: IOColors["warning-850"],
|
|
66
|
+
pressed: IOColors["warning-850"],
|
|
67
|
+
disabled: IOColors["grey-700"]
|
|
82
68
|
}
|
|
69
|
+
},
|
|
70
|
+
success: {
|
|
71
|
+
label: {
|
|
72
|
+
default: IOColors["success-850"],
|
|
73
|
+
pressed: IOColors["success-850"],
|
|
74
|
+
disabled: IOColors["grey-700"]
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
info: {
|
|
78
|
+
label: {
|
|
79
|
+
default: IOColors["info-850"],
|
|
80
|
+
pressed: IOColors["info-850"],
|
|
81
|
+
disabled: IOColors["grey-700"]
|
|
82
|
+
}
|
|
83
|
+
}
|
|
83
84
|
};
|
|
84
85
|
|
|
85
86
|
const DISABLED_OPACITY = 0.5;
|
|
86
87
|
const IOButtonStylesLocal = StyleSheet.create({
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
label: {
|
|
89
|
+
fontSize: 16,
|
|
90
|
+
...makeFontStyleObject("Regular", false, "ReadexPro")
|
|
91
|
+
}
|
|
91
92
|
});
|
|
92
93
|
|
|
93
|
-
export const ButtonLink = React.memo(
|
|
94
|
+
export const ButtonLink = React.memo(
|
|
95
|
+
({
|
|
94
96
|
color = "primary",
|
|
95
97
|
label,
|
|
96
98
|
disabled = false,
|
|
@@ -100,7 +102,7 @@ export const ButtonLink = React.memo(({
|
|
|
100
102
|
accessibilityLabel,
|
|
101
103
|
accessibilityHint,
|
|
102
104
|
testID
|
|
103
|
-
}: ButtonLink) => {
|
|
105
|
+
}: ButtonLink) => {
|
|
104
106
|
const isPressed = useSharedValue(0);
|
|
105
107
|
|
|
106
108
|
// Scaling transformation applied when the button is pressed
|
|
@@ -108,138 +110,136 @@ export const ButtonLink = React.memo(({
|
|
|
108
110
|
|
|
109
111
|
// Using a spring-based animation for our interpolations
|
|
110
112
|
const progressPressed = useDerivedValue(() =>
|
|
111
|
-
|
|
113
|
+
withSpring(isPressed.value, IOSpringValues.button)
|
|
112
114
|
);
|
|
113
115
|
|
|
114
116
|
// Interpolate animation values from `isPressed` values
|
|
115
117
|
const pressedAnimationStyle = useAnimatedStyle(() => {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
118
|
+
// Link color states to the pressed states
|
|
119
|
+
|
|
120
|
+
// Scale down button slightly when pressed
|
|
121
|
+
const scale = interpolate(
|
|
122
|
+
progressPressed.value,
|
|
123
|
+
[0, 1],
|
|
124
|
+
[1, animationScaleValue],
|
|
125
|
+
Extrapolate.CLAMP
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
transform: [{ scale }]
|
|
130
|
+
};
|
|
129
131
|
});
|
|
130
132
|
|
|
131
133
|
const pressedColorLabelAnimationStyle = useAnimatedStyle(() => {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
};
|
|
134
|
+
// Link color states to the pressed states
|
|
135
|
+
|
|
136
|
+
const labelColor = interpolateColor(
|
|
137
|
+
progressPressed.value,
|
|
138
|
+
[0, 1],
|
|
139
|
+
[
|
|
140
|
+
mapColorStates[color].label.default,
|
|
141
|
+
mapColorStates[color].label.pressed
|
|
142
|
+
]
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
return {
|
|
146
|
+
color: labelColor
|
|
147
|
+
};
|
|
147
148
|
});
|
|
148
149
|
|
|
149
150
|
// Animate the <Icon> color prop
|
|
150
151
|
const pressedColorIconAnimationStyle = useAnimatedProps(() => {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
152
|
+
const iconColor = interpolateColor(
|
|
153
|
+
progressPressed.value,
|
|
154
|
+
[0, 1],
|
|
155
|
+
[
|
|
156
|
+
mapColorStates[color].label.default,
|
|
157
|
+
mapColorStates[color].label.pressed
|
|
158
|
+
]
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
return { color: iconColor };
|
|
161
162
|
});
|
|
162
163
|
|
|
163
164
|
const AnimatedIconClassComponent =
|
|
164
|
-
|
|
165
|
+
Animated.createAnimatedComponent(IconClassComponent);
|
|
165
166
|
|
|
166
167
|
const onPressIn = useCallback(() => {
|
|
167
|
-
|
|
168
|
-
|
|
168
|
+
// eslint-disable-next-line functional/immutable-data
|
|
169
|
+
isPressed.value = 1;
|
|
169
170
|
}, [isPressed]);
|
|
170
171
|
const onPressOut = useCallback(() => {
|
|
171
|
-
|
|
172
|
-
|
|
172
|
+
// eslint-disable-next-line functional/immutable-data
|
|
173
|
+
isPressed.value = 0;
|
|
173
174
|
}, [isPressed]);
|
|
174
175
|
|
|
175
176
|
// Icon size
|
|
176
177
|
const iconSize = 24;
|
|
177
178
|
|
|
178
179
|
return (
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
180
|
+
<Pressable
|
|
181
|
+
accessibilityLabel={accessibilityLabel}
|
|
182
|
+
accessibilityHint={accessibilityHint}
|
|
183
|
+
accessibilityRole={"button"}
|
|
184
|
+
testID={testID}
|
|
185
|
+
onPress={onPress}
|
|
186
|
+
onPressIn={onPressIn}
|
|
187
|
+
onPressOut={onPressOut}
|
|
188
|
+
accessible={true}
|
|
189
|
+
disabled={disabled}
|
|
190
|
+
hitSlop={{ top: 14, right: 24, bottom: 14, left: 24 }}
|
|
191
|
+
style={IOButtonStyles.dimensionsDefault}
|
|
192
|
+
>
|
|
193
|
+
<Animated.View
|
|
194
|
+
style={[
|
|
195
|
+
IOButtonStyles.buttonLink,
|
|
196
|
+
iconPosition === "end" && { flexDirection: "row-reverse" },
|
|
197
|
+
disabled ? { opacity: DISABLED_OPACITY } : {},
|
|
198
|
+
/* Prevent Reanimated from overriding background colors
|
|
198
199
|
if button is disabled */
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
ellipsizeMode="tail"
|
|
233
|
-
/* A11y-related props:
|
|
200
|
+
!disabled && pressedAnimationStyle
|
|
201
|
+
]}
|
|
202
|
+
>
|
|
203
|
+
{icon && (
|
|
204
|
+
<>
|
|
205
|
+
{!disabled ? (
|
|
206
|
+
<AnimatedIconClassComponent
|
|
207
|
+
name={icon}
|
|
208
|
+
animatedProps={pressedColorIconAnimationStyle}
|
|
209
|
+
color={mapColorStates[color]?.label?.default}
|
|
210
|
+
size={iconSize}
|
|
211
|
+
/>
|
|
212
|
+
) : (
|
|
213
|
+
<AnimatedIcon
|
|
214
|
+
name={icon}
|
|
215
|
+
color={mapColorStates[color]?.label?.disabled}
|
|
216
|
+
size={iconSize}
|
|
217
|
+
/>
|
|
218
|
+
)}
|
|
219
|
+
<HSpacer size={8} />
|
|
220
|
+
</>
|
|
221
|
+
)}
|
|
222
|
+
<Animated.Text
|
|
223
|
+
style={[
|
|
224
|
+
IOButtonStylesLocal.label,
|
|
225
|
+
disabled
|
|
226
|
+
? { color: mapColorStates[color]?.label?.disabled }
|
|
227
|
+
: { color: mapColorStates[color]?.label?.default },
|
|
228
|
+
!disabled && pressedColorLabelAnimationStyle
|
|
229
|
+
]}
|
|
230
|
+
numberOfLines={1}
|
|
231
|
+
ellipsizeMode="tail"
|
|
232
|
+
/* A11y-related props:
|
|
234
233
|
DON'T UNCOMMENT THEM */
|
|
235
|
-
|
|
234
|
+
/* allowFontScaling
|
|
236
235
|
maxFontSizeMultiplier={1.3} */
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
236
|
+
>
|
|
237
|
+
{label}
|
|
238
|
+
</Animated.Text>
|
|
239
|
+
</Animated.View>
|
|
240
|
+
</Pressable>
|
|
242
241
|
);
|
|
243
|
-
}
|
|
242
|
+
}
|
|
243
|
+
);
|
|
244
244
|
|
|
245
245
|
export default ButtonLink;
|
|
@@ -10,7 +10,14 @@ import Animated, {
|
|
|
10
10
|
useSharedValue,
|
|
11
11
|
withSpring
|
|
12
12
|
} from "react-native-reanimated";
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
IOButtonStyles,
|
|
15
|
+
IOColors,
|
|
16
|
+
IOIconButtonStyles,
|
|
17
|
+
IOScaleValues,
|
|
18
|
+
IOSpringValues,
|
|
19
|
+
hexToRgba
|
|
20
|
+
} from "../../core";
|
|
14
21
|
import { WithTestID } from "../../utils/types";
|
|
15
22
|
import { AnimatedIcon, IOIcons, IconClassComponent } from "../icons";
|
|
16
23
|
|
|
@@ -101,14 +108,10 @@ export const IconButton = ({
|
|
|
101
108
|
const iconColor = interpolateColor(
|
|
102
109
|
progressPressed.value,
|
|
103
110
|
[0, 1],
|
|
104
|
-
[
|
|
105
|
-
mapColorStates[color].icon.default,
|
|
106
|
-
mapColorStates[color].icon.pressed
|
|
107
|
-
]
|
|
111
|
+
[mapColorStates[color].icon.default, mapColorStates[color].icon.pressed]
|
|
108
112
|
);
|
|
109
113
|
return { color: iconColor };
|
|
110
114
|
});
|
|
111
|
-
/* REMOVE_LEGACY_COMPONENT: End ▶ */
|
|
112
115
|
|
|
113
116
|
const handlePressIn = useCallback(() => {
|
|
114
117
|
// eslint-disable-next-line functional/immutable-data
|