@ledgerhq/native-ui 0.1.1 → 0.5.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 (79) hide show
  1. package/README.md +21 -21
  2. package/assets/icons.d.ts +1 -0
  3. package/assets/icons.js +1 -0
  4. package/assets/logos/LedgerLiveAltRegular.d.ts +0 -1
  5. package/assets/logos/LedgerLiveRegular.d.ts +0 -1
  6. package/components/Carousel/index.d.ts +45 -0
  7. package/components/Carousel/index.js +76 -0
  8. package/components/Form/Checkbox/index.d.ts +2 -2
  9. package/components/Form/Checkbox/index.js +5 -5
  10. package/components/Form/Input/BaseInput/index.d.ts +105 -9
  11. package/components/Form/Input/BaseInput/index.js +25 -17
  12. package/components/Form/Input/LegendInput/index.d.ts +14 -3
  13. package/components/Form/Input/LegendInput/index.js +4 -3
  14. package/components/Form/Input/NumberInput/index.d.ts +16 -4
  15. package/components/Form/Input/NumberInput/index.js +17 -9
  16. package/components/Form/Input/QrCodeInput/index.d.ts +15 -4
  17. package/components/Form/Input/QrCodeInput/index.js +5 -4
  18. package/components/Form/Input/SearchInput/index.d.ts +13 -2
  19. package/components/Form/Input/SearchInput/index.js +4 -3
  20. package/components/Form/SelectableList.d.ts +17 -0
  21. package/components/Form/SelectableList.js +32 -0
  22. package/components/Form/Slider/components.js +6 -6
  23. package/components/Form/Slider/index.d.ts +2 -2
  24. package/components/Form/Slider/index.js +1 -1
  25. package/components/Form/Slider/index.native.d.ts +0 -1
  26. package/components/Form/Slider/index.native.js +2 -2
  27. package/components/Form/Switch/index.d.ts +0 -1
  28. package/components/Form/Switch/index.js +4 -4
  29. package/components/Form/Toggle/index.d.ts +0 -1
  30. package/components/Form/index.d.ts +1 -0
  31. package/components/Form/index.js +1 -0
  32. package/components/Icon/IconBox/index.js +2 -2
  33. package/components/Layout/Box/index.d.ts +11 -0
  34. package/components/Layout/Box/index.js +3 -0
  35. package/components/Layout/Flex/index.d.ts +11 -12
  36. package/components/Layout/Flex/index.js +2 -8
  37. package/components/Layout/Modals/BaseModal/index.d.ts +2 -2
  38. package/components/Layout/Modals/BaseModal/index.js +7 -7
  39. package/components/Layout/ScrollContainerHeader/Header.d.ts +0 -1
  40. package/components/Layout/ScrollContainerHeader/Header.js +1 -1
  41. package/components/Layout/Table/Row.d.ts +1 -1
  42. package/components/Layout/index.d.ts +3 -0
  43. package/components/Layout/index.js +3 -0
  44. package/components/Loader/index.d.ts +4 -1
  45. package/components/Loader/index.js +2 -2
  46. package/components/Navigation/SlideIndicator/index.js +15 -8
  47. package/components/Navigation/Stepper/index.js +13 -13
  48. package/components/Navigation/ToggleGroup/index.d.ts +8 -1
  49. package/components/Navigation/ToggleGroup/index.js +1 -1
  50. package/components/Text/getTextStyle.d.ts +10 -17
  51. package/components/Text/getTextStyle.js +24 -31
  52. package/components/Text/index.d.ts +6 -5
  53. package/components/Text/index.js +9 -3
  54. package/components/chart/index.d.ts +0 -1
  55. package/components/chart/index.js +6 -6
  56. package/components/cta/Button/getButtonStyle.js +12 -12
  57. package/components/cta/Button/index.d.ts +5 -16
  58. package/components/cta/Button/index.js +15 -16
  59. package/components/cta/Link/getLinkStyle.js +8 -8
  60. package/components/cta/Link/index.js +2 -2
  61. package/components/cta/getCtaStyle.d.ts +2 -2
  62. package/components/drawer/Notification/index.js +6 -12
  63. package/components/index.d.ts +1 -0
  64. package/components/index.js +1 -0
  65. package/components/message/Alert/index.d.ts +0 -1
  66. package/components/message/Alert/index.js +6 -6
  67. package/components/styled.d.ts +15 -0
  68. package/components/styled.js +12 -0
  69. package/components/tags/Badge/index.d.ts +2 -2
  70. package/components/tags/Badge/index.js +10 -10
  71. package/icons/Close.js +1 -1
  72. package/package.json +8 -10
  73. package/styles/InvertTheme.d.ts +0 -1
  74. package/styles/StyleProvider.d.ts +0 -9
  75. package/styles/StyleProvider.js +1 -1
  76. package/styles/helpers.d.ts +3 -1
  77. package/styles/helpers.js +4 -7
  78. package/styles/theme.d.ts +10 -34
  79. package/styles/theme.js +19 -37
