This repository has been archived by the owner on Oct 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
233 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
node_modules/ | ||
test/ | ||
dist/ | ||
docs/ | ||
examples/ | ||
npm-debug.log | ||
yarn-error.log | ||
|
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,67 @@ | ||
module.exports = { | ||
base: '/vuepress-theme-default-prefers-color-scheme/', | ||
title: 'vuepress-theme-default-prefers-color-scheme', | ||
description: 'add prefers-color-scheme for vuepress default theme', | ||
dest: 'dist/', | ||
evergreen: true, | ||
theme: require.resolve('../../'), | ||
markdown: { | ||
lineNumbers: true | ||
}, | ||
locales: { | ||
'/': { | ||
lang: 'en-US', | ||
title: 'vuepress-theme-default-prefers-color-scheme', | ||
description: 'add prefers-color-scheme for vuepress default theme' | ||
}, | ||
'/zh/': { | ||
lang: 'zh-CN', | ||
title: 'vuepress-theme-default-prefers-color-scheme', | ||
description: '为 vuepress 的默认主题增加 prefers-color-scheme' | ||
} | ||
}, | ||
themeConfig: { | ||
defaultTheme: { dark: [19, 6] }, | ||
repo: 'tolking/vuepress-theme-default-prefers-color-scheme', | ||
docsDir: 'examples', | ||
editLinks: true, | ||
locales: { | ||
'/': { | ||
selectText: 'Languages', | ||
label: 'English', | ||
editLinkText: 'Edit this page on GitHub', | ||
lastUpdated: 'Last Updated', | ||
serviceWorker: { | ||
updatePopup: { | ||
message: "New content is available.", | ||
buttonText: "Refresh" | ||
} | ||
}, | ||
sidebar: [ | ||
'/' | ||
] | ||
}, | ||
'/zh/': { | ||
selectText: '选择语言', | ||
label: '简体中文', | ||
editLinkText: '在 GitHub 上编辑此页', | ||
lastUpdated: '最后更新时间', | ||
serviceWorker: { | ||
updatePopup: { | ||
message: "发现新内容可用.", | ||
buttonText: "刷新" | ||
} | ||
}, | ||
sidebar: [ | ||
'/zh/' | ||
] | ||
} | ||
} | ||
}, | ||
postcss: { | ||
plugins: [ | ||
require('css-prefers-color-scheme/postcss'), | ||
require('autoprefixer') | ||
] | ||
} | ||
} |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,80 @@ | ||
## Introduction | ||
|
||
vuepress-theme-default-prefers-color-scheme is a theme that adds `light` and `dark` themes to the [default theme](https://v1.vuepress.vuejs.org/zh/theme/default-theme-config.html) of vuepress | ||
|
||
## How It Works | ||
|
||
base on [prefers-color-scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme) and [CSS Variables](https://developer.mozilla.org/en-US/docs/Web/CSS/--*) | ||
|
||
#### View Support Browsers | ||
|
||
- [prefers-color-scheme](https://www.caniuse.com/#search=prefers-color-scheme) | ||
- [CSS Variables](https://www.caniuse.com/#search=CSS%20Variables) | ||
|
||
**`prefers-color-scheme` also needs your system support** | ||
|
||
- mac Mojave ^10.14 | ||
- windows 10 ^1809 | ||
|
||
**For unsupported browsers, the same style as the default theme will be displayed** | ||
|
||
## Installation | ||
|
||
``` sh | ||
yarn add vuepress-theme-default-prefers-color-scheme | ||
# or | ||
npm i vuepress-theme-default-prefers-color-scheme | ||
``` | ||
|
||
## Usage | ||
|
||
``` js {3} | ||
// .vuepress -> config.js | ||
module.exports = { | ||
theme: 'default-prefers-color-scheme', | ||
themeConfig: { | ||
// ... | ||
} | ||
} | ||
``` | ||
|
||
## Options | ||
|
||
### defaultTheme | ||
- Type: `string`, `object` | ||
- Default: `undefined` | ||
- Required: `false` | ||
|
||
::: tip | ||
By default, light or dark themes are displayed by [prefers-color-scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme), You can change it by `defaultTheme`. base on [css-prefers-color-scheme](https://github.com/csstools/css-prefers-color-scheme) | ||
::: | ||
|
||
support `light`, `dark` or `{ theme: [begin hours, end hours] }` | ||
|
||
``` js {4,6,8} | ||
module.exports = { | ||
theme: 'default-prefers-color-scheme', | ||
themeConfig: { | ||
defaultTheme: 'dark', | ||
// or | ||
defaultTheme: { dark: [18, 6] }, | ||
// or | ||
defaultTheme: { light: [6, 18], dark: [18, 6] }, | ||
}, | ||
// When using `light theme` or `dark theme`, you need to add a postcss plugins to your config.js | ||
postcss: { | ||
plugins: [ | ||
require('css-prefers-color-scheme/postcss'), | ||
require('autoprefixer') | ||
] | ||
} | ||
} | ||
``` | ||
|
||
[Theme Config](https://v1.vuepress.vuejs.org/theme/default-theme-config.html) | ||
|
||
## Styling | ||
|
||
To apply simple color overrides to the styling of the [default preset](https://github.com/tolking/vuepress-theme-default-prefers-color-scheme/blob/master/styles/palette.styl), In your `.vuepress/styles/palette.styl` file. | ||
|
||
**`$accentColor` and `$accentDarkColor` are best changed together** |
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,80 @@ | ||
## 介绍 | ||
|
||
vuepress-theme-default-prefers-color-scheme 是一款为 [vuepress 默认主题](https://v1.vuepress.vuejs.org/zh/theme/default-theme-config.html) 增加 `浅色` 与 `深色` 主题的一款主题 | ||
|
||
## 原理 | ||
|
||
主要是基于下一代 css 技术中的 [prefers-color-scheme](https://developer.mozilla.org/zh-CN/docs/Web/CSS/@media/prefers-color-scheme) 与 [CSS Variables](https://developer.mozilla.org/zh-CN/docs/Web/CSS/--*) 实现。 | ||
|
||
#### 查看支持浏览器 | ||
|
||
- [prefers-color-scheme](https://www.caniuse.com/#search=prefers-color-scheme) | ||
- [CSS Variables](https://www.caniuse.com/#search=CSS%20Variables) | ||
|
||
**对于 `prefers-color-scheme` 还需要你的操作系统支持切换浅色与深色模式** | ||
|
||
- mac Mojave ^10.14 | ||
- windows 10 ^1809 | ||
|
||
**对于都不支持的浏览器将显示与默认主题几乎相同的样式** | ||
|
||
## 安装 | ||
|
||
``` sh | ||
yarn add vuepress-theme-default-prefers-color-scheme | ||
# or | ||
npm i vuepress-theme-default-prefers-color-scheme | ||
``` | ||
|
||
## 使用 | ||
|
||
``` js {3} | ||
// .vuepress -> config.js | ||
module.exports = { | ||
theme: 'default-prefers-color-scheme', | ||
themeConfig: { | ||
// ... | ||
} | ||
} | ||
``` | ||
|
||
## 配置 | ||
|
||
### defaultTheme | ||
- Type: `string`, `object` | ||
- Default: `undefined` | ||
- Required: `false` | ||
|
||
::: tip | ||
默认情况下,要显示浅色或深色主题由 [prefers-color-scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme) 决定, 你可以通过设置 `defaultTheme` 来指定显示的主题颜色。基于 [css-prefers-color-scheme](https://github.com/csstools/css-prefers-color-scheme) | ||
::: | ||
|
||
支持 `light`, `dark` 或者 `{ theme: [begin hours, end hours] }` | ||
|
||
``` js {4,6,8} | ||
module.exports = { | ||
theme: 'default-prefers-color-scheme', | ||
themeConfig: { | ||
defaultTheme: 'dark', | ||
// or | ||
defaultTheme: { dark: [18, 6] }, | ||
// or | ||
defaultTheme: { light: [6, 18], dark: [18, 6] }, | ||
}, | ||
// 当你指定了显示主题的颜色时,你需要增加如下的 postcss 插件 | ||
postcss: { | ||
plugins: [ | ||
require('css-prefers-color-scheme/postcss'), | ||
require('autoprefixer') | ||
] | ||
} | ||
} | ||
``` | ||
|
||
其它配置与 [官方主题配置](https://v1.vuepress.vuejs.org/theme/default-theme-config.html) 相同 | ||
|
||
## 样式 | ||
|
||
在 `.vuepress/styles/palette.styl` 文件里你可以对 [默认预设的样式](https://github.com/tolking/vuepress-theme-default-prefers-color-scheme/blob/master/styles/palette.styl) 应用简单的颜色替换 | ||
|
||
**`$accentColor` 和 `$accentDarkColor` 最好被一起更改** |
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