Skip to content
This repository has been archived by the owner on Oct 1, 2023. It is now read-only.

Commit

Permalink
Merge pull request #6 from tolking/dev
Browse files Browse the repository at this point in the history
up to 1.0.2
  • Loading branch information
tolking authored Aug 27, 2019
2 parents 36d9445 + 4148350 commit 2dc1b54
Show file tree
Hide file tree
Showing 16 changed files with 354 additions and 206 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
node_modules/
test/
dist/
docs/
examples/
npm-debug.log
yarn-error.log
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

[README](README.md) | [CHANGELOG](CHANGELOG.md)

## 1.0.2

- fix styles

## 1.0.1

- Add `defaultTheme` to control default theme color
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

---

![light.jpg](./examples/public/img/light.jpg)
![light.jpg](./docs/.vuepress/public/img/light.jpg)

![light.jpg](./examples/public/img/dark.jpg)
![light.jpg](./docs/.vuepress/public/img/dark.jpg)

---

Expand Down
67 changes: 67 additions & 0 deletions docs/.vuepress/config.js
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')
]
}
}
File renamed without changes.
File renamed without changes
File renamed without changes
22 changes: 21 additions & 1 deletion examples/started.md → docs/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
## 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
Expand Down Expand Up @@ -26,7 +46,7 @@ module.exports = {
- 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`
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] }`
Expand Down
80 changes: 80 additions & 0 deletions docs/zh/README.md
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` 最好被一起更改**
20 changes: 0 additions & 20 deletions examples/.vuepress/config.js

This file was deleted.

15 changes: 0 additions & 15 deletions examples/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion layouts/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ export default {
</script>

<style lang="stylus">
@require '../styles/index.styl'
@require '../styles/components.styl'
</style>
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vuepress-theme-default-prefers-color-scheme",
"version": "1.0.1",
"version": "1.0.2",
"main": "index.js",
"description": "add prefers-color-scheme for vuepress default theme",
"author": "tolking <[email protected]>",
Expand All @@ -12,9 +12,9 @@
"homepage": "https://github.com/tolking/vuepress-theme-default-prefers-color-scheme",
"doc": "https://tolking.github.io/vuepress-theme-default-prefers-color-scheme",
"scripts": {
"dev": "vuepress dev examples",
"serve": "vuepress dev examples",
"build": "vuepress build examples"
"dev": "vuepress dev docs",
"serve": "vuepress dev docs",
"build": "vuepress build docs"
},
"keywords": [
"vue",
Expand Down
Loading

0 comments on commit 2dc1b54

Please sign in to comment.