@ledgerhq/native-ui 0.2.0 → 0.6.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 +16 -18
- package/assets/logos/LedgerLiveAltRegular.d.ts +0 -1
- package/assets/logos/LedgerLiveRegular.d.ts +0 -1
- package/components/Carousel/index.d.ts +45 -0
- package/components/Carousel/index.js +76 -0
- package/components/Form/Checkbox/index.d.ts +2 -2
- package/components/Form/Checkbox/index.js +5 -5
- package/components/Form/Input/BaseInput/index.d.ts +104 -7
- package/components/Form/Input/BaseInput/index.js +25 -17
- package/components/Form/Input/LegendInput/index.d.ts +14 -3
- package/components/Form/Input/LegendInput/index.js +4 -3
- package/components/Form/Input/NumberInput/index.d.ts +16 -5
- package/components/Form/Input/NumberInput/index.js +17 -9
- package/components/Form/Input/QrCodeInput/index.d.ts +15 -4
- package/components/Form/Input/QrCodeInput/index.js +5 -4
- package/components/Form/Input/SearchInput/index.d.ts +13 -2
- package/components/Form/Input/SearchInput/index.js +4 -3
- package/components/Form/SelectableList.d.ts +22 -0
- package/components/Form/SelectableList.js +31 -0
- package/components/Form/Slider/components.js +6 -6
- package/components/Form/Slider/index.d.ts +0 -1
- package/components/Form/Slider/index.native.d.ts +0 -1
- package/components/Form/Slider/index.native.js +2 -2
- package/components/Form/Switch/index.d.ts +0 -1
- package/components/Form/Switch/index.js +4 -4
- package/components/Form/Toggle/index.d.ts +0 -1
- package/components/Form/index.d.ts +2 -0
- package/components/Form/index.js +2 -0
- package/components/Icon/IconBox/index.js +2 -2
- package/components/Layout/Box/index.d.ts +11 -0
- package/components/Layout/Box/index.js +3 -0
- package/components/Layout/Flex/index.d.ts +11 -12
- package/components/Layout/Flex/index.js +2 -8
- package/components/Layout/Modals/BaseModal/index.js +4 -4
- package/components/Layout/ScrollContainerHeader/Header.d.ts +0 -1
- package/components/Layout/ScrollContainerHeader/Header.js +1 -1
- package/components/Layout/index.d.ts +3 -0
- package/components/Layout/index.js +3 -0
- package/components/Loader/index.js +2 -2
- package/components/Navigation/FlowStepper/index.d.ts +64 -0
- package/components/Navigation/FlowStepper/index.js +38 -0
- package/components/Navigation/SlideIndicator/index.js +15 -8
- package/components/Navigation/Stepper/index.js +12 -12
- package/components/Navigation/index.d.ts +1 -0
- package/components/Navigation/index.js +1 -0
- package/components/ProgressBar/index.d.ts +15 -0
- package/components/ProgressBar/index.js +33 -0
- package/components/Tabs/Chip/index.d.ts +5 -0
- package/components/Tabs/Chip/index.js +20 -0
- package/components/Tabs/Graph/index.d.ts +5 -0
- package/components/Tabs/Graph/index.js +21 -0
- package/components/Tabs/TemplateTabs/index.d.ts +29 -0
- package/components/Tabs/TemplateTabs/index.js +14 -0
- package/components/Tabs/index.d.ts +2 -0
- package/components/Tabs/index.js +2 -0
- package/components/Text/index.js +2 -2
- package/components/chart/index.d.ts +0 -1
- package/components/chart/index.js +6 -6
- package/components/cta/Button/getButtonStyle.js +12 -12
- package/components/cta/Button/index.d.ts +4 -15
- package/components/cta/Button/index.js +13 -14
- package/components/cta/Link/getLinkStyle.js +8 -8
- package/components/index.d.ts +4 -1
- package/components/index.js +5 -1
- package/components/message/Alert/index.d.ts +0 -1
- package/components/message/Alert/index.js +6 -6
- package/components/{drawer → message}/Notification/index.d.ts +5 -4
- package/components/message/Notification/index.js +35 -0
- package/components/message/index.d.ts +1 -0
- package/components/message/index.js +1 -0
- package/components/styled.d.ts +15 -0
- package/components/styled.js +12 -0
- package/components/tags/Badge/index.js +7 -7
- package/components/transitions/Fade.d.ts +5 -0
- package/components/transitions/Fade.js +32 -0
- package/components/transitions/Slide.d.ts +11 -0
- package/components/transitions/Slide.js +49 -0
- package/components/transitions/Transition.d.ts +49 -0
- package/components/transitions/Transition.js +42 -0
- package/components/transitions/index.d.ts +4 -0
- package/components/transitions/index.js +4 -0
- package/components/transitions/types.d.ts +21 -0
- package/components/transitions/types.js +1 -0
- package/icons/Close.js +1 -1
- package/package.json +8 -10
- package/styles/InvertTheme.d.ts +0 -1
- package/styles/StyleProvider.js +1 -1
- package/styles/theme.d.ts +4 -1
- package/styles/theme.js +3 -3
- package/assets/fonts/.DS_Store +0 -0
- package/assets/fonts/alpha/.DS_Store +0 -0
- package/components/Navigation/ToggleGroup/index.d.ts +0 -15
- package/components/Navigation/ToggleGroup/index.js +0 -25
- package/components/drawer/Notification/index.js +0 -37
- package/components/drawer/index.d.ts +0 -1
- package/components/drawer/index.js +0 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React from "react";
|
|
13
|
+
import styled from "styled-components/native";
|
|
14
|
+
import Flex from "../Layout/Flex";
|
|
15
|
+
import Animated, { useDerivedValue, useAnimatedStyle, withTiming, } from "react-native-reanimated";
|
|
16
|
+
const ActiveBar = styled.View `
|
|
17
|
+
background-color: ${(p) => p.theme.colors.neutral.c100};
|
|
18
|
+
position: absolute;
|
|
19
|
+
height: 100%;
|
|
20
|
+
top: 0;
|
|
21
|
+
left: 0;
|
|
22
|
+
`;
|
|
23
|
+
const AnimatedBar = Animated.createAnimatedComponent(ActiveBar);
|
|
24
|
+
function ProgressBar(_a) {
|
|
25
|
+
var { index, length } = _a, props = __rest(_a, ["index", "length"]);
|
|
26
|
+
const width = useDerivedValue(() => Math.round((index / (length - 1)) * 100), [index, length]);
|
|
27
|
+
const animatedStyles = useAnimatedStyle(() => ({
|
|
28
|
+
width: withTiming(`${width.value}%`),
|
|
29
|
+
}));
|
|
30
|
+
return (React.createElement(Flex, Object.assign({ height: 4, width: "100%", backgroundColor: "neutral.c20", position: "relative" }, props),
|
|
31
|
+
React.createElement(AnimatedBar, { style: [animatedStyles] })));
|
|
32
|
+
}
|
|
33
|
+
export default React.memo(ProgressBar);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BaseTabsProps, TabItemProps } from "../TemplateTabs";
|
|
3
|
+
export declare const ChipTab: ({ onPress, isActive, label, }: TabItemProps) => React.ReactElement;
|
|
4
|
+
declare const ChipTabs: (props: BaseTabsProps) => React.ReactElement;
|
|
5
|
+
export default ChipTabs;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import styled from "styled-components/native";
|
|
3
|
+
import Text from "../../Text";
|
|
4
|
+
import { TouchableOpacity } from "react-native";
|
|
5
|
+
import TemplateTabs from "../TemplateTabs";
|
|
6
|
+
const TabBox = styled(TouchableOpacity) `
|
|
7
|
+
text-align: center;
|
|
8
|
+
margin: auto;
|
|
9
|
+
flex: 1;
|
|
10
|
+
padding: ${(p) => p.theme.space[5]}px 0;
|
|
11
|
+
border-radius: 8px;
|
|
12
|
+
background-color: ${(p) => p.isActive ? p.theme.colors.palette.primary.c20 : "transparent"};
|
|
13
|
+
`;
|
|
14
|
+
const StyledTabs = styled(TemplateTabs) ``;
|
|
15
|
+
export const ChipTab = ({ onPress, isActive, label, }) => {
|
|
16
|
+
return (React.createElement(TabBox, { isActive: isActive, onPress: onPress },
|
|
17
|
+
React.createElement(Text, { variant: "small", fontWeight: "semiBold", color: isActive ? "palette.neutral.c100" : "palette.neutral.c80", textAlign: "center" }, label)));
|
|
18
|
+
};
|
|
19
|
+
const ChipTabs = (props) => (React.createElement(StyledTabs, Object.assign({}, props, { Item: ChipTab })));
|
|
20
|
+
export default ChipTabs;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BaseTabsProps, TabItemProps } from "../TemplateTabs";
|
|
3
|
+
export declare const GraphTab: ({ onPress, isActive, label, }: TabItemProps) => React.ReactElement;
|
|
4
|
+
declare const GraphTabs: (props: BaseTabsProps) => React.ReactElement;
|
|
5
|
+
export default GraphTabs;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import styled from "styled-components/native";
|
|
3
|
+
import Text from "../../Text";
|
|
4
|
+
import { TouchableOpacity } from "react-native";
|
|
5
|
+
import Button from "../../cta/Button";
|
|
6
|
+
import TemplateTabs from "../TemplateTabs";
|
|
7
|
+
const TabBbx = styled(TouchableOpacity) `
|
|
8
|
+
text-align: center;
|
|
9
|
+
margin: auto;
|
|
10
|
+
flex: 1;
|
|
11
|
+
`;
|
|
12
|
+
const StyledTabs = styled(TemplateTabs) `
|
|
13
|
+
border: ${(p) => `1px solid ${p.theme.colors.palette.neutral.c40}`};
|
|
14
|
+
border-radius: 35px;
|
|
15
|
+
padding: 4px;
|
|
16
|
+
`;
|
|
17
|
+
export const GraphTab = ({ onPress, isActive, label, }) => {
|
|
18
|
+
return (React.createElement(TabBbx, { onPress: onPress }, isActive ? (React.createElement(Button, { type: "main" }, label)) : (React.createElement(Text, { lineHeight: 36, textAlign: "center" }, label))));
|
|
19
|
+
};
|
|
20
|
+
const GraphTabs = (props) => (React.createElement(StyledTabs, Object.assign({}, props, { Item: GraphTab })));
|
|
21
|
+
export default GraphTabs;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/// <reference types="styled-components-react-native" />
|
|
2
|
+
import React from "react";
|
|
3
|
+
export declare type BaseTabsProps = {
|
|
4
|
+
labels: string[];
|
|
5
|
+
activeIndex: number;
|
|
6
|
+
onChange: (newIndex: number) => void;
|
|
7
|
+
};
|
|
8
|
+
export declare type TabItemProps = Partial<BaseTabsProps> & {
|
|
9
|
+
label: string;
|
|
10
|
+
isActive: boolean;
|
|
11
|
+
index: number;
|
|
12
|
+
onPress: () => void;
|
|
13
|
+
};
|
|
14
|
+
export declare type TabsProps = BaseTabsProps & {
|
|
15
|
+
Item: (props: TabItemProps) => React.ReactElement;
|
|
16
|
+
};
|
|
17
|
+
export declare const TabsContainer: import("styled-components").StyledComponent<typeof import("react-native").View, import("styled-components").DefaultTheme, import("styled-system").SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").FlexboxProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").PositionProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").ColorProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").LayoutProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").OverflowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").BorderProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>> & import("styled-system").BackgroundProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Background<import("styled-system").TLengthStyledSystem>> & {
|
|
18
|
+
columnGap?: string | number | undefined;
|
|
19
|
+
rowGap?: string | number | undefined;
|
|
20
|
+
color?: string | undefined;
|
|
21
|
+
display?: string | undefined;
|
|
22
|
+
position?: string | undefined;
|
|
23
|
+
maxHeight?: number | undefined;
|
|
24
|
+
} & {
|
|
25
|
+
flexDirection: string;
|
|
26
|
+
alignItems: string;
|
|
27
|
+
}, "alignItems" | "flexDirection">;
|
|
28
|
+
declare const TemplateTabsGroup: (props: TabsProps) => React.ReactElement;
|
|
29
|
+
export default TemplateTabsGroup;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import styled from "styled-components/native";
|
|
3
|
+
import FlexBox from "../../Layout/Flex";
|
|
4
|
+
export const TabsContainer = styled(FlexBox).attrs({
|
|
5
|
+
flexDirection: "row",
|
|
6
|
+
alignItems: "stretch",
|
|
7
|
+
}) `
|
|
8
|
+
width: 100%;
|
|
9
|
+
`;
|
|
10
|
+
const TemplateTabsGroup = (props) => {
|
|
11
|
+
const { labels, activeIndex, onChange, Item } = props;
|
|
12
|
+
return (React.createElement(TabsContainer, Object.assign({}, props), labels.map((label, index) => (React.createElement(Item, Object.assign({ key: index }, props, { label: label, index: index, isActive: index === activeIndex, onPress: () => onChange(index) }))))));
|
|
13
|
+
};
|
|
14
|
+
export default TemplateTabsGroup;
|
package/components/Text/index.js
CHANGED
|
@@ -20,7 +20,7 @@ const Base = styled.Text.attrs((p) => {
|
|
|
20
20
|
var _a;
|
|
21
21
|
return ({
|
|
22
22
|
fontSize: p.fontSize ? p.fontSize : (_a = p.variant) !== null && _a !== void 0 ? _a : "paragraph",
|
|
23
|
-
color: p.color || "
|
|
23
|
+
color: p.color || "neutral.c100",
|
|
24
24
|
});
|
|
25
25
|
}) `
|
|
26
26
|
${(p) => getTextStyle(p)}
|
|
@@ -39,7 +39,7 @@ const T = styled.View `
|
|
|
39
39
|
align-items: center;
|
|
40
40
|
`;
|
|
41
41
|
const BracketText = (_a) => {
|
|
42
|
-
var { children, color = "
|
|
42
|
+
var { children, color = "neutral.c100", lineHeight } = _a, props = __rest(_a, ["children", "color", "lineHeight"]);
|
|
43
43
|
const size = lineHeight || getTextStyle(props).lineHeight;
|
|
44
44
|
const theme = useTheme();
|
|
45
45
|
const c = theme ? getColor(theme, color) : "transparent";
|
|
@@ -6,7 +6,7 @@ import { VictoryLine, VictoryChart, VictoryAxis, VictoryArea, VictoryScatter, }
|
|
|
6
6
|
import { hex } from "../../styles/helpers";
|
|
7
7
|
import Flex from "../Layout/Flex";
|
|
8
8
|
const Container = styled(Flex) `
|
|
9
|
-
background-color: ${(p) => p.theme.colors.
|
|
9
|
+
background-color: ${(p) => p.theme.colors.background.main};
|
|
10
10
|
`;
|
|
11
11
|
const sortByDate = (a, b) => {
|
|
12
12
|
if (a.date.getTime() < b.date.getTime())
|
|
@@ -22,7 +22,7 @@ const Chart = ({ data, color, tickFormat = "MMM", valueKey = "value", height = 1
|
|
|
22
22
|
React.createElement(VictoryChart, { scale: { x: "time" }, height: height, domainPadding: { x: [0, 5], y: [30, 10] } },
|
|
23
23
|
React.createElement(VictoryAxis, { dependentAxis: true, crossAxis: true, style: {
|
|
24
24
|
grid: {
|
|
25
|
-
stroke: theme.colors.
|
|
25
|
+
stroke: theme.colors.neutral.c40,
|
|
26
26
|
strokeDasharray: "4 4",
|
|
27
27
|
},
|
|
28
28
|
axisLabel: { display: "none" },
|
|
@@ -32,11 +32,11 @@ const Chart = ({ data, color, tickFormat = "MMM", valueKey = "value", height = 1
|
|
|
32
32
|
} }),
|
|
33
33
|
React.createElement(VictoryAxis, { crossAxis: false, tickFormat: (timestamp) => moment(timestamp).format(tickFormat), style: {
|
|
34
34
|
axis: {
|
|
35
|
-
stroke: theme.colors.
|
|
35
|
+
stroke: theme.colors.neutral.c40,
|
|
36
36
|
strokeDasharray: "4 4",
|
|
37
37
|
},
|
|
38
38
|
tickLabels: {
|
|
39
|
-
fill: theme.colors.
|
|
39
|
+
fill: theme.colors.neutral.c80,
|
|
40
40
|
fontSize: 12,
|
|
41
41
|
lineHeight: 14.52,
|
|
42
42
|
},
|
|
@@ -45,14 +45,14 @@ const Chart = ({ data, color, tickFormat = "MMM", valueKey = "value", height = 1
|
|
|
45
45
|
React.createElement(Defs, null,
|
|
46
46
|
React.createElement(LinearGradient, { id: "chartGradient", x1: "0.5", x2: "0.5", y1: "0", y2: "1" },
|
|
47
47
|
React.createElement(Stop, { stopColor: hex(color), stopOpacity: "0.11" }),
|
|
48
|
-
React.createElement(Stop, { offset: "1", stopColor: hex(theme.colors.
|
|
48
|
+
React.createElement(Stop, { offset: "1", stopColor: hex(theme.colors.neutral.c00), stopOpacity: "0" }))),
|
|
49
49
|
React.createElement(VictoryArea, { data: sortData, interpolation: "monotoneX", sortKey: "date", x: "date", y: valueKey, style: { data: { fill: `url(#chartGradient)` } }, standalone: false }),
|
|
50
50
|
React.createElement(VictoryLine, { data: sortData, interpolation: "monotoneX", x: "date", y: valueKey, style: { data: { stroke: color } } }),
|
|
51
51
|
React.createElement(VictoryScatter, { style: {
|
|
52
52
|
data: {
|
|
53
53
|
stroke: color,
|
|
54
54
|
strokeWidth: 3,
|
|
55
|
-
fill: theme.colors.
|
|
55
|
+
fill: theme.colors.background.main,
|
|
56
56
|
},
|
|
57
57
|
}, size: 5, data: [sortData[sortData.length - 1]], x: "date", y: valueKey }))));
|
|
58
58
|
};
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
export function getButtonColors(colors) {
|
|
2
2
|
return {
|
|
3
3
|
default: {
|
|
4
|
-
primaryColor: colors.
|
|
4
|
+
primaryColor: colors.neutral.c100,
|
|
5
5
|
secondaryColor: "rgba(0,0,0,0)",
|
|
6
6
|
},
|
|
7
7
|
disabled: {
|
|
8
|
-
primaryColor: colors.
|
|
9
|
-
secondaryColor: colors.
|
|
8
|
+
primaryColor: colors.neutral.c50,
|
|
9
|
+
secondaryColor: colors.neutral.c30,
|
|
10
10
|
},
|
|
11
11
|
main: {
|
|
12
|
-
primaryColor: colors.
|
|
13
|
-
secondaryColor: colors.
|
|
12
|
+
primaryColor: colors.neutral.c00,
|
|
13
|
+
secondaryColor: colors.neutral.c100,
|
|
14
14
|
},
|
|
15
15
|
shade: {
|
|
16
|
-
primaryColor: colors.
|
|
17
|
-
secondaryColor: colors.
|
|
18
|
-
tertiaryColor: colors.
|
|
16
|
+
primaryColor: colors.neutral.c00,
|
|
17
|
+
secondaryColor: colors.neutral.c100,
|
|
18
|
+
tertiaryColor: colors.neutral.c40,
|
|
19
19
|
},
|
|
20
20
|
error: {
|
|
21
|
-
primaryColor: colors.
|
|
22
|
-
secondaryColor: colors.
|
|
21
|
+
primaryColor: colors.neutral.c00,
|
|
22
|
+
secondaryColor: colors.error.c100,
|
|
23
23
|
},
|
|
24
24
|
color: {
|
|
25
|
-
primaryColor: colors.
|
|
26
|
-
secondaryColor: colors.
|
|
25
|
+
primaryColor: colors.neutral.c00,
|
|
26
|
+
secondaryColor: colors.primary.c80,
|
|
27
27
|
},
|
|
28
28
|
};
|
|
29
29
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="styled-components-react-native" />
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { SpaceProps } from "styled-system";
|
|
4
3
|
import { TouchableOpacity, TouchableOpacityProps } from "react-native";
|
|
5
|
-
|
|
4
|
+
import { BaseStyledProps } from "../../styled";
|
|
5
|
+
export declare type ButtonProps = TouchableOpacityProps & BaseStyledProps & {
|
|
6
6
|
Icon?: React.ComponentType<{
|
|
7
7
|
size: number;
|
|
8
8
|
color: string;
|
|
@@ -17,19 +17,8 @@ export declare type ButtonProps = TouchableOpacityProps & SpaceProps & {
|
|
|
17
17
|
};
|
|
18
18
|
export declare const Base: import("styled-components").StyledComponent<typeof TouchableOpacity, import("styled-components").DefaultTheme, {
|
|
19
19
|
iconButton?: boolean | undefined;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
size: number;
|
|
23
|
-
color: string;
|
|
24
|
-
}> | null | undefined;
|
|
25
|
-
type?: "default" | "main" | "shade" | "error" | "color" | undefined;
|
|
26
|
-
size?: "large" | "small" | "medium" | undefined;
|
|
27
|
-
iconPosition?: "left" | "right" | undefined;
|
|
28
|
-
outline?: boolean | undefined;
|
|
29
|
-
disabled?: boolean | undefined;
|
|
30
|
-
pressed?: boolean | undefined;
|
|
31
|
-
children?: React.ReactNode;
|
|
32
|
-
}, never>;
|
|
20
|
+
sizeVariant?: ButtonProps["size"];
|
|
21
|
+
} & Omit<ButtonProps, "size">, never>;
|
|
33
22
|
declare const Button: (props: ButtonProps) => React.ReactElement;
|
|
34
23
|
export declare const PromisableButton: (props: ButtonProps) => React.ReactElement;
|
|
35
24
|
export default Button;
|
|
@@ -9,11 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import React, { useCallback, useState } from "react";
|
|
11
11
|
import styled, { useTheme } from "styled-components/native";
|
|
12
|
-
import { color, border, space } from "styled-system";
|
|
13
12
|
import { ActivityIndicator, TouchableOpacity, } from "react-native";
|
|
14
13
|
import { buttonSizeStyle, getButtonColorStyle, } from "../../cta/Button/getButtonStyle";
|
|
15
14
|
import { ctaIconSize, ctaTextType } from "../../cta/getCtaStyle";
|
|
16
15
|
import Text from "../../Text";
|
|
16
|
+
import baseStyled from "../../styled";
|
|
17
17
|
const IconContainer = styled.View `
|
|
18
18
|
${(p) => p.iconButton
|
|
19
19
|
? ""
|
|
@@ -21,12 +21,11 @@ const IconContainer = styled.View `
|
|
|
21
21
|
? `margin-right: 10px;`
|
|
22
22
|
: `margin-left: 10px;`}
|
|
23
23
|
`;
|
|
24
|
-
export const Base =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
export const Base = baseStyled(TouchableOpacity).attrs((p) => (Object.assign(Object.assign({}, getButtonColorStyle(p.theme.colors, p).button), {
|
|
25
|
+
// Avoid conflict with styled-system's size property by nulling size and renaming it
|
|
26
|
+
size: undefined, sizeVariant: p.size }))) `
|
|
27
|
+
|
|
28
28
|
border-radius: ${(p) => p.theme.space[10]}px;
|
|
29
|
-
height: ${(p) => p.theme.space[10]}px;
|
|
30
29
|
padding: 0 ${(p) => p.theme.space[7]}px;
|
|
31
30
|
flex-direction: row;
|
|
32
31
|
border-style: solid;
|
|
@@ -36,7 +35,7 @@ export const Base = styled(TouchableOpacity).attrs((p) => (Object.assign({}, get
|
|
|
36
35
|
align-content: center;
|
|
37
36
|
overflow: hidden;
|
|
38
37
|
position: relative;
|
|
39
|
-
${(p) => buttonSizeStyle[p.
|
|
38
|
+
${(p) => buttonSizeStyle[p.sizeVariant || "medium"]}
|
|
40
39
|
|
|
41
40
|
${(p) => (p.iconButton ? `padding: 0; width: ${p.theme.space[10]}px;` : "")}
|
|
42
41
|
`;
|
|
@@ -69,12 +68,12 @@ const ButtonContainer = (props) => {
|
|
|
69
68
|
iconPosition === "left" && children ? (React.createElement(Text, { variant: ctaTextType[size], fontWeight: "semiBold", color: text.color }, children)) : null));
|
|
70
69
|
};
|
|
71
70
|
const Button = (props) => {
|
|
72
|
-
const { Icon, children, type = "default"
|
|
73
|
-
return (React.createElement(Base, Object.assign({}, props, { type: type,
|
|
74
|
-
React.createElement(ButtonContainer, Object.assign({}, props, { type: type
|
|
71
|
+
const { Icon, children, type = "default" } = props;
|
|
72
|
+
return (React.createElement(Base, Object.assign({}, props, { type: type, iconButton: !!Icon && !children, activeOpacity: 0.5 }),
|
|
73
|
+
React.createElement(ButtonContainer, Object.assign({}, props, { type: type }))));
|
|
75
74
|
};
|
|
76
75
|
export const PromisableButton = (props) => {
|
|
77
|
-
const { Icon, children, onPress, type = "main",
|
|
76
|
+
const { Icon, children, onPress, type = "main", disabled = false } = props;
|
|
78
77
|
const [spinnerOn, setSpinnerOn] = useState(false);
|
|
79
78
|
const theme = useTheme();
|
|
80
79
|
const onPressHandler = useCallback((event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -88,9 +87,9 @@ export const PromisableButton = (props) => {
|
|
|
88
87
|
setSpinnerOn(false);
|
|
89
88
|
}
|
|
90
89
|
}), [onPress]);
|
|
91
|
-
return (React.createElement(Base, Object.assign({}, props, { type: type,
|
|
92
|
-
React.createElement(ButtonContainer, Object.assign({}, props, { type: type,
|
|
90
|
+
return (React.createElement(Base, Object.assign({}, props, { type: type, iconButton: !!Icon && !children, disabled: disabled || spinnerOn, onPress: onPressHandler }),
|
|
91
|
+
React.createElement(ButtonContainer, Object.assign({}, props, { type: type, hide: spinnerOn })),
|
|
93
92
|
React.createElement(SpinnerContainer, null,
|
|
94
|
-
React.createElement(ActivityIndicator, { color: theme.colors.
|
|
93
|
+
React.createElement(ActivityIndicator, { color: theme.colors.neutral.c50, animating: spinnerOn }))));
|
|
95
94
|
};
|
|
96
95
|
export default Button;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export function getLinkColors(colors) {
|
|
2
2
|
return {
|
|
3
3
|
default: {
|
|
4
|
-
disabled: colors.
|
|
5
|
-
main: colors.
|
|
6
|
-
color: colors.
|
|
7
|
-
shade: colors.
|
|
4
|
+
disabled: colors.neutral.c50,
|
|
5
|
+
main: colors.neutral.c100,
|
|
6
|
+
color: colors.primary.c80,
|
|
7
|
+
shade: colors.neutral.c70,
|
|
8
8
|
},
|
|
9
9
|
reversed: {
|
|
10
|
-
disabled: colors.
|
|
11
|
-
main: colors.
|
|
12
|
-
color: colors.
|
|
13
|
-
shade: colors.
|
|
10
|
+
disabled: colors.neutral.c80,
|
|
11
|
+
main: colors.neutral.c00,
|
|
12
|
+
color: colors.primary.c60,
|
|
13
|
+
shade: colors.neutral.c50,
|
|
14
14
|
},
|
|
15
15
|
};
|
|
16
16
|
}
|
package/components/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export * from "./cta";
|
|
2
|
-
export * from "./drawer";
|
|
3
2
|
export * from "./Form";
|
|
4
3
|
export * from "./Icon";
|
|
5
4
|
export * from "./Layout";
|
|
@@ -8,3 +7,7 @@ export * from "./message";
|
|
|
8
7
|
export * from "./Navigation";
|
|
9
8
|
export * from "./tags";
|
|
10
9
|
export { default as Text } from "./Text";
|
|
10
|
+
export { default as Carousel } from "./Carousel";
|
|
11
|
+
export * from "./Tabs";
|
|
12
|
+
export { default as ProgressBar } from "./ProgressBar";
|
|
13
|
+
export * as Transitions from "./transitions";
|
package/components/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export * from "./cta";
|
|
2
|
-
export * from "./drawer";
|
|
3
2
|
export * from "./Form";
|
|
4
3
|
export * from "./Icon";
|
|
5
4
|
export * from "./Layout";
|
|
@@ -8,3 +7,8 @@ export * from "./message";
|
|
|
8
7
|
export * from "./Navigation";
|
|
9
8
|
export * from "./tags";
|
|
10
9
|
export { default as Text } from "./Text";
|
|
10
|
+
export { default as Carousel } from "./Carousel";
|
|
11
|
+
export * from "./Tabs";
|
|
12
|
+
export { default as ProgressBar } from "./ProgressBar";
|
|
13
|
+
import * as Transitions_1 from "./transitions";
|
|
14
|
+
export { Transitions_1 as Transitions };
|
|
@@ -13,16 +13,16 @@ const icons = {
|
|
|
13
13
|
};
|
|
14
14
|
const alertColors = {
|
|
15
15
|
info: {
|
|
16
|
-
backgroundColor: "
|
|
17
|
-
color: "
|
|
16
|
+
backgroundColor: "primary.c20",
|
|
17
|
+
color: "primary.c90",
|
|
18
18
|
},
|
|
19
19
|
warning: {
|
|
20
|
-
backgroundColor: "
|
|
21
|
-
color: "
|
|
20
|
+
backgroundColor: "warning.c30",
|
|
21
|
+
color: "warning.c100",
|
|
22
22
|
},
|
|
23
23
|
error: {
|
|
24
|
-
backgroundColor: "
|
|
25
|
-
color: "
|
|
24
|
+
backgroundColor: "error.c30",
|
|
25
|
+
color: "error.c100",
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
28
|
const StyledIconContainer = styled.View `
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { TextProps, TouchableOpacityProps } from "react-native";
|
|
3
3
|
declare type Props = {
|
|
4
|
-
Icon
|
|
4
|
+
Icon?: React.ComponentType<{
|
|
5
5
|
size: number;
|
|
6
6
|
color?: string;
|
|
7
7
|
}>;
|
|
8
|
-
|
|
8
|
+
iconColor?: string;
|
|
9
9
|
variant?: "primary" | "secondary";
|
|
10
10
|
title: string;
|
|
11
11
|
subtitle?: string;
|
|
12
12
|
numberOfLines?: TextProps["numberOfLines"];
|
|
13
13
|
onClose?: TouchableOpacityProps["onPress"];
|
|
14
|
-
|
|
14
|
+
linkText?: string;
|
|
15
|
+
onLinkPress?: TouchableOpacityProps["onPress"];
|
|
15
16
|
};
|
|
16
|
-
export default function Notification({ Icon,
|
|
17
|
+
export default function Notification({ Icon, iconColor, variant, numberOfLines, title, subtitle, onClose, linkText, onLinkPress, }: Props): React.ReactElement;
|
|
17
18
|
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import styled, { useTheme } from "styled-components/native";
|
|
3
|
+
import FlexBox from "../../Layout/Flex";
|
|
4
|
+
import { TouchableOpacity, } from "react-native";
|
|
5
|
+
import Text from "../../Text";
|
|
6
|
+
import CloseMedium from "@ledgerhq/icons-ui/native/CloseMedium";
|
|
7
|
+
import { Flex } from "../../Layout";
|
|
8
|
+
const NotificationContainer = styled.View `
|
|
9
|
+
display: flex;
|
|
10
|
+
width: 100%;
|
|
11
|
+
flex-direction: row;
|
|
12
|
+
align-items: center;
|
|
13
|
+
${(p) => p.variant === "primary" &&
|
|
14
|
+
`
|
|
15
|
+
padding: 16px;
|
|
16
|
+
`}
|
|
17
|
+
background-color: ${(p) => p.variant === "primary" ? p.theme.colors.primary.c90 : "transparent"};
|
|
18
|
+
border-radius: ${(p) => `${p.theme.radii[1]}px`};
|
|
19
|
+
`;
|
|
20
|
+
export default function Notification({ Icon, iconColor, variant = "primary", numberOfLines, title, subtitle, onClose, linkText, onLinkPress, }) {
|
|
21
|
+
const { colors } = useTheme();
|
|
22
|
+
const textColor = variant === "primary" ? colors.neutral.c00 : colors.neutral.c100;
|
|
23
|
+
return (React.createElement(NotificationContainer, { variant: variant },
|
|
24
|
+
Icon && (React.createElement(FlexBox, { mr: 16 },
|
|
25
|
+
React.createElement(Icon, { size: 20, color: iconColor || textColor }))),
|
|
26
|
+
React.createElement(FlexBox, { flexShrink: 1 },
|
|
27
|
+
React.createElement(Text, { variant: "body", fontWeight: "medium", color: textColor, numberOfLines: numberOfLines }, title),
|
|
28
|
+
!!subtitle && (React.createElement(Text, { variant: "body", fontWeight: "medium", color: variant === "primary" ? colors.neutral.c00 : colors.neutral.c80, mt: 2 }, subtitle)),
|
|
29
|
+
linkText && onLinkPress && (React.createElement(Flex, { mt: 3 },
|
|
30
|
+
React.createElement(TouchableOpacity, { onPress: onLinkPress },
|
|
31
|
+
React.createElement(Text, { variant: "body", fontWeight: "semiBold", color: textColor }, linkText))))),
|
|
32
|
+
onClose && (React.createElement(FlexBox, { marginLeft: "auto", pl: 16 },
|
|
33
|
+
React.createElement(TouchableOpacity, { onPress: onClose },
|
|
34
|
+
React.createElement(CloseMedium, { size: 14, color: textColor }))))));
|
|
35
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="styled-components-react-native" />
|
|
2
|
+
import { ReactNativeStyledInterface, DefaultTheme } from "styled-components/native";
|
|
3
|
+
import { FlexboxProps, SpaceProps, PositionProps, ColorProps, LayoutProps, OverflowProps, BorderProps, BackgroundProps } from "styled-system";
|
|
4
|
+
import { InterpolationFunction } from "styled-components";
|
|
5
|
+
export declare type BaseStyledProps = SpaceProps & FlexboxProps & PositionProps & ColorProps & LayoutProps & OverflowProps & BorderProps & BackgroundProps & {
|
|
6
|
+
columnGap?: string | number;
|
|
7
|
+
rowGap?: string | number;
|
|
8
|
+
color?: string;
|
|
9
|
+
display?: string;
|
|
10
|
+
position?: string;
|
|
11
|
+
maxHeight?: number;
|
|
12
|
+
};
|
|
13
|
+
export declare const baseStyles: InterpolationFunction<unknown>;
|
|
14
|
+
declare const _default: ReactNativeStyledInterface<DefaultTheme>;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import styled from "styled-components/native";
|
|
2
|
+
import { compose, flexbox, space, position, color, layout, overflow, border, background, } from "styled-system";
|
|
3
|
+
export const baseStyles = compose(flexbox, space, position, color, layout, overflow, border, background);
|
|
4
|
+
const proxyStyled = new Proxy(styled, {
|
|
5
|
+
apply(target, thisArg, argumentsList) {
|
|
6
|
+
return styled(target.apply(thisArg, argumentsList)(baseStyles));
|
|
7
|
+
},
|
|
8
|
+
get(target, property) {
|
|
9
|
+
return styled(target[property].apply(styled, [baseStyles]));
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
export default proxyStyled;
|
|
@@ -4,22 +4,22 @@ import Text from "../../Text";
|
|
|
4
4
|
const badgesStyle = {
|
|
5
5
|
main: {
|
|
6
6
|
default: {
|
|
7
|
-
color: "
|
|
7
|
+
color: "neutral.c80",
|
|
8
8
|
borderWidth: 1,
|
|
9
|
-
borderColor: "
|
|
9
|
+
borderColor: "neutral.c40",
|
|
10
10
|
},
|
|
11
11
|
active: {
|
|
12
|
-
color: "
|
|
13
|
-
backgroundColor: "
|
|
12
|
+
color: "neutral.c00",
|
|
13
|
+
backgroundColor: "neutral.c100",
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
16
|
primary: {
|
|
17
17
|
default: {
|
|
18
|
-
color: "
|
|
18
|
+
color: "primary.c90",
|
|
19
19
|
},
|
|
20
20
|
active: {
|
|
21
|
-
color: "
|
|
22
|
-
backgroundColor: "
|
|
21
|
+
color: "primary.c90",
|
|
22
|
+
backgroundColor: "primary.c20",
|
|
23
23
|
},
|
|
24
24
|
},
|
|
25
25
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React, { useRef, useMemo, useEffect } from "react";
|
|
2
|
+
import { Animated } from "react-native";
|
|
3
|
+
/**
|
|
4
|
+
* A fade-in / fade-out transition changing the opacity of its children based on their status.
|
|
5
|
+
*/
|
|
6
|
+
export function Fade({ status, duration, style, children }) {
|
|
7
|
+
const fadeAnim = useRef(new Animated.Value(status === "entered" ? 1 : 0)).current;
|
|
8
|
+
const fadeIn = useMemo(() => Animated.timing(fadeAnim, {
|
|
9
|
+
toValue: 1,
|
|
10
|
+
duration,
|
|
11
|
+
useNativeDriver: true,
|
|
12
|
+
}), [duration, fadeAnim]);
|
|
13
|
+
const fadeOut = useMemo(() => Animated.timing(fadeAnim, {
|
|
14
|
+
toValue: 0,
|
|
15
|
+
duration,
|
|
16
|
+
useNativeDriver: true,
|
|
17
|
+
}), [duration, fadeAnim]);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (status === "entering") {
|
|
20
|
+
fadeIn.start();
|
|
21
|
+
}
|
|
22
|
+
if (status === "exiting") {
|
|
23
|
+
fadeOut.start();
|
|
24
|
+
}
|
|
25
|
+
}, [fadeIn, fadeOut, status]);
|
|
26
|
+
return (React.createElement(Animated.View, { style: [
|
|
27
|
+
{
|
|
28
|
+
opacity: fadeAnim,
|
|
29
|
+
},
|
|
30
|
+
style,
|
|
31
|
+
] }, children));
|
|
32
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TransitionProps } from "./types";
|
|
2
|
+
export interface SlideProps extends TransitionProps {
|
|
3
|
+
/**
|
|
4
|
+
* The direction of the slide animation.
|
|
5
|
+
*/
|
|
6
|
+
direction?: "left" | "right";
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A slide left/right transition translating its children based on their status and a given direction.
|
|
10
|
+
*/
|
|
11
|
+
export declare function Slide({ status, duration, style, direction, children, }: SlideProps): JSX.Element;
|