@@ -3,7 +3,6 @@ import { ThemeNames } from "@ledgerhq/ui-shared";
3
3
  interface Props {
4
4
  children: React.ReactNode;
5
5
  selectedPalette?: ThemeNames;
6
- fontsPath?: string;
7
6
  }
8
7
  export declare const InvertTheme: ({ children }: Props) => React.ReactElement;
9
8
  export {};
@@ -7,15 +7,6 @@ declare type Props = {
7
7
  };
8
8
  declare module "styled-components" {
9
9
  interface DefaultTheme extends Theme {
10
- sizes: {
11
- topBarHeight: number;
12
- sideBarWidth: number;
13
- };
14
- radii: number[];
15
- fontSizes: number[];
16
- space: number[];
17
- colors: Record<string, any>;
18
- zIndexes: number[];
19
10
  }
20
11
  }
21
12
  export declare const StyleProvider: ({ children, selectedPalette, }: Props) => React.ReactElement;
@@ -3,6 +3,6 @@ import { ThemeProvider } from "styled-components/native";
3
3
  import defaultTheme from "./theme";
4
4
  import { palettes } from "@ledgerhq/ui-shared";
5
5
  export const StyleProvider = ({ children, selectedPalette, }) => {
6
- const theme = useMemo(() => (Object.assign(Object.assign({}, defaultTheme), { colors: Object.assign(Object.assign({}, defaultTheme.colors), { palette: palettes[selectedPalette] }), theme: selectedPalette })), [selectedPalette]);
6
+ const theme = useMemo(() => (Object.assign(Object.assign({}, defaultTheme), { colors: Object.assign(Object.assign(Object.assign({}, defaultTheme.colors), palettes[selectedPalette]), { palette: palettes[selectedPalette] }), theme: selectedPalette })), [selectedPalette]);
7
7
  return React.createElement(ThemeProvider, { theme: theme }, children);
8
8
  };
@@ -3,4 +3,6 @@ export declare const hex: (color: string) => string;
3
3
  export declare const darken: (c: string, a: number) => string;
4
4
  export declare const lighten: (c: string, a: number) => string;
5
5
  export declare const mix: (c: string, b: string, a: number) => string;
6
- export declare const getColor: (p: Record<string, any>, color: string) => string;
6
+ export declare const getColor: (p: {
7
+ colors: unknown;
8
+ }, color: string) => string;
package/styles/helpers.js CHANGED
@@ -5,13 +5,10 @@ export const darken = (c, a) => Color(c).darken(a).toString();
5
5
  export const lighten = (c, a) => Color(c).lighten(a).toString();
6
6
  export const mix = (c, b, a) => Color(c).mix(Color(b), a).toString();
7
7
  const get = (object, path) => {
8
- let p = path;
9
- if (typeof path === "string")
10
- p = path.split(".").filter((key) => key.length);
11
- // @ts-expect-error FIXME
12
- return p.reduce(
13
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
14
- (dive, key) => dive && dive[key], object);
8
+ const p = typeof path === "string"
9
+ ? path.split(".").filter((key) => key.length)
10
+ : path;
11
+ return p.reduce((dive, key) => dive && dive[key], object);
15
12
  };
