@ledgerhq/native-ui 0.40.0-nightly.0 → 0.40.0-nightly.1
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.
|
@@ -26,6 +26,7 @@ declare const overrideColor: {
|
|
|
26
26
|
export type Tokens = Record<string, string | number>;
|
|
27
27
|
type ColorToken = `colors-${keyof ModeColors}` | `colors-${keyof typeof overrideColor.light}` | `colors-${keyof typeof overrideColor.dark}`;
|
|
28
28
|
type OtherToken = keyof (SpacingScale & typeof overrideOther);
|
|
29
|
-
|
|
29
|
+
type Theme = "dark" | "light";
|
|
30
|
+
export declare const useTokens: ((theme: Theme, usedTokens: Array<ColorToken | OtherToken>) => Tokens) & import("lodash").MemoizedFunction;
|
|
30
31
|
export {};
|
|
31
32
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pre-ldls/libs/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAe,UAAU,EAAW,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGjF,QAAA,MAAM,aAAa;;;;;;;;;;;CAWT,CAAC;AAEX,QAAA,MAAM,aAAa;;;;;;;;;;CAUT,CAAC;AAEX,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pre-ldls/libs/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAe,UAAU,EAAW,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGjF,QAAA,MAAM,aAAa;;;;;;;;;;;CAWT,CAAC;AAEX,QAAA,MAAM,aAAa;;;;;;;;;;CAUT,CAAC;AAEX,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;AACrD,KAAK,UAAU,GACX,UAAU,MAAM,UAAU,EAAE,GAC5B,UAAU,MAAM,OAAO,aAAa,CAAC,KAAK,EAAE,GAC5C,UAAU,MAAM,OAAO,aAAa,CAAC,IAAI,EAAE,CAAC;AAEhD,KAAK,UAAU,GAAG,MAAM,CAAC,YAAY,GAAG,OAAO,aAAa,CAAC,CAAC;AAC9D,KAAK,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;AAY9B,eAAO,MAAM,SAAS,WACZ,KAAK,cAAc,MAAM,UAAU,GAAG,UAAU,CAAC,gDA2B1D,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import memoize from "lodash/memoize";
|
|
2
2
|
import { dark, light, spacing } from "./design-tokens";
|
|
3
|
-
//
|
|
3
|
+
// Missing overrides
|
|
4
4
|
const overrideOther = {
|
|
5
5
|
"radius-s": "8px",
|
|
6
6
|
"radius-xs": "4px",
|
|
@@ -27,19 +27,24 @@ const overrideColor = {
|
|
|
27
27
|
function pxToNumber(value) {
|
|
28
28
|
return Number(value.replace("px", ""));
|
|
29
29
|
}
|
|
30
|
+
function getThemeColors(theme) {
|
|
31
|
+
const baseColors = theme === "dark" ? dark : light;
|
|
32
|
+
const overrides = overrideColor[theme];
|
|
33
|
+
return { ...baseColors, ...overrides };
|
|
34
|
+
}
|
|
30
35
|
export const useTokens = memoize((theme, usedTokens) => {
|
|
36
|
+
if (!usedTokens.length)
|
|
37
|
+
return {};
|
|
31
38
|
const usedSet = new Set(usedTokens);
|
|
32
|
-
const colors = {
|
|
33
|
-
dark: { ...dark, ...overrideColor.dark },
|
|
34
|
-
light: { ...light, ...overrideColor.light },
|
|
35
|
-
}[theme];
|
|
36
39
|
const tokens = {};
|
|
40
|
+
const colors = getThemeColors(theme);
|
|
37
41
|
Object.entries(colors).forEach(([key, value]) => {
|
|
38
42
|
const colorKey = `colors-${key}`;
|
|
39
43
|
if (usedSet.has(colorKey)) {
|
|
40
44
|
tokens[colorKey] = value;
|
|
41
45
|
}
|
|
42
46
|
});
|
|
47
|
+
// Add spacing and other tokens
|
|
43
48
|
[spacing, overrideOther].forEach((obj) => {
|
|
44
49
|
Object.entries(obj).forEach(([key, value]) => {
|
|
45
50
|
if (usedSet.has(key)) {
|
|
@@ -48,4 +53,6 @@ export const useTokens = memoize((theme, usedTokens) => {
|
|
|
48
53
|
});
|
|
49
54
|
});
|
|
50
55
|
return tokens;
|
|
51
|
-
}
|
|
56
|
+
},
|
|
57
|
+
// Simple cache key
|
|
58
|
+
(theme, usedTokens) => `${theme}-${usedTokens.sort().join(",")}`);
|