Skip to content

Commit bbd7295

Browse files
committed
docs(helper): [css] add documents
1 parent 7818395 commit bbd7295

File tree

1 file changed

+55
-18
lines changed

1 file changed

+55
-18
lines changed

docs/guide/api/helper.md

Lines changed: 55 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ A function to create a `style component` that can be used to handle global style
1919
**Usage**
2020

2121
```vue
22+
2223
<script setup>
23-
import { createGlobalStyle } from '@vue3-styled-components/package'
24+
import { createGlobalStyle } from '@vue3-styled-components/package'
2425
25-
const GlobalStyle = createGlobalStyle`
26+
const GlobalStyle = createGlobalStyle`
2627
body {
2728
color: ${(props) => props.color};
2829
}
@@ -48,18 +49,19 @@ A function to generate keyframes. It takes a template literal as an argument and
4849
**Usage**
4950

5051
```vue
52+
5153
<script setup lang="ts">
52-
import { styled, keyframes } from '@vue3-styled-components/package'
54+
import { styled, keyframes } from '@vue3-styled-components/package'
5355
54-
const animation = keyframes`
56+
const animation = keyframes`
5557
from {
5658
opacity: 0;
5759
}
5860
to {
5961
opacity: 1;
6062
}
6163
`
62-
const DivWithAnimation = styled('div')`
64+
const DivWithAnimation = styled('div')`
6365
width: 100%;
6466
height: 40px;
6567
animation: ${animation} 2s ease-in infinite;
@@ -70,9 +72,43 @@ const DivWithAnimation = styled('div')`
7072
</template>
7173
```
7274

75+
## `css`
76+
77+
A function to generate CSS from a template literal with interpolations.
78+
79+
**Augments**
80+
81+
- Tagged Template Literal, `TemplateStringsArray`, `required`
82+
83+
**Return**
84+
85+
- Interpolations, `(string | function)[]`
86+
87+
**Usage**
88+
89+
```vue
90+
91+
<script setup lang="ts">
92+
import { styled, css } from '@vue3-styled-components/package'
93+
94+
const mixin = css`
95+
color: red;
96+
background-color: blue;
97+
`
98+
const DivWithStyles = styled('div')`
99+
${mixin}
100+
`
101+
</script>
102+
103+
<template>
104+
<DivWithStyles>Div with mixin</DivWithStyles>
105+
</template>
106+
```
107+
73108
## `withAttrs`
74109

75110
A function to add attributes to a `ComponentInstance` or `HTMLElements`.
111+
76112
**Augments**
77113

78114
- Component or Html Tag, `ComponentInstance | SupportedHTMLElements`, `required`
@@ -85,16 +121,17 @@ A function to add attributes to a `ComponentInstance` or `HTMLElements`.
85121
**Usage**
86122

87123
```vue
124+
88125
<script setup lang="ts">
89-
import { withAttrs } from '@vue3-styled-components/package'
126+
import { withAttrs } from '@vue3-styled-components/package'
90127
91-
const DivWithAttrs = withAttrs('div', {
92-
class: 'div-with-attrs'
93-
})
128+
const DivWithAttrs = withAttrs('div', {
129+
class: 'div-with-attrs'
130+
})
94131
95-
const DivWithAttrs2 = withAttrs(DivWithAttrs, {
96-
class: 'div-with-attrs-2'
97-
})
132+
const DivWithAttrs2 = withAttrs(DivWithAttrs, {
133+
class: 'div-with-attrs-2'
134+
})
98135
</script>
99136
100137
<template>
@@ -103,12 +140,12 @@ const DivWithAttrs2 = withAttrs(DivWithAttrs, {
103140
</template>
104141
105142
<style scope>
106-
.div-with-attrs {
107-
color: red;
108-
}
143+
.div-with-attrs {
144+
color: red;
145+
}
109146
110-
.div-with-attrs-2 {
111-
color: blue;
112-
}
147+
.div-with-attrs-2 {
148+
color: blue;
149+
}
113150
</style>
114151
```

0 commit comments

Comments
 (0)