16
13
  export const getColor = (p, color) => {
17
14
  const c = get(p.colors, color);
package/styles/theme.d.ts CHANGED
@@ -1,39 +1,10 @@
1
+ import { ColorPalette } from "@ledgerhq/ui-shared";
1
2
  export declare const space: number[];
2
- export declare const fontSizes: number[];
3
+ export declare type TextVariants = "h1" | "h2" | "h3" | "h4" | "large" | "body" | "bodyLineHeight" | "paragraph" | "paragraphLineHeight" | "small" | "subtitle" | "tiny";
4
+ export declare type ThemeScale<Type, Aliases extends string> = Array<Type> & Record<Aliases, Type>;
5
+ export declare const fontSizes: ThemeScale<number, TextVariants>;
3
6
  export declare const radii: number[];
4
7
  export declare const zIndexes: number[];
5
- declare const exportedColors: {
6
- transparent: string;
7
- pearl: string;
8
- alertRed: string;
9
- warning: string;
10
- black: string;
11
- dark: string;
12
- separator: string;
13
- fog: string;
14
- gold: string;
15
- graphite: string;
16
- grey: string;
17
- identity: string;
18
- lightFog: string;
19
- sliderGrey: string;
20
- lightGraphite: string;
21
- lightGrey: string;
22
- starYellow: string;
23
- orange: string;
24
- positiveGreen: string;
25
- greenPill: string;
26
- smoke: string;
27
- wallet: string;
28
- blueTransparentBackground: string;
29
- pillActiveBackground: string;
30
- lightGreen: string;
31
- lightRed: string;
32
- lightWarning: string;
33
- white: string;
34
- experimentalBlue: string;
35
- };
36
- export { exportedColors as colors };
37
8
  export declare type Theme = {
38
9
  theme: string;
39
10
  sizes: {
@@ -43,7 +14,12 @@ export declare type Theme = {
43
14
  radii: number[];
44
15
  fontSizes: number[];
45
16
  space: number[];
46
- colors: Record<string, any>;
17
+ colors: ColorPalette & {
18
+ /**
19
+ * @deprecated Do not use the .palette prefix anymore!
20
+ */
21
+ palette: ColorPalette;
22
+ };
47
23
  zIndexes: number[];
48
24
  };
49
25
  declare const theme: Theme;
package/styles/theme.js CHANGED
@@ -1,42 +1,24 @@
1
+ import { palettes } from "@ledgerhq/ui-shared";
2
+ // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
1
3
  export const space = [0, 2, 4, 8, 12, 14, 16, 24, 32, 40, 48, 64, 80, 96, 120];
2
- export const fontSizes = [8, 9, 10, 12, 13, 16, 18, 22, 32];
4
+ // 0 1 2 3 4 5 6 7 8
5
+ export const fontSizes = [10, 11, 12, 13, 14, 16, 18, 24, 28];
6
+ [
7
+ fontSizes.tiny,
8
+ fontSizes.subtitle,
9
+ fontSizes.small,
10
+ fontSizes.paragraph,
11
+ fontSizes.body,
12
+ fontSizes.large,
13
+ fontSizes.h3,
14
+ fontSizes.h2,
15
+ fontSizes.h1,
16
+ ] = fontSizes;
17
+ fontSizes.bodyLineHeight = fontSizes.body;
18
+ fontSizes.paragraphLineHeight = fontSizes.paragraph;
19
+ fontSizes.h4 = fontSizes.h3;
3
20
  export const radii = [0, 4, 8];
4
21
  export const zIndexes = [-1, 0, 1, 9, 10, 90, 100, 900, 1000];
5
- // @Rebrand remove this
6
- const colors = {
7
- transparent: "transparent",
8
- pearl: "#ff0000",
9
- alertRed: "#ea2e49",
10
- warning: "#f57f17",
11
- black: "#000000",
12
- dark: "#142533",
13
- separator: "#aaaaaa",
14
- fog: "#d8d8d8",
15
- gold: "#d6ad42",
16
- graphite: "#767676",
17
- grey: "#999999",
18
- identity: "#41ccb4",
19
- lightFog: "#eeeeee",
20
- sliderGrey: "#F0EFF1",
21
- lightGraphite: "#fafafa",
22
- lightGrey: "#f9f9f9",
23
- starYellow: "#FFD24A",
24
- orange: "#ffa726",
25
- positiveGreen: "rgba(102, 190, 84, 1)",
26
- greenPill: "#41ccb4",
27
- smoke: "#666666",
28
- wallet: "#6490f1",
29
- blueTransparentBackground: "rgba(100, 144, 241, 0.15)",
30
- pillActiveBackground: "rgba(100, 144, 241, 0.1)",
31
- lightGreen: "rgba(102, 190, 84, 0.1)",
32
- lightRed: "rgba(234, 46, 73, 0.1)",
33
- lightWarning: "rgba(245, 127, 23, 0.1)",
34
- white: "#ffffff",
35
- experimentalBlue: "#165edb",
36
- };
37
- // prettier-ignore
38
- const exportedColors = colors;
39
- export { exportedColors as colors };
40
22
  const theme = {
41
23
  theme: "light",
42
24
  sizes: {
@@ -46,7 +28,7 @@ const theme = {
46
28
  radii,
47
29
  fontSizes,
48
30
  space,
49
- colors,
31
+ colors: Object.assign(Object.assign({}, palettes.light), { palette: palettes.light }),
50
32
  zIndexes,
51
33
  };
52
34
  export default theme;