Skip to content

Commit 02d5a2e

Browse files
committed
release: v2.1.1
2 parents 088b6ad + b433f76 commit 02d5a2e

35 files changed

Lines changed: 938 additions & 289 deletions

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"editor.lineHeight": 24,
44
"vetur.validation.template": false,
55
"editor.codeActionsOnSave": {
6-
"source.fixAll.eslint": true,
6+
"source.fixAll.eslint": "always"
77
},
88
"editor.formatOnSave": true,
99
}

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
## 更新日志
22

3+
### 2.1.1
4+
5+
*2024-07-02*
6+
7+
#### Docs 📝
8+
9+
- 预览页新增持久化主题、
10+
- 伴随操作系统切换主题
11+
- 新增`startViewTransition`视图过渡
12+
13+
#### Feat ✨
14+
15+
- 新增`Rate``Progress`暗黑化工具方法`darken`
16+
- 新增白屏解决脚本`dark-mode`
17+
18+
#### Fix 🐛
19+
20+
- 修复`Progress``Rate`无法支持暗黑模式
21+
322
### 2.0.1
423

524
*2024-06-19*

EXAMPLE.md

Lines changed: 0 additions & 92 deletions
This file was deleted.

README.en.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
<h1 style="color: #409eff; text-align: center; font-size: 50px">Element-theme-darkplus</h1>
2+
3+
<p style='text-align: center'>
4+
<a href="https://github.com/ElemeFE/element">
5+
<img src="https://img.shields.io/badge/element--ui-2.15.14-blue.svg" alt="element-ui" />
6+
</a>
7+
<a href="https://github.com/gulpjs/gulp">
8+
<img src="https://img.shields.io/badge/gulp-4.0.2-brightgreen.svg" alt="gulp" />
9+
</a>
10+
<a href="https://github.com/sass/dart-sass">
11+
<img src="https://img.shields.io/badge/sass-1.32.13-important.svg" alt="sass" />
12+
</a>
13+
</p>
14+
15+
[简体中文](README.md) | English
16+
17+
## Introduction
18+
19+
The [element-theme-darkplus](https://github.com/dongwei1125/theme-dark) is an [Element](https://github.com/ElemeFE/element) component dark theme base on the latest version `v2.15.14`.
20+
21+
- [Preview](https://dongwei1125.github.io/theme-dark)
22+
- [Look Around](https://juejin.cn/post/7254372820172030011)
23+
24+
## Sample
25+
26+
- [Simple Switch](https://codepen.io/dongwei1125/pen/VwOoWLy)
27+
- [Progress](https://codepen.io/dongwei1125/pen/vYwoZez)
28+
- [StartViewTransition/Persistence/System Responsive](https://codepen.io/dongwei1125/pen/dyExzaP)
29+
30+
## Install
31+
32+
```bash
33+
npm i element-theme-darkplus -S
34+
```
35+
36+
## Import
37+
38+
```javascript
39+
// webpack
40+
import 'element-theme-darkplus/lib/index.css';
41+
42+
// CDN
43+
<link rel="stylesheet" href="https://unpkg.com/element-theme-darkplus/lib/index.css">
44+
```
45+
46+
## Import on demand
47+
48+
```javascript
49+
import 'element-theme-darkplus/lib/input.css';
50+
51+
// CDN
52+
<link rel="stylesheet" href="https://unpkg.com/element-theme-darkplus/lib/input.css">
53+
```
54+
55+
## Switch
56+
57+
If you have a chalk theme, a dark theme, two themes free to switch, then this way is best for you.
58+
59+
```javascript
60+
import 'element-ui/lib/theme-chalk/index.css';
61+
import 'element-theme-darkplus/lib/index.color.css';
62+
```
63+
64+
The official chalk theme [theme-chalk](https://github.com/ElementUI/theme-chalk) includes component basic styles and chalk colors, while the dark theme [element-theme-darkplus](https://github.com/dongwei1125/theme-dark) also includes component basic styles and dark colors. Importing both will result in redundant component basic styles. Therefore, we have provided an additional theme pack that only includes dark colors. The import method is very simple, just add a `color` suffix to the style file with the same name.
65+
66+
```javascript
67+
import `element-theme-darkplus/lib/index.color.css`;
68+
import `element-theme-darkplus/lib/input.color.css`;
69+
```
70+
71+
## Advanced
72+
73+
The rating component [Rate](https://github.com/ElemeFE/element/blob/master/packages/rate/src/main.vue) is special, with default values defined for color related `props` within the `Element`, and inline styles used in the `template`, resulting in external theme styles that cannot be overwritten.
74+
75+
| `Props` | `Default` |
76+
| --- | --- |
77+
| `void-color` | `#c6d1de` |
78+
| `disabled-void-color` | `#eff2f7` |
79+
| `text-color` | `#1f2d3d` |
80+
81+
The transitive null value reset the corresponding `props` value for the subject to take effect.
82+
83+
```html
84+
<el-rate :value="3" show-text void-color="" text-color="" />
85+
```
86+
87+
The progress bar component [Progress](https://github.com/ElemeFE/element/blob/master/packages/progress/src/progress.vue) is similar, only line progress bar are supported, and circle and dashboard shapes are not supported.
88+
89+
| `Props` | `Default` |
90+
| --- | --- |
91+
| `define-back-color` | `#ebeef5` |
92+
| `text-color` | `#606266` |
93+
94+
```html
95+
<el-progress :percentage="20" define-back-color="" text-color="" />
96+
```
97+
98+
Although the two components can pass null values to reset properties to support dark themes, for students who are not concerned about this feature, it is unclear why properties such as `text-color=""` are passed in, which undoubtedly adds mental burden at the development level.
99+
100+
The style approach cannot solve the fundamental problem of `Rate` and `Progress`.
101+
102+
We have considered another approach, which is to redefine the `Rate` and `Progress` components, but without compromising the scalability and uniqueness of the original components. Therefore, we adopted the method of inheriting the original components and added an intermediate layer in `javascript` to help users initially empty the relevant color `props`.
103+
104+
### Import
105+
106+
```javascript
107+
import ElementUI from 'element-ui'
108+
import Darken from 'element-theme-darkplus/utils/darken'
109+
110+
Vue.use(ElementUI)
111+
Vue.use(Darken(ElementUI))
112+
```
113+
114+
### Import on demand
115+
116+
```javascript
117+
import { Progress, Rate } from 'element-ui'
118+
import Darken from 'element-theme-darkplus/utils/darken'
119+
120+
Vue.component(Progress.name, Darken(Progress))// or Vue.use(Darken(Progress))
121+
Vue.component(Rate.name, Darken(Rate))
122+
```
123+
124+
### CDN
125+
126+
```html
127+
<script src="https://unpkg.com/element-theme-darkplus/utils/darken.js"></script>
128+
```
129+
130+
## Problem
131+
132+
### How to persist themes, update themes responsive to the system?
133+
134+
The theme `switch` in [The preview page](https://dongwei1125.github.io/theme-dark) has added common dark theme functions, such as browser caching to permanently save the user's frequently used theme status, dynamically switching theme styles according to operating system presets, and media query style transition. You can refer to the component [ThemeToggle](https://github.com/dongwei1125/theme-dark/tree/master/docs/components/ThemeToggle/dark).
135+
136+
### Persistent loading for the first time in dark mode with white screen?
137+
138+
The reason is that the page has already been loaded, and the instance component only starts adding the `dark` class name to the `DOM` root element during the [Vue](https://v2.cn.vuejs.org/v2/api/#%E9%80%89%E9%A1%B9-%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E9%92%A9%E5%AD%90) lifecycle. However, before the loading time, it still defaults to the initial style, which will cause the page to white screen.
139+
140+
The solution is very simple. Add a script to the `head` in the `html`, which reads cache or operating system theme keywords before loading the page, and considers whether to add a `dark` class name to the root element of the `DOM`.
141+
142+
```html
143+
<script src="https://unpkg.com/element-theme-darkplus/utils/dark-mode.js"></script>
144+
```

0 commit comments

Comments
 (0)