Skip to content

Commit 1066cf6

Browse files
committed
docs(advance): add description for nest css and auto prefix
1 parent 5c4764f commit 1066cf6

File tree

7 files changed

+136
-4
lines changed

7 files changed

+136
-4
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
✅ Add or override attrs
4848

49-
✅ Support nesting css. (web only: https://drafts.csswg.org/css-nesting/#nesting)
49+
✅ Support nesting css.
5050

5151
## 📖Documentation
5252

@@ -180,4 +180,7 @@ const StyledDiv = styled.div`
180180

181181
<br>
182182

183-
And thanks [styled-components](https://github.com/styled-components).
183+
And thanks
184+
185+
- [styled-components](https://github.com/styled-components).
186+
- [stylis](https://github.com/thysultan/stylis)

docs/.vitepress/en.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ function sidebarGuide() {
5454
items: [
5555
{ text: 'Theming', link: 'theming' },
5656
{ text: 'Global Styles', link: 'global-style' },
57-
{ text: 'CSS Mixin', link: 'css-mixin' }
57+
{ text: 'CSS Mixin', link: 'css-mixin' },
58+
{ text: 'Nest CSS', link: 'nest-css' },
59+
{ text: 'Auto Prefix', link: 'auto-prefix' },
5860
],
5961
},
6062
{

docs/.vitepress/zh.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ function sidebarGuide() {
7878
items: [
7979
{ text: '主题', link: 'theming' },
8080
{ text: '全局样式', link: 'global-style' },
81-
{ text: '样式复用', link: 'css-mixin' }
81+
{ text: '样式复用', link: 'css-mixin' },
82+
{ text: '嵌套CSS', link: 'nest-css' },
83+
{ text: 'CSS私有前缀', link: 'auto-prefix' },
8284
],
8385
},
8486
{

docs/guide/advances/auto-prefix.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
outline: deep
3+
---
4+
5+
# Auto Prefix Added
6+
7+
This feature is a part of the `@vvibe/vue-styled-components` package. It automatically adds vendor prefixes to CSS rules based on the browser support you specify. This ensures that your CSS rules are compatible with the most widely used browsers, which can help improve the compatibility of your website.
8+
9+
The `@vvibe/vue-styled-components` package uses the `stylis` library to add vendor prefixes.
10+
11+
Here's an example:
12+
13+
```js
14+
import { styled } from '@vvibe/vue-styled-components';
15+
const StyledDiv = styled.div`
16+
display: flex;
17+
}`
18+
19+
// output:
20+
// .styled-div {
21+
// display: -webkit-box;
22+
// display: -webkit-flex;
23+
// display: -ms-flexbox;
24+
// display: flex;
25+
// }
26+
```

docs/guide/advances/nest-css.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
outline: deep
3+
---
4+
5+
# Nest CSS
6+
7+
In Vue Styled Components, you can write CSS in the same way as `less` or `sass`. `@vvibe/vue-styled-components` is based on `stylis` compiling CSS to basic css, so you needn't worry about the compatibility.
8+
9+
For example, you can write CSS like this:
10+
11+
```js
12+
import { styled } from '@vvibe/vue-styled-components';
13+
const StyledDiv = styled.div`
14+
width: 100px;
15+
height: 100px;
16+
&:hover {
17+
background-color: #000;
18+
&:active {
19+
background-color: #fff;
20+
}
21+
}
22+
}`
23+
24+
// output:
25+
// .styled-xxx {
26+
// width: 100px;
27+
// height: 100px;
28+
// }
29+
// .styled-xxx:hover {
30+
// background-color: #000;
31+
// }
32+
// .styled-xxx:hover:active {
33+
// background-color: #fff;
34+
// }
35+
```

docs/zh/guide/advances/auto-prefix.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
outline: deep
3+
---
4+
5+
# 自动添加浏览器私有前缀
6+
7+
The `@vvibe/vue-styled-components` package uses the `stylis` library to add vendor prefixes.
8+
9+
这是 `@vvibe/vue-styled-components` 包的一部分。它会自动为 CSS 规则添加浏览器私有前缀。这可以确保你的 CSS 规则在最常见的浏览器中兼容,这有助于提高你的网站兼容性。
10+
11+
`@vvibe/vue-styled-components` 使用 `stylis` 库来编译以及添加浏览器私有前缀。
12+
13+
```js
14+
import { styled } from '@vvibe/vue-styled-components';
15+
const StyledDiv = styled.div`
16+
display: flex;
17+
}`
18+
19+
// output:
20+
// .styled-div {
21+
// display: -webkit-box;
22+
// display: -webkit-flex;
23+
// display: -ms-flexbox;
24+
// display: flex;
25+
// }
26+
```

docs/zh/guide/advances/nest-css.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
outline: deep
3+
---
4+
5+
# 嵌套 CSS
6+
7+
你可以像 `less`, `sass` 一样使用嵌套 CSS。 `@vvibe/vue-styled-components` 并非使用最新的CSS规范([nest css](https://drafts.csswg.org/css-nesting/#nesting))来实现,而是使用了 `stylis` 编译为最基础的 CSS,因此你不需要担心其兼容性问题。
8+
9+
如下:
10+
11+
```js
12+
import { styled } from '@vvibe/vue-styled-components';
13+
const StyledDiv = styled.div`
14+
width: 100px;
15+
height: 100px;
16+
background-color: #ccc;
17+
color: #000;
18+
&:hover {
19+
background-color: #000;
20+
color: #fff;
21+
&:active {
22+
background-color: #fff;
23+
}
24+
}
25+
}`
26+
27+
// output:
28+
// .styled-xxx {
29+
// width: 100px;
30+
// height: 100px;
31+
// }
32+
// .styled-xxx:hover {
33+
// background-color: #000;
34+
// }
35+
// .styled-xxx:hover:active {
36+
// background-color: #fff;
37+
// }
38+
```

0 commit comments

Comments
 (0)