Skip to content

Commit e4bb8dc

Browse files
committed
docs(advances): [css-mixin] add embedded css demo
1 parent 797f82a commit e4bb8dc

File tree

2 files changed

+57
-4
lines changed

2 files changed

+57
-4
lines changed

docs/guide/advances/css-mixin.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,47 @@ Such as:
3434

3535
## Embedded CSS with Conditional
3636

37+
:::demo
38+
3739
```vue
3840
<script setup lang="ts">
3941
import { styled, css } from '@vvibe/vue-styled-components'
42+
import { ref } from 'vue'
43+
44+
const status = ref<boolean>(false)
45+
46+
const StyledButton = styled.button`
47+
height: 36px;
48+
margin-left: 20px;
49+
padding: 4px 12px;
50+
border-radius: 8px;
51+
background-color: skyblue;
52+
`
4053
4154
const testCss1 = css`
42-
background: white;
55+
color: #fff;
56+
background: darkred;
4357
`
4458
const testCss2 = css`
45-
background: blue;
59+
color: #000;
60+
background: orange;
4661
`
4762
const TestEmbedComponent = styled('div', { status: Boolean })`
63+
width: 200px;
64+
border-radius: 8px;
65+
text-align: center;
66+
line-height: 40px;
4867
${(props) => props.status ? testCss1 : testCss2}
4968
`
5069
</script>
70+
<template>
71+
<div style="display: flex; align-items: center;">
72+
<TestEmbedComponent :status="status">Test</TestEmbedComponent>
73+
<StyledButton @click="status = !status">Change Status</StyledButton>
74+
</div>
75+
</template>
5176
```
77+
:::
5278

5379
## Using Common CSS with Class
5480

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

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,48 @@ Such as:
3232

3333
## 有条件地嵌套 CSS
3434

35+
36+
:::demo
37+
3538
```vue
3639
<script setup lang="ts">
3740
import { styled, css } from '@vvibe/vue-styled-components'
41+
import { ref } from 'vue'
42+
43+
const status = ref<boolean>(false)
44+
45+
const StyledButton = styled.button`
46+
height: 36px;
47+
margin-left: 20px;
48+
padding: 4px 12px;
49+
border-radius: 8px;
50+
background-color: skyblue;
51+
`
3852
3953
const testCss1 = css`
40-
background: white;
54+
color: #fff;
55+
background: darkred;
4156
`
4257
const testCss2 = css`
43-
background: blue;
58+
color: #000;
59+
background: orange;
4460
`
4561
const TestEmbedComponent = styled('div', { status: Boolean })`
62+
width: 200px;
63+
border-radius: 8px;
64+
text-align: center;
65+
line-height: 40px;
4666
${(props) => props.status ? testCss1 : testCss2}
4767
`
4868
</script>
69+
<template>
70+
<div style="display: flex; align-items: center;">
71+
<TestEmbedComponent :status="status">Test</TestEmbedComponent>
72+
<StyledButton @click="status = !status">Change Status</StyledButton>
73+
</div>
74+
</template>
4975
```
76+
:::
5077

5178
# 公共 CSS 类
5279

0 commit comments

Comments
 (0)