@ledgerhq/react-ui 0.1.1 → 0.4.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 +54 -13
- package/assets/icons.d.ts +1 -0
- package/assets/icons.js +1 -0
- package/components/Chart/index.js +1 -1
- package/components/Table/Columns.d.ts +2 -2
- package/components/Table/Columns.js +2 -2
- package/components/Table/index.d.ts +3 -2
- package/components/Table/index.js +1 -4
- package/components/Table/stories.helper.js +6 -6
- package/components/Tag/index.d.ts +18 -5
- package/components/Tag/index.js +54 -21
- package/components/animations/GlitchText/index.d.ts +7 -0
- package/components/animations/GlitchText/index.js +35 -0
- package/components/asorted/Divider/index.js +2 -2
- package/components/asorted/Icon/Icon.d.ts +1 -0
- package/components/asorted/Icon/Icon.js +8 -1
- package/components/asorted/Icon/index.d.ts +1 -1
- package/components/asorted/Icon/index.js +1 -1
- package/components/asorted/Text/index.d.ts +9 -31
- package/components/asorted/Text/index.js +11 -17
- package/components/asorted/Text/styles.d.ts +7 -2
- package/components/asorted/Text/styles.js +69 -85
- package/components/asorted/index.d.ts +1 -1
- package/components/asorted/index.js +1 -1
- package/components/cards/Carousel/Slide.js +3 -3
- package/components/cards/Carousel/index.js +8 -8
- package/components/cta/Button/index.d.ts +26 -14
- package/components/cta/Button/index.js +77 -66
- package/components/cta/Link/index.d.ts +12 -4
- package/components/cta/Link/index.js +4 -3
- package/components/cta/Toggle/index.js +1 -1
- package/components/cta/getCtaStyle.d.ts +2 -2
- package/components/cta/index.d.ts +1 -0
- package/components/cta/index.js +1 -0
- package/components/form/BaseInput/index.d.ts +86 -15
- package/components/form/BaseInput/index.js +47 -20
- package/components/form/Checkbox/Checkbox.js +12 -9
- package/components/form/Dropdown/index.js +3 -3
- package/components/form/LegendInput/index.js +3 -3
- package/components/form/NumberInput/index.d.ts +1 -1
- package/components/form/NumberInput/index.js +18 -7
- package/components/form/QrCodeInput/index.js +4 -4
- package/components/form/QuantityInput/index.js +8 -8
- package/components/form/Radio/RadioElement.d.ts +5 -2
- package/components/form/Radio/RadioElement.js +16 -14
- package/components/form/Radio/RadioListElement.d.ts +22 -0
- package/components/form/Radio/RadioListElement.js +63 -0
- package/components/form/Radio/index.d.ts +8 -1
- package/components/form/Radio/index.js +2 -0
- package/components/form/SearchInput/index.js +1 -1
- package/components/form/SelectInput/DropdownIndicator.js +1 -1
- package/components/form/SelectInput/MenuList.js +1 -1
- package/components/form/SelectInput/Option.js +12 -12
- package/components/form/SelectInput/ValueContainer.js +2 -2
- package/components/form/SelectInput/index.d.ts +3 -2
- package/components/form/SelectInput/index.js +5 -5
- package/components/form/SplitInput/index.js +5 -5
- package/components/form/Switch/Switch.js +9 -9
- package/components/helpers.d.ts +2 -2
- package/components/layout/Box/index.d.ts +11 -0
- package/components/layout/Box/index.js +3 -0
- package/components/layout/Drawer/index.d.ts +13 -0
- package/components/layout/{Side/Side.js → Drawer/index.js} +12 -12
- package/components/layout/Flex/index.d.ts +10 -7
- package/components/layout/Flex/index.js +2 -11
- package/components/layout/Grid/index.d.ts +3 -2
- package/components/layout/Grid/index.js +3 -3
- package/components/layout/Popin/index.d.ts +33 -6
- package/components/layout/Popin/index.js +65 -41
- package/components/layout/Side/Provider.d.ts +9 -8
- package/components/layout/Side/Provider.js +1 -3
- package/components/layout/Side/index.js +7 -10
- package/components/layout/index.d.ts +2 -0
- package/components/layout/index.js +2 -0
- package/components/loaders/ProgressLoader/index.js +4 -4
- package/components/message/Alert/index.js +7 -7
- package/components/message/Log/index.js +2 -2
- package/components/message/Notification/Badge.js +2 -2
- package/components/message/Notification/index.d.ts +8 -14
- package/components/message/Notification/index.js +9 -29
- package/components/message/StatusNotification/index.d.ts +11 -0
- package/components/message/StatusNotification/index.js +33 -0
- package/components/message/Tip/index.d.ts +8 -0
- package/components/message/Tip/index.js +43 -0
- package/components/message/Tooltip/index.d.ts +3 -2
- package/components/message/Tooltip/index.js +26 -3
- package/components/message/Tooltip/styles.js +3 -3
- package/components/message/index.d.ts +3 -0
- package/components/message/index.js +3 -0
- package/components/navigation/Aside/index.d.ts +8 -1
- package/components/navigation/Breadcrumb/index.js +5 -5
- package/components/navigation/Header/index.d.ts +3 -3
- package/components/navigation/progress/ProgressBar/Onboarding.js +6 -6
- package/components/navigation/progress/Stepper/index.js +10 -10
- package/components/navigation/sideBar/Item/Item.d.ts +4 -7
- package/components/navigation/sideBar/Item/Item.js +34 -16
- package/components/navigation/sideBar/SideBar/SideBar.d.ts +1 -1
- package/components/navigation/sideBar/SideBar/SideBar.js +14 -6
- package/components/navigation/sideBar/Toggle/Toggle.js +2 -2
- package/components/styled.d.ts +13 -0
- package/components/styled.js +13 -0
- package/components/tabs/Bar/index.js +4 -4
- package/components/tabs/Chip/index.d.ts +13 -0
- package/components/tabs/Chip/index.js +21 -0
- package/components/tabs/Pill/index.js +7 -7
- package/components/tabs/Tabs/index.js +8 -7
- package/components/tabs/index.d.ts +2 -0
- package/components/tabs/index.js +2 -0
- package/package.json +19 -8
- package/styles/InvertTheme.d.ts +1 -8
- package/styles/StyleProvider.d.ts +3 -3
- package/styles/StyleProvider.js +3 -3
- package/styles/global.d.ts +1 -0
- package/styles/global.js +16 -38
- package/styles/index.d.ts +0 -1
- package/styles/index.js +0 -1
- package/styles/theme.d.ts +63 -39
- package/styles/theme.js +34 -8
- package/components/layout/Side/Side.d.ts +0 -13
- package/styles/reset.d.ts +0 -2
- package/styles/reset.js +0 -62
package/README.md
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# `@ledgerhq/react-ui`
|
|
2
2
|
|
|
3
|
-

