-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
添加暗黑模式 #19
Comments
1 task
f2c-ci-robot bot
pushed a commit
that referenced
this issue
Oct 27, 2023
将所有组件内使用的 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 变量,用于在外部自定义配色。 ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
计划在组件内部直接提供暗黑模式,一些实现细节:
The text was updated successfully, but these errors were encountered: