twust_macro 1.1.0

Zero-config Static type-checker for Tailwind CSS
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
/*
 * Author: Oyelowo Oyedayo
 * Email: oyelowo.oss@gmail.com
 * Copyright (c) 2023 Oyelowo Oyedayo
 * Licensed under the MIT license
 */
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct TailwindConfig {
    pub theme: Theme,
    pub allowed_lists: Option<AllowedLists>,
    pub variants: Option<Variants>,
    pub core_plugins: Option<CorePlugins>,
    pub plugins: Option<Plugins>,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct CorePlugins {
    pub screens: Option<bool>,
    pub colors: Option<bool>,
    pub spacing: Option<bool>,

    pub width: Option<bool>,
    pub height: Option<bool>,

    pub min_width: Option<bool>,

    pub min_height: Option<bool>,

    pub max_width: Option<bool>,

    pub max_height: Option<bool>,

    pub padding: Option<bool>,
    pub margin: Option<bool>,
    pub negative_margin: Option<bool>,

    pub shadows: Option<bool>,

    pub z_index: Option<bool>,
    pub opacity: Option<bool>,
    pub stroke: Option<bool>,

    pub accent_color: Option<bool>,
    pub accessibility: Option<bool>,

    pub align_content: Option<bool>,
    pub align_items: Option<bool>,
    pub align_self: Option<bool>,
    pub animation: Option<bool>,
    pub appearance: Option<bool>,
    pub aspect_ratio: Option<bool>,
    pub grayscale: Option<bool>,
    pub backdrop_blur: Option<bool>,
    pub backdrop_brightness: Option<bool>,
    pub backdrop_contrast: Option<bool>,
    pub backdrop_filter: Option<bool>,
    pub backdrop_grayscale: Option<bool>,
    pub backdrop_hue_rotate: Option<bool>,
    pub backdrop_invert: Option<bool>,
    pub backdrop_opacity: Option<bool>,
    pub backdrop_saturate: Option<bool>,
    pub backdrop_sepia: Option<bool>,
    pub background_attachment: Option<bool>,
    pub background_blend_mode: Option<bool>,
    pub background_clip: Option<bool>,
    pub background_color: Option<bool>,
    pub background_image: Option<bool>,
    pub background_opacity: Option<bool>,
    pub background_origin: Option<bool>,
    pub background_position: Option<bool>,
    pub background_repeat: Option<bool>,
    pub background_size: Option<bool>,
    pub blur: Option<bool>,
    pub border_collapse: Option<bool>,
    pub border_color: Option<bool>,
    pub border_opacity: Option<bool>,
    pub border_radius: Option<bool>,
    pub border_spacing: Option<bool>,
    pub border_style: Option<bool>,
    pub border_width: Option<bool>,
    pub box_decoration_break: Option<bool>,
    pub box_shadow: Option<bool>,
    pub box_shadow_color: Option<bool>,
    pub box_sizing: Option<bool>,
    pub break_after: Option<bool>,
    pub break_before: Option<bool>,
    pub break_inside: Option<bool>,
    pub brightness: Option<bool>,
    pub caption_side: Option<bool>,
    pub caret_color: Option<bool>,
    pub clear: Option<bool>,
    pub columns: Option<bool>,
    pub container: Option<bool>,
    pub content: Option<bool>,
    pub contrast: Option<bool>,
    pub cursor: Option<bool>,
    pub display: Option<bool>,
    pub divide_color: Option<bool>,
    pub divide_opacity: Option<bool>,
    pub divide_style: Option<bool>,
    pub divide_width: Option<bool>,
    pub drop_shadow: Option<bool>,
    pub fill: Option<bool>,
    pub filter: Option<bool>,
    pub flex: Option<bool>,
    pub flex_basis: Option<bool>,
    pub flex_direction: Option<bool>,
    pub flex_grow: Option<bool>,
    pub flex_shrink: Option<bool>,
    pub flex_wrap: Option<bool>,
    pub float: Option<bool>,
    pub font_family: Option<bool>,
    pub font_size: Option<bool>,
    pub font_smoothing: Option<bool>,
    pub font_style: Option<bool>,
    pub font_variant_numeric: Option<bool>,
    pub font_weight: Option<bool>,
    pub gap: Option<bool>,
    pub gradient_color_stops: Option<bool>,
    pub grid_auto_columns: Option<bool>,
    pub grid_auto_flow: Option<bool>,
    pub grid_auto_rows: Option<bool>,
    pub grid_column: Option<bool>,
    pub grid_column_end: Option<bool>,
    pub grid_column_start: Option<bool>,
    pub grid_row: Option<bool>,
    pub grid_row_end: Option<bool>,
    pub grid_row_start: Option<bool>,
    pub grid_template_columns: Option<bool>,
    pub grid_template_rows: Option<bool>,
    pub hue_rotate: Option<bool>,
    pub hyphens: Option<bool>,
    pub top: Option<bool>,
    pub right: Option<bool>,
    pub left: Option<bool>,
    pub bottom: Option<bool>,
    pub start: Option<bool>,
    pub end: Option<bool>,
    pub inset: Option<bool>,
    pub invert: Option<bool>,
    pub isolation: Option<bool>,
    pub justify_content: Option<bool>,
    pub justify_items: Option<bool>,
    pub justify_self: Option<bool>,
    pub letter_spacing: Option<bool>,
    pub line_clamp: Option<bool>,
    pub line_height: Option<bool>,
    pub list_style_image: Option<bool>,
    pub list_style_position: Option<bool>,
    pub list_style_type: Option<bool>,
    pub mix_blend_mode: Option<bool>,
    pub object_fit: Option<bool>,
    pub object_position: Option<bool>,
    pub order: Option<bool>,
    pub outline_color: Option<bool>,
    pub outline_offset: Option<bool>,
    pub outline_style: Option<bool>,
    pub outline_width: Option<bool>,
    pub overflow: Option<bool>,
    pub overscroll_behavior: Option<bool>,
    pub place_content: Option<bool>,
    pub place_items: Option<bool>,
    pub place_self: Option<bool>,
    pub placeholder_color: Option<bool>,
    pub placeholder_opacity: Option<bool>,
    pub pointer_events: Option<bool>,
    pub position: Option<bool>,
    pub preflight: Option<bool>,
    pub resize: Option<bool>,
    pub ring_color: Option<bool>,
    pub ring_offset_color: Option<bool>,
    pub ring_offset_width: Option<bool>,
    pub ring_opacity: Option<bool>,
    pub ring_width: Option<bool>,
    pub rotate: Option<bool>,
    pub saturate: Option<bool>,
    pub scale: Option<bool>,
    pub scroll_behavior: Option<bool>,
    pub scroll_margin: Option<bool>,
    pub scroll_padding: Option<bool>,
    pub scroll_snap_align: Option<bool>,
    pub scroll_snap_stop: Option<bool>,
    pub scroll_snap_type: Option<bool>,
    pub sepia: Option<bool>,
    pub skew: Option<bool>,
    pub space: Option<bool>,
    pub stroke_width: Option<bool>,
    pub table_layout: Option<bool>,
    pub text_align: Option<bool>,
    pub text_color: Option<bool>,
    pub text_decoration: Option<bool>,
    pub text_decoration_color: Option<bool>,
    pub text_decoration_style: Option<bool>,
    pub text_decoration_thickness: Option<bool>,
    pub text_indent: Option<bool>,
    pub text_opacity: Option<bool>,
    pub text_overflow: Option<bool>,
    pub text_transform: Option<bool>,
    pub text_underline_offset: Option<bool>,
    pub touch_action: Option<bool>,
    pub transform: Option<bool>,
    pub transform_origin: Option<bool>,

    pub transition_delay: Option<bool>,
    pub transition_duration: Option<bool>,
    pub transition_property: Option<bool>,
    pub transition_timing_function: Option<bool>,
    pub translate: Option<bool>,
    pub user_select: Option<bool>,
    pub vertical_align: Option<bool>,
    pub visibility: Option<bool>,
    pub whitespace: Option<bool>,
    pub will_change: Option<bool>,
    pub word_break: Option<bool>,
    pub screen_readers: Option<bool>,
    // pub extend: HashMap<Key, HashMap<String, String>>,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct AllowedLists {
    pub classes: Option<Vec<String>>,
    pub modifiers: Option<Vec<String>>,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct Theme {
    #[serde(flatten)]
    pub overrides: CustomisableClasses,
    pub extend: CustomisableClasses,
}

// Represents a color which can either be a simple string or a nested structure.
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
#[serde(untagged)]
pub enum ColorValue {
    Simple(String),
    Shades(HashMap<String, String>),
}

// #[derive(Debug, Deserialize)]
// struct Theme {
//     colors: Option<HashMap<String, ColorValue>>,
// }

#[derive(Debug, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ScreenValue {
    Simple(String),
    Range(RangeBreakpoint),
    MultiRange(Vec<RangeBreakpoint>),
    Raw(RawBreakpoint),
}

#[derive(Debug, Serialize, Deserialize)]
pub struct RangeBreakpoint {
    #[serde(skip_serializing_if = "Option::is_none")]
    min: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    max: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct RawBreakpoint {
    raw: String,
}

pub type Key = String;

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct CustomisableClasses {
    // pub screens: Option<HashMap<String, String>>,
    pub screens: Option<HashMap<Key, ScreenValue>>,
    pub colors: Option<HashMap<Key, ColorValue>>,
    pub spacing: Option<HashMap<Key, String>>,

    pub width: Option<HashMap<Key, String>>,
    pub height: Option<HashMap<Key, String>>,

    pub min_width: Option<HashMap<Key, String>>,

    pub min_height: Option<HashMap<Key, String>>,

    pub max_width: Option<HashMap<Key, String>>,

    pub max_height: Option<HashMap<Key, String>>,

    pub padding: Option<HashMap<Key, String>>,
    pub margin: Option<HashMap<Key, String>>,
    pub negative_margin: Option<HashMap<Key, String>>,

    pub shadows: Option<HashMap<Key, String>>,

    pub z_index: Option<HashMap<Key, String>>,
    pub opacity: Option<HashMap<Key, String>>,
    pub stroke: Option<HashMap<Key, ColorValue>>,

    pub accent_color: Option<HashMap<Key, ColorValue>>,
    pub accessibility: Option<HashMap<Key, String>>,

    pub align_content: Option<HashMap<Key, String>>,
    pub align_items: Option<HashMap<Key, String>>,
    pub align_self: Option<HashMap<Key, String>>,
    pub animation: Option<HashMap<Key, String>>,
    pub appearance: Option<HashMap<Key, String>>,
    pub aspect_ratio: Option<HashMap<Key, String>>,
    pub grayscale: Option<HashMap<Key, String>>,
    pub backdrop_blur: Option<HashMap<Key, String>>,
    pub backdrop_brightness: Option<HashMap<Key, String>>,
    pub backdrop_contrast: Option<HashMap<Key, String>>,
    pub backdrop_filter: Option<HashMap<Key, String>>,
    pub backdrop_grayscale: Option<HashMap<Key, String>>,
    pub backdrop_hue_rotate: Option<HashMap<Key, String>>,
    pub backdrop_invert: Option<HashMap<Key, String>>,
    pub backdrop_opacity: Option<HashMap<Key, String>>,
    pub backdrop_saturate: Option<HashMap<Key, String>>,
    pub backdrop_sepia: Option<HashMap<Key, String>>,
    pub background_attachment: Option<HashMap<Key, String>>,
    pub background_blend_mode: Option<HashMap<Key, String>>,
    pub background_clip: Option<HashMap<Key, String>>,
    pub background_color: Option<HashMap<Key, ColorValue>>,
    pub background_image: Option<HashMap<Key, String>>,
    pub background_opacity: Option<HashMap<Key, String>>,
    pub background_origin: Option<HashMap<Key, String>>,
    pub background_position: Option<HashMap<Key, String>>,
    pub background_repeat: Option<HashMap<Key, String>>,
    pub background_size: Option<HashMap<Key, String>>,
    pub blur: Option<HashMap<Key, String>>,
    pub border_collapse: Option<HashMap<Key, String>>,
    pub border_color: Option<HashMap<Key, ColorValue>>,
    pub border_opacity: Option<HashMap<Key, String>>,
    pub border_radius: Option<HashMap<Key, String>>,
    pub border_spacing: Option<HashMap<Key, String>>,
    pub border_style: Option<HashMap<Key, String>>,
    pub border_width: Option<HashMap<Key, String>>,
    pub box_decoration_break: Option<HashMap<Key, String>>,
    pub box_shadow: Option<HashMap<Key, String>>,
    pub box_shadow_color: Option<HashMap<Key, ColorValue>>,
    pub box_sizing: Option<HashMap<Key, String>>,
    pub break_after: Option<HashMap<Key, String>>,
    pub break_before: Option<HashMap<Key, String>>,
    pub break_inside: Option<HashMap<Key, String>>,
    pub brightness: Option<HashMap<Key, String>>,
    pub caption_side: Option<HashMap<Key, String>>,
    pub caret_color: Option<HashMap<Key, ColorValue>>,
    pub clear: Option<HashMap<Key, String>>,
    pub columns: Option<HashMap<Key, String>>,
    pub container: Option<HashMap<Key, String>>,
    pub content: Option<HashMap<Key, String>>,
    pub contrast: Option<HashMap<Key, String>>,
    pub cursor: Option<HashMap<Key, String>>,
    pub display: Option<HashMap<Key, String>>,
    pub divide_color: Option<HashMap<Key, ColorValue>>,
    pub divide_opacity: Option<HashMap<Key, String>>,
    pub divide_style: Option<HashMap<Key, String>>,
    pub divide_width: Option<HashMap<Key, String>>,
    pub drop_shadow: Option<HashMap<Key, String>>,
    pub fill: Option<HashMap<Key, ColorValue>>,
    pub filter: Option<HashMap<Key, String>>,
    pub flex: Option<HashMap<Key, String>>,
    pub flex_basis: Option<HashMap<Key, String>>,
    pub flex_direction: Option<HashMap<Key, String>>,
    pub flex_grow: Option<HashMap<Key, String>>,
    pub flex_shrink: Option<HashMap<Key, String>>,
    pub flex_wrap: Option<HashMap<Key, String>>,
    pub float: Option<HashMap<Key, String>>,
    pub font_family: Option<HashMap<Key, String>>,
    pub font_size: Option<HashMap<Key, String>>,
    pub font_smoothing: Option<HashMap<Key, String>>,
    pub font_style: Option<HashMap<Key, String>>,
    pub font_variant_numeric: Option<HashMap<Key, String>>,
    pub font_weight: Option<HashMap<Key, String>>,
    pub gap: Option<HashMap<Key, String>>,
    pub gradient_color_stops: Option<HashMap<Key, ColorValue>>,
    pub grid_auto_columns: Option<HashMap<Key, String>>,
    pub grid_auto_flow: Option<HashMap<Key, String>>,
    pub grid_auto_rows: Option<HashMap<Key, String>>,
    pub grid_column: Option<HashMap<Key, String>>,
    pub grid_column_end: Option<HashMap<Key, String>>,
    pub grid_column_start: Option<HashMap<Key, String>>,
    pub grid_row: Option<HashMap<Key, String>>,
    pub grid_row_end: Option<HashMap<Key, String>>,
    pub grid_row_start: Option<HashMap<Key, String>>,
    pub grid_template_columns: Option<HashMap<Key, String>>,
    pub grid_template_rows: Option<HashMap<Key, String>>,
    pub hue_rotate: Option<HashMap<Key, String>>,
    pub hyphens: Option<HashMap<Key, String>>,
    pub top: Option<HashMap<Key, String>>,
    pub right: Option<HashMap<Key, String>>,
    pub left: Option<HashMap<Key, String>>,
    pub bottom: Option<HashMap<Key, String>>,
    pub start: Option<HashMap<Key, String>>,
    pub end: Option<HashMap<Key, String>>,
    pub inset: Option<HashMap<Key, String>>,
    pub invert: Option<HashMap<Key, String>>,
    pub isolation: Option<HashMap<Key, String>>,
    pub justify_content: Option<HashMap<Key, String>>,
    pub justify_items: Option<HashMap<Key, String>>,
    pub justify_self: Option<HashMap<Key, String>>,
    pub letter_spacing: Option<HashMap<Key, String>>,
    pub line_clamp: Option<HashMap<Key, String>>,
    pub line_height: Option<HashMap<Key, String>>,
    pub list_style_image: Option<HashMap<Key, String>>,
    pub list_style_position: Option<HashMap<Key, String>>,
    pub list_style_type: Option<HashMap<Key, String>>,
    pub mix_blend_mode: Option<HashMap<Key, String>>,
    pub object_fit: Option<HashMap<Key, String>>,
    pub object_position: Option<HashMap<Key, String>>,
    pub order: Option<HashMap<Key, String>>,
    pub outline_color: Option<HashMap<Key, ColorValue>>,
    pub outline_offset: Option<HashMap<Key, String>>,
    pub outline_style: Option<HashMap<Key, String>>,
    pub outline_width: Option<HashMap<Key, String>>,
    pub overflow: Option<HashMap<Key, String>>,
    pub overscroll_behavior: Option<HashMap<Key, String>>,
    pub place_content: Option<HashMap<Key, String>>,
    pub place_items: Option<HashMap<Key, String>>,
    pub place_self: Option<HashMap<Key, String>>,
    pub placeholder_color: Option<HashMap<Key, ColorValue>>,
    pub placeholder_opacity: Option<HashMap<Key, String>>,
    pub pointer_events: Option<HashMap<Key, String>>,
    pub position: Option<HashMap<Key, String>>,
    pub preflight: Option<HashMap<Key, String>>,
    pub resize: Option<HashMap<Key, String>>,
    pub ring_color: Option<HashMap<Key, ColorValue>>,
    pub ring_offset_color: Option<HashMap<Key, ColorValue>>,
    pub ring_offset_width: Option<HashMap<Key, String>>,
    pub ring_opacity: Option<HashMap<Key, String>>,
    pub ring_width: Option<HashMap<Key, String>>,
    pub rotate: Option<HashMap<Key, String>>,
    pub saturate: Option<HashMap<Key, String>>,
    pub scale: Option<HashMap<Key, String>>,
    pub scroll_behavior: Option<HashMap<Key, String>>,
    pub scroll_margin: Option<HashMap<Key, String>>,
    pub scroll_padding: Option<HashMap<Key, String>>,
    pub scroll_snap_align: Option<HashMap<Key, String>>,
    pub scroll_snap_stop: Option<HashMap<Key, String>>,
    pub scroll_snap_type: Option<HashMap<Key, String>>,
    pub sepia: Option<HashMap<Key, String>>,
    pub skew: Option<HashMap<Key, String>>,
    pub space: Option<HashMap<Key, String>>,
    pub stroke_width: Option<HashMap<Key, String>>,
    pub table_layout: Option<HashMap<Key, String>>,
    pub text_align: Option<HashMap<Key, String>>,
    pub text_color: Option<HashMap<Key, ColorValue>>,
    pub text_decoration: Option<HashMap<Key, String>>,
    pub text_decoration_color: Option<HashMap<Key, ColorValue>>,
    pub text_decoration_style: Option<HashMap<Key, String>>,
    pub text_decoration_thickness: Option<HashMap<Key, String>>,
    pub text_indent: Option<HashMap<Key, String>>,
    pub text_opacity: Option<HashMap<Key, String>>,
    pub text_overflow: Option<HashMap<Key, String>>,
    pub text_transform: Option<HashMap<Key, String>>,
    pub text_underline_offset: Option<HashMap<Key, String>>,
    pub touch_action: Option<HashMap<Key, String>>,
    pub transform: Option<HashMap<Key, String>>,
    pub transform_origin: Option<HashMap<Key, String>>,

    pub transition_delay: Option<HashMap<Key, String>>,
    pub transition_duration: Option<HashMap<Key, String>>,
    pub transition_property: Option<HashMap<Key, String>>,
    pub transition_timing_function: Option<HashMap<Key, String>>,
    pub translate: Option<HashMap<Key, String>>,
    pub user_select: Option<HashMap<Key, String>>,
    pub vertical_align: Option<HashMap<Key, String>>,
    pub visibility: Option<HashMap<Key, String>>,
    pub whitespace: Option<HashMap<Key, String>>,
    pub will_change: Option<HashMap<Key, String>>,
    pub word_break: Option<HashMap<Key, String>>,

    pub screen_readers: Option<HashMap<Key, String>>,

    // Modifiers
    pub aria: Option<HashMap<Key, String>>,
    pub supports: Option<HashMap<Key, String>>,
    pub data: Option<HashMap<Key, String>>,
    // pub extend: HashMap<Key, HashMap<String, String>>,
}

// #[derive(Serialize, Deserialize, Debug)]
// pub struct Extend {
//     pub screens: Option<HashMap<Key, String>>,
//     // add other fields as needed
// }

#[derive(Serialize, Deserialize, Default, Debug)]
pub struct Variants {}

#[derive(Serialize, Deserialize, Default, Debug)]
pub struct Plugins {}