|
|
3
|
+
[](https://github.com/LedgerHQ/ui/actions/workflows/react.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/@ledgerhq/react-ui)
|
|
5
|
+
[](https://ledger-live-ui-react.vercel.app)
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
### Design and interface resources for React
|
|
6
8
|
|
|
7
|
-
This package contains [React](https://reactjs.org/) components and styles built on top of our design system and used internally at [Ledger](https://www.ledger.com/).
|
|
9
|
+
#### This package contains [React](https://reactjs.org/) components and styles built on top of our design system and used internally at [Ledger](https://www.ledger.com/).
|
|
8
10
|
|
|
9
11
|
## Reference
|
|
10
12
|
|
|
11
|
-
[
|
|
13
|
+
**[🔗 Storybook](https://ledger-live-ui-react.vercel.app/)**
|
|
12
14
|
|
|
13
15
|
## Installation
|
|
14
16
|
|
|
@@ -18,7 +20,15 @@ This package contains [React](https://reactjs.org/) components and styles built
|
|
|
18
20
|
npm i @ledgerhq/react-ui
|
|
19
21
|
```
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
### Peer dependencies
|
|
24
|
+
|
|
25
|
+
This library uses [styled components](https://styled-components.com/) heavily and relies on it being installed separately (to avoid package duplication).
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
npm i styled-components
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
And (obviously) if React packages are not already installed:
|
|
22
32
|
|
|
23
33
|
```sh
|
|
24
34
|
npm i react react-dom
|
|
@@ -49,12 +59,10 @@ import { Text, Flex, Logos } from "@ledgerhq/react-ui";
|
|
|
49
59
|
function Hello() {
|
|
50
60
|
return (
|
|
51
61
|
<Flex flexDirection="column" alignItems="center" rowGap={12} p={12}>
|
|
52
|
-
<Text color="
|
|
62
|
+
<Text color="neutral.c100">
|
|
53
63
|
<Logos.LedgerLiveRegular />
|
|
54
64
|
</Text>
|
|
55
|
-
<Text
|
|
56
|
-
Hello, world!
|
|
57
|
-
</Text>
|
|
65
|
+
<Text variant="h1">Hello, world!</Text>
|
|
58
66
|
</Flex>
|
|
59
67
|
);
|
|
60
68
|
}
|
|
@@ -92,6 +100,41 @@ With webpack 5 the rule below will process the font files and save them in the `
|
|
|
92
100
|
},
|
|
93
101
|
```
|
|
94
102
|
|
|
103
|
+
#### Scoped Imports
|
|
104
|
+
|
|
105
|
+
If you are using a loader that saves the fonts with custom names (for instance when using `create-react-app`), you can use the `fontMappings` prop to map the font names.
|
|
106
|
+
|
|
107
|
+
```js
|
|
108
|
+
// These imports return the path to the public folder where the loader saves the fonts during the build.
|
|
109
|
+
import HMAlphaMono from "@ledgerhq/react-ui/assets/fonts/HMAlphaMono-Medium.woff2";
|
|
110
|
+
import InterBold from "@ledgerhq/react-ui/assets/fonts/Inter-Bold.woff2";
|
|
111
|
+
import InterExtraBold from "@ledgerhq/react-ui/assets/fonts/Inter-ExtraBold.woff2";
|
|
112
|
+
import InterExtraLight from "@ledgerhq/react-ui/assets/fonts/Inter-ExtraLight-BETA.woff2";
|
|
113
|
+
import InterLight from "@ledgerhq/react-ui/assets/fonts/Inter-Light-BETA.woff2";
|
|
114
|
+
import InterMedium from "@ledgerhq/react-ui/assets/fonts/Inter-Medium.woff2";
|
|
115
|
+
import InterRegular from "@ledgerhq/react-ui/assets/fonts/Inter-Regular.woff2";
|
|
116
|
+
import InterSemiBold from "@ledgerhq/react-ui/assets/fonts/Inter-SemiBold.woff2";
|
|
117
|
+
|
|
118
|
+
// Map the font names with the file path.
|
|
119
|
+
const fontMap = {
|
|
120
|
+
"HMAlphaMono-Medium": HMAlphaMono,
|
|
121
|
+
"Inter-Bold": InterBold,
|
|
122
|
+
"Inter-ExtraBold": InterExtraBold,
|
|
123
|
+
"Inter-ExtraLight-BETA": InterExtraLight,
|
|
124
|
+
"Inter-Light-BETA": InterLight,
|
|
125
|
+
"Inter-Medium": InterMedium,
|
|
126
|
+
"Inter-Regular": InterRegular,
|
|
127
|
+
"Inter-SemiBold": InterSemiBold,
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// The substring call is used to make the path relative (removes the prepending /).
|
|
131
|
+
const fontMappings = (name) => fontMap[name].substring(1);
|
|
132
|
+
|
|
133
|
+
/* … */
|
|
134
|
+
|
|
135
|
+
<StyleProvider fontPath="path/to/fonts" fontMappings={fontMappings}>
|
|
136
|
+
```
|
|
137
|
+
|
|
95
138
|
#### Manually
|
|
96
139
|
|
|
97
140
|
The `.woff2` font files are located in the `src/assets/fonts` folder.
|
|
@@ -129,12 +172,10 @@ function Root() {
|
|
|
129
172
|
return (
|
|
130
173
|
<StyleProvider fontsPath="assets" selectedPalette={palette}>
|
|
131
174
|
<Flex flexDirection="column" alignItems="center" rowGap={12} p={12}>
|
|
132
|
-
<Text color="
|
|
175
|
+
<Text color="neutral.c100">
|
|
133
176
|
<Logos.LedgerLiveRegular />
|
|
134
177
|
</Text>
|
|
135
|
-
<Text
|
|
136
|
-
Hello, world!
|
|
137
|
-
</Text>
|
|
178
|
+
<Text variant="h1">Hello, world!</Text>
|
|
138
179
|
<Switch
|
|
139
180
|
name="select-theme"
|
|
140
181
|
checked={isLight}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@ledgerhq/icons-ui/react";
|
package/assets/icons.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@ledgerhq/icons-ui/react";
|
|
@@ -72,7 +72,7 @@ const defaultValue = {
|
|
|
72
72
|
export default (_a) => {
|
|
73
73
|
var { data, color, variant = defaultValue.variant, valueKey = defaultValue.valueKey, timeOptions = defaultValue.timeOptions } = _a, chartProps = __rest(_a, ["data", "color", "variant", "valueKey", "timeOptions"]);
|
|
74
74
|
const theme = useTheme();
|
|
75
|
-
const config = useMemo(() => getConfig(variant, { gridColor: theme.colors.
|
|
75
|
+
const config = useMemo(() => getConfig(variant, { gridColor: theme.colors.neutral.c40, timeOptions }), [variant, theme.colors.neutral.c40, timeOptions]);
|
|
76
76
|
// inject default font configuration at mount
|
|
77
77
|
useEffect(() => {
|
|
78
78
|
defaults.font = fontConfig;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Props as IconProps } from "../asorted/Icon";
|
|
3
|
-
import Text, {
|
|
3
|
+
import Text, { TextProps } from "../asorted/Text";
|
|
4
4
|
export interface CellProps<T> {
|
|
5
5
|
elt: T;
|
|
6
6
|
rowIndex: number;
|
|
@@ -16,7 +16,7 @@ export interface Column<T> {
|
|
|
16
16
|
* A column which contains a single icon and that has a fixed width.
|
|
17
17
|
*/
|
|
18
18
|
export declare function IconColumn<T>({ props, header, layout, }: {
|
|
19
|
-
props: (elt: T) => Pick<IconProps, "name" | "weight"> &
|
|
19
|
+
props: (elt: T) => Pick<IconProps, "name" | "weight"> & TextProps;
|
|
20
20
|
header?: HeaderFn;
|
|
21
21
|
layout?: string;
|
|
22
22
|
}): Column<T>;
|
|
@@ -46,8 +46,8 @@ subtitleProps, }) {
|
|
|
46
46
|
return {
|
|
47
47
|
layout: layout || "auto",
|
|
48
48
|
render: ({ elt }) => (React.createElement(FlexBox, { flexDirection: "column" },
|
|
49
|
-
title && (React.createElement(Text, Object.assign({
|
|
50
|
-
subtitle && (React.createElement(Text, Object.assign({
|
|
49
|
+
title && (React.createElement(Text, Object.assign({ fontWeight: "medium", variant: "body", textOverflow: "ellipsis", overflow: "hidden", color: "neutral.c100" }, ((titleProps && titleProps(elt)) || {})), title(elt))),
|
|
50
|
+
subtitle && (React.createElement(Text, Object.assign({ fontWeight: "medium", variant: "paragraph", textOverflow: "ellipsis", overflow: "hidden", color: "neutral.c80" }, ((subtitleProps && subtitleProps(elt)) || {})), subtitle(elt))))),
|
|
51
51
|
header,
|
|
52
52
|
};
|
|
53
53
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { BorderProps, GridColumnProps } from "styled-system";
|
|
3
3
|
import { Props as GridProps } from "../layout/Grid";
|
|
4
4
|
import type { Column } from "./Columns";
|
|
5
|
+
import { BaseStyledProps } from "../styled";
|
|
5
6
|
export type { Column };
|
|
6
|
-
export interface ContainerExtraProps extends
|
|
7
|
+
export interface ContainerExtraProps extends BorderProps, BaseStyledProps {
|
|
7
8
|
}
|
|
8
9
|
export interface ContainerProps extends ContainerExtraProps, GridProps {
|
|
9
10
|
}
|
|
@@ -11,13 +11,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import React, { memo, useMemo } from "react";
|
|
13
13
|
import styled from "styled-components";
|
|
14
|
-
import {
|
|
14
|
+
import { border, gridColumn } from "styled-system";
|
|
15
15
|
import Grid from "../layout/Grid";
|
|
16
16
|
export const Container = styled(Grid) `
|
|
17
|
-
${space}
|
|
18
|
-
${color}
|
|
19
17
|
${border}
|
|
20
|
-
${flexbox}
|
|
21
18
|
`;
|
|
22
19
|
export const ExtraRowContainer = styled.div `
|
|
23
20
|
${gridColumn}
|
|
@@ -4,7 +4,7 @@ import Text from "../asorted/Text";
|
|
|
4
4
|
import { IconColumn, TextColumn } from "./Columns";
|
|
5
5
|
function Header({ children }) {
|
|
6
6
|
const theme = useTheme();
|
|
7
|
-
return (React.createElement(Text, {
|
|
7
|
+
return (React.createElement(Text, { fontWeight: "semiBold", variant: "paragraph", style: { borderBottom: `1px solid ${theme.colors.neutral.c40}` }, mx: -4, px: 4, pb: 8 }, children));
|
|
8
8
|
}
|
|
9
9
|
export const balance = {
|
|
10
10
|
data: [
|
|
@@ -59,14 +59,14 @@ export const balance = {
|
|
|
59
59
|
header: () => React.createElement(Header, null, "Evolution"),
|
|
60
60
|
subtitle: (elt) => (elt.evolution > 0 ? "+" : "") + elt.evolution,
|
|
61
61
|
subtitleProps: (elt) => ({
|
|
62
|
-
color: elt.evolution < 0 ? "
|
|
62
|
+
color: elt.evolution < 0 ? "error.c100" : "success.c100",
|
|
63
63
|
}),
|
|
64
64
|
}),
|
|
65
65
|
IconColumn({
|
|
66
66
|
header: () => React.createElement(Header, null, "\u00A0"),
|
|
67
67
|
props: (elt) => ({
|
|
68
68
|
name: "StarSolid",
|
|
69
|
-
color: elt.starred ? "
|
|
69
|
+
color: elt.starred ? "neutral.c100" : "neutral.c70",
|
|
70
70
|
}),
|
|
71
71
|
}),
|
|
72
72
|
],
|
|
@@ -145,7 +145,7 @@ export const accounts = {
|
|
|
145
145
|
IconColumn({
|
|
146
146
|
props: (elt) => ({
|
|
147
147
|
name: elt.synchronized ? "CircledCheck" : "Clock",
|
|
148
|
-
color: elt.synchronized ? "
|
|
148
|
+
color: elt.synchronized ? "success.c100" : "neutral.c80",
|
|
149
149
|
}),
|
|
150
150
|
}),
|
|
151
151
|
TextColumn({
|
|
@@ -160,13 +160,13 @@ export const accounts = {
|
|
|
160
160
|
layout: "1fr",
|
|
161
161
|
subtitle: (elt) => (elt.evolution > 0 ? "+" : "") + elt.evolution,
|
|
162
162
|
subtitleProps: (elt) => ({
|
|
163
|
-
color: elt.evolution < 0 ? "
|
|
163
|
+
color: elt.evolution < 0 ? "error.c100" : "success.c100",
|
|
164
164
|
}),
|
|
165
165
|
}),
|
|
166
166
|
IconColumn({
|
|
167
167
|
props: (elt) => ({
|
|
168
168
|
name: "StarSolid",
|
|
169
|
-
color: elt.starred ? "
|
|
169
|
+
color: elt.starred ? "neutral.c100" : "neutral.c70",
|
|
170
170
|
}),
|
|
171
171
|
}),
|
|
172
172
|
],
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { BorderProps
|
|
3
|
-
|
|
2
|
+
import { BorderProps } from "styled-system";
|
|
3
|
+
import { TextProps } from "../asorted/Text";
|
|
4
|
+
import { BaseStyledProps } from "../styled";
|
|
5
|
+
export declare type Size = "large" | "medium" | "small";
|
|
6
|
+
export declare type Type = "plain" | "opacity" | "outlined" | "outlinedOpacity";
|
|
7
|
+
export declare type TagProps = BaseStyledProps & BorderProps & React.PropsWithChildren<{
|
|
4
8
|
/**
|
|
5
9
|
* Changes the appearance based on the active state.
|
|
6
10
|
*/
|
|
@@ -8,6 +12,15 @@ export declare type Props = React.PropsWithChildren<{
|
|
|
8
12
|
/**
|
|
9
13
|
* Tag style.
|
|
10
14
|
*/
|
|
11
|
-
type?:
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
type?: Type;
|
|
16
|
+
/**
|
|
17
|
+
* Size of the tag, affects the padding and the casing (uppercase for small and medium)
|
|
18
|
+
*/
|
|
19
|
+
size?: Size;
|
|
20
|
+
/**
|
|
21
|
+
* Props passed to the text component, overriding props set internally by Tag component
|
|
22
|
+
*/
|
|
23
|
+
textProps?: TextProps;
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
}>;
|
|
26
|
+
export default function Tag({ children, textProps, size, ...props }: TagProps): JSX.Element;
|
package/components/Tag/index.js
CHANGED
|
@@ -10,50 +10,83 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import React from "react";
|
|
13
|
-
import
|
|
14
|
-
import { border, space, color } from "styled-system";
|
|
13
|
+
import { border } from "styled-system";
|
|
15
14
|
import Text from "../asorted/Text";
|
|
16
|
-
|
|
15
|
+
import baseStyled from "../styled";
|
|
16
|
+
function getColor({ type, active, disabled }) {
|
|
17
17
|
switch (type) {
|
|
18
|
-
case "
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
case "plain":
|
|
19
|
+
if (disabled)
|
|
20
|
+
return active ? "neutral.c00" : "neutral.c70";
|
|
21
|
+
return active ? "neutral.c00" : "primary.c90";
|
|
21
22
|
default:
|
|
22
|
-
return
|
|
23
|
+
return disabled ? "neutral.c70" : "primary.c90";
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
|
-
function getBgColor({ type, active }) {
|
|
26
|
+
function getBgColor({ type, active, disabled }) {
|
|
26
27
|
switch (type) {
|
|
28
|
+
case "plain":
|
|
29
|
+
return active ? (disabled ? "neutral.c70" : "primary.c90") : undefined;
|
|
27
30
|
case "opacity":
|
|
28
|
-
return active ? "
|
|
29
|
-
|
|
31
|
+
return active ? (disabled ? "neutral.c30" : "primary.c20") : undefined;
|
|
32
|
+
default:
|
|
30
33
|
return;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function getBorderColor({ type, active, disabled }) {
|
|
37
|
+
if (!active)
|
|
38
|
+
return;
|
|
39
|
+
switch (type) {
|
|
40
|
+
case "outlined":
|
|
41
|
+
return disabled ? "neutral.c70" : "primary.c90";
|
|
42
|
+
case "outlinedOpacity":
|
|
43
|
+
return disabled ? "neutral.c40" : "primary.c40";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function getPadding({ size }) {
|
|
47
|
+
switch (size) {
|
|
48
|
+
case "small":
|
|
49
|
+
return "3px 5px";
|
|
50
|
+
case "medium":
|
|
51
|
+
return "6px 8px";
|
|
52
|
+
case "large":
|
|
31
53
|
default:
|
|
32
|
-
return
|
|
54
|
+
return "9px 10px 10px";
|
|
33
55
|
}
|
|
34
56
|
}
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
|
|
57
|
+
function getTextProps({ size }) {
|
|
58
|
+
switch (size) {
|
|
59
|
+
case "small":
|
|
60
|
+
case "medium":
|
|
61
|
+
return {
|
|
62
|
+
variant: "tiny",
|
|
63
|
+
fontWeight: "semiBold",
|
|
64
|
+
uppercase: true,
|
|
65
|
+
};
|
|
66
|
+
case "large":
|
|
67
|
+
default:
|
|
68
|
+
return {
|
|
69
|
+
variant: "extraSmall",
|
|
70
|
+
fontWeight: "semiBold",
|
|
71
|
+
};
|
|
38
72
|
}
|
|
39
73
|
}
|
|
40
|
-
const TagContainer =
|
|
74
|
+
const TagContainer = baseStyled.div.attrs((props) => ({
|
|
41
75
|
backgroundColor: props.bg || props.backgroundColor || getBgColor(props),
|
|
42
76
|
color: props.color || getColor(props),
|
|
43
77
|
borderColor: getBorderColor(props),
|
|
44
|
-
p: "7px", // TODO: use spacing from the theme when it gets updated
|
|
45
78
|
})) `
|
|
46
79
|
display: inline-flex;
|
|
47
80
|
justify-content: center;
|
|
48
81
|
border: 1px solid transparent;
|
|
49
82
|
border-radius: ${(p) => `${p.theme.radii[1]}px`};
|
|
83
|
+
padding: ${(p) => getPadding(p)};
|
|
50
84
|
${border}
|
|
51
|
-
${space}
|
|
52
|
-
${color}
|
|
53
85
|
`;
|
|
54
86
|
export default function Tag(_a) {
|
|
55
|
-
var { children } = _a, props = __rest(_a, ["children"]);
|
|
87
|
+
var { children, textProps, size = "large" } = _a, props = __rest(_a, ["children", "textProps", "size"]);
|
|
56
88
|
const textColor = getColor(props);
|
|
57
|
-
|
|
58
|
-
|
|
89
|
+
const baseTextProps = getTextProps(Object.assign({ size }, props));
|
|
90
|
+
return (React.createElement(TagContainer, Object.assign({ size: size }, props),
|
|
91
|
+
React.createElement(Text, Object.assign({}, baseTextProps, { color: textColor }, (textProps ? textProps : {})), children)));
|
|
59
92
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
function makeRandomString(length) {
|
|
3
|
+
let result = "";
|
|
4
|
+
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
5
|
+
const charactersLength = characters.length;
|
|
6
|
+
for (let i = 0; i < length; i++) {
|
|
7
|
+
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
8
|
+
}
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
11
|
+
const INTERVAL = 77;
|
|
12
|
+
export default function GlitchText({ text, duration = 800, delay = 500 }) {
|
|
13
|
+
const [shownText, setShownText] = useState(text);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
let frameT = 0;
|
|
16
|
+
const startFrame = Math.floor((1 + delay) / INTERVAL);
|
|
17
|
+
const totalFrames = Math.floor((delay + duration) / INTERVAL);
|
|
18
|
+
const interval = setInterval(() => {
|
|
19
|
+
if (frameT >= startFrame) {
|
|
20
|
+
if (frameT >= totalFrames) {
|
|
21
|
+
setShownText(text);
|
|
22
|
+
clearInterval(interval);
|
|
23
|
+
frameT = 0;
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const t1 = text.substr(0, -totalFrames + frameT + text.length);
|
|
27
|
+
const t2 = t1.length > 0 ? text.substr(t1.length, text.length) : text;
|
|
28
|
+
setShownText(t1 + makeRandomString(t2.length));
|
|
29
|
+
}
|
|
30
|
+
frameT++;
|
|
31
|
+
}, INTERVAL);
|
|
32
|
+
return () => interval && clearInterval(interval);
|
|
33
|
+
}, [delay, duration, text]);
|
|
34
|
+
return React.createElement(React.Fragment, null, shownText);
|
|
35
|
+
}
|
|
@@ -2,11 +2,11 @@ import React from "react";
|
|
|
2
2
|
import styled from "styled-components";
|
|
3
3
|
const Divider = styled.div `
|
|
4
4
|
display: block;
|
|
5
|
-
background: ${(p) => p.theme.colors.
|
|
5
|
+
background: ${(p) => p.theme.colors.neutral.c90};
|
|
6
6
|
height: 1px;
|
|
7
7
|
|
|
8
8
|
&[data-variant="light"] {
|
|
9
|
-
background: ${(p) => p.theme.colors.
|
|
9
|
+
background: ${(p) => p.theme.colors.neutral.c40};
|
|
10
10
|
}
|
|
11
11
|
`;
|
|
12
12
|
export default ({ variant = "default" }) => React.createElement(Divider, { "data-variant": variant });
|
|
@@ -7,4 +7,5 @@ export declare type Props = {
|
|
|
7
7
|
};
|
|
8
8
|
export declare const iconNames: string[];
|
|
9
9
|
declare const Icon: ({ name, size, color, weight, }: Props) => JSX.Element | null;
|
|
10
|
+
export declare const IconBox: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
10
11
|
export default Icon;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as icons from "@ledgerhq/icons-ui/react";
|
|
2
2
|
import React from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
3
4
|
export const iconNames = Array.from(Object.keys(icons).reduce((set, rawKey) => {
|
|
4
5
|
const key = rawKey
|
|
5
6
|
.replace(/(.+)(Regular|Light|UltraLight|Thin|Medium)+$/g, "$1")
|
|
@@ -8,7 +9,7 @@ export const iconNames = Array.from(Object.keys(icons).reduce((set, rawKey) => {
|
|
|
8
9
|
set.add(key);
|
|
9
10
|
return set;
|
|
10
11
|
}, new Set()));
|
|
11
|
-
const Icon = ({ name, size = 16, color = "currentColor", weight = "
|
|
12
|
+
const Icon = ({ name, size = 16, color = "currentColor", weight = "Medium", }) => {
|
|
12
13
|
const maybeIconName = `${name}${weight}`;
|
|
13
14
|
if (maybeIconName in icons) {
|
|
14
15
|
// @ts-expect-error FIXME I don't know how to make you happy ts
|
|
@@ -17,4 +18,10 @@ const Icon = ({ name, size = 16, color = "currentColor", weight = "Regular", })
|
|
|
17
18
|
}
|
|
18
19
|
return null;
|
|
19
20
|
};
|
|
21
|
+
export const IconBox = styled.div `
|
|
22
|
+
padding: ${(p) => p.theme.space[6]}px;
|
|
23
|
+
border: 1px solid ${(p) => p.theme.colors.neutral.c40};
|
|
24
|
+
border-radius: ${(p) => p.theme.radii[2]}px;
|
|
25
|
+
display: inline-flex;
|
|
26
|
+
`;
|
|
20
27
|
export default Icon;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default, iconNames } from "./Icon";
|
|
1
|
+
export { default, iconNames, IconBox } from "./Icon";
|
|
2
2
|
export type { Props } from "./Icon";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default, iconNames } from "./Icon";
|
|
1
|
+
export { default, iconNames, IconBox } from "./Icon";
|
|
@@ -1,41 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import type { Theme } from "../../../styles/theme";
|
|
1
|
+
import { BaseStyledProps } from "../../styled";
|
|
2
|
+
import { TextVariants } from "../../../styles/theme";
|
|
4
3
|
declare type FontFamilies = "Inter|ExtraLight" | "Inter|Light" | "Inter|Regular" | "Inter|Medium" | "Inter|SemiBold" | "Inter|Bold" | "Inter|ExtraBold" | "Alpha|Medium";
|
|
5
|
-
|
|
6
|
-
export interface TextProps {
|
|
4
|
+
declare type WhiteSpace = "normal" | "nowrap" | "pre" | "pre-line" | "pre-wrap";
|
|
5
|
+
export interface TextProps extends BaseStyledProps {
|
|
7
6
|
fontFamily?: string;
|
|
8
7
|
ff?: FontFamilies;
|
|
9
|
-
fontSize?: number | string;
|
|
8
|
+
fontSize?: number | string | TextVariants;
|
|
9
|
+
variant?: TextVariants;
|
|
10
10
|
textAlign?: string;
|
|
11
|
-
textTransform?: string;
|
|
12
|
-
color?: string;
|
|
13
|
-
fontWeight?: string;
|
|
14
|
-
mt?: number | string;
|
|
15
|
-
mb?: number | string;
|
|
16
|
-
ml?: number | string;
|
|
17
|
-
mr?: number | string;
|
|
18
|
-
lineHeight?: string;
|
|
19
|
-
bracket?: boolean;
|
|
20
|
-
type?: TextTypes;
|
|
21
|
-
children: React.ReactNode;
|
|
22
|
-
}
|
|
23
|
-
export interface BaseTextProps extends SpaceProps, LayoutProps {
|
|
24
|
-
fontFamily?: string;
|
|
25
|
-
ff?: FontFamilies;
|
|
26
|
-
fontSize?: number | string;
|
|
27
|
-
textAlign?: string;
|
|
28
|
-
color?: string;
|
|
29
11
|
fontWeight?: string;
|
|
30
12
|
lineHeight?: string;
|
|
31
|
-
type?: TextTypes;
|
|
32
13
|
textTransform?: string;
|
|
33
14
|
textOverflow?: string;
|
|
15
|
+
uppercase?: boolean;
|
|
16
|
+
whiteSpace?: WhiteSpace;
|
|
34
17
|
}
|
|
35
|
-
declare const Text: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme,
|
|
36
|
-
color: string;
|
|
37
|
-
className: string;
|
|
38
|
-
} & BaseTextProps & {
|
|
39
|
-
theme: Theme;
|
|
40
|
-
}, "className" | "color">;
|
|
18
|
+
declare const Text: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, TextProps, keyof TextProps>;
|
|
41
19
|
export default Text;
|
|
@@ -1,29 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { fontSize, fontWeight, textAlign,
|
|
1
|
+
import baseStyled from "../../styled";
|
|
2
|
+
import { compose, fontSize, fontWeight, textAlign, lineHeight, letterSpacing, system, } from "styled-system";
|
|
3
3
|
import fontFamily from "../../../styles/styled/fontFamily";
|
|
4
|
+
import { textVariantStyle } from "./styles";
|
|
4
5
|
const uppercase = system({
|
|
5
6
|
uppercase: {
|
|
6
7
|
property: "textTransform",
|
|
7
8
|
transform: (value) => (value ? "uppercase" : "none"),
|
|
8
9
|
},
|
|
9
10
|
});
|
|
10
|
-
const Text =
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const Text = baseStyled.span.attrs(({ variant = "body", fontSize, color }) => ({
|
|
12
|
+
fontSize: fontSize ? fontSize : variant,
|
|
13
|
+
color: color || "neutral.c100",
|
|
13
14
|
})) `
|
|
14
|
-
|
|
15
|
-
${
|
|
16
|
-
${
|
|
17
|
-
${fontSize
|
|
18
|
-
${textAlign};
|
|
19
|
-
${color};
|
|
20
|
-
${fontWeight};
|
|
21
|
-
${space};
|
|
22
|
-
${letterSpacing};
|
|
23
|
-
${layout}
|
|
24
|
-
${system({
|
|
15
|
+
font-weight: 500;
|
|
16
|
+
white-space: ${(props) => { var _a; return (_a = props.whiteSpace) !== null && _a !== void 0 ? _a : "normal"; }};
|
|
17
|
+
${(p) => textVariantStyle[p.variant || "body"]}
|
|
18
|
+
${compose(uppercase, lineHeight, fontFamily, fontSize, textAlign, fontWeight, letterSpacing, system({
|
|
25
19
|
textOverflow: true,
|
|
26
|
-
})}
|
|
20
|
+
}))}
|
|
27
21
|
${(p) => (p.textTransform ? `text-transform: ${p.textTransform};` : "")}
|
|
28
22
|
`;
|
|
29
23
|
export default Text;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { GlobalStyleProps } from "../../../styles/global";
|
|
2
|
+
import { TextVariants } from "../../../styles/theme";
|
|
2
3
|
export declare const fontStyles: import("styled-components").FlattenInterpolation<import("styled-components").ThemedStyledProps<GlobalStyleProps, import("styled-components").DefaultTheme>>;
|
|
3
|
-
declare const
|
|
4
|
-
|
|
4
|
+
export declare const textVariantStyle: Record<TextVariants, {
|
|
5
|
+
fontFamily: string;
|
|
6
|
+
lineHeight?: string | number;
|
|
7
|
+
fontWeight?: number;
|
|
8
|
+
"text-transform"?: string;
|
|
9
|
+
}>;
|