@incremark/theme 0.2.3
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/LICENSE +22 -0
- package/README.en.md +133 -0
- package/README.md +187 -0
- package/dist/index.d.ts +375 -0
- package/dist/index.js +440 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +937 -0
- package/dist/styles.css.map +1 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 wangyishuai
|
|
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
|
+
|
package/README.en.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# @incremark/theme
|
|
2
|
+
|
|
3
|
+
Incremark Theme Package - Unified Theme System
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @incremark/theme
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Basic Usage
|
|
14
|
+
|
|
15
|
+
Import styles in your React or Vue application:
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
// React
|
|
19
|
+
import '@incremark/react/styles.css'
|
|
20
|
+
// Or import directly from theme package
|
|
21
|
+
import '@incremark/theme/styles.css'
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```vue
|
|
25
|
+
<!-- Vue -->
|
|
26
|
+
<style>
|
|
27
|
+
@import '@incremark/vue/style.css';
|
|
28
|
+
/* Or import directly from theme package */
|
|
29
|
+
@import '@incremark/theme/styles.css';
|
|
30
|
+
</style>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Theme Configuration
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import { applyTheme, themes, type ThemeConfig } from '@incremark/theme'
|
|
37
|
+
|
|
38
|
+
// Use preset theme
|
|
39
|
+
const container = document.querySelector('.incremark')
|
|
40
|
+
if (container) {
|
|
41
|
+
applyTheme(container as HTMLElement, themes.dark)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Custom theme
|
|
45
|
+
const customTheme: ThemeConfig = {
|
|
46
|
+
fontFamily: 'Georgia, serif',
|
|
47
|
+
color: '#2c3e50',
|
|
48
|
+
pendingBorderColor: '#e74c3c',
|
|
49
|
+
codeBackground: '#1e1e1e'
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
applyTheme(container as HTMLElement, customTheme)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### CSS Variables
|
|
56
|
+
|
|
57
|
+
The theme package supports customization through CSS variables:
|
|
58
|
+
|
|
59
|
+
```css
|
|
60
|
+
.incremark {
|
|
61
|
+
--incremark-font-family: 'Your Font', sans-serif;
|
|
62
|
+
--incremark-color: #333;
|
|
63
|
+
--incremark-pending-border-color: #a855f7;
|
|
64
|
+
--incremark-code-background: #24292e;
|
|
65
|
+
--incremark-code-header-background: #1f2428;
|
|
66
|
+
--incremark-blockquote-border-color: #3b82f6;
|
|
67
|
+
--incremark-blockquote-background: #f0f7ff;
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## API
|
|
72
|
+
|
|
73
|
+
### `ThemeConfig`
|
|
74
|
+
|
|
75
|
+
Theme configuration interface:
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
interface ThemeConfig {
|
|
79
|
+
fontFamily?: string
|
|
80
|
+
lineHeight?: string
|
|
81
|
+
color?: string
|
|
82
|
+
pendingBorderColor?: string
|
|
83
|
+
codeBackground?: string
|
|
84
|
+
codeHeaderBackground?: string
|
|
85
|
+
blockquoteBorderColor?: string
|
|
86
|
+
blockquoteBackground?: string
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### `themes`
|
|
91
|
+
|
|
92
|
+
Preset themes:
|
|
93
|
+
|
|
94
|
+
- `themes.default` - Default theme
|
|
95
|
+
- `themes.dark` - Dark theme
|
|
96
|
+
- `themes.light` - Light theme
|
|
97
|
+
|
|
98
|
+
### `applyTheme(element, config)`
|
|
99
|
+
|
|
100
|
+
Apply theme configuration to a DOM element.
|
|
101
|
+
|
|
102
|
+
### `getThemeCSSVariables(config)`
|
|
103
|
+
|
|
104
|
+
Get theme CSS variables string.
|
|
105
|
+
|
|
106
|
+
## Style Classes
|
|
107
|
+
|
|
108
|
+
The theme package provides a unified CSS class name system:
|
|
109
|
+
|
|
110
|
+
- `.incremark` - Main container
|
|
111
|
+
- `.incremark-block` - Block container
|
|
112
|
+
- `.incremark-heading` - Heading
|
|
113
|
+
- `.incremark-paragraph` - Paragraph
|
|
114
|
+
- `.incremark-code` - Code block
|
|
115
|
+
- `.incremark-inline-code` - Inline code
|
|
116
|
+
- `.incremark-list` - List
|
|
117
|
+
- `.incremark-table` - Table
|
|
118
|
+
- `.incremark-blockquote` - Blockquote
|
|
119
|
+
- `.incremark-hr` - Horizontal rule
|
|
120
|
+
- `.incremark-math-inline` - Inline math
|
|
121
|
+
- `.incremark-math-block` - Block math
|
|
122
|
+
- `.incremark-mermaid` - Mermaid diagram
|
|
123
|
+
|
|
124
|
+
## Migration Guide
|
|
125
|
+
|
|
126
|
+
### Migrating from Previous Versions
|
|
127
|
+
|
|
128
|
+
If you previously used `@incremark/react/styles.css` or Vue component scoped styles, now you just need to:
|
|
129
|
+
|
|
130
|
+
1. Ensure `@incremark/theme` package is installed
|
|
131
|
+
2. Import theme styles: `import '@incremark/theme/styles.css'`
|
|
132
|
+
3. All style class names remain unchanged, backward compatible
|
|
133
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# @incremark/theme
|
|
2
|
+
|
|
3
|
+
Incremark 主题样式包 - 统一的主题系统
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @incremark/theme
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 使用
|
|
12
|
+
|
|
13
|
+
### 基础使用
|
|
14
|
+
|
|
15
|
+
在 React 或 Vue 应用中导入样式:
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
// React
|
|
19
|
+
import '@incremark/react/styles.css'
|
|
20
|
+
// 或直接导入主题包
|
|
21
|
+
import '@incremark/theme/styles.css'
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```vue
|
|
25
|
+
<!-- Vue -->
|
|
26
|
+
<style>
|
|
27
|
+
@import '@incremark/vue/style.css';
|
|
28
|
+
/* 或直接导入主题包 */
|
|
29
|
+
@import '@incremark/theme/styles.css';
|
|
30
|
+
</style>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### 主题配置
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import { applyTheme, defaultTheme, darkTheme, type DesignTokens } from '@incremark/theme'
|
|
37
|
+
|
|
38
|
+
// 使用预设主题
|
|
39
|
+
const container = document.querySelector('.incremark')
|
|
40
|
+
if (container) {
|
|
41
|
+
applyTheme(container as HTMLElement, 'dark')
|
|
42
|
+
// 或使用主题对象
|
|
43
|
+
applyTheme(container as HTMLElement, darkTheme)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// 自定义主题(部分替换)
|
|
47
|
+
const customTheme: Partial<DesignTokens> = {
|
|
48
|
+
color: {
|
|
49
|
+
text: {
|
|
50
|
+
primary: '#2c3e50'
|
|
51
|
+
},
|
|
52
|
+
code: {
|
|
53
|
+
background: '#1e1e1e'
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
applyTheme(container as HTMLElement, customTheme)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### CSS 变量
|
|
62
|
+
|
|
63
|
+
主题包支持通过 CSS 变量进行定制:
|
|
64
|
+
|
|
65
|
+
```css
|
|
66
|
+
/* 默认主题变量在 :root 中定义 */
|
|
67
|
+
.incremark {
|
|
68
|
+
--incremark-typography-font-family-base: 'Your Font', sans-serif;
|
|
69
|
+
--incremark-color-text-primary: #333;
|
|
70
|
+
--incremark-color-status-pending: #a855f7;
|
|
71
|
+
--incremark-color-code-background: #24292e;
|
|
72
|
+
--incremark-color-code-header-background: #1f2428;
|
|
73
|
+
--incremark-border-radius-lg: 12px;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* 深色主题 */
|
|
77
|
+
[data-theme="dark"] .incremark,
|
|
78
|
+
.theme-dark .incremark {
|
|
79
|
+
--incremark-color-text-primary: #e6edf3;
|
|
80
|
+
--incremark-color-background-base: #0d1117;
|
|
81
|
+
--incremark-color-code-background: #0d1117;
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## API
|
|
86
|
+
|
|
87
|
+
### 类型定义
|
|
88
|
+
|
|
89
|
+
#### `DesignTokens`
|
|
90
|
+
|
|
91
|
+
完整的设计 Token 接口,包含所有主题变量:
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
interface DesignTokens {
|
|
95
|
+
color: ColorTokens
|
|
96
|
+
typography: TypographyTokens
|
|
97
|
+
spacing: SpacingTokens
|
|
98
|
+
border: BorderTokens
|
|
99
|
+
shadow: ShadowTokens
|
|
100
|
+
animation: AnimationTokens
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
详细类型定义请参考 `src/tokens/` 目录。
|
|
105
|
+
|
|
106
|
+
### 预设主题
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
import { defaultTheme, darkTheme } from '@incremark/theme'
|
|
110
|
+
|
|
111
|
+
// defaultTheme - 默认浅色主题
|
|
112
|
+
// darkTheme - 深色主题
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### 工具函数
|
|
116
|
+
|
|
117
|
+
#### `applyTheme(element, theme)`
|
|
118
|
+
|
|
119
|
+
将主题应用到 DOM 元素。
|
|
120
|
+
|
|
121
|
+
**参数:**
|
|
122
|
+
- `element: HTMLElement` - 目标元素
|
|
123
|
+
- `theme: 'default' | 'dark' | DesignTokens | Partial<DesignTokens>` - 主题配置
|
|
124
|
+
|
|
125
|
+
**示例:**
|
|
126
|
+
```typescript
|
|
127
|
+
// 使用预设主题名
|
|
128
|
+
applyTheme(element, 'dark')
|
|
129
|
+
|
|
130
|
+
// 使用主题对象
|
|
131
|
+
applyTheme(element, darkTheme)
|
|
132
|
+
|
|
133
|
+
// 部分替换
|
|
134
|
+
applyTheme(element, {
|
|
135
|
+
color: { text: { primary: '#custom' } }
|
|
136
|
+
})
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
#### `generateCSSVars(tokens, options)`
|
|
140
|
+
|
|
141
|
+
从 Token 生成 CSS Variables 字符串。
|
|
142
|
+
|
|
143
|
+
**参数:**
|
|
144
|
+
- `tokens: DesignTokens` - 设计 Token 对象
|
|
145
|
+
- `options.prefix?: string` - CSS 变量前缀(默认 'incremark')
|
|
146
|
+
- `options.selector?: string` - CSS 选择器(默认 ':root')
|
|
147
|
+
|
|
148
|
+
**返回:** `string` - CSS Variables 字符串
|
|
149
|
+
|
|
150
|
+
#### `mergeTheme(base, override)`
|
|
151
|
+
|
|
152
|
+
深度合并两个主题对象。
|
|
153
|
+
|
|
154
|
+
**参数:**
|
|
155
|
+
- `base: DesignTokens` - 基础主题
|
|
156
|
+
- `override: Partial<DesignTokens>` - 要覆盖的部分
|
|
157
|
+
|
|
158
|
+
**返回:** `DesignTokens` - 合并后的完整主题
|
|
159
|
+
|
|
160
|
+
## 样式类名
|
|
161
|
+
|
|
162
|
+
主题包提供了统一的 CSS 类名系统:
|
|
163
|
+
|
|
164
|
+
- `.incremark` - 主容器
|
|
165
|
+
- `.incremark-block` - 块容器
|
|
166
|
+
- `.incremark-heading` - 标题
|
|
167
|
+
- `.incremark-paragraph` - 段落
|
|
168
|
+
- `.incremark-code` - 代码块
|
|
169
|
+
- `.incremark-inline-code` - 行内代码
|
|
170
|
+
- `.incremark-list` - 列表
|
|
171
|
+
- `.incremark-table` - 表格
|
|
172
|
+
- `.incremark-blockquote` - 引用块
|
|
173
|
+
- `.incremark-hr` - 分隔线
|
|
174
|
+
- `.incremark-math-inline` - 行内数学公式
|
|
175
|
+
- `.incremark-math-block` - 块级数学公式
|
|
176
|
+
- `.incremark-mermaid` - Mermaid 图表
|
|
177
|
+
|
|
178
|
+
## 迁移指南
|
|
179
|
+
|
|
180
|
+
### 从旧版本迁移
|
|
181
|
+
|
|
182
|
+
如果你之前使用的是 `@incremark/react/styles.css` 或 Vue 组件的 scoped 样式,现在只需要:
|
|
183
|
+
|
|
184
|
+
1. 确保安装了 `@incremark/theme` 包
|
|
185
|
+
2. 导入主题样式:`import '@incremark/theme/styles.css'`
|
|
186
|
+
3. 所有样式类名保持不变,向后兼容
|
|
187
|
+
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 颜色 Token 类型定义
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* 基础色系统 - 包含各种颜色的完整色阶
|
|
6
|
+
*/
|
|
7
|
+
interface BaseColorPalette {
|
|
8
|
+
/** 10 级色阶 */
|
|
9
|
+
1: string;
|
|
10
|
+
2: string;
|
|
11
|
+
3: string;
|
|
12
|
+
4: string;
|
|
13
|
+
5: string;
|
|
14
|
+
6: string;
|
|
15
|
+
7: string;
|
|
16
|
+
8: string;
|
|
17
|
+
9: string;
|
|
18
|
+
10: string;
|
|
19
|
+
}
|
|
20
|
+
interface BaseColors {
|
|
21
|
+
/** 蓝色系 */
|
|
22
|
+
blue: BaseColorPalette;
|
|
23
|
+
/** 紫色系 */
|
|
24
|
+
purple: BaseColorPalette;
|
|
25
|
+
/** 绿色系 */
|
|
26
|
+
green: BaseColorPalette;
|
|
27
|
+
/** 红色系 */
|
|
28
|
+
red: BaseColorPalette;
|
|
29
|
+
/** 橙色系 */
|
|
30
|
+
orange: BaseColorPalette;
|
|
31
|
+
/** 青色系 */
|
|
32
|
+
cyan: BaseColorPalette;
|
|
33
|
+
}
|
|
34
|
+
interface ColorTokens {
|
|
35
|
+
/** Neutral 中性色系统(10 级灰度) */
|
|
36
|
+
neutral: {
|
|
37
|
+
/** 最浅 - 纯白 */
|
|
38
|
+
1: string;
|
|
39
|
+
/** 极浅灰 - 背景色 */
|
|
40
|
+
2: string;
|
|
41
|
+
/** 浅灰 - 次级背景 */
|
|
42
|
+
3: string;
|
|
43
|
+
/** 浅中灰 - 边框浅色 */
|
|
44
|
+
4: string;
|
|
45
|
+
/** 中灰 - 边框默认 */
|
|
46
|
+
5: string;
|
|
47
|
+
/** 中深灰 - 禁用文本 */
|
|
48
|
+
6: string;
|
|
49
|
+
/** 深灰 - 次要文本 */
|
|
50
|
+
7: string;
|
|
51
|
+
/** 深灰 - 主要文本 */
|
|
52
|
+
8: string;
|
|
53
|
+
/** 极深灰 - 强调文本 */
|
|
54
|
+
9: string;
|
|
55
|
+
/** 最深 - 接近黑 */
|
|
56
|
+
10: string;
|
|
57
|
+
};
|
|
58
|
+
/** 品牌主题色 */
|
|
59
|
+
brand: {
|
|
60
|
+
/** 主题色 - 用于链接、按钮等 */
|
|
61
|
+
primary: string;
|
|
62
|
+
/** 主题色 hover 状态 */
|
|
63
|
+
primaryHover: string;
|
|
64
|
+
/** 主题色 active 状态 */
|
|
65
|
+
primaryActive: string;
|
|
66
|
+
/** 主题色浅色背景 */
|
|
67
|
+
primaryLight: string;
|
|
68
|
+
};
|
|
69
|
+
/** 文本颜色(基于 neutral) */
|
|
70
|
+
text: {
|
|
71
|
+
/** 主要文本颜色 */
|
|
72
|
+
primary: string;
|
|
73
|
+
/** 次要文本颜色 */
|
|
74
|
+
secondary: string;
|
|
75
|
+
/** 第三级文本颜色 */
|
|
76
|
+
tertiary: string;
|
|
77
|
+
/** 反色文本(用于深色背景) */
|
|
78
|
+
inverse: string;
|
|
79
|
+
};
|
|
80
|
+
/** 背景颜色(基于 neutral) */
|
|
81
|
+
background: {
|
|
82
|
+
/** 基础背景色 */
|
|
83
|
+
base: string;
|
|
84
|
+
/** 提升的背景色(卡片等) */
|
|
85
|
+
elevated: string;
|
|
86
|
+
/** 遮罩背景色 */
|
|
87
|
+
overlay: string;
|
|
88
|
+
};
|
|
89
|
+
/** 边框颜色(基于 neutral) */
|
|
90
|
+
border: {
|
|
91
|
+
/** 浅色边框 - 极浅 */
|
|
92
|
+
subtle: string;
|
|
93
|
+
/** 默认边框颜色 - 浅灰色 */
|
|
94
|
+
default: string;
|
|
95
|
+
/** 深色边框 - 深灰色 */
|
|
96
|
+
strong: string;
|
|
97
|
+
};
|
|
98
|
+
/** 代码相关颜色 */
|
|
99
|
+
code: {
|
|
100
|
+
/** 行内代码背景色 */
|
|
101
|
+
inlineBackground: string;
|
|
102
|
+
/** 行内代码文本颜色 */
|
|
103
|
+
inlineText: string;
|
|
104
|
+
/** 代码块背景色 */
|
|
105
|
+
blockBackground: string;
|
|
106
|
+
/** 代码块文本颜色 */
|
|
107
|
+
blockText: string;
|
|
108
|
+
/** 代码块头部背景色 */
|
|
109
|
+
headerBackground: string;
|
|
110
|
+
};
|
|
111
|
+
/** 状态颜色 */
|
|
112
|
+
status: {
|
|
113
|
+
/** 待处理状态 */
|
|
114
|
+
pending: string;
|
|
115
|
+
/** 已完成状态 */
|
|
116
|
+
completed: string;
|
|
117
|
+
};
|
|
118
|
+
/** 交互元素颜色 */
|
|
119
|
+
interactive: {
|
|
120
|
+
/** 链接颜色 */
|
|
121
|
+
link: string;
|
|
122
|
+
/** 链接 hover 颜色 */
|
|
123
|
+
linkHover: string;
|
|
124
|
+
/** 链接访问过的颜色 */
|
|
125
|
+
linkVisited: string;
|
|
126
|
+
/** 选中状态(checkbox 等) */
|
|
127
|
+
checked: string;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* 字体 Token 类型定义
|
|
133
|
+
*
|
|
134
|
+
* 注意:具体值待讨论确定后再填充
|
|
135
|
+
*/
|
|
136
|
+
interface TypographyTokens {
|
|
137
|
+
/** 字体族 */
|
|
138
|
+
fontFamily: {
|
|
139
|
+
/** 基础字体族 */
|
|
140
|
+
base: string;
|
|
141
|
+
/** 等宽字体族 */
|
|
142
|
+
mono: string;
|
|
143
|
+
};
|
|
144
|
+
/** 字体大小 */
|
|
145
|
+
fontSize: {
|
|
146
|
+
/** 极小字体 */
|
|
147
|
+
xs: string;
|
|
148
|
+
/** 小字体 */
|
|
149
|
+
sm: string;
|
|
150
|
+
/** 基础字体大小 */
|
|
151
|
+
base: string;
|
|
152
|
+
/** 中等字体 */
|
|
153
|
+
md: string;
|
|
154
|
+
/** 大字体 */
|
|
155
|
+
lg: string;
|
|
156
|
+
/** 标题字体大小 */
|
|
157
|
+
heading: {
|
|
158
|
+
h1: string;
|
|
159
|
+
h2: string;
|
|
160
|
+
h3: string;
|
|
161
|
+
h4: string;
|
|
162
|
+
h5: string;
|
|
163
|
+
h6: string;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
/** 字重 */
|
|
167
|
+
fontWeight: {
|
|
168
|
+
/** 正常字重 */
|
|
169
|
+
normal: number;
|
|
170
|
+
/** 中等字重 */
|
|
171
|
+
medium: number;
|
|
172
|
+
/** 半粗字重 */
|
|
173
|
+
semibold: number;
|
|
174
|
+
/** 粗体字重 */
|
|
175
|
+
bold: number;
|
|
176
|
+
};
|
|
177
|
+
/** 行高 */
|
|
178
|
+
lineHeight: {
|
|
179
|
+
/** 紧密行高 */
|
|
180
|
+
tight: number;
|
|
181
|
+
/** 正常行高 */
|
|
182
|
+
normal: number;
|
|
183
|
+
/** 宽松行高 */
|
|
184
|
+
relaxed: number;
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* 间距 Token 类型定义
|
|
190
|
+
*
|
|
191
|
+
* 注意:具体值待讨论确定后再填充
|
|
192
|
+
*/
|
|
193
|
+
interface SpacingTokens {
|
|
194
|
+
/** 极小间距 */
|
|
195
|
+
xs: string;
|
|
196
|
+
/** 小间距 */
|
|
197
|
+
sm: string;
|
|
198
|
+
/** 中间距 */
|
|
199
|
+
md: string;
|
|
200
|
+
/** 大间距 */
|
|
201
|
+
lg: string;
|
|
202
|
+
/** 超大间距 */
|
|
203
|
+
xl: string;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* 边框 Token 类型定义
|
|
208
|
+
*/
|
|
209
|
+
interface BorderTokens {
|
|
210
|
+
/** 圆角 */
|
|
211
|
+
radius: {
|
|
212
|
+
/** 小圆角 */
|
|
213
|
+
sm: string;
|
|
214
|
+
/** 中等圆角 */
|
|
215
|
+
md: string;
|
|
216
|
+
/** 大圆角 */
|
|
217
|
+
lg: string;
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* 阴影 Token 类型定义
|
|
223
|
+
*
|
|
224
|
+
* 注意:如果不需要阴影可以删除此文件
|
|
225
|
+
*/
|
|
226
|
+
interface ShadowTokens {
|
|
227
|
+
/** 小阴影 */
|
|
228
|
+
sm: string;
|
|
229
|
+
/** 中等阴影 */
|
|
230
|
+
md: string;
|
|
231
|
+
/** 大阴影 */
|
|
232
|
+
lg: string;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* 动画 Token 类型定义
|
|
237
|
+
*/
|
|
238
|
+
interface AnimationTokens {
|
|
239
|
+
/** 动画持续时间 */
|
|
240
|
+
duration: {
|
|
241
|
+
/** 快速动画 */
|
|
242
|
+
fast: string;
|
|
243
|
+
/** 正常动画 */
|
|
244
|
+
normal: string;
|
|
245
|
+
/** 慢速动画 */
|
|
246
|
+
slow: string;
|
|
247
|
+
};
|
|
248
|
+
/** 缓动函数 */
|
|
249
|
+
easing: {
|
|
250
|
+
/** 缓入缓出 */
|
|
251
|
+
easeInOut: string;
|
|
252
|
+
/** 缓出 */
|
|
253
|
+
easeOut: string;
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Token 系统主入口
|
|
259
|
+
*
|
|
260
|
+
* 定义完整的设计 Token 类型
|
|
261
|
+
*/
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* 完整的设计 Token 类型
|
|
265
|
+
*/
|
|
266
|
+
interface DesignTokens {
|
|
267
|
+
/** 基础色系统 - 各种颜色的完整色阶 */
|
|
268
|
+
baseColors: BaseColors;
|
|
269
|
+
/** 颜色系统 */
|
|
270
|
+
color: ColorTokens;
|
|
271
|
+
/** 字体系统 */
|
|
272
|
+
typography: TypographyTokens;
|
|
273
|
+
/** 间距系统 */
|
|
274
|
+
spacing: SpacingTokens;
|
|
275
|
+
/** 边框系统 */
|
|
276
|
+
border: BorderTokens;
|
|
277
|
+
/** 阴影系统 */
|
|
278
|
+
shadow: ShadowTokens;
|
|
279
|
+
/** 动画系统 */
|
|
280
|
+
animation: AnimationTokens;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* 默认主题值定义
|
|
285
|
+
*/
|
|
286
|
+
|
|
287
|
+
declare const defaultTheme: DesignTokens;
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* 深色主题值定义
|
|
291
|
+
*/
|
|
292
|
+
|
|
293
|
+
declare const darkTheme: DesignTokens;
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* 从 Token 生成 CSS Variables
|
|
297
|
+
*/
|
|
298
|
+
|
|
299
|
+
interface GenerateCSSVarsOptions {
|
|
300
|
+
/** CSS Variables 前缀,默认 'incremark' */
|
|
301
|
+
prefix?: string;
|
|
302
|
+
/** CSS 选择器,默认 ':root' */
|
|
303
|
+
selector?: string;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* 从 DesignTokens 生成 CSS Variables 字符串
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* ```typescript
|
|
310
|
+
* const cssVars = generateCSSVars(defaultTheme, {
|
|
311
|
+
* prefix: 'incremark',
|
|
312
|
+
* selector: ':root'
|
|
313
|
+
* })
|
|
314
|
+
* // 输出:
|
|
315
|
+
* // :root {
|
|
316
|
+
* // --incremark-color-text-primary: #1f2328;
|
|
317
|
+
* // ...
|
|
318
|
+
* // }
|
|
319
|
+
* ```
|
|
320
|
+
*/
|
|
321
|
+
declare function generateCSSVars(tokens: DesignTokens, options?: GenerateCSSVarsOptions): string;
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* 深度合并主题,支持部分替换
|
|
325
|
+
*/
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* 合并主题,支持部分替换
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```typescript
|
|
332
|
+
* const customTheme = mergeTheme(defaultTheme, {
|
|
333
|
+
* color: {
|
|
334
|
+
* text: {
|
|
335
|
+
* primary: '#custom-color'
|
|
336
|
+
* }
|
|
337
|
+
* }
|
|
338
|
+
* })
|
|
339
|
+
* // 只替换 text.primary,其他保持默认值
|
|
340
|
+
* ```
|
|
341
|
+
*/
|
|
342
|
+
declare function mergeTheme(base: DesignTokens, override: Partial<DesignTokens>): DesignTokens;
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* 应用主题到 DOM 元素
|
|
346
|
+
*/
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* 应用主题到 DOM 元素
|
|
350
|
+
*
|
|
351
|
+
* @param element - 目标元素,默认为 document.documentElement
|
|
352
|
+
* @param theme - 主题配置,可以是:
|
|
353
|
+
* - 字符串:'default' | 'dark'
|
|
354
|
+
* - 完整主题对象:DesignTokens
|
|
355
|
+
* - 部分主题对象:Partial<DesignTokens>(会合并到默认主题)
|
|
356
|
+
*
|
|
357
|
+
* @example
|
|
358
|
+
* ```typescript
|
|
359
|
+
* // 使用预设主题(通过类名切换)
|
|
360
|
+
* applyTheme(containerElement, 'dark') // 添加 .theme-dark 类
|
|
361
|
+
* applyTheme(containerElement, 'default') // 移除 .theme-dark 类
|
|
362
|
+
*
|
|
363
|
+
* // 使用自定义主题(通过 inline style 设置 CSS 变量)
|
|
364
|
+
* applyTheme(containerElement, {
|
|
365
|
+
* color: {
|
|
366
|
+
* brand: {
|
|
367
|
+
* primary: '#8b5cf6'
|
|
368
|
+
* }
|
|
369
|
+
* }
|
|
370
|
+
* })
|
|
371
|
+
* ```
|
|
372
|
+
*/
|
|
373
|
+
declare function applyTheme(element: (HTMLElement | Document) | undefined, theme: 'default' | 'dark' | DesignTokens | Partial<DesignTokens>): void;
|
|
374
|
+
|
|
375
|
+
export { type AnimationTokens, type BorderTokens, type ColorTokens, type DesignTokens, type GenerateCSSVarsOptions, type ShadowTokens, type SpacingTokens, type DesignTokens as ThemeTokens, type TypographyTokens, applyTheme, darkTheme, defaultTheme, generateCSSVars, mergeTheme };
|