@react-native-rethemed/radix-ui-tokens 0.1.0 → 0.1.2
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 +2 -0
- package/dist/index.cjs +8 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +3 -0
- package/dist/theme.cjs +148 -0
- package/dist/{esm/theme.d.ts → theme.d.cts} +18 -16
- package/dist/{cjs/theme.d.ts → theme.d.mts} +18 -16
- package/dist/theme.mjs +146 -0
- package/dist/tokens.gen.cjs +3708 -0
- package/dist/tokens.gen.d.cts +3562 -0
- package/dist/tokens.gen.d.mts +3562 -0
- package/dist/tokens.gen.mjs +3696 -0
- package/package.json +13 -15
- package/dist/cjs/index.d.ts +0 -2
- package/dist/cjs/index.js +0 -10
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/theme.js +0 -161
- package/dist/cjs/tokens.gen.d.ts +0 -3695
- package/dist/cjs/tokens.gen.js +0 -1056
- package/dist/esm/index.d.ts +0 -2
- package/dist/esm/index.js +0 -2
- package/dist/esm/package.json +0 -1
- package/dist/esm/theme.js +0 -156
- package/dist/esm/tokens.gen.d.ts +0 -3695
- package/dist/esm/tokens.gen.js +0 -1053
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @react-native-rethemed/radix-ui-tokens
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@react-native-rethemed/radix-ui-tokens)
|
|
4
|
+
|
|
3
5
|
Radix UI Themes tokens (Radix Colors scales, typography, radii, shadows) for React Native, ready for [react-native-rethemed](https://github.com/manakuro/react-native-rethemed).
|
|
4
6
|
|
|
5
7
|
Radix Themes configured like `<Theme>`: accent / gray scales (12 steps + alpha) for light and dark, panel colors, space, radius, the Text / Heading presets and shadows.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_tokens_gen = require("./tokens.gen.cjs");
|
|
3
|
+
const require_theme = require("./theme.cjs");
|
|
4
|
+
exports.createRadixUiTheme = require_theme.createRadixUiTheme;
|
|
5
|
+
exports.fontWeights = require_tokens_gen.fontWeights;
|
|
6
|
+
exports.getMatchingGrayColor = require_theme.getMatchingGrayColor;
|
|
7
|
+
exports.radixUiTheme = require_theme.radixUiTheme;
|
|
8
|
+
exports.scales = require_tokens_gen.scales;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { fontWeights, scales } from "./tokens.gen.cjs";
|
|
2
|
+
import { AccentColor, GrayColor, Radius, RadixUiThemeOptions, ScaleName, Scaling, createRadixUiTheme, getMatchingGrayColor, radixUiTheme } from "./theme.cjs";
|
|
3
|
+
export { type AccentColor, type GrayColor, type Radius, type RadixUiThemeOptions, type ScaleName, type Scaling, createRadixUiTheme, fontWeights, getMatchingGrayColor, radixUiTheme, scales };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { fontWeights, scales } from "./tokens.gen.mjs";
|
|
2
|
+
import { AccentColor, GrayColor, Radius, RadixUiThemeOptions, ScaleName, Scaling, createRadixUiTheme, getMatchingGrayColor, radixUiTheme } from "./theme.mjs";
|
|
3
|
+
export { type AccentColor, type GrayColor, type Radius, type RadixUiThemeOptions, type ScaleName, type Scaling, createRadixUiTheme, fontWeights, getMatchingGrayColor, radixUiTheme, scales };
|
package/dist/index.mjs
ADDED
package/dist/theme.cjs
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
const require_tokens_gen = require("./tokens.gen.cjs");
|
|
2
|
+
let _react_native_rethemed_core_config = require("@react-native-rethemed/core/config");
|
|
3
|
+
//#region src/theme.ts
|
|
4
|
+
/**
|
|
5
|
+
* The gray `grayColor: 'auto'` picks for an accent, as Radix Themes'
|
|
6
|
+
* `getMatchingGrayColor` does.
|
|
7
|
+
*/
|
|
8
|
+
function getMatchingGrayColor(accentColor) {
|
|
9
|
+
switch (accentColor) {
|
|
10
|
+
case "tomato":
|
|
11
|
+
case "red":
|
|
12
|
+
case "ruby":
|
|
13
|
+
case "crimson":
|
|
14
|
+
case "pink":
|
|
15
|
+
case "plum":
|
|
16
|
+
case "purple":
|
|
17
|
+
case "violet": return "mauve";
|
|
18
|
+
case "iris":
|
|
19
|
+
case "indigo":
|
|
20
|
+
case "blue":
|
|
21
|
+
case "sky":
|
|
22
|
+
case "cyan": return "slate";
|
|
23
|
+
case "teal":
|
|
24
|
+
case "jade":
|
|
25
|
+
case "mint":
|
|
26
|
+
case "green": return "sage";
|
|
27
|
+
case "grass":
|
|
28
|
+
case "lime": return "olive";
|
|
29
|
+
case "yellow":
|
|
30
|
+
case "amber":
|
|
31
|
+
case "orange":
|
|
32
|
+
case "brown":
|
|
33
|
+
case "gold":
|
|
34
|
+
case "bronze": return "sand";
|
|
35
|
+
case "gray": return "gray";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const round = (n, digits = 2) => {
|
|
39
|
+
const factor = 10 ** digits;
|
|
40
|
+
return Math.round(n * factor) / factor;
|
|
41
|
+
};
|
|
42
|
+
const scaled = (table, factor) => Object.fromEntries(Object.entries(table).map(([key, value]) => [key, round(value * factor)]));
|
|
43
|
+
/** `'gray.a2'` → that step of the theme's gray in `scheme`; hex as-is. */
|
|
44
|
+
function grayRef(value, gray, scheme) {
|
|
45
|
+
return value.startsWith("gray.") ? gray[value.slice(5)][scheme] : value;
|
|
46
|
+
}
|
|
47
|
+
/** `#rrggbbaa` → `{ color: '#rrggbb', opacity }`. */
|
|
48
|
+
function splitAlpha(hex) {
|
|
49
|
+
if (hex.length !== 9) return {
|
|
50
|
+
color: hex,
|
|
51
|
+
opacity: 1
|
|
52
|
+
};
|
|
53
|
+
return {
|
|
54
|
+
color: hex.slice(0, 7),
|
|
55
|
+
opacity: round(Number.parseInt(hex.slice(7), 16) / 255, 3)
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** Android elevation per shadow level; CSS has none, so picked by hand. */
|
|
59
|
+
const SHADOW_ELEVATIONS = {
|
|
60
|
+
2: 2,
|
|
61
|
+
3: 4,
|
|
62
|
+
4: 8,
|
|
63
|
+
5: 12,
|
|
64
|
+
6: 16
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* A Radix Themes theme, configured like `<Theme>`:
|
|
68
|
+
*
|
|
69
|
+
* ```ts
|
|
70
|
+
* createRadixUiTheme({ accentColor: 'blue', radius: 'large', colors: ['red'] })
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* - `semanticTokens.colors`: `accent` and `gray` (each `1`–`12`, `a1`–`a12`,
|
|
74
|
+
* `contrast`, `surface`, `indicator`, `track`), `color` (`background`,
|
|
75
|
+
* `panel-solid`, `panel-translucent`, `surface`, `overlay`), plus the
|
|
76
|
+
* scales in `colors`. Every one switches with light/dark.
|
|
77
|
+
* - `spacing` (`1`–`9`), `fontSizes` (`1`–`9`) and `radii` (`1`–`6`,
|
|
78
|
+
* `full`) follow `scaling` and `radius`.
|
|
79
|
+
* - Text presets: `themed.text.text[3]()` is `<Text size="3">` and
|
|
80
|
+
* `themed.text.heading[3]()` is `<Heading size="3">` (bold, tighter line
|
|
81
|
+
* height), both with Radix's letter spacing.
|
|
82
|
+
* - `shadows` `2`–`6`: one layer each, light-mode values; `1` is inset and
|
|
83
|
+
* left out.
|
|
84
|
+
*/
|
|
85
|
+
function createRadixUiTheme(options = {}) {
|
|
86
|
+
const { accentColor = "indigo", grayColor = "auto", radius = "medium", scaling = "100%", colors = [] } = options;
|
|
87
|
+
const factor = require_tokens_gen.scalings[scaling];
|
|
88
|
+
const gray = require_tokens_gen.scales[grayColor === "auto" ? getMatchingGrayColor(accentColor) : grayColor];
|
|
89
|
+
const sizes = require_tokens_gen.fontSizes;
|
|
90
|
+
const spacingsEm = require_tokens_gen.letterSpacings;
|
|
91
|
+
const preset = (size, lineHeight, extraEm = 0) => {
|
|
92
|
+
const fontSize = round(sizes[size] * factor);
|
|
93
|
+
return {
|
|
94
|
+
fontSize,
|
|
95
|
+
lineHeight: round(lineHeight * factor),
|
|
96
|
+
letterSpacing: round((spacingsEm[size] + extraEm) * fontSize, 3)
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
return (0, _react_native_rethemed_core_config.defineTheme)({
|
|
100
|
+
tokens: {
|
|
101
|
+
spacing: scaled(require_tokens_gen.space, factor),
|
|
102
|
+
radii: {
|
|
103
|
+
...scaled(require_tokens_gen.radii, factor * require_tokens_gen.radiusFactors[radius]),
|
|
104
|
+
full: require_tokens_gen.radiusFull[radius]
|
|
105
|
+
},
|
|
106
|
+
fontSizes: scaled(require_tokens_gen.fontSizes, factor),
|
|
107
|
+
fontWeights: require_tokens_gen.fontWeights,
|
|
108
|
+
shadows: Object.fromEntries(Object.entries(require_tokens_gen.shadows).map(([key, layer]) => {
|
|
109
|
+
const { color, opacity } = splitAlpha(grayRef(layer.color, gray, "light"));
|
|
110
|
+
return [key, {
|
|
111
|
+
shadowColor: color,
|
|
112
|
+
shadowOffset: {
|
|
113
|
+
width: layer.x,
|
|
114
|
+
height: layer.y
|
|
115
|
+
},
|
|
116
|
+
shadowOpacity: opacity,
|
|
117
|
+
shadowRadius: layer.blur / 2,
|
|
118
|
+
elevation: SHADOW_ELEVATIONS[key]
|
|
119
|
+
}];
|
|
120
|
+
}))
|
|
121
|
+
},
|
|
122
|
+
semanticTokens: {
|
|
123
|
+
colors: {
|
|
124
|
+
accent: require_tokens_gen.scales[accentColor],
|
|
125
|
+
gray,
|
|
126
|
+
color: Object.fromEntries(Object.entries(require_tokens_gen.backgroundColors).map(([key, value]) => [key, {
|
|
127
|
+
light: grayRef(value.light, gray, "light"),
|
|
128
|
+
dark: grayRef(value.dark, gray, "dark")
|
|
129
|
+
}])),
|
|
130
|
+
...Object.fromEntries(colors.map((name) => [name, require_tokens_gen.scales[name]]))
|
|
131
|
+
},
|
|
132
|
+
text: {
|
|
133
|
+
text: Object.fromEntries(Object.entries(require_tokens_gen.lineHeights).map(([size, lineHeight]) => [size, preset(size, lineHeight)])),
|
|
134
|
+
heading: Object.fromEntries(Object.entries(require_tokens_gen.headingLineHeights).map(([size, lineHeight]) => [size, {
|
|
135
|
+
...preset(size, lineHeight, 0),
|
|
136
|
+
fontWeight: "bold"
|
|
137
|
+
}]))
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
defaults: { fontSize: "3" }
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/** Radix Themes' defaults: `indigo` accent, `slate` gray, `medium` radius, `100%` scaling. */
|
|
144
|
+
const radixUiTheme = createRadixUiTheme();
|
|
145
|
+
//#endregion
|
|
146
|
+
exports.createRadixUiTheme = createRadixUiTheme;
|
|
147
|
+
exports.getMatchingGrayColor = getMatchingGrayColor;
|
|
148
|
+
exports.radixUiTheme = radixUiTheme;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { radiusFactors, scales, scalings } from "./tokens.gen.cjs";
|
|
2
|
+
import { ThemeConfig } from "@react-native-rethemed/core/config";
|
|
3
|
+
//#region src/theme.d.ts
|
|
3
4
|
/** Every Radix color scale. */
|
|
4
5
|
export type ScaleName = keyof typeof scales;
|
|
5
6
|
/** `<Theme accentColor>`: every scale except the five tinted grays. */
|
|
@@ -9,20 +10,20 @@ export type GrayColor = 'auto' | Extract<ScaleName, 'gray' | 'mauve' | 'slate' |
|
|
|
9
10
|
export type Radius = keyof typeof radiusFactors;
|
|
10
11
|
export type Scaling = keyof typeof scalings;
|
|
11
12
|
export type RadixUiThemeOptions = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
/** Default `indigo`. */
|
|
14
|
+
accentColor?: AccentColor;
|
|
15
|
+
/** Default `auto`. */
|
|
16
|
+
grayColor?: GrayColor;
|
|
17
|
+
/** Default `medium`. */
|
|
18
|
+
radius?: Radius;
|
|
19
|
+
/** Default `100%`. */
|
|
20
|
+
scaling?: Scaling;
|
|
21
|
+
/**
|
|
22
|
+
* More scales to use by name (`'red.9'`, `'green.a3'`), e.g. for status
|
|
23
|
+
* colors. `accent`, `gray` and `color` are always included; every scale
|
|
24
|
+
* would add ~870 colors to the generated types, so pick what you use.
|
|
25
|
+
*/
|
|
26
|
+
colors?: Exclude<ScaleName, 'gray'>[];
|
|
26
27
|
};
|
|
27
28
|
/**
|
|
28
29
|
* The gray `grayColor: 'auto'` picks for an accent, as Radix Themes'
|
|
@@ -51,3 +52,4 @@ export declare function getMatchingGrayColor(accentColor: AccentColor): Exclude<
|
|
|
51
52
|
export declare function createRadixUiTheme(options?: RadixUiThemeOptions): ThemeConfig;
|
|
52
53
|
/** Radix Themes' defaults: `indigo` accent, `slate` gray, `medium` radius, `100%` scaling. */
|
|
53
54
|
export declare const radixUiTheme: ThemeConfig;
|
|
55
|
+
//#endregion
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { radiusFactors, scales, scalings } from "./tokens.gen.mjs";
|
|
2
|
+
import { ThemeConfig } from "@react-native-rethemed/core/config";
|
|
3
|
+
//#region src/theme.d.ts
|
|
3
4
|
/** Every Radix color scale. */
|
|
4
5
|
export type ScaleName = keyof typeof scales;
|
|
5
6
|
/** `<Theme accentColor>`: every scale except the five tinted grays. */
|
|
@@ -9,20 +10,20 @@ export type GrayColor = 'auto' | Extract<ScaleName, 'gray' | 'mauve' | 'slate' |
|
|
|
9
10
|
export type Radius = keyof typeof radiusFactors;
|
|
10
11
|
export type Scaling = keyof typeof scalings;
|
|
11
12
|
export type RadixUiThemeOptions = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
/** Default `indigo`. */
|
|
14
|
+
accentColor?: AccentColor;
|
|
15
|
+
/** Default `auto`. */
|
|
16
|
+
grayColor?: GrayColor;
|
|
17
|
+
/** Default `medium`. */
|
|
18
|
+
radius?: Radius;
|
|
19
|
+
/** Default `100%`. */
|
|
20
|
+
scaling?: Scaling;
|
|
21
|
+
/**
|
|
22
|
+
* More scales to use by name (`'red.9'`, `'green.a3'`), e.g. for status
|
|
23
|
+
* colors. `accent`, `gray` and `color` are always included; every scale
|
|
24
|
+
* would add ~870 colors to the generated types, so pick what you use.
|
|
25
|
+
*/
|
|
26
|
+
colors?: Exclude<ScaleName, 'gray'>[];
|
|
26
27
|
};
|
|
27
28
|
/**
|
|
28
29
|
* The gray `grayColor: 'auto'` picks for an accent, as Radix Themes'
|
|
@@ -51,3 +52,4 @@ export declare function getMatchingGrayColor(accentColor: AccentColor): Exclude<
|
|
|
51
52
|
export declare function createRadixUiTheme(options?: RadixUiThemeOptions): ThemeConfig;
|
|
52
53
|
/** Radix Themes' defaults: `indigo` accent, `slate` gray, `medium` radius, `100%` scaling. */
|
|
53
54
|
export declare const radixUiTheme: ThemeConfig;
|
|
55
|
+
//#endregion
|
package/dist/theme.mjs
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { backgroundColors, fontSizes, fontWeights, headingLineHeights, letterSpacings, lineHeights, radii, radiusFactors, radiusFull, scales, scalings, shadows, space } from "./tokens.gen.mjs";
|
|
2
|
+
import { defineTheme } from "@react-native-rethemed/core/config";
|
|
3
|
+
//#region src/theme.ts
|
|
4
|
+
/**
|
|
5
|
+
* The gray `grayColor: 'auto'` picks for an accent, as Radix Themes'
|
|
6
|
+
* `getMatchingGrayColor` does.
|
|
7
|
+
*/
|
|
8
|
+
function getMatchingGrayColor(accentColor) {
|
|
9
|
+
switch (accentColor) {
|
|
10
|
+
case "tomato":
|
|
11
|
+
case "red":
|
|
12
|
+
case "ruby":
|
|
13
|
+
case "crimson":
|
|
14
|
+
case "pink":
|
|
15
|
+
case "plum":
|
|
16
|
+
case "purple":
|
|
17
|
+
case "violet": return "mauve";
|
|
18
|
+
case "iris":
|
|
19
|
+
case "indigo":
|
|
20
|
+
case "blue":
|
|
21
|
+
case "sky":
|
|
22
|
+
case "cyan": return "slate";
|
|
23
|
+
case "teal":
|
|
24
|
+
case "jade":
|
|
25
|
+
case "mint":
|
|
26
|
+
case "green": return "sage";
|
|
27
|
+
case "grass":
|
|
28
|
+
case "lime": return "olive";
|
|
29
|
+
case "yellow":
|
|
30
|
+
case "amber":
|
|
31
|
+
case "orange":
|
|
32
|
+
case "brown":
|
|
33
|
+
case "gold":
|
|
34
|
+
case "bronze": return "sand";
|
|
35
|
+
case "gray": return "gray";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const round = (n, digits = 2) => {
|
|
39
|
+
const factor = 10 ** digits;
|
|
40
|
+
return Math.round(n * factor) / factor;
|
|
41
|
+
};
|
|
42
|
+
const scaled = (table, factor) => Object.fromEntries(Object.entries(table).map(([key, value]) => [key, round(value * factor)]));
|
|
43
|
+
/** `'gray.a2'` → that step of the theme's gray in `scheme`; hex as-is. */
|
|
44
|
+
function grayRef(value, gray, scheme) {
|
|
45
|
+
return value.startsWith("gray.") ? gray[value.slice(5)][scheme] : value;
|
|
46
|
+
}
|
|
47
|
+
/** `#rrggbbaa` → `{ color: '#rrggbb', opacity }`. */
|
|
48
|
+
function splitAlpha(hex) {
|
|
49
|
+
if (hex.length !== 9) return {
|
|
50
|
+
color: hex,
|
|
51
|
+
opacity: 1
|
|
52
|
+
};
|
|
53
|
+
return {
|
|
54
|
+
color: hex.slice(0, 7),
|
|
55
|
+
opacity: round(Number.parseInt(hex.slice(7), 16) / 255, 3)
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** Android elevation per shadow level; CSS has none, so picked by hand. */
|
|
59
|
+
const SHADOW_ELEVATIONS = {
|
|
60
|
+
2: 2,
|
|
61
|
+
3: 4,
|
|
62
|
+
4: 8,
|
|
63
|
+
5: 12,
|
|
64
|
+
6: 16
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* A Radix Themes theme, configured like `<Theme>`:
|
|
68
|
+
*
|
|
69
|
+
* ```ts
|
|
70
|
+
* createRadixUiTheme({ accentColor: 'blue', radius: 'large', colors: ['red'] })
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* - `semanticTokens.colors`: `accent` and `gray` (each `1`–`12`, `a1`–`a12`,
|
|
74
|
+
* `contrast`, `surface`, `indicator`, `track`), `color` (`background`,
|
|
75
|
+
* `panel-solid`, `panel-translucent`, `surface`, `overlay`), plus the
|
|
76
|
+
* scales in `colors`. Every one switches with light/dark.
|
|
77
|
+
* - `spacing` (`1`–`9`), `fontSizes` (`1`–`9`) and `radii` (`1`–`6`,
|
|
78
|
+
* `full`) follow `scaling` and `radius`.
|
|
79
|
+
* - Text presets: `themed.text.text[3]()` is `<Text size="3">` and
|
|
80
|
+
* `themed.text.heading[3]()` is `<Heading size="3">` (bold, tighter line
|
|
81
|
+
* height), both with Radix's letter spacing.
|
|
82
|
+
* - `shadows` `2`–`6`: one layer each, light-mode values; `1` is inset and
|
|
83
|
+
* left out.
|
|
84
|
+
*/
|
|
85
|
+
function createRadixUiTheme(options = {}) {
|
|
86
|
+
const { accentColor = "indigo", grayColor = "auto", radius = "medium", scaling = "100%", colors = [] } = options;
|
|
87
|
+
const factor = scalings[scaling];
|
|
88
|
+
const gray = scales[grayColor === "auto" ? getMatchingGrayColor(accentColor) : grayColor];
|
|
89
|
+
const sizes = fontSizes;
|
|
90
|
+
const spacingsEm = letterSpacings;
|
|
91
|
+
const preset = (size, lineHeight, extraEm = 0) => {
|
|
92
|
+
const fontSize = round(sizes[size] * factor);
|
|
93
|
+
return {
|
|
94
|
+
fontSize,
|
|
95
|
+
lineHeight: round(lineHeight * factor),
|
|
96
|
+
letterSpacing: round((spacingsEm[size] + extraEm) * fontSize, 3)
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
return defineTheme({
|
|
100
|
+
tokens: {
|
|
101
|
+
spacing: scaled(space, factor),
|
|
102
|
+
radii: {
|
|
103
|
+
...scaled(radii, factor * radiusFactors[radius]),
|
|
104
|
+
full: radiusFull[radius]
|
|
105
|
+
},
|
|
106
|
+
fontSizes: scaled(fontSizes, factor),
|
|
107
|
+
fontWeights,
|
|
108
|
+
shadows: Object.fromEntries(Object.entries(shadows).map(([key, layer]) => {
|
|
109
|
+
const { color, opacity } = splitAlpha(grayRef(layer.color, gray, "light"));
|
|
110
|
+
return [key, {
|
|
111
|
+
shadowColor: color,
|
|
112
|
+
shadowOffset: {
|
|
113
|
+
width: layer.x,
|
|
114
|
+
height: layer.y
|
|
115
|
+
},
|
|
116
|
+
shadowOpacity: opacity,
|
|
117
|
+
shadowRadius: layer.blur / 2,
|
|
118
|
+
elevation: SHADOW_ELEVATIONS[key]
|
|
119
|
+
}];
|
|
120
|
+
}))
|
|
121
|
+
},
|
|
122
|
+
semanticTokens: {
|
|
123
|
+
colors: {
|
|
124
|
+
accent: scales[accentColor],
|
|
125
|
+
gray,
|
|
126
|
+
color: Object.fromEntries(Object.entries(backgroundColors).map(([key, value]) => [key, {
|
|
127
|
+
light: grayRef(value.light, gray, "light"),
|
|
128
|
+
dark: grayRef(value.dark, gray, "dark")
|
|
129
|
+
}])),
|
|
130
|
+
...Object.fromEntries(colors.map((name) => [name, scales[name]]))
|
|
131
|
+
},
|
|
132
|
+
text: {
|
|
133
|
+
text: Object.fromEntries(Object.entries(lineHeights).map(([size, lineHeight]) => [size, preset(size, lineHeight)])),
|
|
134
|
+
heading: Object.fromEntries(Object.entries(headingLineHeights).map(([size, lineHeight]) => [size, {
|
|
135
|
+
...preset(size, lineHeight, 0),
|
|
136
|
+
fontWeight: "bold"
|
|
137
|
+
}]))
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
defaults: { fontSize: "3" }
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/** Radix Themes' defaults: `indigo` accent, `slate` gray, `medium` radius, `100%` scaling. */
|
|
144
|
+
const radixUiTheme = createRadixUiTheme();
|
|
145
|
+
//#endregion
|
|
146
|
+
export { createRadixUiTheme, getMatchingGrayColor, radixUiTheme };
|