-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: extract all css colors into css variables (#20)
将所有组件内使用的 css 颜色提取为 css 变量,方便在外部(比如主题)自定义配色,也可用于适配 dark mode。 /kind feature Fixes #19 TODO: - [x] 完善文档 example: <img width="759" alt="图片" src="https://github.com/halo-dev/plugin-search-widget/assets/21301288/16b55768-f4c7-4613-875e-33e6da74aae3"> <img width="695" alt="图片" src="https://github.com/halo-dev/plugin-search-widget/assets/21301288/9c71fb1a-a742-40c2-9f75-f4f568a729fa"> 在外部定义 css 的方式如下: ```html <style> @media (prefers-color-scheme: dark) { :root { color-scheme: dark; --halo-search-widget-color-modal-layer: rgba(0, 0, 0, 0.8); --halo-search-widget-color-modal-content-bg: rgb(15 23 42); --halo-search-widget-color-form-input: rgb(255, 255, 255); --halo-search-widget-color-form-input-placeholder: rgb(148 163 184); --halo-search-widget-color-form-input-bg: rgb(15 23 42); --halo-search-widget-color-form-divider: rgb(30 41 59); --halo-search-widget-color-result-item-bg: rgb(30 41 59); --halo-search-widget-color-result-item-hover-bg: rgb(51 65 85); --halo-search-widget-color-result-item-title: rgb(255 255 255); --halo-search-widget-color-result-item-content: rgb(148 163 184); --halo-search-widget-color-command-kbd-item: rgb(148 163 184); --halo-search-widget-color-command-kbd-border: rgb(30 41 59); --halo-search-widget-color-result-empty: rgb(148 163 184); } } </style> ``` 此外,此 PR 也附带了一套暗黑模式的 css 变量,使用方式: 1. 在 html 或者 body 添加 class:`color-scheme-dark / dark / color-scheme-auto` 2. 在 html 或者 body 添加 data:`data-theme="dark / auto"` ```release-note 提供 CSS 变量,用于在外部自定义配色。 ```
- Loading branch information
Showing
12 changed files
with
322 additions
and
99 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
@media (prefers-color-scheme: dark) { | ||
.color-scheme-auto, | ||
[data-color-scheme='auto'] { | ||
color-scheme: dark; | ||
--halo-search-widget-color-modal-layer: rgba(0, 0, 0, 0.8); | ||
--halo-search-widget-color-modal-content-bg: rgb(15 23 42); | ||
--halo-search-widget-color-form-input: rgb(255, 255, 255); | ||
--halo-search-widget-color-form-input-placeholder: rgb(148 163 184); | ||
--halo-search-widget-color-form-input-bg: rgb(15 23 42); | ||
--halo-search-widget-color-form-divider: rgb(30 41 59); | ||
--halo-search-widget-color-result-item-bg: rgb(30 41 59); | ||
--halo-search-widget-color-result-item-hover-bg: rgb(51 65 85); | ||
--halo-search-widget-color-result-item-title: rgb(255 255 255); | ||
--halo-search-widget-color-result-item-content: rgb(148 163 184); | ||
--halo-search-widget-color-command-kbd-item: rgb(148 163 184); | ||
--halo-search-widget-color-command-kbd-border: rgb(30 41 59); | ||
--halo-search-widget-color-result-empty: rgb(148 163 184); | ||
} | ||
} | ||
|
||
.color-scheme-dark, | ||
.dark, | ||
[data-color-scheme='dark'] { | ||
color-scheme: dark; | ||
--halo-search-widget-color-modal-layer: rgba(0, 0, 0, 0.8); | ||
--halo-search-widget-color-modal-content-bg: rgb(15 23 42); | ||
--halo-search-widget-color-form-input: rgb(255, 255, 255); | ||
--halo-search-widget-color-form-input-placeholder: rgb(148 163 184); | ||
--halo-search-widget-color-form-input-bg: rgb(15 23 42); | ||
--halo-search-widget-color-form-divider: rgb(30 41 59); | ||
--halo-search-widget-color-result-item-bg: rgb(30 41 59); | ||
--halo-search-widget-color-result-item-hover-bg: rgb(51 65 85); | ||
--halo-search-widget-color-result-item-title: rgb(255 255 255); | ||
--halo-search-widget-color-result-item-content: rgb(148 163 184); | ||
--halo-search-widget-color-command-kbd-item: rgb(148 163 184); | ||
--halo-search-widget-color-command-kbd-border: rgb(30 41 59); | ||
--halo-search-widget-color-result-empty: rgb(148 163 184); | ||
} |
Oops, something went wrong.