@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.
Files changed (121) hide show
  1. package/README.md +54 -13
  2. package/assets/icons.d.ts +1 -0
  3. package/assets/icons.js +1 -0
  4. package/components/Chart/index.js +1 -1
  5. package/components/Table/Columns.d.ts +2 -2
  6. package/components/Table/Columns.js +2 -2
  7. package/components/Table/index.d.ts +3 -2
  8. package/components/Table/index.js +1 -4
  9. package/components/Table/stories.helper.js +6 -6
  10. package/components/Tag/index.d.ts +18 -5
  11. package/components/Tag/index.js +54 -21
  12. package/components/animations/GlitchText/index.d.ts +7 -0
  13. package/components/animations/GlitchText/index.js +35 -0
  14. package/components/asorted/Divider/index.js +2 -2
  15. package/components/asorted/Icon/Icon.d.ts +1 -0
  16. package/components/asorted/Icon/Icon.js +8 -1
  17. package/components/asorted/Icon/index.d.ts +1 -1
  18. package/components/asorted/Icon/index.js +1 -1
  19. package/components/asorted/Text/index.d.ts +9 -31
  20. package/components/asorted/Text/index.js +11 -17
  21. package/components/asorted/Text/styles.d.ts +7 -2
  22. package/components/asorted/Text/styles.js +69 -85
  23. package/components/asorted/index.d.ts +1 -1
  24. package/components/asorted/index.js +1 -1
  25. package/components/cards/Carousel/Slide.js +3 -3
  26. package/components/cards/Carousel/index.js +8 -8
  27. package/components/cta/Button/index.d.ts +26 -14
  28. package/components/cta/Button/index.js +77 -66
  29. package/components/cta/Link/index.d.ts +12 -4
  30. package/components/cta/Link/index.js +4 -3
  31. package/components/cta/Toggle/index.js +1 -1
  32. package/components/cta/getCtaStyle.d.ts +2 -2
  33. package/components/cta/index.d.ts +1 -0
  34. package/components/cta/index.js +1 -0
  35. package/components/form/BaseInput/index.d.ts +86 -15
  36. package/components/form/BaseInput/index.js +47 -20
  37. package/components/form/Checkbox/Checkbox.js +12 -9
  38. package/components/form/Dropdown/index.js +3 -3
  39. package/components/form/LegendInput/index.js +3 -3
  40. package/components/form/NumberInput/index.d.ts +1 -1
  41. package/components/form/NumberInput/index.js +18 -7
  42. package/components/form/QrCodeInput/index.js +4 -4
  43. package/components/form/QuantityInput/index.js +8 -8
  44. package/components/form/Radio/RadioElement.d.ts +5 -2
  45. package/components/form/Radio/RadioElement.js +16 -14
  46. package/components/form/Radio/RadioListElement.d.ts +22 -0
  47. package/components/form/Radio/RadioListElement.js +63 -0
  48. package/components/form/Radio/index.d.ts +8 -1
  49. package/components/form/Radio/index.js +2 -0
  50. package/components/form/SearchInput/index.js +1 -1
  51. package/components/form/SelectInput/DropdownIndicator.js +1 -1
  52. package/components/form/SelectInput/MenuList.js +1 -1
  53. package/components/form/SelectInput/Option.js +12 -12
  54. package/components/form/SelectInput/ValueContainer.js +2 -2
  55. package/components/form/SelectInput/index.d.ts +3 -2
  56. package/components/form/SelectInput/index.js +5 -5
  57. package/components/form/SplitInput/index.js +5 -5
  58. package/components/form/Switch/Switch.js +9 -9
  59. package/components/helpers.d.ts +2 -2
  60. package/components/layout/Box/index.d.ts +11 -0
  61. package/components/layout/Box/index.js +3 -0
  62. package/components/layout/Drawer/index.d.ts +13 -0
  63. package/components/layout/{Side/Side.js → Drawer/index.js} +12 -12
  64. package/components/layout/Flex/index.d.ts +10 -7
  65. package/components/layout/Flex/index.js +2 -11
  66. package/components/layout/Grid/index.d.ts +3 -2
  67. package/components/layout/Grid/index.js +3 -3
  68. package/components/layout/Popin/index.d.ts +33 -6
  69. package/components/layout/Popin/index.js +65 -41
  70. package/components/layout/Side/Provider.d.ts +9 -8
  71. package/components/layout/Side/Provider.js +1 -3
  72. package/components/layout/Side/index.js +7 -10
  73. package/components/layout/index.d.ts +2 -0
  74. package/components/layout/index.js +2 -0
  75. package/components/loaders/ProgressLoader/index.js +4 -4
  76. package/components/message/Alert/index.js +7 -7
  77. package/components/message/Log/index.js +2 -2
  78. package/components/message/Notification/Badge.js +2 -2
  79. package/components/message/Notification/index.d.ts +8 -14
  80. package/components/message/Notification/index.js +9 -29
  81. package/components/message/StatusNotification/index.d.ts +11 -0
  82. package/components/message/StatusNotification/index.js +33 -0
  83. package/components/message/Tip/index.d.ts +8 -0
  84. package/components/message/Tip/index.js +43 -0
  85. package/components/message/Tooltip/index.d.ts +3 -2
  86. package/components/message/Tooltip/index.js +26 -3
  87. package/components/message/Tooltip/styles.js +3 -3
  88. package/components/message/index.d.ts +3 -0
  89. package/components/message/index.js +3 -0
  90. package/components/navigation/Aside/index.d.ts +8 -1
  91. package/components/navigation/Breadcrumb/index.js +5 -5
  92. package/components/navigation/Header/index.d.ts +3 -3
  93. package/components/navigation/progress/ProgressBar/Onboarding.js +6 -6
  94. package/components/navigation/progress/Stepper/index.js +10 -10
  95. package/components/navigation/sideBar/Item/Item.d.ts +4 -7
  96. package/components/navigation/sideBar/Item/Item.js +34 -16
  97. package/components/navigation/sideBar/SideBar/SideBar.d.ts +1 -1
  98. package/components/navigation/sideBar/SideBar/SideBar.js +14 -6
  99. package/components/navigation/sideBar/Toggle/Toggle.js +2 -2
  100. package/components/styled.d.ts +13 -0
  101. package/components/styled.js +13 -0
  102. package/components/tabs/Bar/index.js +4 -4
  103. package/components/tabs/Chip/index.d.ts +13 -0
  104. package/components/tabs/Chip/index.js +21 -0
  105. package/components/tabs/Pill/index.js +7 -7
  106. package/components/tabs/Tabs/index.js +8 -7
  107. package/components/tabs/index.d.ts +2 -0
  108. package/components/tabs/index.js +2 -0
  109. package/package.json +19 -8
  110. package/styles/InvertTheme.d.ts +1 -8
  111. package/styles/StyleProvider.d.ts +3 -3
  112. package/styles/StyleProvider.js +3 -3
  113. package/styles/global.d.ts +1 -0
  114. package/styles/global.js +16 -38
  115. package/styles/index.d.ts +0 -1
  116. package/styles/index.js +0 -1
  117. package/styles/theme.d.ts +63 -39
  118. package/styles/theme.js +34 -8
  119. package/components/layout/Side/Side.d.ts +0 -13
  120. package/styles/reset.d.ts +0 -2
  121. package/styles/reset.js +0 -62
package/README.md CHANGED
@@ -1,14 +1,16 @@
1
1
  # `@ledgerhq/react-ui`
2
2
 
3
- ![build](https://github.com/LedgerHQ/ui/actions/workflows/react.yml/badge.svg)
3
+ [![build](https://github.com/LedgerHQ/ui/actions/workflows/react.yml/badge.svg)](https://github.com/LedgerHQ/ui/actions/workflows/react.yml)
4
+ [![npm](https://img.shields.io/npm/v/@ledgerhq/react-ui)](https://www.npmjs.com/package/@ledgerhq/react-ui)
5
+ [![storybook](https://img.shields.io/badge/Storybook-📚-61DBFB)](https://ledger-live-ui-react.vercel.app)
4
6
 
5
- #### Design and interface resources
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
- [📚 The storybook is hosted here.](https://ledger-live-ui-react.vercel.app/)
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
- _If the `react` packages are not installed yet:_
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="palette.neutral.c100">
62
+ <Text color="neutral.c100">
53
63
  <Logos.LedgerLiveRegular />
54
64
  </Text>
55
- <Text type="h1" ff="Alpha|Medium">
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="palette.neutral.c100">
175
+ <Text color="neutral.c100">
133
176
  <Logos.LedgerLiveRegular />
134
177
  </Text>
135
- <Text type="h1" ff="Alpha|Medium">
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";
@@ -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.palette.neutral.c40, timeOptions }), [variant, theme.colors.palette.neutral.c40, timeOptions]);
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, { BaseTextProps } from "../asorted/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"> & BaseTextProps;
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({ ff: "Inter|Medium", fontSize: 4, textOverflow: "ellipsis", overflow: "hidden", color: "palette.neutral.c100" }, ((titleProps && titleProps(elt)) || {})), title(elt))),
50
- subtitle && (React.createElement(Text, Object.assign({ ff: "Inter|Medium", fontSize: 3, textOverflow: "ellipsis", overflow: "hidden", color: "palette.neutral.c80" }, ((subtitleProps && subtitleProps(elt)) || {})), subtitle(elt))))),
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 { SpaceProps, ColorProps, BorderProps, FlexboxProps, GridColumnProps } from "styled-system";
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 SpaceProps, ColorProps, BorderProps, FlexboxProps {
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 { space, color, border, flexbox, gridColumn, } from "styled-system";
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, { ff: "Inter|SemiBold", fontSize: 13, style: { borderBottom: `1px solid ${theme.colors.palette.neutral.c40}` }, mx: -4, px: 4, pb: 8 }, children));
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 ? "palette.error.c100" : "palette.success.c100",
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 ? "palette.neutral.c100" : "palette.neutral.c70",
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 ? "palette.success.c100" : "palette.neutral.c80",
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 ? "palette.error.c100" : "palette.success.c100",
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 ? "palette.neutral.c100" : "palette.neutral.c70",
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, ColorProps } from "styled-system";
3
- export declare type Props = React.PropsWithChildren<{
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?: "plain" | "opacity" | "outlined";
12
- } & BorderProps & ColorProps>;
13
- export default function Tag({ children, ...props }: Props): JSX.Element;
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;
@@ -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 styled from "styled-components";
14
- import { border, space, color } from "styled-system";
13
+ import { border } from "styled-system";
15
14
  import Text from "../asorted/Text";
