-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: 调整暗黑主题样式的加载方式, 避免样式污染和构建错误 (#2988)
* refactor: 调整暗黑主题样式的加载方式, 避免样式污染和构建错误 * test: 完善单测
- Loading branch information
1 parent
e28baa0
commit fa142fa
Showing
19 changed files
with
67 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,27 @@ | ||
@import '../variables.less'; | ||
|
||
:root { | ||
.@{s2-cls-prefix}-dark-theme { | ||
@white: #fff; | ||
|
||
// container | ||
@{css-var-prefix}-background: #000; | ||
@{css-var-prefix}-tooltip-background: rgba(43, 43, 43, 0.95); | ||
@{css-var-prefix}-tooltip-operator-background: rgba(43, 43, 43, 0.95); | ||
@{css-var-prefix}-tooltip-operator-menu-selected-background: #1677ff; | ||
|
||
// container | ||
@{css-var-prefix}-container-background: #191919; | ||
@{css-var-prefix}-block-background: #232323; | ||
|
||
// text | ||
@{css-var-prefix}-font: @white; | ||
|
||
each(range(19), { | ||
@fadePercent: 100 - @value * 5; | ||
@{css-var-prefix}-font-@{fadePercent}: fade(@white, @fadePercent); | ||
}); | ||
|
||
// border | ||
@{css-var-prefix}-border: fade(@white, 15); | ||
@{css-var-prefix}-divider: fade(@white, 10); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,9 @@ | ||
import { PALETTE_MAP, STYLE_ELEMENT_ID } from '../common/constant'; | ||
import { PALETTE_MAP } from '../common/constant'; | ||
import type { Palette, ThemeName } from '../common/interface/theme'; | ||
import DarkVars from '../styles/theme/dark.less'; | ||
import { injectCssText } from './inject-css-text'; | ||
|
||
/** | ||
* 获取当前的主题色板 | ||
*/ | ||
export const getPalette = (themeName?: ThemeName): Palette => { | ||
return PALETTE_MAP[themeName!] || PALETTE_MAP['default']; | ||
}; | ||
|
||
/** | ||
* 根据主题注入组件的 CSS 变量 | ||
*/ | ||
export const injectThemeVars = (themeName?: ThemeName) => { | ||
// 目前仅 dark 主题需要定制 | ||
injectCssText( | ||
STYLE_ELEMENT_ID, | ||
themeName === 'dark' ? (DarkVars as string) : '', | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters