@haklex/rich-style-token 0.0.65 → 0.0.67

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 CHANGED
@@ -1,181 +1,93 @@
1
1
  # @haklex/rich-style-token
2
2
 
3
- 设计令牌和 CSS 变量,基于 Vanilla Extract 实现零运行时样式。
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
- ```tsx
14
- import { vars } from '@haklex/rich-style-token'
15
- import { style } from '@vanilla-extract/css'
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
- 主题契约生成标准 CSS 自定义属性(`--rc-*`),使用方可在运行时覆写。
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
- `ThemeTokens` 类型自动从 `vars` 契约推导,支持 `color`、`spacing`、`typography`、`borderRadius` 四组的任意子集覆写。
23
+ // Generate inline style object from a theme
24
+ const style = createThemeStyle(articleTheme)
48
25
 
49
- ### 方式二:纯 CSS
26
+ // Use CSS variables in your styles
27
+ // vars.fontSize, vars.lineHeight, vars.fontFamily, etc.
50
28
 
51
- ```css
52
- .my-theme {
53
- --rc-accent: #0ea5e9;
54
- --rc-text: #0c4a6e;
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
- ### 可覆写的 CSS 变量
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
- ```ts
71
- // CSS 变量契约
72
- export { vars } from './vars.css'
43
+ ### Context Providers
73
44
 
74
- // 运行时覆写工具
75
- export { createThemeStyle } from './create-theme-style'
76
- export type { ThemeTokens } from './create-theme-style'
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
- // Portal 主题
84
- export {
85
- PortalThemeProvider,
86
- PortalThemeWrapper,
87
- usePortalTheme,
88
- } from './portal-theme'
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
- ### vars.spacing
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
- ```ts
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
- ### vars.typography
126
-
127
- ```ts
128
- vars.typography.fontFamily // 字体族
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
- ### vars.borderRadius
81
+ ### Sub-path Exports
142
82
 
143
- ```ts
144
- vars.borderRadius.sm // article: 4px, comment: 3px
145
- vars.borderRadius.md // article: 8px, comment: 6px
146
- vars.borderRadius.lg // article: 12px, comment: 8px
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
@@ -26,18 +26,16 @@ function PortalThemeProvider({
26
26
  function usePortalTheme() {
27
27
  return React.useContext(PortalThemeContext);
28
28
  }
29
- function PortalThemeWrapper({
30
- children
31
- }) {
29
+ function PortalThemeWrapper({ children }) {
32
30
  const { className, theme } = usePortalTheme();
33
31
  if (!className) return children;
34
32
  return /* @__PURE__ */ jsx(
35
33
  "div",
36
34
  {
37
- style: { display: "contents" },
38
- className,
39
35
  suppressHydrationWarning: true,
36
+ className,
40
37
  "data-theme": theme,
38
+ style: { display: "contents" },
41
39
  children
42
40
  }
43
41
  );
@@ -12,7 +12,7 @@ export declare function PortalThemeProvider({ className, theme, children, }: {
12
12
  children?: React.ReactNode;
13
13
  }): import("react/jsx-runtime").JSX.Element;
14
14
  export declare function usePortalTheme(): PortalThemeContextType;
15
- export declare function PortalThemeWrapper({ children, }: {
15
+ export declare function PortalThemeWrapper({ children }: {
16
16
  children: React.ReactNode;
17
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 {};
@@ -1 +1 @@
1
- {"version":3,"file":"portal-theme.d.ts","sourceRoot":"","sources":["../src/portal-theme.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,CAAA;AA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,9 +1,14 @@
1
1
  {
2
2
  "name": "@haklex/rich-style-token",
3
- "type": "module",
4
- "version": "0.0.65",
3
+ "version": "0.0.67",
5
4
  "description": "Style tokens and CSS variables for haklex rich editor",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/Innei/haklex.git",
8
+ "directory": "packages/rich-style-token"
9
+ },
6
10
  "license": "MIT",
11
+ "type": "module",
7
12
  "exports": {
8
13
  ".": {
9
14
  "import": "./dist/index.mjs",
@@ -18,9 +23,6 @@
18
23
  "files": [
19
24
  "dist"
20
25
  ],
21
- "peerDependencies": {
22
- "react": ">=19"
23
- },
24
26
  "devDependencies": {
25
27
  "@types/react": "^19.2.14",
26
28
  "@vanilla-extract/css": "^1.18.0",
@@ -30,6 +32,9 @@
30
32
  "vite": "^7.3.1",
31
33
  "vite-plugin-dts": "^4.5.4"
32
34
  },
35
+ "peerDependencies": {
36
+ "react": ">=19"
37
+ },
33
38
  "publishConfig": {
34
39
  "access": "public"
35
40
  },