@cwcss/crosswind 0.1.4
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.
- package/PLUGIN.md +235 -0
- package/benchmark/framework-comparison.bench.ts +850 -0
- package/bin/cli.ts +365 -0
- package/bin/crosswind +0 -0
- package/bin/headwind +0 -0
- package/build.ts +8 -0
- package/crosswind.config.ts +9 -0
- package/example/comprehensive.html +70 -0
- package/example/index.html +21 -0
- package/example/output.css +236 -0
- package/examples/plugin/README.md +112 -0
- package/examples/plugin/build.ts +32 -0
- package/examples/plugin/src/index.html +34 -0
- package/examples/plugin/src/index.ts +7 -0
- package/headwind +2 -0
- package/package.json +92 -0
- package/src/build.ts +101 -0
- package/src/config.ts +529 -0
- package/src/generator.ts +2173 -0
- package/src/index.ts +10 -0
- package/src/parser.ts +1471 -0
- package/src/plugin.ts +118 -0
- package/src/preflight-forms.ts +229 -0
- package/src/preflight.ts +388 -0
- package/src/rules-advanced.ts +477 -0
- package/src/rules-effects.ts +457 -0
- package/src/rules-forms.ts +103 -0
- package/src/rules-grid.ts +241 -0
- package/src/rules-interactivity.ts +525 -0
- package/src/rules-layout.ts +385 -0
- package/src/rules-transforms.ts +412 -0
- package/src/rules-typography.ts +486 -0
- package/src/rules.ts +805 -0
- package/src/scanner.ts +84 -0
- package/src/transformer-compile-class.ts +275 -0
- package/src/types.ts +197 -0
- package/test/advanced-features.test.ts +911 -0
- package/test/arbitrary.test.ts +396 -0
- package/test/attributify.test.ts +592 -0
- package/test/bracket-syntax.test.ts +1133 -0
- package/test/build.test.ts +99 -0
- package/test/colors.test.ts +934 -0
- package/test/flexbox.test.ts +669 -0
- package/test/generator.test.ts +597 -0
- package/test/grid.test.ts +584 -0
- package/test/layout.test.ts +404 -0
- package/test/modifiers.test.ts +417 -0
- package/test/parser.test.ts +564 -0
- package/test/performance-regression.test.ts +376 -0
- package/test/performance.test.ts +568 -0
- package/test/plugin.test.ts +160 -0
- package/test/scanner.test.ts +94 -0
- package/test/sizing.test.ts +481 -0
- package/test/spacing.test.ts +394 -0
- package/test/transformer-compile-class.test.ts +287 -0
- package/test/transforms.test.ts +448 -0
- package/test/typography.test.ts +632 -0
- package/test/variants-form-states.test.ts +225 -0
- package/test/variants-group-peer.test.ts +66 -0
- package/test/variants-media.test.ts +213 -0
- package/test/variants-positional.test.ts +58 -0
- package/test/variants-pseudo-elements.test.ts +47 -0
- package/test/variants-state.test.ts +62 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import type { UtilityRule } from './rules'
|
|
2
|
+
|
|
3
|
+
// Grid utilities
|
|
4
|
+
|
|
5
|
+
export const gridTemplateColumnsRule: UtilityRule = (parsed) => {
|
|
6
|
+
if (parsed.utility === 'grid-cols') {
|
|
7
|
+
const cols: Record<string, string> = {
|
|
8
|
+
1: 'repeat(1, minmax(0, 1fr))',
|
|
9
|
+
2: 'repeat(2, minmax(0, 1fr))',
|
|
10
|
+
3: 'repeat(3, minmax(0, 1fr))',
|
|
11
|
+
4: 'repeat(4, minmax(0, 1fr))',
|
|
12
|
+
5: 'repeat(5, minmax(0, 1fr))',
|
|
13
|
+
6: 'repeat(6, minmax(0, 1fr))',
|
|
14
|
+
7: 'repeat(7, minmax(0, 1fr))',
|
|
15
|
+
8: 'repeat(8, minmax(0, 1fr))',
|
|
16
|
+
9: 'repeat(9, minmax(0, 1fr))',
|
|
17
|
+
10: 'repeat(10, minmax(0, 1fr))',
|
|
18
|
+
11: 'repeat(11, minmax(0, 1fr))',
|
|
19
|
+
12: 'repeat(12, minmax(0, 1fr))',
|
|
20
|
+
none: 'none',
|
|
21
|
+
subgrid: 'subgrid',
|
|
22
|
+
}
|
|
23
|
+
return parsed.value ? { 'grid-template-columns': cols[parsed.value] || parsed.value } : undefined
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const gridColumnRule: UtilityRule = (parsed) => {
|
|
28
|
+
if (parsed.utility === 'col') {
|
|
29
|
+
const spans: Record<string, string> = {
|
|
30
|
+
'auto': 'auto',
|
|
31
|
+
'span-1': 'span 1 / span 1',
|
|
32
|
+
'span-2': 'span 2 / span 2',
|
|
33
|
+
'span-3': 'span 3 / span 3',
|
|
34
|
+
'span-4': 'span 4 / span 4',
|
|
35
|
+
'span-5': 'span 5 / span 5',
|
|
36
|
+
'span-6': 'span 6 / span 6',
|
|
37
|
+
'span-7': 'span 7 / span 7',
|
|
38
|
+
'span-8': 'span 8 / span 8',
|
|
39
|
+
'span-9': 'span 9 / span 9',
|
|
40
|
+
'span-10': 'span 10 / span 10',
|
|
41
|
+
'span-11': 'span 11 / span 11',
|
|
42
|
+
'span-12': 'span 12 / span 12',
|
|
43
|
+
'span-full': '1 / -1',
|
|
44
|
+
}
|
|
45
|
+
return parsed.value ? { 'grid-column': spans[parsed.value] || parsed.value } : undefined
|
|
46
|
+
}
|
|
47
|
+
if (parsed.utility === 'col-span' && parsed.value) {
|
|
48
|
+
const spans: Record<string, string> = {
|
|
49
|
+
auto: 'auto',
|
|
50
|
+
1: 'span 1 / span 1',
|
|
51
|
+
2: 'span 2 / span 2',
|
|
52
|
+
3: 'span 3 / span 3',
|
|
53
|
+
4: 'span 4 / span 4',
|
|
54
|
+
5: 'span 5 / span 5',
|
|
55
|
+
6: 'span 6 / span 6',
|
|
56
|
+
7: 'span 7 / span 7',
|
|
57
|
+
8: 'span 8 / span 8',
|
|
58
|
+
9: 'span 9 / span 9',
|
|
59
|
+
10: 'span 10 / span 10',
|
|
60
|
+
11: 'span 11 / span 11',
|
|
61
|
+
12: 'span 12 / span 12',
|
|
62
|
+
full: '1 / -1',
|
|
63
|
+
}
|
|
64
|
+
// Handle arbitrary values: col-span-[15] -> span 15 / span 15
|
|
65
|
+
if (parsed.arbitrary) {
|
|
66
|
+
return { 'grid-column': `span ${parsed.value} / span ${parsed.value}` } as Record<string, string>
|
|
67
|
+
}
|
|
68
|
+
return { 'grid-column': spans[parsed.value] || parsed.value } as Record<string, string>
|
|
69
|
+
}
|
|
70
|
+
if (parsed.utility === 'col-start' && parsed.value) {
|
|
71
|
+
return { 'grid-column-start': parsed.value } as Record<string, string>
|
|
72
|
+
}
|
|
73
|
+
if (parsed.utility === 'col-end' && parsed.value) {
|
|
74
|
+
return { 'grid-column-end': parsed.value } as Record<string, string>
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const gridTemplateRowsRule: UtilityRule = (parsed) => {
|
|
79
|
+
if (parsed.utility === 'grid-rows') {
|
|
80
|
+
const rows: Record<string, string> = {
|
|
81
|
+
1: 'repeat(1, minmax(0, 1fr))',
|
|
82
|
+
2: 'repeat(2, minmax(0, 1fr))',
|
|
83
|
+
3: 'repeat(3, minmax(0, 1fr))',
|
|
84
|
+
4: 'repeat(4, minmax(0, 1fr))',
|
|
85
|
+
5: 'repeat(5, minmax(0, 1fr))',
|
|
86
|
+
6: 'repeat(6, minmax(0, 1fr))',
|
|
87
|
+
none: 'none',
|
|
88
|
+
subgrid: 'subgrid',
|
|
89
|
+
}
|
|
90
|
+
return parsed.value ? { 'grid-template-rows': rows[parsed.value] || parsed.value } : undefined
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export const gridRowRule: UtilityRule = (parsed) => {
|
|
95
|
+
if (parsed.utility === 'row') {
|
|
96
|
+
const spans: Record<string, string> = {
|
|
97
|
+
'auto': 'auto',
|
|
98
|
+
'span-1': 'span 1 / span 1',
|
|
99
|
+
'span-2': 'span 2 / span 2',
|
|
100
|
+
'span-3': 'span 3 / span 3',
|
|
101
|
+
'span-4': 'span 4 / span 4',
|
|
102
|
+
'span-5': 'span 5 / span 5',
|
|
103
|
+
'span-6': 'span 6 / span 6',
|
|
104
|
+
'span-full': '1 / -1',
|
|
105
|
+
}
|
|
106
|
+
return parsed.value ? { 'grid-row': spans[parsed.value] || parsed.value } : undefined
|
|
107
|
+
}
|
|
108
|
+
if (parsed.utility === 'row-span' && parsed.value) {
|
|
109
|
+
const spans: Record<string, string> = {
|
|
110
|
+
auto: 'auto',
|
|
111
|
+
1: 'span 1 / span 1',
|
|
112
|
+
2: 'span 2 / span 2',
|
|
113
|
+
3: 'span 3 / span 3',
|
|
114
|
+
4: 'span 4 / span 4',
|
|
115
|
+
5: 'span 5 / span 5',
|
|
116
|
+
6: 'span 6 / span 6',
|
|
117
|
+
full: '1 / -1',
|
|
118
|
+
}
|
|
119
|
+
// Handle arbitrary values: row-span-[15] -> span 15 / span 15
|
|
120
|
+
if (parsed.arbitrary) {
|
|
121
|
+
return { 'grid-row': `span ${parsed.value} / span ${parsed.value}` } as Record<string, string>
|
|
122
|
+
}
|
|
123
|
+
return { 'grid-row': spans[parsed.value] || parsed.value } as Record<string, string>
|
|
124
|
+
}
|
|
125
|
+
if (parsed.utility === 'row-start' && parsed.value) {
|
|
126
|
+
return { 'grid-row-start': parsed.value } as Record<string, string>
|
|
127
|
+
}
|
|
128
|
+
if (parsed.utility === 'row-end' && parsed.value) {
|
|
129
|
+
return { 'grid-row-end': parsed.value } as Record<string, string>
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export const gridAutoFlowRule: UtilityRule = (parsed) => {
|
|
134
|
+
if (parsed.utility === 'grid-flow' && parsed.value) {
|
|
135
|
+
const flows: Record<string, string> = {
|
|
136
|
+
'row': 'row',
|
|
137
|
+
'col': 'column',
|
|
138
|
+
'dense': 'dense',
|
|
139
|
+
'row-dense': 'row dense',
|
|
140
|
+
'col-dense': 'column dense',
|
|
141
|
+
}
|
|
142
|
+
return flows[parsed.value] ? { 'grid-auto-flow': flows[parsed.value] } : undefined
|
|
143
|
+
}
|
|
144
|
+
return undefined
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export const gridAutoColumnsRule: UtilityRule = (parsed) => {
|
|
148
|
+
if (parsed.utility === 'auto-cols') {
|
|
149
|
+
const values: Record<string, string> = {
|
|
150
|
+
auto: 'auto',
|
|
151
|
+
min: 'min-content',
|
|
152
|
+
max: 'max-content',
|
|
153
|
+
fr: 'minmax(0, 1fr)',
|
|
154
|
+
}
|
|
155
|
+
return parsed.value ? { 'grid-auto-columns': values[parsed.value] || parsed.value } : undefined
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export const gridAutoRowsRule: UtilityRule = (parsed) => {
|
|
160
|
+
if (parsed.utility === 'auto-rows') {
|
|
161
|
+
const values: Record<string, string> = {
|
|
162
|
+
auto: 'auto',
|
|
163
|
+
min: 'min-content',
|
|
164
|
+
max: 'max-content',
|
|
165
|
+
fr: 'minmax(0, 1fr)',
|
|
166
|
+
}
|
|
167
|
+
return parsed.value ? { 'grid-auto-rows': values[parsed.value] || parsed.value } : undefined
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export const gapRule: UtilityRule = (parsed, config) => {
|
|
172
|
+
if (parsed.utility === 'gap' && parsed.value) {
|
|
173
|
+
return { gap: config.theme.spacing[parsed.value] || parsed.value } as Record<string, string>
|
|
174
|
+
}
|
|
175
|
+
if (parsed.utility === 'gap-x' && parsed.value) {
|
|
176
|
+
return { 'column-gap': config.theme.spacing[parsed.value] || parsed.value } as Record<string, string>
|
|
177
|
+
}
|
|
178
|
+
if (parsed.utility === 'gap-y' && parsed.value) {
|
|
179
|
+
return { 'row-gap': config.theme.spacing[parsed.value] || parsed.value } as Record<string, string>
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export const placeContentRule: UtilityRule = (parsed) => {
|
|
184
|
+
if (parsed.utility === 'place' && parsed.value && parsed.value.startsWith('content-')) {
|
|
185
|
+
const val = parsed.value.replace('content-', '')
|
|
186
|
+
const values: Record<string, string> = {
|
|
187
|
+
center: 'center',
|
|
188
|
+
start: 'start',
|
|
189
|
+
end: 'end',
|
|
190
|
+
between: 'space-between',
|
|
191
|
+
around: 'space-around',
|
|
192
|
+
evenly: 'space-evenly',
|
|
193
|
+
stretch: 'stretch',
|
|
194
|
+
}
|
|
195
|
+
return values[val] ? { 'place-content': values[val] } : undefined
|
|
196
|
+
}
|
|
197
|
+
return undefined
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export const placeItemsRule: UtilityRule = (parsed) => {
|
|
201
|
+
if (parsed.utility === 'place' && parsed.value && parsed.value.startsWith('items-')) {
|
|
202
|
+
const val = parsed.value.replace('items-', '')
|
|
203
|
+
const values: Record<string, string> = {
|
|
204
|
+
start: 'start',
|
|
205
|
+
end: 'end',
|
|
206
|
+
center: 'center',
|
|
207
|
+
stretch: 'stretch',
|
|
208
|
+
}
|
|
209
|
+
return values[val] ? { 'place-items': values[val] } : undefined
|
|
210
|
+
}
|
|
211
|
+
return undefined
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export const placeSelfRule: UtilityRule = (parsed) => {
|
|
215
|
+
if (parsed.utility === 'place' && parsed.value && parsed.value.startsWith('self-')) {
|
|
216
|
+
const val = parsed.value.replace('self-', '')
|
|
217
|
+
const values: Record<string, string> = {
|
|
218
|
+
auto: 'auto',
|
|
219
|
+
start: 'start',
|
|
220
|
+
end: 'end',
|
|
221
|
+
center: 'center',
|
|
222
|
+
stretch: 'stretch',
|
|
223
|
+
}
|
|
224
|
+
return values[val] ? { 'place-self': values[val] } : undefined
|
|
225
|
+
}
|
|
226
|
+
return undefined
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export const gridRules: UtilityRule[] = [
|
|
230
|
+
gridTemplateColumnsRule,
|
|
231
|
+
gridColumnRule,
|
|
232
|
+
gridTemplateRowsRule,
|
|
233
|
+
gridRowRule,
|
|
234
|
+
gridAutoFlowRule,
|
|
235
|
+
gridAutoColumnsRule,
|
|
236
|
+
gridAutoRowsRule,
|
|
237
|
+
gapRule,
|
|
238
|
+
placeContentRule,
|
|
239
|
+
placeItemsRule,
|
|
240
|
+
placeSelfRule,
|
|
241
|
+
]
|