@unocss/transformer-directives 0.45.9 → 0.45.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +134 -3
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  <!-- @unocss-ignore -->
4
4
 
5
- UnoCSS transformer for `@apply` and `theme()` directive
5
+ UnoCSS transformer for `@apply`、`@screen` and `theme()` directive
6
6
 
7
7
  ## Install
8
8
 
@@ -44,8 +44,6 @@ Will be transformed to:
44
44
  }
45
45
  ```
46
46
 
47
- > Currently only `@apply` is supported.
48
-
49
47
  #### CSS Variable Style
50
48
 
51
49
  To be compatible with vanilla CSS, you can use CSS Variables to replace the `@apply` directive.
@@ -74,6 +72,139 @@ transformerDirective({
74
72
  })
75
73
  ```
76
74
 
75
+ ### `@screen`
76
+
77
+ The `@screen` directive allows you to create media queries that reference your breakpoints by name comes from [`theme.breakpoints`](https://github.com/unocss/unocss/blob/main/README.md#extend-theme).
78
+
79
+ ```css
80
+ .grid {
81
+ @apply grid grid-cols-2;
82
+ }
83
+ @screen xs {
84
+ .grid {
85
+ @apply grid-cols-1;
86
+ }
87
+ }
88
+ @screen sm {
89
+ .grid {
90
+ @apply grid-cols-3;
91
+ }
92
+ }
93
+ /* ... */
94
+ ...
95
+ ```
96
+
97
+ Will be transformed to:
98
+
99
+ ```css
100
+ .grid {
101
+ display: grid;
102
+ grid-template-columns: repeat(2, minmax(0, 1fr));
103
+ }
104
+ @media (min-width: 320px) {
105
+ .grid {
106
+ grid-template-columns: repeat(1, minmax(0, 1fr));
107
+ }
108
+ }
109
+ @media (min-width: 640px) {
110
+ .grid {
111
+ grid-template-columns: repeat(3, minmax(0, 1fr));
112
+ }
113
+ }
114
+ /* ... */
115
+ ```
116
+
117
+ #### Breakpoint Variant Support
118
+ `@screen` also supports `lt`、`at` variants
119
+
120
+ ##### `@screen lt`
121
+
122
+ ```css
123
+ .grid {
124
+ @apply grid grid-cols-2;
125
+ }
126
+ @screen lt-xs {
127
+ .grid {
128
+ @apply grid-cols-1;
129
+ }
130
+ }
131
+ @screen lt-sm {
132
+ .grid {
133
+ @apply grid-cols-3;
134
+ }
135
+ }
136
+ /* ... */
137
+ ```
138
+
139
+ Will be transformed to:
140
+
141
+ ```css
142
+ .grid {
143
+ display: grid;
144
+ grid-template-columns: repeat(2, minmax(0, 1fr));
145
+ }
146
+ @media (max-width: 319.9px) {
147
+ .grid {
148
+ grid-template-columns: repeat(1, minmax(0, 1fr));
149
+ }
150
+ }
151
+ @media (max-width: 639.9px) {
152
+ .grid {
153
+ grid-template-columns: repeat(3, minmax(0, 1fr));
154
+ }
155
+ }
156
+ /* ... */
157
+ ```
158
+
159
+ ##### `@screen at`
160
+
161
+ ```css
162
+ .grid {
163
+ @apply grid grid-cols-2;
164
+ }
165
+ @screen at-xs {
166
+ .grid {
167
+ @apply grid-cols-1;
168
+ }
169
+ }
170
+ @screen at-xl {
171
+ .grid {
172
+ @apply grid-cols-3;
173
+ }
174
+ }
175
+ @screen at-xxl {
176
+ .grid {
177
+ @apply grid-cols-4;
178
+ }
179
+ }
180
+ /* ... */
181
+ ```
182
+
183
+ Will be transformed to:
184
+
185
+ ```css
186
+ .grid {
187
+ display: grid;
188
+ grid-template-columns: repeat(2, minmax(0, 1fr));
189
+ }
190
+ @media (min-width: 320px) and (max-width: 639.9px) {
191
+ .grid {
192
+ grid-template-columns: repeat(1, minmax(0, 1fr));
193
+ }
194
+ }
195
+ @media (min-width: 1280px) and (max-width: 1535.9px) {
196
+ .grid {
197
+ grid-template-columns: repeat(3, minmax(0, 1fr));
198
+ }
199
+ }
200
+ @media (min-width: 1536px) {
201
+ .grid {
202
+ grid-template-columns: repeat(4, minmax(0, 1fr));
203
+ }
204
+ }
205
+ /* ... */
206
+ ```
207
+
77
208
  ### `theme()`
78
209
 
79
210
  Use the `theme()` function to access your theme config values using dot notation.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/transformer-directives",
3
- "version": "0.45.9",
3
+ "version": "0.45.14",
4
4
  "description": "UnoCSS transformer for `@apply` directive",
5
5
  "author": "hannoeru <me@hanlee.co>",
6
6
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "dist"
32
32
  ],
33
33
  "dependencies": {
34
- "@unocss/core": "0.45.9",
34
+ "@unocss/core": "0.45.14",
35
35
  "css-tree": "^2.2.1"
36
36
  },
37
37
  "devDependencies": {