@haklex/rich-style-token 0.0.64 → 0.0.66
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 +59 -147
- package/dist/index.mjs +9 -187
- package/dist/portal-theme.d.ts +5 -5
- package/dist/portal-theme.d.ts.map +1 -1
- package/dist/styles.d.ts +5 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.mjs +193 -0
- package/package.json +10 -1
- package/LICENSE +0 -28
package/README.md
CHANGED
|
@@ -1,181 +1,93 @@
|
|
|
1
1
|
# @haklex/rich-style-token
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Design tokens, CSS variables, and variant presets for the Haklex rich editor theme system.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
pnpm add @haklex/rich-style-token
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Peer Dependencies
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export const container = style({
|
|
18
|
-
color: vars.color.text,
|
|
19
|
-
padding: vars.spacing.md,
|
|
20
|
-
borderRadius: vars.borderRadius.md,
|
|
21
|
-
})
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## 运行时颜色覆写
|
|
13
|
+
| Package | Version |
|
|
14
|
+
| --- | --- |
|
|
15
|
+
| `react` | `>=19` |
|
|
25
16
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
### 方式一:`createThemeStyle`(类型安全)
|
|
17
|
+
## Usage
|
|
29
18
|
|
|
30
19
|
```tsx
|
|
31
|
-
import { createThemeStyle } from '@haklex/rich-style-token'
|
|
32
|
-
|
|
33
|
-
const style = createThemeStyle({
|
|
34
|
-
color: {
|
|
35
|
-
accent: '#0ea5e9',
|
|
36
|
-
text: '#0c4a6e',
|
|
37
|
-
bg: '#f0f9ff',
|
|
38
|
-
},
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
// CSS 变量向下级联,所有子组件自动生效
|
|
42
|
-
<div style={style}>
|
|
43
|
-
<RichEditor />
|
|
44
|
-
</div>
|
|
45
|
-
```
|
|
20
|
+
import { createThemeStyle, articleTheme, vars } from '@haklex/rich-style-token'
|
|
21
|
+
import { PortalThemeProvider } from '@haklex/rich-style-token'
|
|
46
22
|
|
|
47
|
-
|
|
23
|
+
// Generate inline style object from a theme
|
|
24
|
+
const style = createThemeStyle(articleTheme)
|
|
48
25
|
|
|
49
|
-
|
|
26
|
+
// Use CSS variables in your styles
|
|
27
|
+
// vars.fontSize, vars.lineHeight, vars.fontFamily, etc.
|
|
50
28
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
--rc-bg: #f0f9ff;
|
|
56
|
-
}
|
|
29
|
+
// Provide portal theme context for overlays
|
|
30
|
+
<PortalThemeProvider theme="light" variant="article">
|
|
31
|
+
{children}
|
|
32
|
+
</PortalThemeProvider>
|
|
57
33
|
```
|
|
58
34
|
|
|
59
|
-
|
|
35
|
+
## Exports
|
|
60
36
|
|
|
61
|
-
|
|
62
|
-
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
63
|
-
| **Color** | `--rc-text`, `--rc-text-secondary`, `--rc-bg`, `--rc-bg-secondary`, `--rc-border`, `--rc-accent`, `--rc-accent-light`, `--rc-link`, `--rc-code-text`, `--rc-code-bg`, `--rc-quote-border`, `--rc-quote-bg`, `--rc-alert-info`, `--rc-alert-warning`, `--rc-alert-tip`, `--rc-alert-caution`, `--rc-alert-important` |
|
|
64
|
-
| **Spacing** | `--rc-space-xs`, `--rc-space-sm`, `--rc-space-md`, `--rc-space-lg`, `--rc-space-xl` |
|
|
65
|
-
| **Typography** | `--rc-font-family`, `--rc-font-mono`, `--rc-font-size-2xs`, `--rc-font-size-xs`, `--rc-font-size-sm`, `--rc-font-size-md`, `--rc-font-size-lg`, `--rc-font-size-base`, `--rc-font-size-small`, `--rc-line-height`, `--rc-line-height-tight` |
|
|
66
|
-
| **Border Radius** | `--rc-radius-sm`, `--rc-radius-md`, `--rc-radius-lg` |
|
|
37
|
+
### Theme Construction
|
|
67
38
|
|
|
68
|
-
|
|
39
|
+
| Export | Description |
|
|
40
|
+
| --- | --- |
|
|
41
|
+
| `createThemeStyle(tokens)` | Generate a CSS variable style object from theme tokens |
|
|
69
42
|
|
|
70
|
-
|
|
71
|
-
// CSS 变量契约
|
|
72
|
-
export { vars } from './vars.css'
|
|
43
|
+
### Context Providers
|
|
73
44
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
45
|
+
| Export | Description |
|
|
46
|
+
| --- | --- |
|
|
47
|
+
| `PortalContainerProvider` | Provide a custom portal container element |
|
|
48
|
+
| `usePortalContainer()` | Access the portal container element |
|
|
49
|
+
| `PortalThemeProvider` | Provide theme context for portaled overlays |
|
|
50
|
+
| `PortalThemeWrapper` | Wrapper element that applies theme variables |
|
|
51
|
+
| `usePortalTheme()` | Access the current portal theme |
|
|
77
52
|
|
|
78
|
-
|
|
79
|
-
export { articleLayout, commentLayout, noteLayout } from './themes'
|
|
80
|
-
export { fonts } from './themes'
|
|
81
|
-
export { darkColors, lightArticleColors, lightCommentColors } from './themes'
|
|
53
|
+
### Design Tokens
|
|
82
54
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
55
|
+
| Export | Description |
|
|
56
|
+
| --- | --- |
|
|
57
|
+
| `articleLayout` | Layout tokens for the `article` variant (sans-serif, 16px) |
|
|
58
|
+
| `noteLayout` | Layout tokens for the `note` variant (CJK serif, 16px) |
|
|
59
|
+
| `commentLayout` | Layout tokens for the `comment` variant (sans-serif, 14px) |
|
|
60
|
+
| `darkColors` | Color tokens for dark mode |
|
|
61
|
+
| `lightArticleColors` | Color tokens for light article/note mode |
|
|
62
|
+
| `lightCommentColors` | Color tokens for light comment mode |
|
|
63
|
+
| `fonts` | Font family definitions |
|
|
90
64
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
### vars.color
|
|
94
|
-
|
|
95
|
-
```ts
|
|
96
|
-
vars.color.text // 主文本色
|
|
97
|
-
vars.color.textSecondary // 次要文本
|
|
98
|
-
vars.color.bg // 背景色
|
|
99
|
-
vars.color.bgSecondary // 次要背景
|
|
100
|
-
vars.color.border // 边框色
|
|
101
|
-
vars.color.accent // 强调色
|
|
102
|
-
vars.color.accentLight // 浅强调色
|
|
103
|
-
vars.color.link // 链接色
|
|
104
|
-
vars.color.codeText // 代码文本
|
|
105
|
-
vars.color.codeBg // 代码背景
|
|
106
|
-
vars.color.quoteBorder // 引用边框
|
|
107
|
-
vars.color.quoteBg // 引用背景
|
|
108
|
-
vars.color.alertInfo // 提示色
|
|
109
|
-
vars.color.alertWarning // 警告色
|
|
110
|
-
vars.color.alertTip // 建议色
|
|
111
|
-
vars.color.alertCaution // 注意色
|
|
112
|
-
vars.color.alertImportant // 重要色
|
|
113
|
-
```
|
|
65
|
+
### Theme Objects
|
|
114
66
|
|
|
115
|
-
|
|
67
|
+
| Export | Description |
|
|
68
|
+
| --- | --- |
|
|
69
|
+
| `articleTheme` | Complete theme for the `article` variant |
|
|
70
|
+
| `noteTheme` | Complete theme for the `note` variant |
|
|
71
|
+
| `commentTheme` | Complete theme for the `comment` variant |
|
|
72
|
+
| `vars` | Typed CSS variable references (use in Vanilla Extract styles) |
|
|
116
73
|
|
|
117
|
-
|
|
118
|
-
vars.spacing.xs // article: 4px, comment: 2px
|
|
119
|
-
vars.spacing.sm // article: 8px, comment: 4px
|
|
120
|
-
vars.spacing.md // article: 16px, comment: 10px
|
|
121
|
-
vars.spacing.lg // article: 24px, comment: 16px
|
|
122
|
-
vars.spacing.xl // article: 32px, comment: 20px
|
|
123
|
-
```
|
|
74
|
+
### Types
|
|
124
75
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
vars.typography.fontMono // 等宽字体
|
|
130
|
-
vars.typography.fontSize2xs // 超小字号(0.625em)
|
|
131
|
-
vars.typography.fontSizeXs // 特小字号(0.75em)
|
|
132
|
-
vars.typography.fontSizeSm // 小字号(0.8125em)
|
|
133
|
-
vars.typography.fontSizeMd // 中字号(0.875em)
|
|
134
|
-
vars.typography.fontSizeLg // 大字号(1.25em)
|
|
135
|
-
vars.typography.fontSizeBase // 基础字号
|
|
136
|
-
vars.typography.fontSizeSmall // 兼容小字号(px)
|
|
137
|
-
vars.typography.lineHeight // 行高
|
|
138
|
-
vars.typography.lineHeightTight // 紧行高
|
|
139
|
-
```
|
|
76
|
+
| Export | Description |
|
|
77
|
+
| --- | --- |
|
|
78
|
+
| `ThemeTokens` | Shape of a complete theme token set |
|
|
79
|
+
| `PortalTheme` | Portal theme descriptor |
|
|
140
80
|
|
|
141
|
-
###
|
|
81
|
+
### Sub-path Exports
|
|
142
82
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
## 预设主题
|
|
150
|
-
|
|
151
|
-
```ts
|
|
152
|
-
import {
|
|
153
|
-
lightArticleColors,
|
|
154
|
-
darkColors,
|
|
155
|
-
articleLayout,
|
|
156
|
-
} from '@haklex/rich-style-token'
|
|
157
|
-
|
|
158
|
-
// 浅色文章主题
|
|
159
|
-
lightArticleColors.text // '#1a1a1a'
|
|
160
|
-
lightArticleColors.accent // '#33A6B8'
|
|
83
|
+
| Import Path | Description |
|
|
84
|
+
| --- | --- |
|
|
85
|
+
| `@haklex/rich-style-token` | All tokens, themes, providers, and utilities |
|
|
86
|
+
| `@haklex/rich-style-token/styles` | Vanilla Extract style definitions |
|
|
161
87
|
|
|
162
|
-
|
|
163
|
-
darkColors.text // '#e5e5e5'
|
|
164
|
-
darkColors.accent // '#F596AA'
|
|
88
|
+
## Part of Haklex
|
|
165
89
|
|
|
166
|
-
|
|
167
|
-
articleLayout.typography.fontSizeBase // '16px'
|
|
168
|
-
articleLayout.typography.lineHeight // '1.7'
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
## 依赖
|
|
172
|
-
|
|
173
|
-
```json
|
|
174
|
-
{
|
|
175
|
-
"@vanilla-extract/css": "^1.17.1",
|
|
176
|
-
"react": ">=19"
|
|
177
|
-
}
|
|
178
|
-
```
|
|
90
|
+
This package is part of the [Haklex](../../README.md) rich editor ecosystem.
|
|
179
91
|
|
|
180
92
|
## License
|
|
181
93
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,37 +1,14 @@
|
|
|
1
|
+
import { articleLayout, articleTheme, commentLayout, commentTheme, createThemeStyle, darkColors, fonts, lightArticleColors, lightCommentColors, noteLayout, noteTheme, vars } from "./styles.mjs";
|
|
1
2
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
var articleTheme = "yglj5t0";
|
|
5
|
-
var noteTheme = "yglj5t1";
|
|
6
|
-
var commentTheme = "yglj5t2";
|
|
7
|
-
function extractVarName(cssVarRef) {
|
|
8
|
-
const match = cssVarRef.match(/^var\((.+)\)$/);
|
|
9
|
-
return match ? match[1] : cssVarRef;
|
|
10
|
-
}
|
|
11
|
-
function createThemeStyle(tokens) {
|
|
12
|
-
const style = {};
|
|
13
|
-
for (const [group, values] of Object.entries(tokens)) {
|
|
14
|
-
if (!values) continue;
|
|
15
|
-
const contractGroup = vars[group];
|
|
16
|
-
if (!contractGroup) continue;
|
|
17
|
-
for (const [key, value] of Object.entries(values)) {
|
|
18
|
-
if (value == null) continue;
|
|
19
|
-
const cssVarRef = contractGroup[key];
|
|
20
|
-
if (cssVarRef) {
|
|
21
|
-
style[extractVarName(cssVarRef)] = value;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return style;
|
|
26
|
-
}
|
|
27
|
-
const PortalThemeContext = createContext({
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
const PortalThemeContext = React.createContext({
|
|
28
5
|
className: "",
|
|
29
6
|
theme: "light"
|
|
30
7
|
});
|
|
31
|
-
const PortalContainerContext = createContext(null);
|
|
8
|
+
const PortalContainerContext = React.createContext(null);
|
|
32
9
|
const PortalContainerProvider = PortalContainerContext.Provider;
|
|
33
10
|
function usePortalContainer() {
|
|
34
|
-
return
|
|
11
|
+
return React.useContext(PortalContainerContext) ?? document.body;
|
|
35
12
|
}
|
|
36
13
|
function PortalThemeProvider({
|
|
37
14
|
className,
|
|
@@ -41,13 +18,13 @@ function PortalThemeProvider({
|
|
|
41
18
|
return /* @__PURE__ */ jsx(
|
|
42
19
|
PortalThemeContext.Provider,
|
|
43
20
|
{
|
|
44
|
-
value: useMemo(() => ({ className, theme }), [className, theme]),
|
|
21
|
+
value: React.useMemo(() => ({ className, theme }), [className, theme]),
|
|
45
22
|
children
|
|
46
23
|
}
|
|
47
24
|
);
|
|
48
25
|
}
|
|
49
26
|
function usePortalTheme() {
|
|
50
|
-
return
|
|
27
|
+
return React.useContext(PortalThemeContext);
|
|
51
28
|
}
|
|
52
29
|
function PortalThemeWrapper({ children }) {
|
|
53
30
|
const { className, theme } = usePortalTheme();
|
|
@@ -55,169 +32,14 @@ function PortalThemeWrapper({ children }) {
|
|
|
55
32
|
return /* @__PURE__ */ jsx(
|
|
56
33
|
"div",
|
|
57
34
|
{
|
|
58
|
-
style: { display: "contents" },
|
|
59
|
-
className,
|
|
60
35
|
suppressHydrationWarning: true,
|
|
36
|
+
className,
|
|
61
37
|
"data-theme": theme,
|
|
38
|
+
style: { display: "contents" },
|
|
62
39
|
children
|
|
63
40
|
}
|
|
64
41
|
);
|
|
65
42
|
}
|
|
66
|
-
const fonts = {
|
|
67
|
-
fontFamilySans: '"PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji',
|
|
68
|
-
fontFamilySerif: '"Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif", "source-han-serif-sc", "Songti SC", STSong, "华文宋体", serif',
|
|
69
|
-
fontMono: '"SF Mono", SFMono-Regular, ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace'
|
|
70
|
-
};
|
|
71
|
-
const lightArticleColors = {
|
|
72
|
-
text: "#000",
|
|
73
|
-
textSecondary: "#27272a",
|
|
74
|
-
// zinc-800
|
|
75
|
-
textTertiary: "#71717a",
|
|
76
|
-
// zinc-500
|
|
77
|
-
textQuaternary: "#a1a1aa",
|
|
78
|
-
// zinc-400
|
|
79
|
-
bg: "#ffffff",
|
|
80
|
-
bgSecondary: "#fafafa",
|
|
81
|
-
// zinc-50
|
|
82
|
-
bgTertiary: "#f4f4f5",
|
|
83
|
-
// zinc-100
|
|
84
|
-
fill: "#e8e8ec",
|
|
85
|
-
// interactive fill 1 — list item selected/hover
|
|
86
|
-
fillSecondary: "#eeeeef",
|
|
87
|
-
// interactive fill 2 — button/control hover
|
|
88
|
-
fillTertiary: "#f4f4f6",
|
|
89
|
-
// interactive fill 3 — large area hover (card, table row)
|
|
90
|
-
fillQuaternary: "#f9f9fa",
|
|
91
|
-
// interactive fill 4 — most subtle feedback
|
|
92
|
-
border: "#f4f4f5",
|
|
93
|
-
// zinc-100 - lighter, less prominent
|
|
94
|
-
accent: "#2563eb",
|
|
95
|
-
accentLight: "#2563eb20",
|
|
96
|
-
link: "#2563eb",
|
|
97
|
-
codeText: "#3f3f46",
|
|
98
|
-
// zinc-700
|
|
99
|
-
codeBg: "#f4f4f5",
|
|
100
|
-
// zinc-100
|
|
101
|
-
hrBorder: "#e4e4e7",
|
|
102
|
-
// zinc-200 - one step darker than border
|
|
103
|
-
quoteBorder: "#2563eb",
|
|
104
|
-
quoteBg: "#eff6ff",
|
|
105
|
-
alertInfo: "#006bb7",
|
|
106
|
-
alertWarning: "#cc5500",
|
|
107
|
-
alertTip: "#11cc00",
|
|
108
|
-
alertCaution: "#cc0011",
|
|
109
|
-
alertImportant: "#5500cc"
|
|
110
|
-
};
|
|
111
|
-
const lightCommentColors = {
|
|
112
|
-
...lightArticleColors,
|
|
113
|
-
quoteBorder: "#a1a1aa",
|
|
114
|
-
// zinc-400
|
|
115
|
-
quoteBg: "#fafafa"
|
|
116
|
-
// zinc-50
|
|
117
|
-
};
|
|
118
|
-
const darkColors = {
|
|
119
|
-
text: "#fafafa",
|
|
120
|
-
textSecondary: "#a1a1aa",
|
|
121
|
-
// zinc-400
|
|
122
|
-
textTertiary: "#71717a",
|
|
123
|
-
// zinc-500
|
|
124
|
-
textQuaternary: "#52525b",
|
|
125
|
-
// zinc-600
|
|
126
|
-
bg: "#09090b",
|
|
127
|
-
// zinc-950
|
|
128
|
-
bgSecondary: "#18181b",
|
|
129
|
-
// zinc-900
|
|
130
|
-
bgTertiary: "#27272a",
|
|
131
|
-
// zinc-800
|
|
132
|
-
fill: "#2a2a2f",
|
|
133
|
-
// interactive fill 1 — list item selected/hover
|
|
134
|
-
fillSecondary: "#222226",
|
|
135
|
-
// interactive fill 2 — button/control hover
|
|
136
|
-
fillTertiary: "#1b1b1f",
|
|
137
|
-
// interactive fill 3 — large area hover
|
|
138
|
-
fillQuaternary: "#131316",
|
|
139
|
-
// interactive fill 4 — most subtle feedback
|
|
140
|
-
border: "#27272a",
|
|
141
|
-
// zinc-800 - lighter/less prominent
|
|
142
|
-
accent: "#60a5fa",
|
|
143
|
-
accentLight: "#60a5fa20",
|
|
144
|
-
link: "#60a5fa",
|
|
145
|
-
codeText: "#e4e4e7",
|
|
146
|
-
// zinc-200
|
|
147
|
-
codeBg: "#27272a",
|
|
148
|
-
// zinc-800
|
|
149
|
-
hrBorder: "#27272a",
|
|
150
|
-
// zinc-800 - same as border
|
|
151
|
-
quoteBorder: "#60a5fa",
|
|
152
|
-
quoteBg: "#1e3a5f",
|
|
153
|
-
alertInfo: "#7db9e5",
|
|
154
|
-
alertWarning: "#da864a",
|
|
155
|
-
alertTip: "#54da48",
|
|
156
|
-
alertCaution: "#e16973",
|
|
157
|
-
alertImportant: "#9966e0"
|
|
158
|
-
};
|
|
159
|
-
const sharedSpacing = {
|
|
160
|
-
xs: "4px",
|
|
161
|
-
sm: "8px",
|
|
162
|
-
md: "16px",
|
|
163
|
-
lg: "24px",
|
|
164
|
-
xl: "32px"
|
|
165
|
-
};
|
|
166
|
-
const sharedBorderRadius = { sm: "4px", md: "8px", lg: "12px" };
|
|
167
|
-
const sharedBoxShadow = {
|
|
168
|
-
topBar: "0 8px 30px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06)",
|
|
169
|
-
modal: "0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1)",
|
|
170
|
-
menu: "0 1px 4px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.08)"
|
|
171
|
-
};
|
|
172
|
-
const baseTypography = {
|
|
173
|
-
fontFamilySans: fonts.fontFamilySans,
|
|
174
|
-
fontFamilySerif: fonts.fontFamilySerif,
|
|
175
|
-
fontMono: fonts.fontMono,
|
|
176
|
-
fontSize2xs: "0.625em",
|
|
177
|
-
fontSizeXs: "0.75em",
|
|
178
|
-
fontSizeSm: "0.8125em",
|
|
179
|
-
fontSizeMd: "0.875em",
|
|
180
|
-
fontSizeLg: "1.25em",
|
|
181
|
-
fontSizeBase: "16px",
|
|
182
|
-
fontSizeSmall: "14px",
|
|
183
|
-
lineHeight: "1.7",
|
|
184
|
-
lineHeightTight: "1.4"
|
|
185
|
-
};
|
|
186
|
-
const articleLayout = {
|
|
187
|
-
layout: { maxWidth: "700px" },
|
|
188
|
-
boxShadow: sharedBoxShadow,
|
|
189
|
-
spacing: sharedSpacing,
|
|
190
|
-
typography: {
|
|
191
|
-
...baseTypography,
|
|
192
|
-
fontFamily: fonts.fontFamilySans
|
|
193
|
-
},
|
|
194
|
-
borderRadius: sharedBorderRadius
|
|
195
|
-
};
|
|
196
|
-
const noteLayout = {
|
|
197
|
-
layout: { maxWidth: "700px" },
|
|
198
|
-
boxShadow: sharedBoxShadow,
|
|
199
|
-
spacing: sharedSpacing,
|
|
200
|
-
typography: {
|
|
201
|
-
...baseTypography,
|
|
202
|
-
fontFamily: fonts.fontFamilySerif,
|
|
203
|
-
lineHeight: "1.8"
|
|
204
|
-
},
|
|
205
|
-
borderRadius: sharedBorderRadius
|
|
206
|
-
};
|
|
207
|
-
const commentLayout = {
|
|
208
|
-
layout: { maxWidth: "none" },
|
|
209
|
-
boxShadow: sharedBoxShadow,
|
|
210
|
-
spacing: { xs: "2px", sm: "4px", md: "10px", lg: "16px", xl: "20px" },
|
|
211
|
-
typography: {
|
|
212
|
-
...baseTypography,
|
|
213
|
-
fontFamily: fonts.fontFamilySans,
|
|
214
|
-
fontSizeBase: "14px",
|
|
215
|
-
fontSizeSmall: "12px",
|
|
216
|
-
lineHeight: "1.5",
|
|
217
|
-
lineHeightTight: "1.3"
|
|
218
|
-
},
|
|
219
|
-
borderRadius: { sm: "3px", md: "6px", lg: "8px" }
|
|
220
|
-
};
|
|
221
43
|
export {
|
|
222
44
|
PortalContainerProvider,
|
|
223
45
|
PortalThemeProvider,
|
package/dist/portal-theme.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
export type PortalTheme = 'light' | 'dark';
|
|
3
3
|
type PortalThemeContextType = {
|
|
4
4
|
className: string;
|
|
5
5
|
theme: PortalTheme;
|
|
6
6
|
};
|
|
7
|
-
export declare const PortalContainerProvider:
|
|
7
|
+
export declare const PortalContainerProvider: React.Provider<Element | null>;
|
|
8
8
|
export declare function usePortalContainer(): Element;
|
|
9
9
|
export declare function PortalThemeProvider({ className, theme, children, }: {
|
|
10
10
|
className: string;
|
|
11
11
|
theme: PortalTheme;
|
|
12
|
-
children?: ReactNode;
|
|
12
|
+
children?: React.ReactNode;
|
|
13
13
|
}): import("react/jsx-runtime").JSX.Element;
|
|
14
14
|
export declare function usePortalTheme(): PortalThemeContextType;
|
|
15
15
|
export declare function PortalThemeWrapper({ children }: {
|
|
16
|
-
children: ReactNode;
|
|
17
|
-
}): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean |
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
}): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
18
18
|
export {};
|
|
19
19
|
//# sourceMappingURL=portal-theme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portal-theme.d.ts","sourceRoot":"","sources":["../src/portal-theme.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"portal-theme.d.ts","sourceRoot":"","sources":["../src/portal-theme.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;AAE3C,KAAK,sBAAsB,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,WAAW,CAAC;CACpB,CAAC;AAQF,eAAO,MAAM,uBAAuB,gCAAkC,CAAC;AAEvE,wBAAgB,kBAAkB,IAAI,OAAO,CAE5C;AAED,wBAAgB,mBAAmB,CAAC,EAClC,SAAS,EACT,KAAK,EACL,QAAQ,GACT,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B,2CAQA;AAED,wBAAgB,cAAc,2BAE7B;AAED,wBAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,yTAa7E"}
|
package/dist/styles.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { ThemeTokens } from './create-theme-style';
|
|
2
|
+
export { createThemeStyle } from './create-theme-style';
|
|
3
|
+
export { articleLayout, commentLayout, darkColors, fonts, lightArticleColors, lightCommentColors, noteLayout, } from './themes';
|
|
4
|
+
export { articleTheme, commentTheme, noteTheme, vars } from './vars.css';
|
|
5
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EACL,aAAa,EACb,aAAa,EACb,UAAU,EACV,KAAK,EACL,kBAAkB,EAClB,kBAAkB,EAClB,UAAU,GACX,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/styles.mjs
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
var vars = { color: { text: "var(--rc-text)", textSecondary: "var(--rc-text-secondary)", textTertiary: "var(--rc-text-tertiary)", textQuaternary: "var(--rc-text-quaternary)", bg: "var(--rc-bg)", bgSecondary: "var(--rc-bg-secondary)", bgTertiary: "var(--rc-bg-tertiary)", fill: "var(--rc-fill)", fillSecondary: "var(--rc-fill-secondary)", fillTertiary: "var(--rc-fill-tertiary)", fillQuaternary: "var(--rc-fill-quaternary)", border: "var(--rc-border)", accent: "var(--rc-accent)", accentLight: "var(--rc-accent-light)", link: "var(--rc-link)", codeText: "var(--rc-code-text)", codeBg: "var(--rc-code-bg)", hrBorder: "var(--rc-hr-border)", quoteBorder: "var(--rc-quote-border)", quoteBg: "var(--rc-quote-bg)", alertInfo: "var(--rc-alert-info)", alertWarning: "var(--rc-alert-warning)", alertTip: "var(--rc-alert-tip)", alertCaution: "var(--rc-alert-caution)", alertImportant: "var(--rc-alert-important)" }, spacing: { xs: "var(--rc-space-xs)", sm: "var(--rc-space-sm)", md: "var(--rc-space-md)", lg: "var(--rc-space-lg)", xl: "var(--rc-space-xl)" }, typography: { fontFamily: "var(--rc-font-family)", fontFamilySans: "var(--rc-font-family-sans)", fontFamilySerif: "var(--rc-font-family-serif)", fontMono: "var(--rc-font-mono)", fontSize2xs: "var(--rc-font-size-2xs)", fontSizeXs: "var(--rc-font-size-xs)", fontSizeSm: "var(--rc-font-size-sm)", fontSizeMd: "var(--rc-font-size-md)", fontSizeLg: "var(--rc-font-size-lg)", fontSizeBase: "var(--rc-font-size-base)", fontSizeSmall: "var(--rc-font-size-small)", lineHeight: "var(--rc-line-height)", lineHeightTight: "var(--rc-line-height-tight)" }, borderRadius: { sm: "var(--rc-radius-sm)", md: "var(--rc-radius-md)", lg: "var(--rc-radius-lg)" }, layout: { maxWidth: "var(--rc-max-width)" }, boxShadow: { topBar: "var(--rc-shadow-top-bar)", modal: "var(--rc-shadow-modal)", menu: "var(--rc-shadow-menu)" } };
|
|
2
|
+
var articleTheme = "yglj5t0";
|
|
3
|
+
var noteTheme = "yglj5t1";
|
|
4
|
+
var commentTheme = "yglj5t2";
|
|
5
|
+
function extractVarName(cssVarRef) {
|
|
6
|
+
const match = cssVarRef.match(/^var\((.+)\)$/);
|
|
7
|
+
return match ? match[1] : cssVarRef;
|
|
8
|
+
}
|
|
9
|
+
function createThemeStyle(tokens) {
|
|
10
|
+
const style = {};
|
|
11
|
+
for (const [group, values] of Object.entries(tokens)) {
|
|
12
|
+
if (!values) continue;
|
|
13
|
+
const contractGroup = vars[group];
|
|
14
|
+
if (!contractGroup) continue;
|
|
15
|
+
for (const [key, value] of Object.entries(values)) {
|
|
16
|
+
if (value == null) continue;
|
|
17
|
+
const cssVarRef = contractGroup[key];
|
|
18
|
+
if (cssVarRef) {
|
|
19
|
+
style[extractVarName(cssVarRef)] = value;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return style;
|
|
24
|
+
}
|
|
25
|
+
const fonts = {
|
|
26
|
+
fontFamilySans: '"PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, "noto sans sc", "hiragino sans gb", -apple-system, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Not Color Emoji',
|
|
27
|
+
fontFamilySerif: '"Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif", "source-han-serif-sc", "Songti SC", STSong, "华文宋体", serif',
|
|
28
|
+
fontMono: '"SF Mono", SFMono-Regular, ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace'
|
|
29
|
+
};
|
|
30
|
+
const lightArticleColors = {
|
|
31
|
+
text: "#000",
|
|
32
|
+
textSecondary: "#27272a",
|
|
33
|
+
// zinc-800
|
|
34
|
+
textTertiary: "#71717a",
|
|
35
|
+
// zinc-500
|
|
36
|
+
textQuaternary: "#a1a1aa",
|
|
37
|
+
// zinc-400
|
|
38
|
+
bg: "#ffffff",
|
|
39
|
+
bgSecondary: "#fafafa",
|
|
40
|
+
// zinc-50
|
|
41
|
+
bgTertiary: "#f4f4f5",
|
|
42
|
+
// zinc-100
|
|
43
|
+
fill: "#e8e8ec",
|
|
44
|
+
// interactive fill 1 — list item selected/hover
|
|
45
|
+
fillSecondary: "#eeeeef",
|
|
46
|
+
// interactive fill 2 — button/control hover
|
|
47
|
+
fillTertiary: "#f4f4f6",
|
|
48
|
+
// interactive fill 3 — large area hover (card, table row)
|
|
49
|
+
fillQuaternary: "#f9f9fa",
|
|
50
|
+
// interactive fill 4 — most subtle feedback
|
|
51
|
+
border: "#f4f4f5",
|
|
52
|
+
// zinc-100 - lighter, less prominent
|
|
53
|
+
accent: "#2563eb",
|
|
54
|
+
accentLight: "#2563eb20",
|
|
55
|
+
link: "#2563eb",
|
|
56
|
+
codeText: "#3f3f46",
|
|
57
|
+
// zinc-700
|
|
58
|
+
codeBg: "#f4f4f5",
|
|
59
|
+
// zinc-100
|
|
60
|
+
hrBorder: "#e4e4e7",
|
|
61
|
+
// zinc-200 - one step darker than border
|
|
62
|
+
quoteBorder: "#2563eb",
|
|
63
|
+
quoteBg: "#eff6ff",
|
|
64
|
+
alertInfo: "#006bb7",
|
|
65
|
+
alertWarning: "#cc5500",
|
|
66
|
+
alertTip: "#11cc00",
|
|
67
|
+
alertCaution: "#cc0011",
|
|
68
|
+
alertImportant: "#5500cc"
|
|
69
|
+
};
|
|
70
|
+
const lightCommentColors = {
|
|
71
|
+
...lightArticleColors,
|
|
72
|
+
quoteBorder: "#a1a1aa",
|
|
73
|
+
// zinc-400
|
|
74
|
+
quoteBg: "#fafafa"
|
|
75
|
+
// zinc-50
|
|
76
|
+
};
|
|
77
|
+
const darkColors = {
|
|
78
|
+
text: "#fafafa",
|
|
79
|
+
textSecondary: "#a1a1aa",
|
|
80
|
+
// zinc-400
|
|
81
|
+
textTertiary: "#71717a",
|
|
82
|
+
// zinc-500
|
|
83
|
+
textQuaternary: "#52525b",
|
|
84
|
+
// zinc-600
|
|
85
|
+
bg: "#09090b",
|
|
86
|
+
// zinc-950
|
|
87
|
+
bgSecondary: "#18181b",
|
|
88
|
+
// zinc-900
|
|
89
|
+
bgTertiary: "#27272a",
|
|
90
|
+
// zinc-800
|
|
91
|
+
fill: "#2a2a2f",
|
|
92
|
+
// interactive fill 1 — list item selected/hover
|
|
93
|
+
fillSecondary: "#222226",
|
|
94
|
+
// interactive fill 2 — button/control hover
|
|
95
|
+
fillTertiary: "#1b1b1f",
|
|
96
|
+
// interactive fill 3 — large area hover
|
|
97
|
+
fillQuaternary: "#131316",
|
|
98
|
+
// interactive fill 4 — most subtle feedback
|
|
99
|
+
border: "#27272a",
|
|
100
|
+
// zinc-800 - lighter/less prominent
|
|
101
|
+
accent: "#60a5fa",
|
|
102
|
+
accentLight: "#60a5fa20",
|
|
103
|
+
link: "#60a5fa",
|
|
104
|
+
codeText: "#e4e4e7",
|
|
105
|
+
// zinc-200
|
|
106
|
+
codeBg: "#27272a",
|
|
107
|
+
// zinc-800
|
|
108
|
+
hrBorder: "#27272a",
|
|
109
|
+
// zinc-800 - same as border
|
|
110
|
+
quoteBorder: "#60a5fa",
|
|
111
|
+
quoteBg: "#1e3a5f",
|
|
112
|
+
alertInfo: "#7db9e5",
|
|
113
|
+
alertWarning: "#da864a",
|
|
114
|
+
alertTip: "#54da48",
|
|
115
|
+
alertCaution: "#e16973",
|
|
116
|
+
alertImportant: "#9966e0"
|
|
117
|
+
};
|
|
118
|
+
const sharedSpacing = {
|
|
119
|
+
xs: "4px",
|
|
120
|
+
sm: "8px",
|
|
121
|
+
md: "16px",
|
|
122
|
+
lg: "24px",
|
|
123
|
+
xl: "32px"
|
|
124
|
+
};
|
|
125
|
+
const sharedBorderRadius = { sm: "4px", md: "8px", lg: "12px" };
|
|
126
|
+
const sharedBoxShadow = {
|
|
127
|
+
topBar: "0 8px 30px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06)",
|
|
128
|
+
modal: "0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1)",
|
|
129
|
+
menu: "0 1px 4px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.08)"
|
|
130
|
+
};
|
|
131
|
+
const baseTypography = {
|
|
132
|
+
fontFamilySans: fonts.fontFamilySans,
|
|
133
|
+
fontFamilySerif: fonts.fontFamilySerif,
|
|
134
|
+
fontMono: fonts.fontMono,
|
|
135
|
+
fontSize2xs: "0.625em",
|
|
136
|
+
fontSizeXs: "0.75em",
|
|
137
|
+
fontSizeSm: "0.8125em",
|
|
138
|
+
fontSizeMd: "0.875em",
|
|
139
|
+
fontSizeLg: "1.25em",
|
|
140
|
+
fontSizeBase: "16px",
|
|
141
|
+
fontSizeSmall: "14px",
|
|
142
|
+
lineHeight: "1.7",
|
|
143
|
+
lineHeightTight: "1.4"
|
|
144
|
+
};
|
|
145
|
+
const articleLayout = {
|
|
146
|
+
layout: { maxWidth: "700px" },
|
|
147
|
+
boxShadow: sharedBoxShadow,
|
|
148
|
+
spacing: sharedSpacing,
|
|
149
|
+
typography: {
|
|
150
|
+
...baseTypography,
|
|
151
|
+
fontFamily: fonts.fontFamilySans
|
|
152
|
+
},
|
|
153
|
+
borderRadius: sharedBorderRadius
|
|
154
|
+
};
|
|
155
|
+
const noteLayout = {
|
|
156
|
+
layout: { maxWidth: "700px" },
|
|
157
|
+
boxShadow: sharedBoxShadow,
|
|
158
|
+
spacing: sharedSpacing,
|
|
159
|
+
typography: {
|
|
160
|
+
...baseTypography,
|
|
161
|
+
fontFamily: fonts.fontFamilySerif,
|
|
162
|
+
lineHeight: "1.8"
|
|
163
|
+
},
|
|
164
|
+
borderRadius: sharedBorderRadius
|
|
165
|
+
};
|
|
166
|
+
const commentLayout = {
|
|
167
|
+
layout: { maxWidth: "none" },
|
|
168
|
+
boxShadow: sharedBoxShadow,
|
|
169
|
+
spacing: { xs: "2px", sm: "4px", md: "10px", lg: "16px", xl: "20px" },
|
|
170
|
+
typography: {
|
|
171
|
+
...baseTypography,
|
|
172
|
+
fontFamily: fonts.fontFamilySans,
|
|
173
|
+
fontSizeBase: "14px",
|
|
174
|
+
fontSizeSmall: "12px",
|
|
175
|
+
lineHeight: "1.5",
|
|
176
|
+
lineHeightTight: "1.3"
|
|
177
|
+
},
|
|
178
|
+
borderRadius: { sm: "3px", md: "6px", lg: "8px" }
|
|
179
|
+
};
|
|
180
|
+
export {
|
|
181
|
+
articleLayout,
|
|
182
|
+
articleTheme,
|
|
183
|
+
commentLayout,
|
|
184
|
+
commentTheme,
|
|
185
|
+
createThemeStyle,
|
|
186
|
+
darkColors,
|
|
187
|
+
fonts,
|
|
188
|
+
lightArticleColors,
|
|
189
|
+
lightCommentColors,
|
|
190
|
+
noteLayout,
|
|
191
|
+
noteTheme,
|
|
192
|
+
vars
|
|
193
|
+
};
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haklex/rich-style-token",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.66",
|
|
5
5
|
"description": "Style tokens and CSS variables for haklex rich editor",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
9
|
"import": "./dist/index.mjs",
|
|
10
10
|
"types": "./dist/index.d.ts"
|
|
11
|
+
},
|
|
12
|
+
"./styles": {
|
|
13
|
+
"import": "./dist/styles.mjs",
|
|
14
|
+
"types": "./dist/styles.d.ts"
|
|
11
15
|
}
|
|
12
16
|
},
|
|
13
17
|
"main": "./dist/index.mjs",
|
|
@@ -29,6 +33,11 @@
|
|
|
29
33
|
"publishConfig": {
|
|
30
34
|
"access": "public"
|
|
31
35
|
},
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "https://github.com/Innei/haklex.git",
|
|
39
|
+
"directory": "packages/rich-style-token"
|
|
40
|
+
},
|
|
32
41
|
"scripts": {
|
|
33
42
|
"build": "vite build",
|
|
34
43
|
"dev:build": "vite build --watch"
|
package/LICENSE
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Innei
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
Additional Terms and Conditions
|
|
25
|
-
|
|
26
|
-
----------------
|
|
27
|
-
|
|
28
|
-
Use of this software is governed by the terms of MIT and, in addition, by the terms and conditions described in the additional file (ADDITIONAL_TERMS.md). By using this software, you agree to abide by these additional terms and conditions.
|