Skip to content

Commit fd7f73b

Browse files
committed
docs: 补充主题功能引导文档中背景和网格的应用优先级说明
1 parent 1d1eb23 commit fd7f73b

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

sites/docs/docs/tutorial/basic/theme.en.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,43 @@ lf.setTheme({}, 'customTheme')
112112
### Theme Style Priority
113113

114114
The priority of theme styles (from low to high):
115+
116+
#### Node, Edge, Text and Other Element Style Priority
115117
1. Built-in base styles (defaultTheme)
116118
2. Applied theme mode styles (specified via `themeMode` or second parameter of `setTheme`)
117119
3. Custom styles (specified via `style` or first parameter of `setTheme`)
118120

121+
#### Background and Grid Style Priority
122+
Background and grid configurations have independent update mechanisms, with priority divided into two phases:
123+
124+
**Initialization Phase Priority** (from low to high):
125+
1. Configuration in style: `background` and `grid` configurations in the constructor's `style` parameter
126+
2. Direct Parameter Configuration: Values set through `background` and `grid` parameters in the constructor (overrides configurations in style)
127+
128+
**Runtime Phase Priority** (from low to high):
129+
1. Current Configuration: `background` and `grid` configurations after initialization
130+
2. Theme Mode Configuration: When calling `setTheme(style, themeMode)`, background and grid configurations in themeMode will override current configuration
131+
3. Custom Configuration: `background` and `grid` configurations in the style parameter of `setTheme(style, themeMode)` will override theme mode configuration
132+
133+
```tsx | pure
134+
// Example: Priority application of background and grid
135+
136+
// Initialization: Direct parameters > style parameters
137+
const lf = new LogicFlow({
138+
style: {
139+
background: { color: '#f0f0f0' }, // Lower priority
140+
grid: { size: 15 } // Lower priority
141+
},
142+
background: { color: '#f5f5f5' }, // Final effective (overrides style configuration)
143+
grid: { size: 20 }, // Final effective (overrides style configuration)
144+
})
145+
146+
// Runtime: style parameters > themeMode parameters > current configuration
147+
lf.setTheme({
148+
background: { color: '#ffffff' }, // Final effective background configuration
149+
grid: { size: 10, visible: true }, // Final effective grid configuration
150+
}, 'dark') // Background and grid configurations in dark theme mode will be overridden by style parameters
151+
```
152+
119153
## Usage Example
120154
<code id="graphData" src="../../../src/tutorial/basic/instance/theme"></code>

sites/docs/docs/tutorial/basic/theme.zh.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,44 @@ lf.setTheme({}, 'customTheme')
113113
### 主题样式优先级
114114

115115
主题样式的应用优先级(从低到高):
116+
117+
#### 节点、边、文本等元素样式优先级
116118
1. 内置基础样式(defaultTheme)
117119
2. 应用的主题模式样式(通过 `themeMode``setTheme` 的第二个参数设置)
118120
3. 自定义样式(通过 `style``setTheme` 的第一个参数设置)
119121

122+
#### 背景和网格样式优先级
123+
背景(background)和网格(grid)配置具有独立的更新机制,其优先级分为两个阶段:
124+
125+
**初始化阶段优先级**(从低到高):
126+
1. style 中的配置:通过构造函数 `style` 参数中的 `background``grid` 配置
127+
2. 直接参数配置:通过构造函数中的 `background``grid` 参数设置的值(会覆盖 style 中的配置)
128+
129+
**运行时阶段优先级**(从低到高):
130+
1. 当前配置:初始化后的 `background``grid` 配置
131+
2. 主题模式配置:调用 `setTheme(style, themeMode)` 时,themeMode 中的背景和网格配置会覆盖当前配置
132+
3. 自定义配置:`setTheme(style, themeMode)` 中 style 参数的 `background``grid` 配置会覆盖主题模式配置
133+
134+
```tsx | pure
135+
// 示例:背景和网格的优先级应用
136+
137+
// 初始化时:直接参数 > style 参数
138+
const lf = new LogicFlow({
139+
style: {
140+
background: { color: '#f0f0f0' }, // 优先级较低
141+
grid: { size: 15 } // 优先级较低
142+
},
143+
background: { color: '#f5f5f5' }, // 最终生效(覆盖 style 中的配置)
144+
grid: { size: 20 }, // 最终生效(覆盖 style 中的配置)
145+
})
146+
147+
// 运行时:style 参数 > themeMode 参数 > 当前配置
148+
lf.setTheme({
149+
background: { color: '#ffffff' }, // 最终生效的背景配置
150+
grid: { size: 10, visible: true }, // 最终生效的网格配置
151+
}, 'dark') // dark 主题模式的背景和网格配置会被 style 参数覆盖
152+
```
153+
120154
## 使用示例
121155
<code id="graphData" src="../../../src/tutorial/basic/instance/theme"></code>
122156

0 commit comments

Comments
 (0)