-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrules.pest
219 lines (193 loc) · 6.81 KB
/
rules.pest
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
style_definition = _{ ((style | property) ~ " ")* ~ (style | property) }
property = _{
border_radius
| background_color
| text_size
| border_color
| text_color
| interaction
| focus_policy
| image
| transform
| global_transform
| visibility
| inherited_visibility
| view_visibility
| z_index
}
COLOR_BASE = {
"black"
| "white"
}
border_color = { "border_color-" ~ (COLOR | COLOR_BASE) }
border_radius = { "rounded-" ~ ("none" | "sm" | "md" | "lg" | "full" | VALUE) }
background_color = { "bg-" ~ (COLOR | COLOR_BASE) }
text_color = { "text_color-" ~ (COLOR | COLOR_BASE) }
text_size = { "text-" ~ ("xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "7xl" | "8xl" | "9xl" | VALUE) }
interaction = { "interaction-" ~ ("hovered" | "pressed" | "none") }
focus_policy = { "focus-" ~ ("block" | "none") }
image = { "image-" ~ IDENTIFIER }
transform = { "transform-" ~ (("t-" ~ VEC3) | ("r-" ~ VEC4)) | (("s-") ~ VEC3) }
global_transform = { "global_transform-" ~ IDENTIFIER }
visibility = { "visibility-" ~ ("visible" | "hidden" | "inherit") }
inherited_visibility = { "inherited_visibility-" ~ ("true" | "false") }
view_visibility = { "view_visibility-" ~ ("visible" | "hidden") }
z_index = { "z-" ~ (DIGIT | ("global-" ~ DIGIT)) }
COLOR = { COLOR_NAME ~ "-" ~ COLOR_VALUE }
COLOR_NAME = {
"slate"
| "gray"
| "zinc"
| "neutral"
| "stone"
| "red"
| "orange"
| "amber"
| "yellow"
| "lime"
| "green"
| "emerald"
| "teal"
| "cyan"
| "sky"
| "blue"
| "indigo"
| "violet"
| "purple"
| "fuchsia"
| "pink"
| "rose"
}
COLOR_VALUE = { "50" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900" }
UNIT = _{ "px" | "%" | "vw" | "vh" | "vmin" | "vmax" }
NUMBER = @{ ASCII_DIGIT+ }
PREDEFINED_VALUES = _{
"1px"
| "2px"
| "4px"
| "8px"
| "0px"
| "0%"
| "50%"
| "100%"
| "1vw"
| "2vw"
| "4vw"
| "0vw"
| "1vh"
| "2vh"
| "4vh"
| "0vh"
| "1vmin"
| "2vmin"
| "4vmin"
| "0vmin"
| "1vmax"
| "2vmax"
| "4vmax"
| "0vmax"
}
DIGIT = @{ (ASCII_DIGIT)+ }
DECIMAL = @{ DIGIT ~ "." ~ DIGIT }
VALUE = @{ ( DECIMAL | DIGIT ) ~ UNIT }
VEC2 = @{ (DECIMAL | DIGIT) ~ "_" ~ (DECIMAL | DIGIT) }
VEC3 = @{ VEC2 ~ "_" ~ (DECIMAL | DIGIT) }
VEC4 = @{ VEC2 ~ "_" ~ VEC2 }
BVEC4 = @{ VALUE ~ "_" ~ VALUE ~ "_" ~ VALUE ~ "_" ~ VALUE }
DISPLAY = _{ "flex" | "grid" | "none" }
POSITION_TYPE = _{ "relative" | "absolute" }
OVERFLOW = _{ "visible" | "clip" | "clip-x" | "clip-y" }
DIRECTION = _{ "ltr" | "rtl" | "inherit" }
ALIGN_ITEMS = _{ "start" | "center" | "end" | "stretch" | "flex-start" | "flex-end" | "baseline" | "default" }
JUSTIFY_ITEMS = _{ "start" | "center" | "end" | "stretch" | "baseline" | "default" }
ALIGN_SELF = _{ "start" | "center" | "end" | "stretch" | "flex-start" | "flex-end" | "baseline" | "auto" }
JUSTIFY_SELF = _{ "start" | "end" | "stretch" | "center" | "baseline" | "auto" }
ALIGN_CONTENT = _{ "start" | "end" | "stretch" | "center" | "flex-start" | "flex-end" | "between" | "evenly" | "around" | "default" }
JUSTIFY_CONTENT = _{ "start" | "end" | "stretch" | "center" | "flex-start" | "flex-end" | "between" | "evenly" | "around" | "default" }
FLEX_DIRECTION = _{ "row" | "col" | "row-reverse" | "col-reverse" }
FLEX_WRAP = _{ "wrap" | "nowrap" | "wrap-reverse" }
GRID_AUTO_FLOW = _{ "row" | "col" | "col-dense" | "row-dense" }
GRID_TEMPLATE_ROWS = @{ VALUE ~ ("," ~ VALUE)* }
GRID_TEMPLATE_COLUMNS = @{ VALUE ~ ("," ~ VALUE)* }
GRID_AUTO_ROWS = @{ VALUE ~ ("," ~ VALUE)* }
GRID_AUTO_COLUMNS = @{ VALUE ~ ("," ~ VALUE)* }
GRID_PLACEMENT = @{ VALUE ~ (" " ~ VALUE)? }
display_style = { "display-" ~ DISPLAY }
position_type_style = { "position-" ~ POSITION_TYPE }
overflow_style = { "overflow-" ~ OVERFLOW }
direction_style = { "direction-" ~ DIRECTION }
left_style = { "left-" ~ VALUE }
right_style = { "right-" ~ VALUE }
top_style = { "top-" ~ VALUE }
bottom_style = { "bottom-" ~ VALUE }
width_style = { "width-" ~ VALUE }
height_style = { "height-" ~ VALUE }
min_width_style = { "min_width-" ~ VALUE }
min_height_style = { "min_height-" ~ VALUE }
max_width_style = { "max_width-" ~ VALUE }
max_height_style = { "max_height-" ~ VALUE }
aspect_ratio_style = { "aspect-" ~ (DECIMAL | DIGIT) }
align_items_style = { "align_items-" ~ ALIGN_ITEMS }
justify_items_style = { "justify_items-" ~ JUSTIFY_ITEMS }
align_self_style = { "align_self-" ~ ALIGN_SELF }
justify_self_style = { "justify_self-" ~ JUSTIFY_SELF }
align_content_style = { "align_content-" ~ ALIGN_CONTENT }
justify_content_style = { "justify_content-" ~ JUSTIFY_CONTENT }
margin_style = { "margin-" ~ (BVEC4 | VALUE) }
padding_style = { "padding-" ~ (BVEC4 | VALUE) }
border_style = { "border-" ~ (BVEC4 | VALUE) }
flex_direction_style = { "flex_direction-" ~ FLEX_DIRECTION }
flex_wrap_style = { "flex_wrap-" ~ FLEX_WRAP }
flex_grow_style = { "flex_grow-" ~ (DECIMAL | DIGIT) }
flex_shrink_style = { "flex_shrink-" ~ (DECIMAL | DIGIT) }
flex_basis_style = { "flex_basis-" ~ VALUE }
row_gap_style = { "row_gap-" ~ VALUE }
column_gap_style = { "column_gap-" ~ VALUE }
grid_auto_flow_style = { "grid_auto_flow-" ~ GRID_AUTO_FLOW }
grid_template_rows_style = { "grid_template_rows-" ~ GRID_TEMPLATE_ROWS }
grid_template_columns_style = { "grid_template_columns-" ~ GRID_TEMPLATE_COLUMNS }
grid_auto_rows_style = { "grid_auto_rows-" ~ GRID_AUTO_ROWS }
grid_auto_columns_style = { "grid_auto_columns-" ~ GRID_AUTO_COLUMNS }
grid_row_style = { "grid_row-" ~ GRID_PLACEMENT }
grid_column_style = { "grid_column-" ~ GRID_PLACEMENT }
style = _{
display_style
| position_type_style
| overflow_style
| direction_style
| left_style
| right_style
| top_style
| bottom_style
| width_style
| height_style
| min_width_style
| min_height_style
| max_width_style
| max_height_style
| aspect_ratio_style
| align_items_style
| justify_items_style
| align_self_style
| justify_self_style
| align_content_style
| justify_content_style
| margin_style
| padding_style
| border_style
| flex_direction_style
| flex_wrap_style
| flex_grow_style
| flex_shrink_style
| flex_basis_style
| row_gap_style
| column_gap_style
| grid_auto_flow_style
| grid_template_rows_style
| grid_template_columns_style
| grid_auto_rows_style
| grid_auto_columns_style
| grid_row_style
| grid_column_style
}
IDENTIFIER = @{ ASCII_ALPHANUMERIC+ }