16
- function getColor({ type, active }) {
15
+ import baseStyled from "../styled";
16
+ function getColor({ type, active, disabled }) {
17
17
  switch (type) {
18
- case "opacity":
19
- case "outlined":
20
- return "palette.primary.c90";
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 active ? "palette.neutral.c00" : "palette.primary.c90";
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 ? "palette.primary.c20" : undefined;
29
- case "outlined":
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 active ? "palette.primary.c90" : undefined;
54
+ return "9px 10px 10px";
33
55
  }
34
56
  }
35
- function getBorderColor({ type, active }) {
36
- if (type === "outlined" && active) {
37
- return "palette.primary.c90";
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 = styled.div.attrs((props) => ({
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
- return (React.createElement(TagContainer, Object.assign({}, props),
58
- React.createElement(Text, { type: "tag", color: textColor }, children)));
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,7 @@
1
+ /// <reference types="react" />
2
+ export interface GlitchTextProps {
3
+ text: string;
4
+ duration?: number;
5
+ delay?: number;
6
+ }
7
+ export default function GlitchText({ text, duration, delay }: GlitchTextProps): JSX.Element;
@@ -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.palette.neutral.c90};
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.palette.neutral.c40};
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 = "Regular", }) => {
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 React from "react";
2
- import { SpaceProps, LayoutProps } from "styled-system";
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
- export declare type TextTypes = "h1" | "h2" | "h3" | "highlight" | "emphasis" | "body" | "cta" | "link" | "small" | "tiny" | "subTitle" | "navigation" | "tag" | "large" | "paragraph";
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 styled from "styled-components";
2
- import { fontSize, fontWeight, textAlign, color, space, lineHeight, letterSpacing, system, layout, } from "styled-system";
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 = styled.span.attrs((p) => ({
11
- color: p.color || p.theme.colors.palette.neutral.c100,
12
- className: `${p.type ? `ll-text_${p.type} ` : ""}`,
11
+ const Text = baseStyled.span.attrs(({ variant = "body", fontSize, color }) => ({
12
+ fontSize: fontSize ? fontSize : variant,
13
+ color: color || "neutral.c100",
13
14
  })) `
14
- ${uppercase};
15
- ${lineHeight};
16
- ${fontFamily};
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 _default: import("styled-components").FlattenSimpleInterpolation;
4
- export default _default;
4
+ export declare const textVariantStyle: Record<TextVariants, {
5
+ fontFamily: string;
6
+ lineHeight?: string | number;
7
+ fontWeight?: number;
8
+ "text-transform"?: string;
9
+ }>;