Skip to content

Commit 288631b

Browse files
committed
docs: update demo code
1 parent 0952efa commit 288631b

File tree

3 files changed

+86
-91
lines changed

3 files changed

+86
-91
lines changed

docs/guide/advances/theming.md

Lines changed: 45 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,15 @@ the `ThemeProvider`'s scope can access this theme object.
1616
:::demo
1717

1818
```vue
19-
2019
<script setup lang="ts">
21-
import { styled, ThemeProvider } from '@vue3-styled-components/package'
20+
import { styled, ThemeProvider } from '@vue3-styled-components/package'
2221
23-
const StyledWrapper = styled.div`
24-
display: flex;
25-
justify-content: space-around;
26-
`
22+
const StyledWrapper = styled.div`
23+
display: flex;
24+
justify-content: space-around;
25+
`
2726
28-
const StyledLink = styled.a`
27+
const StyledLink = styled.a`
2928
margin-right: 8px;
3029
color: ${(props) => props.theme.primary} !important;
3130
font-weight: bold;
@@ -54,42 +53,40 @@ and see the updates reflected in your styled components.
5453
:::demo
5554

5655
```vue
57-
5856
<script setup lang="ts">
59-
import { styled, ThemeProvider } from '@vue3-styled-components/package'
60-
import { ref } from 'vue'
61-
62-
const theme = ref<Record<string, string>>({ primary: 'blue' })
63-
64-
const StyledWrapper = styled.div`
65-
display: flex;
66-
justify-content: space-between;
67-
align-items: center;
68-
`
69-
70-
const StyledLink = styled.a`
71-
color: ${(props) => props.theme.primary} !important;
72-
`
73-
74-
const StyledButton = styled.button`
75-
width: 140px;
76-
height: 36px;
77-
margin-left: 20px;
78-
padding: 4px 12px;
79-
border-radius: 9999px;
80-
box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
81-
background-color: skyblue;
82-
font-weight: bold;
83-
`
84-
85-
const changeTheme = () => {
86-
if (theme.value.primary === 'red') {
87-
theme.value.primary = 'blue'
88-
} else {
89-
theme.value.primary = 'red'
90-
}
91-
}
57+
import { styled, ThemeProvider } from '@vue3-styled-components/package'
58+
import { ref } from 'vue'
59+
60+
const theme = ref<Record<string, string>>({ primary: 'blue' })
9261
62+
const StyledWrapper = styled.div`
63+
display: flex;
64+
justify-content: space-between;
65+
align-items: center;
66+
`
67+
68+
const StyledLink = styled.a`
69+
color: ${(props) => props.theme.primary} !important;
70+
`
71+
72+
const StyledButton = styled.button`
73+
width: 140px;
74+
height: 36px;
75+
margin-left: 20px;
76+
padding: 4px 12px;
77+
border-radius: 9999px;
78+
box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
79+
background-color: skyblue;
80+
font-weight: bold;
81+
`
82+
83+
const changeTheme = () => {
84+
if (theme.value.primary === 'red') {
85+
theme.value.primary = 'blue'
86+
} else {
87+
theme.value.primary = 'red'
88+
}
89+
}
9390
</script>
9491
9592
<template>
@@ -114,16 +111,14 @@ and use properties defined in the theme for their styles.
114111
:::demo
115112

116113
```vue
117-
118114
<script setup lang="ts">
119-
import { ThemeProvider } from '@vue3-styled-components/package'
120-
import { defineComponent, h, inject } from 'vue'
121-
122-
const Link = defineComponent(() => {
123-
const theme = inject('$theme')
124-
return () => h('a', { style: { color: theme.primary } }, 'This is a link')
125-
})
115+
import { ThemeProvider } from '@vue3-styled-components/package'
116+
import { defineComponent, h, inject } from 'vue'
126117
118+
const Link = defineComponent(() => {
119+
const theme = inject('$theme')
120+
return () => h('a', { style: { color: theme.primary } }, 'This is a link')
121+
})
127122
</script>
128123
129124
<template>
@@ -133,4 +128,4 @@ and use properties defined in the theme for their styles.
133128
</template>
134129
```
135130

136-
:::
131+
:::

docs/guide/basic/animations.md

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,46 +7,45 @@ a styled component.
77
:::demo
88

99
```vue
10-
1110
<script setup lang="ts">
12-
import { styled, keyframes } from '@vue3-styled-components/package'
13-
14-
const rotate = keyframes`
15-
from {
16-
transform: rotate(0deg);
17-
}
18-
to {
19-
transform: rotate(360deg);
20-
}
21-
`
22-
const translate = keyframes`
23-
0 {
24-
transform: translateX(0);
25-
}
26-
50% {
27-
transform: translateX(250%);
28-
}
29-
60% {
30-
transform: rotate(360deg);
31-
}
32-
`
33-
34-
const StyledBaseDiv = styled.div`
35-
display: inline-block;
36-
width: 100px;
37-
height: 100px;
38-
`
39-
40-
const StyledRotateDiv = styled(StyledBaseDiv)`
41-
background-color: skyblue;
42-
animation: ${rotate} 2s linear infinite;
43-
`
44-
45-
const StyledTranslateDiv = styled(StyledBaseDiv)`
46-
margin-left: 10px;
47-
background-color: darkred;
48-
animation: ${translate} 2s ease infinite alternate;
49-
`
11+
import { styled, keyframes } from '@vue3-styled-components/package'
12+
13+
const rotate = keyframes`
14+
from {
15+
transform: rotate(0deg);
16+
}
17+
to {
18+
transform: rotate(360deg);
19+
}
20+
`
21+
const translate = keyframes`
22+
0 {
23+
transform: translateX(0);
24+
}
25+
50% {
26+
transform: translateX(250%);
27+
}
28+
60% {
29+
transform: rotate(360deg);
30+
}
31+
`
32+
33+
const StyledBaseDiv = styled.div`
34+
display: inline-block;
35+
width: 100px;
36+
height: 100px;
37+
`
38+
39+
const StyledRotateDiv = styled(StyledBaseDiv)`
40+
background-color: skyblue;
41+
animation: ${rotate} 2s linear infinite;
42+
`
43+
44+
const StyledTranslateDiv = styled(StyledBaseDiv)`
45+
margin-left: 10px;
46+
background-color: darkred;
47+
animation: ${translate} 2s ease infinite alternate;
48+
`
5049
</script>
5150
5251
<template>
@@ -55,4 +54,4 @@ a styled component.
5554
</template>
5655
```
5756

58-
:::
57+
:::

docs/guide/basic/styling-any-component.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ const StyledLink = styled(Link)`
4242

4343
## Styling Styled Component
4444

45-
You can also style styled components. For example, with `StyledLink`, using `styled` and passing styles, you can get a `blue link`.
45+
You can also style styled components. For example, with `StyledLink`, using `styled` and passing styles, you can get
46+
a `blue link`.
4647

4748
:::demo
4849

0 commit comments

Comments
 (0)