@thi.ng/meta-css 0.2.0 → 0.4.0
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/CHANGELOG.md +16 -1
- package/README.md +458 -413
- package/index.js +6 -6
- package/package.json +8 -5
- package/specs/a11y.json +32 -0
- package/specs/aspect.json +38 -0
- package/specs/background.json +26 -0
- package/specs/borders.json +17 -0
- package/specs/dimensions.json +43 -25
- package/specs/display.json +6 -0
- package/specs/grids.json +60 -0
- package/specs/icons.json +30 -0
- package/specs/normalize.json +156 -0
- package/specs/positions.json +1 -1
- package/specs/selection.json +15 -0
- package/specs/shadows.json +43 -0
- package/specs/typography.json +15 -5
- package/specs/grid.json +0 -39
- package/specs/shadow.json +0 -26
- /package/specs/{overflow.json → overflows.json} +0 -0
package/README.md
CHANGED
|
@@ -11,15 +11,9 @@ This project is part of the
|
|
|
11
11
|
[@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo and anti-framework.
|
|
12
12
|
|
|
13
13
|
- [About](#about)
|
|
14
|
-
|
|
15
|
-
- [
|
|
16
|
-
|
|
17
|
-
- [Force inclusion of unreferenced classes](#force-inclusion-of-unreferenced-classes)
|
|
18
|
-
- [Export](#export)
|
|
19
|
-
- [Media query variations](#media-query-variations)
|
|
20
|
-
- [Framework generation rules](#framework-generation-rules)
|
|
21
|
-
- [Overall file structure](#overall-file-structure)
|
|
22
|
-
- [Example spec](#example-spec)
|
|
14
|
+
- [Generating CSS frameworks](#generating-css-frameworks)
|
|
15
|
+
- [Framework generation specs & syntax](#framework-generation-specs--syntax)
|
|
16
|
+
- [Example generation spec](#example-generation-spec)
|
|
23
17
|
- [Spec structure](#spec-structure)
|
|
24
18
|
- [Variations](#variations)
|
|
25
19
|
- [Parametric IDs](#parametric-ids)
|
|
@@ -27,6 +21,14 @@ This project is part of the
|
|
|
27
21
|
- [Properties](#properties)
|
|
28
22
|
- [Key value generation](#key-value-generation)
|
|
29
23
|
- [Media query definitions](#media-query-definitions)
|
|
24
|
+
- [Converting meta stylesheets to CSS](#converting-meta-stylesheets-to-css)
|
|
25
|
+
- [Meta-stylesheets syntax](#meta-stylesheets-syntax)
|
|
26
|
+
- [Class identifiers & media query prefixes](#class-identifiers--media-query-prefixes)
|
|
27
|
+
- [Media query prefixes](#media-query-prefixes)
|
|
28
|
+
- [Including custom CSS files](#including-custom-css-files)
|
|
29
|
+
- [Force inclusion of unreferenced classes](#force-inclusion-of-unreferenced-classes)
|
|
30
|
+
- [Exporting a generated framework as CSS](#exporting-a-generated-framework-as-css)
|
|
31
|
+
- [Media query variations](#media-query-variations)
|
|
30
32
|
- [Bundled CSS base framework](#bundled-css-base-framework)
|
|
31
33
|
- [Classes by category](#classes-by-category)
|
|
32
34
|
- [Media queries](#media-queries)
|
|
@@ -35,13 +37,6 @@ This project is part of the
|
|
|
35
37
|
- [Installation](#installation)
|
|
36
38
|
- [Dependencies](#dependencies)
|
|
37
39
|
- [Usage examples](#usage-examples)
|
|
38
|
-
- [CLI](#cli)
|
|
39
|
-
- [Basic usage example](#basic-usage-example)
|
|
40
|
-
- [Generating framework code from bundled base definitions](#generating-framework-code-from-bundled-base-definitions)
|
|
41
|
-
- [Generating CSS from `.meta` stylesheets](#generating-css-from-meta-stylesheets)
|
|
42
|
-
- [*.meta stylesheets](#meta-stylesheets)
|
|
43
|
-
- [Resulting CSS output](#resulting-css-output)
|
|
44
|
-
- [index.html](#indexhtml)
|
|
45
40
|
- [Authors](#authors)
|
|
46
41
|
- [License](#license)
|
|
47
42
|
|
|
@@ -50,32 +45,41 @@ This project is part of the
|
|
|
50
45
|
Data-driven CSS framework codegen, transpiler & bundler.
|
|
51
46
|
|
|
52
47
|
This toolchain and the overall workflow proposed by it is heavily building atop
|
|
53
|
-
the concept of _CSS utility classes_
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
the concept of _CSS utility classes_ (as known from Tachyons, Turret or the
|
|
49
|
+
newer Tailwind projects). How and where those CSS classes are applied is however
|
|
50
|
+
a defining point of difference to other existing approaches. Furthermore, using
|
|
51
|
+
JSON as data format for expressing generative rules and as intermediate format
|
|
52
|
+
for generated frameworks, removes the need for any complex CSS-related
|
|
53
|
+
dependencies and makes it trivial to build secondary tooling around (e.g. part
|
|
54
|
+
of this readme is an auto-generated report of the included base framework
|
|
55
|
+
specs).
|
|
56
|
+
|
|
57
|
+
This readme aims to provide a thorough overview of this toolchain and some
|
|
57
58
|
concrete usage examples...
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
Note: In all cases, final CSS generation itself is handled by
|
|
61
|
+
[thi.ng/hiccup-css](https://github.com/thi-ng/umbrella/blob/develop/packages/hiccup-css/).
|
|
62
|
+
|
|
63
|
+
**👷🏻 This is all WIP!** Also see included & linked examples for basic usage...
|
|
60
64
|
|
|
61
|
-
|
|
65
|
+
## Generating CSS frameworks
|
|
62
66
|
|
|
63
67
|
The `generate` command is used to generate custom frameworks with (likely)
|
|
64
68
|
hundreds of CSS utility classes from a number of extremely compact, parametric
|
|
65
69
|
JSON rule specs. This process generates all desired, combinatorial versions of
|
|
66
70
|
various rules/declarations and exports them to another JSON file used as
|
|
67
|
-
|
|
68
|
-
[syntax/format of the generator rules](#framework-generation-
|
|
71
|
+
intermediary for the other commands provided by this toolchain. The
|
|
72
|
+
[syntax/format of the generator rules](#framework-generation-specs--syntax) is explained
|
|
69
73
|
further on. These rule specs can be split up into multiple files for better
|
|
70
74
|
handling, can define [arbitrary media query criteria]() (all later combinable),
|
|
71
75
|
shared lookup tables for colors, margins, sizes, timings etc.
|
|
72
76
|
|
|
73
|
-
The package
|
|
77
|
+
The package includes generator specs for a basic, fully customizable,
|
|
74
78
|
[tachyons.io](https://tachyons.io)-derived [CSS
|
|
75
79
|
framework](#bundled-css-base-framework). These specs and resulting framework are
|
|
76
|
-
used for some example projects in this repo, but
|
|
77
|
-
starting points for creating other custom
|
|
78
|
-
shared back similarly)...
|
|
80
|
+
still being worked on and are used for some example projects in this repo, but
|
|
81
|
+
are mostly intended as basic starting points for creating other custom
|
|
82
|
+
frameworks (in the hope they'll be shared back similarly)...
|
|
79
83
|
|
|
80
84
|
```text
|
|
81
85
|
metacss generate --help
|
|
@@ -93,130 +97,12 @@ Main:
|
|
|
93
97
|
--prec INT Number of fractional digits (default: 3)
|
|
94
98
|
```
|
|
95
99
|
|
|
96
|
-
###
|
|
97
|
-
|
|
98
|
-
The `convert` command is used to compile & bundle actual CSS from user-provided
|
|
99
|
-
MetaCSS stylesheets (`*.meta` files) and the JSON framework specs created by the
|
|
100
|
-
`generate` command. The meta-stylesheets support any CSS selectors, are nestable
|
|
101
|
-
and compose full CSS declarations from lists of the utility classes in the
|
|
102
|
-
generated framework.
|
|
103
|
-
|
|
104
|
-
Each item (aka utility class name) can be prefixed with an arbitrary number of
|
|
105
|
-
media query IDs (also custom defined in the framework): e.g. `dark:bg-black`
|
|
106
|
-
might refer to a CSS class to set a black ground, with the `dark:` prefix
|
|
107
|
-
referring to a defined media query which only applies this class when dark mode
|
|
108
|
-
is enabled...
|
|
109
|
-
|
|
110
|
-
Selectors, declarations and media query criteria will be deduplicated and merged
|
|
111
|
-
from multiple input files. The resulting CSS will only contain referenced rules
|
|
112
|
-
and can be generated in minified or pretty printed formats (it's also possible
|
|
113
|
-
to force include CSS classes which are otherwise unreferenced, using the
|
|
114
|
-
`--force` CLI arg). Additionally, multiple .meta files can be watched for
|
|
115
|
-
changes, their definitions will be merged, and existing CSS files can be
|
|
116
|
-
included (prepended) in the bundled outout too.
|
|
117
|
-
|
|
118
|
-
```text
|
|
119
|
-
metacss convert --help
|
|
120
|
-
|
|
121
|
-
Usage: metacss convert [opts] input [...]
|
|
122
|
-
|
|
123
|
-
Flags:
|
|
124
|
-
|
|
125
|
-
--no-header Don't emit generated header comment
|
|
126
|
-
-p, --pretty Pretty print output
|
|
127
|
-
-v, --verbose Display extra process information
|
|
128
|
-
-w, --watch Watch input files for changes
|
|
129
|
-
|
|
130
|
-
Main:
|
|
131
|
-
|
|
132
|
-
--force STR[,..] [multiple] CSS classes to force include (wildcards are
|
|
133
|
-
supported, @-prefix will read from file)
|
|
134
|
-
-I STR, --include STR [multiple] Include CSS files (prepend)
|
|
135
|
-
-o STR, --out STR Output file (or stdout)
|
|
136
|
-
-s STR, --specs STR [required] Path to generated JSON defs
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
#### Including custom CSS files
|
|
140
|
-
|
|
141
|
-
One or more existing CSS files can be included & prepended to the output via the
|
|
142
|
-
`--include`/`-I` arg (which can be given multiple times). These files are used
|
|
143
|
-
verbatim and will **not** be transformed or reformatted in any way.
|
|
144
|
-
|
|
145
|
-
#### Force inclusion of unreferenced classes
|
|
146
|
-
|
|
147
|
-
Only the CSS classes (and their optionally associated media queries) referenced
|
|
148
|
-
in a `.meta` stylesheet will appear in the export CSS bundle. This ensures that
|
|
149
|
-
the resulting CSS will only contain what's actually used (same effect as
|
|
150
|
-
tree-shaking, only vastly more efficient). However, this also means any CSS
|
|
151
|
-
classes (and optionally, their media query qualifiers) which are otherwise
|
|
152
|
-
referenced (e.g. from JS/TS source code or HTML docs) **will not** be included
|
|
153
|
-
by default and they will need to be listed manually for forced inclusion.
|
|
154
|
-
|
|
155
|
-
This can be achieved via the `--force`/`-f` arg (also can be given multiple
|
|
156
|
-
times). This option also supports basic `*`-wildcard patterns, e.g. `bg-*` to
|
|
157
|
-
include all classes with prefix `bg-`. Furthermore, for larger projects it's
|
|
158
|
-
useful to store these names/patterns in a separate file. For that purpose, use
|
|
159
|
-
the `@` prefix (e.g. `-f @includes.txt`) to indicate reading from file (only
|
|
160
|
-
reading from a single file is supported at current)... See the [meta-css-basics
|
|
161
|
-
example
|
|
162
|
-
project](https://github.com/thi-ng/umbrella/blob/develop/examples/meta-css-basics)
|
|
163
|
-
for concrete usage...
|
|
164
|
-
|
|
165
|
-
### Export
|
|
166
|
-
|
|
167
|
-
The `export` command is intended for those who're mainly interested in the CSS
|
|
168
|
-
framework generation aspects of this toolchain. This command merely takes an
|
|
169
|
-
existing generated framework JSON file and serializes it to a single CSS file,
|
|
170
|
-
e.g. to be then used with other CSS tooling (e.g. `postcss`).
|
|
171
|
-
|
|
172
|
-
#### Media query variations
|
|
173
|
-
|
|
174
|
-
Users can choose to generate variations of all defined utility classes for any
|
|
175
|
-
of the framework-defined media query IDs. This will create additional suffixed
|
|
176
|
-
versions of all classes (with their appropriate media query wrappers) and cause
|
|
177
|
-
a potentially massive output (depending on the overall number/complexity of the
|
|
178
|
-
generated classes). Again, the idea is that the resulting CSS file will be
|
|
179
|
-
post-processed with 3rd party CSS tooling...
|
|
180
|
-
|
|
181
|
-
For example, if the framework contains a CSS class `w-50` (e.g. to set the width
|
|
182
|
-
to 50%) and media queries for different screen sizes (e.g. named `ns`, `l`),
|
|
183
|
-
then the export with said media queries will also generate classes `w-50-ns`
|
|
184
|
-
and `w-50-l` (incl. their corresponding `@media` wrappers).
|
|
185
|
-
|
|
186
|
-
As with the `convert` command, additional CSS files can also be included
|
|
187
|
-
(prepended) in the output file.
|
|
188
|
-
|
|
189
|
-
```text
|
|
190
|
-
metacss export --help
|
|
191
|
-
|
|
192
|
-
Usage: metacss export [opts] input
|
|
193
|
-
|
|
194
|
-
Flags:
|
|
195
|
-
|
|
196
|
-
--no-header Don't emit generated header comment
|
|
197
|
-
-p, --pretty Pretty print output
|
|
198
|
-
-v, --verbose Display extra process information
|
|
199
|
-
|
|
200
|
-
Main:
|
|
201
|
-
|
|
202
|
-
-I STR, --include STR [multiple] Include CSS files (prepend)
|
|
203
|
-
-m STR, --media STR Media query IDs (use 'ALL' for all)
|
|
204
|
-
-o STR, --out STR Output file (or stdout)
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
Note: In all cases, final CSS generation itself is handled by
|
|
208
|
-
[thi.ng/hiccup-css](https://github.com/thi-ng/umbrella/blob/develop/packages/hiccup-css/)
|
|
209
|
-
|
|
210
|
-
**👷🏻 This is all WIP!** See example below for basic example usage...
|
|
211
|
-
|
|
212
|
-
## Framework generation rules
|
|
100
|
+
### Framework generation specs & syntax
|
|
213
101
|
|
|
214
102
|
This section gives an overview of the JSON format used to generate CSS
|
|
215
103
|
frameworks of dozens (usually hundreds) of utility classes, including many
|
|
216
104
|
possible variations (per spec).
|
|
217
105
|
|
|
218
|
-
### Overall file structure
|
|
219
|
-
|
|
220
106
|
Generation specs use a simple JSON structure as shown below. The specs can be
|
|
221
107
|
split over multiple files within a directory and will all be merged by the
|
|
222
108
|
`generate` command of the toolchain.
|
|
@@ -228,15 +114,25 @@ split over multiple files within a directory and will all be merged by the
|
|
|
228
114
|
"name": "Framework name",
|
|
229
115
|
"version": "0.0.0",
|
|
230
116
|
},
|
|
231
|
-
// optional media queries and their criteria
|
|
117
|
+
// optional media queries and their criteria, will be merged from multiple spec files
|
|
232
118
|
"media": {
|
|
233
119
|
"large": { "min-width": "60rem" },
|
|
234
120
|
"dark": { "prefers-color-scheme": "dark" }
|
|
235
121
|
},
|
|
236
122
|
// optional shared values/LUTs (arrays or objects)
|
|
123
|
+
// tables are always local to the current spec file only...
|
|
237
124
|
"tables": {
|
|
238
125
|
"margins": [0, 0.25, 0.5, 1, 2, 4]
|
|
239
126
|
},
|
|
127
|
+
// optional shared variations
|
|
128
|
+
"vars": {
|
|
129
|
+
"size": ["width", "height"]
|
|
130
|
+
},
|
|
131
|
+
// optional thi.ng/hiccup-css declarations which will be part of the framework
|
|
132
|
+
// (e.g. for CSS reset purposes), will be merged from multiple spec files
|
|
133
|
+
"decls": [
|
|
134
|
+
["html", { "box-sizing": "border-box" }]
|
|
135
|
+
],
|
|
240
136
|
// array of actual generation specs
|
|
241
137
|
"specs": [
|
|
242
138
|
//...
|
|
@@ -244,7 +140,7 @@ split over multiple files within a directory and will all be merged by the
|
|
|
244
140
|
}
|
|
245
141
|
```
|
|
246
142
|
|
|
247
|
-
### Example spec
|
|
143
|
+
### Example generation spec
|
|
248
144
|
|
|
249
145
|
The following generator document uses a single small generative rule spec to
|
|
250
146
|
create altogether 21 utility classes for various possible margins (where 21 = 3
|
|
@@ -336,8 +232,8 @@ An individual generator spec JSON object can contain the following keys:
|
|
|
336
232
|
| `var` | string[], optional | Array of variation IDs (see section below) |
|
|
337
233
|
| `user` | any, optional | Custom user data, comments, metadata etc. |
|
|
338
234
|
|
|
339
|
-
The number of generated CSS classes per spec is number of items in `values`
|
|
340
|
-
multiplied
|
|
235
|
+
The number of generated CSS classes per spec is the number of items in `values`
|
|
236
|
+
multiplied by the number of variations in `var` (if any).
|
|
341
237
|
|
|
342
238
|
Any `user` data will be stored (as is) with each generated CSS class, but
|
|
343
239
|
currently has no other direct use in the toolchain and is meant for additional
|
|
@@ -517,98 +413,453 @@ ALWAYS combined using `and`:
|
|
|
517
413
|
See [media queries in the bundled base
|
|
518
414
|
specs](https://github.com/thi-ng/umbrella/blob/982fff7bfcc48f108b6ad88f854ef00be4078510/packages/meta-css/specs/_info.json#L6-L24)
|
|
519
415
|
|
|
520
|
-
##
|
|
416
|
+
## Converting meta stylesheets to CSS
|
|
521
417
|
|
|
522
|
-
The
|
|
418
|
+
The `convert` command is used to compile & bundle actual CSS from user-provided
|
|
419
|
+
MetaCSS stylesheets (`*.meta` files) and the JSON framework specs created by the
|
|
420
|
+
`generate` command. The meta-stylesheets support any CSS selectors, are nestable
|
|
421
|
+
and compose full CSS declarations from lists of the utility classes in the
|
|
422
|
+
generated framework.
|
|
523
423
|
|
|
524
|
-
|
|
424
|
+
Each item (aka utility class name) can be prefixed with an arbitrary number of
|
|
425
|
+
media query IDs (also custom defined in the framework): e.g. `dark:bg-black`
|
|
426
|
+
might refer to a CSS class to set a black ground, with the `dark:` prefix
|
|
427
|
+
referring to a defined media query which only applies this class when dark mode
|
|
428
|
+
is enabled...
|
|
525
429
|
|
|
526
|
-
|
|
430
|
+
Selectors, declarations and media query criteria will be deduplicated and merged
|
|
431
|
+
from multiple input files. **The resulting CSS will only contain referenced
|
|
432
|
+
rules** and can be generated in minified or pretty printed formats (it's also
|
|
433
|
+
possible to [force include CSS classes which are otherwise
|
|
434
|
+
unreferenced](#force-inclusion-of-unreferenced-classes)). Additionally, multiple
|
|
435
|
+
`.meta` stylesheets can be watched for changes (their definitions getting
|
|
436
|
+
merged), and existing CSS files can be included (prepended) in the bundled
|
|
437
|
+
output too.
|
|
527
438
|
|
|
528
|
-
|
|
439
|
+
```text
|
|
440
|
+
metacss convert --help
|
|
529
441
|
|
|
530
|
-
|
|
442
|
+
Usage: metacss convert [opts] input [...]
|
|
531
443
|
|
|
532
|
-
|
|
444
|
+
Flags:
|
|
533
445
|
|
|
534
|
-
|
|
446
|
+
-d, --no-decls Don't emit framework decls
|
|
447
|
+
--no-header Don't emit generated header comment
|
|
448
|
+
-p, --pretty Pretty print output
|
|
449
|
+
-v, --verbose Display extra process information
|
|
450
|
+
-w, --watch Watch input files for changes
|
|
535
451
|
|
|
536
|
-
|
|
452
|
+
Main:
|
|
537
453
|
|
|
538
|
-
|
|
454
|
+
-e STR, --eval STR eval meta stylesheet in given string (ignores other
|
|
455
|
+
inputs & includes)
|
|
456
|
+
-f STR, --force STR [multiple] CSS classes to force include (wildcards are
|
|
457
|
+
supported, @-prefix will read from file)
|
|
458
|
+
-I STR, --include STR [multiple] Include CSS files (prepend)
|
|
459
|
+
-o STR, --out STR Output file (or stdout)
|
|
460
|
+
-s STR, --specs STR [required] Path to generated JSON defs
|
|
461
|
+
```
|
|
539
462
|
|
|
540
|
-
|
|
463
|
+
### Meta-stylesheets syntax
|
|
541
464
|
|
|
542
|
-
|
|
465
|
+
As mentioned earlier, the `convert` command transpiles meta-stylesheets into
|
|
466
|
+
actual CSS. These stylesheets support any CSS selector, support selector
|
|
467
|
+
nesting and have the following basic syntax:
|
|
543
468
|
|
|
544
|
-
|
|
469
|
+
```text
|
|
470
|
+
// line comment
|
|
471
|
+
selector {
|
|
472
|
+
class-id1 class-id2 ...
|
|
473
|
+
{
|
|
474
|
+
nested-selector {
|
|
475
|
+
class-id3 ...
|
|
476
|
+
{
|
|
477
|
+
...
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
```
|
|
545
483
|
|
|
546
|
-
|
|
484
|
+
#### Class identifiers & media query prefixes
|
|
547
485
|
|
|
548
|
-
|
|
486
|
+
As indicated by the above file structure, `*.meta` stylesheets purely consist of
|
|
487
|
+
CSS selectors and the names of the generated framework-defined utility classes.
|
|
488
|
+
For example, using the [bundled framework specs](#bundled-css-base-framework),
|
|
489
|
+
this simple meta-stylesheet `body { ma0 monospace blue }` creates a CSS rule for
|
|
490
|
+
`body` with the definitions of the generated `ma0`, `monospace` and `blue`
|
|
491
|
+
classes inline-expanded:
|
|
549
492
|
|
|
550
|
-
|
|
493
|
+
```css
|
|
494
|
+
body {
|
|
495
|
+
margin: 0rem;
|
|
496
|
+
font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
|
|
497
|
+
color: #357edd;
|
|
498
|
+
}
|
|
499
|
+
```
|
|
551
500
|
|
|
552
|
-
####
|
|
501
|
+
#### Media query prefixes
|
|
553
502
|
|
|
554
|
-
|
|
503
|
+
This toolchain doesn't pre-generate media-query-specific versions of any CSS
|
|
504
|
+
class, and any class ID/token can be prefixed with any number of media query IDs
|
|
505
|
+
(separated by `:`). These [media queries are defined as part of the framework
|
|
506
|
+
generation specs](#media-query-definitions) and when used as a prefix, multiple
|
|
507
|
+
query IDs can be combined freely. For example, the meta-stylesheet `a:hover {
|
|
508
|
+
dark:bg-blue dark:anim:bg-anim2 }` will auto-create two separate CSS
|
|
509
|
+
`@media`-query blocks for the query IDs `dark` and `(dark AND anim)`:
|
|
555
510
|
|
|
556
|
-
|
|
511
|
+
```css
|
|
512
|
+
@media (prefers-color-scheme: dark) {
|
|
513
|
+
a:hover {
|
|
514
|
+
background-color: #357edd;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
557
517
|
|
|
558
|
-
|
|
518
|
+
@media (prefers-color-scheme: dark) and (not (prefers-reduced-motion)) {
|
|
519
|
+
a:hover {
|
|
520
|
+
transition: 0.25s background-color ease-in-out;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
```
|
|
559
524
|
|
|
560
|
-
|
|
525
|
+
A more detailed example, split over two files (for merging & bundling):
|
|
561
526
|
|
|
562
|
-
|
|
527
|
+
readme.meta:
|
|
563
528
|
|
|
564
|
-
|
|
529
|
+
```text tangle:export/readme.meta
|
|
530
|
+
body {
|
|
531
|
+
// no margins
|
|
532
|
+
ma0
|
|
533
|
+
// default colors
|
|
534
|
+
bg-white black
|
|
535
|
+
// colors for dark mode
|
|
536
|
+
dark:bg-black dark:white
|
|
537
|
+
}
|
|
565
538
|
|
|
566
|
-
|
|
539
|
+
#app { ma3 }
|
|
567
540
|
|
|
568
|
-
|
|
541
|
+
.bt-group-v > a {
|
|
542
|
+
db w-100 l:w-50 ph3 pv2 bwb1
|
|
543
|
+
dark:bg-purple dark:white dark:b--black
|
|
544
|
+
light:bg-light-blue light:black light:b--white
|
|
569
545
|
|
|
570
|
-
|
|
546
|
+
// nested selectors
|
|
547
|
+
{
|
|
548
|
+
:hover { bg-gold black anim:bg-anim2 }
|
|
549
|
+
:first-child { brt3 }
|
|
550
|
+
:last-child { brb3 bwb0 }
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
```
|
|
571
554
|
|
|
572
|
-
|
|
555
|
+
readme2.meta:
|
|
573
556
|
|
|
574
|
-
|
|
557
|
+
We will merge the definitions in this file with the ones above (i.e. adding &
|
|
558
|
+
overriding some of the declarations, here: a larger border radius):
|
|
575
559
|
|
|
576
|
-
|
|
560
|
+
```text tangle:export/readme2.meta
|
|
561
|
+
#app { pa2 }
|
|
577
562
|
|
|
578
|
-
|
|
563
|
+
.bt-group-v > a {
|
|
564
|
+
{
|
|
565
|
+
:first-child { brt4 }
|
|
566
|
+
:last-child { brb4 }
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
```
|
|
579
570
|
|
|
580
|
-
|
|
571
|
+
```bash
|
|
572
|
+
# if no --out dir is specified, writes result to stdout...
|
|
573
|
+
# use previously generated framework for resolving all identifiers & media queries
|
|
574
|
+
metacss convert --pretty --specs framework.json readme.meta readme2.meta
|
|
575
|
+
```
|
|
581
576
|
|
|
582
|
-
|
|
577
|
+
Resulting CSS bundle output:
|
|
583
578
|
|
|
584
|
-
|
|
579
|
+
```css
|
|
580
|
+
/*! MetaCSS base v0.0.1 - generated by thi.ng/meta-css @ 2023-12-18T12:22:36.548Z */
|
|
581
|
+
body {
|
|
582
|
+
margin: 0rem;
|
|
583
|
+
background-color: #fff;
|
|
584
|
+
color: #000;
|
|
585
|
+
}
|
|
585
586
|
|
|
586
|
-
|
|
587
|
+
#app {
|
|
588
|
+
margin: 1rem;
|
|
589
|
+
padding: .5rem;
|
|
590
|
+
}
|
|
587
591
|
|
|
588
|
-
|
|
592
|
+
.bt-group-v > a {
|
|
593
|
+
display: block;
|
|
594
|
+
width: 100%;
|
|
595
|
+
padding-left: 1rem;
|
|
596
|
+
padding-right: 1rem;
|
|
597
|
+
padding-top: .5rem;
|
|
598
|
+
padding-bottom: .5rem;
|
|
599
|
+
border-bottom-style: solid;
|
|
600
|
+
border-bottom-width: .125rem;
|
|
601
|
+
}
|
|
589
602
|
|
|
590
|
-
|
|
603
|
+
.bt-group-v > a:hover {
|
|
604
|
+
background-color: #ffb700;
|
|
605
|
+
color: #000;
|
|
606
|
+
}
|
|
591
607
|
|
|
592
|
-
|
|
608
|
+
.bt-group-v > a:first-child {
|
|
609
|
+
border-top-left-radius: 1rem;
|
|
610
|
+
border-top-right-radius: 1rem;
|
|
611
|
+
}
|
|
593
612
|
|
|
594
|
-
|
|
613
|
+
.bt-group-v > a:last-child {
|
|
614
|
+
border-bottom-left-radius: 1rem;
|
|
615
|
+
border-bottom-right-radius: 1rem;
|
|
616
|
+
border-bottom-style: solid;
|
|
617
|
+
border-bottom-width: 0rem;
|
|
618
|
+
}
|
|
595
619
|
|
|
596
|
-
|
|
620
|
+
@media (prefers-color-scheme:dark) {
|
|
597
621
|
|
|
598
|
-
|
|
622
|
+
body {
|
|
623
|
+
background-color: #000;
|
|
624
|
+
color: #fff;
|
|
625
|
+
}
|
|
599
626
|
|
|
600
|
-
|
|
627
|
+
.bt-group-v > a {
|
|
628
|
+
background-color: #5e2ca5;
|
|
629
|
+
color: #fff;
|
|
630
|
+
border-color: #000;
|
|
631
|
+
}
|
|
601
632
|
|
|
602
|
-
|
|
633
|
+
}
|
|
603
634
|
|
|
604
|
-
|
|
635
|
+
@media (min-width:60rem) {
|
|
605
636
|
|
|
606
|
-
|
|
637
|
+
.bt-group-v > a {
|
|
638
|
+
width: 50%;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
@media (prefers-color-scheme:light) {
|
|
644
|
+
|
|
645
|
+
.bt-group-v > a {
|
|
646
|
+
background-color: #96ccff;
|
|
647
|
+
color: #000;
|
|
648
|
+
border-color: #fff;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
@media not (prefers-reduced-motion) {
|
|
654
|
+
|
|
655
|
+
.bt-group-v > a:hover {
|
|
656
|
+
transition: 0.2s background-color ease-in-out;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
}
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
### Including custom CSS files
|
|
663
|
+
|
|
664
|
+
One or more existing CSS files can be included & prepended to the output via the
|
|
665
|
+
`--include`/`-I` arg (which can be given multiple times). These files are used
|
|
666
|
+
verbatim and will **not** be transformed or reformatted in any way.
|
|
667
|
+
|
|
668
|
+
### Force inclusion of unreferenced classes
|
|
669
|
+
|
|
670
|
+
Only the CSS classes (and their optionally associated media queries) referenced
|
|
671
|
+
in a `.meta` stylesheet will appear in the export CSS bundle. This ensures that
|
|
672
|
+
the resulting CSS will only contain what's actually used (same effect as
|
|
673
|
+
tree-shaking, only vastly more efficient). However, this also means any CSS
|
|
674
|
+
classes (and optionally, their media query qualifiers) which are otherwise
|
|
675
|
+
referenced (e.g. from JS/TS source code or HTML docs) **will not** be included
|
|
676
|
+
by default and they will need to be listed manually for forced inclusion.
|
|
677
|
+
|
|
678
|
+
This can be achieved via the `--force`/`-f` arg (also can be given multiple
|
|
679
|
+
times). This option also supports basic `*`-wildcard patterns, e.g. `bg-*` to
|
|
680
|
+
include all classes with prefix `bg-`. Furthermore, for larger projects it's
|
|
681
|
+
useful to store these names/patterns in a separate file. For that purpose, use
|
|
682
|
+
the `@` prefix (e.g. `-f @includes.txt`) to indicate reading from file (only
|
|
683
|
+
reading from a single file is supported at current)... See the [meta-css-basics
|
|
684
|
+
example
|
|
685
|
+
project](https://github.com/thi-ng/umbrella/blob/develop/examples/meta-css-basics)
|
|
686
|
+
for concrete usage...
|
|
687
|
+
|
|
688
|
+
## Exporting a generated framework as CSS
|
|
689
|
+
|
|
690
|
+
The `export` command is intended for those who're mainly interested in the CSS
|
|
691
|
+
framework generation aspects of this toolchain. This command merely takes an
|
|
692
|
+
existing generated framework JSON file and serializes it to a single CSS file,
|
|
693
|
+
e.g. to be then used with other CSS tooling (e.g. `postcss`).
|
|
694
|
+
|
|
695
|
+
### Media query variations
|
|
696
|
+
|
|
697
|
+
Users can choose to generate variations of all defined utility classes for any
|
|
698
|
+
of the framework-defined media query IDs. This will create additional suffixed
|
|
699
|
+
versions of all classes (with their appropriate media query wrappers) and cause
|
|
700
|
+
a potentially massive output (depending on the overall number/complexity of the
|
|
701
|
+
generated classes). Again, the idea is that the resulting CSS file will be
|
|
702
|
+
post-processed with 3rd party CSS tooling...
|
|
703
|
+
|
|
704
|
+
For example, if the framework contains a CSS class `w-50` (e.g. to set the width
|
|
705
|
+
to 50%) and media queries for different screen sizes (e.g. named `ns`, `l`),
|
|
706
|
+
then the export with said media queries will also generate classes `w-50-ns`
|
|
707
|
+
and `w-50-l` (incl. their corresponding `@media` wrappers).
|
|
708
|
+
|
|
709
|
+
As with the `convert` command, additional CSS files can also be included
|
|
710
|
+
(prepended) in the output file.
|
|
711
|
+
|
|
712
|
+
```text
|
|
713
|
+
metacss export --help
|
|
714
|
+
|
|
715
|
+
Usage: metacss export [opts] input
|
|
716
|
+
|
|
717
|
+
Flags:
|
|
718
|
+
|
|
719
|
+
-d, --no-decls Don't emit framework decls
|
|
720
|
+
--no-header Don't emit generated header comment
|
|
721
|
+
-p, --pretty Pretty print output
|
|
722
|
+
-v, --verbose Display extra process information
|
|
723
|
+
|
|
724
|
+
Main:
|
|
725
|
+
|
|
726
|
+
-I STR, --include STR [multiple] Include CSS files (prepend)
|
|
727
|
+
-m ID, --media ID [multiple] Media query IDs (use 'ALL' for all)
|
|
728
|
+
-o STR, --out STR Output file (or stdout)
|
|
729
|
+
```
|
|
730
|
+
|
|
731
|
+
## Bundled CSS base framework
|
|
732
|
+
|
|
733
|
+
The package includes a large number of useful specs in [/specs](https://github.com/thi-ng/umbrella/blob/develop/packages/meta-css/specs/). These are provided as starting point to define your custom framework(s)...
|
|
734
|
+
|
|
735
|
+
Currently available CSS classes in MetaCSS base v0.0.1:
|
|
736
|
+
|
|
737
|
+
### Classes by category
|
|
738
|
+
|
|
739
|
+
#### Accessibility <!-- notoc -->
|
|
740
|
+
|
|
741
|
+
`screen-reader` / `screen-reader-focus`
|
|
742
|
+
|
|
743
|
+
#### Animations / transitions <!-- notoc -->
|
|
744
|
+
|
|
745
|
+
`bg-anim1` / `bg-anim2` / `bg-anim3`
|
|
746
|
+
|
|
747
|
+
#### Aspect ratios <!-- notoc -->
|
|
748
|
+
|
|
749
|
+
`aspect-ratio-16x9` / `aspect-ratio-1x1` / `aspect-ratio-3x4` / `aspect-ratio-4x3` / `aspect-ratio-4x6` / `aspect-ratio-6x4` / `aspect-ratio-9x16` / `aspect-ratio-object`
|
|
750
|
+
|
|
751
|
+
#### Background <!-- notoc -->
|
|
752
|
+
|
|
753
|
+
`bg-contain` / `bg-cover` / `bg-pos-center` / `bg-pos-e` / `bg-pos-n` / `bg-pos-ne` / `bg-pos-nw` / `bg-pos-s` / `bg-pos-se` / `bg-pos-sw` / `bg-pos-w`
|
|
754
|
+
|
|
755
|
+
#### Border radius <!-- notoc -->
|
|
756
|
+
|
|
757
|
+
`br-100` / `br-pill` / `br0` / `br1` / `br2` / `br3` / `br4` / `brb0` / `brb1` / `brb2` / `brb3` / `brb4` / `brl0` / `brl1` / `brl2` / `brl3` / `brl4` / `brr0` / `brr1` / `brr2` / `brr3` / `brr4` / `brt0` / `brt1` / `brt2` / `brt3` / `brt4`
|
|
758
|
+
|
|
759
|
+
#### Border width <!-- notoc -->
|
|
760
|
+
|
|
761
|
+
`bw-1px` / `bw0` / `bw1` / `bw2` / `bw3` / `bw4` / `bw5` / `bwb-1px` / `bwb0` / `bwb1` / `bwb2` / `bwb3` / `bwb4` / `bwb5` / `bwl-1px` / `bwl0` / `bwl1` / `bwl2` / `bwl3` / `bwl4` / `bwl5` / `bwr-1px` / `bwr0` / `bwr1` / `bwr2` / `bwr3` / `bwr4` / `bwr5` / `bwt-1px` / `bwt0` / `bwt1` / `bwt2` / `bwt3` / `bwt4` / `bwt5`
|
|
762
|
+
|
|
763
|
+
#### Colors <!-- notoc -->
|
|
764
|
+
|
|
765
|
+
`b--black` / `b--blue` / `b--dark-blue` / `b--dark-gray` / `b--dark-green` / `b--dark-pink` / `b--dark-red` / `b--gold` / `b--gray` / `b--green` / `b--hot-pink` / `b--light-blue` / `b--light-gray` / `b--light-green` / `b--light-pink` / `b--light-purple` / `b--light-red` / `b--light-silver` / `b--light-yellow` / `b--lightest-blue` / `b--mid-gray` / `b--moon-gray` / `b--navy` / `b--near-black` / `b--near-white` / `b--orange` / `b--pink` / `b--purple` / `b--red` / `b--silver` / `b--transparent` / `b--vcol1` / `b--vcol10` / `b--vcol11` / `b--vcol12` / `b--vcol13` / `b--vcol14` / `b--vcol15` / `b--vcol16` / `b--vcol2` / `b--vcol3` / `b--vcol4` / `b--vcol5` / `b--vcol6` / `b--vcol7` / `b--vcol8` / `b--vcol9` / `b--washed-blue` / `b--washed-green` / `b--washed-red` / `b--washed-yellow` / `b--white` / `b--yellow` / `bg-black` / `bg-blue` / `bg-dark-blue` / `bg-dark-gray` / `bg-dark-green` / `bg-dark-pink` / `bg-dark-red` / `bg-gold` / `bg-gray` / `bg-green` / `bg-hot-pink` / `bg-light-blue` / `bg-light-gray` / `bg-light-green` / `bg-light-pink` / `bg-light-purple` / `bg-light-red` / `bg-light-silver` / `bg-light-yellow` / `bg-lightest-blue` / `bg-mid-gray` / `bg-moon-gray` / `bg-navy` / `bg-near-black` / `bg-near-white` / `bg-orange` / `bg-pink` / `bg-purple` / `bg-red` / `bg-silver` / `bg-transparent` / `bg-vcol1` / `bg-vcol10` / `bg-vcol11` / `bg-vcol12` / `bg-vcol13` / `bg-vcol14` / `bg-vcol15` / `bg-vcol16` / `bg-vcol2` / `bg-vcol3` / `bg-vcol4` / `bg-vcol5` / `bg-vcol6` / `bg-vcol7` / `bg-vcol8` / `bg-vcol9` / `bg-washed-blue` / `bg-washed-green` / `bg-washed-red` / `bg-washed-yellow` / `bg-white` / `bg-yellow` / `black` / `blue` / `dark-blue` / `dark-gray` / `dark-green` / `dark-pink` / `dark-red` / `gold` / `gray` / `green` / `hot-pink` / `light-blue` / `light-gray` / `light-green` / `light-pink` / `light-purple` / `light-red` / `light-silver` / `light-yellow` / `lightest-blue` / `mid-gray` / `moon-gray` / `navy` / `near-black` / `near-white` / `o-0` / `o-10` / `o-100` / `o-20` / `o-30` / `o-40` / `o-50` / `o-60` / `o-70` / `o-80` / `o-90` / `orange` / `pink` / `purple` / `red` / `silver` / `transparent` / `vcol1` / `vcol10` / `vcol11` / `vcol12` / `vcol13` / `vcol14` / `vcol15` / `vcol16` / `vcol2` / `vcol3` / `vcol4` / `vcol5` / `vcol6` / `vcol7` / `vcol8` / `vcol9` / `washed-blue` / `washed-green` / `washed-red` / `washed-yellow` / `white` / `yellow`
|
|
766
|
+
|
|
767
|
+
#### Cursors <!-- notoc -->
|
|
768
|
+
|
|
769
|
+
`cursor-alias` / `cursor-auto` / `cursor-cell` / `cursor-col` / `cursor-context` / `cursor-copy` / `cursor-cross` / `cursor-default` / `cursor-e` / `cursor-ew` / `cursor-forbidden` / `cursor-grab` / `cursor-grabbing` / `cursor-help` / `cursor-in` / `cursor-move` / `cursor-n` / `cursor-ne` / `cursor-news` / `cursor-no-drop` / `cursor-none` / `cursor-ns` / `cursor-nw` / `cursor-nwse` / `cursor-out` / `cursor-pointer` / `cursor-progress` / `cursor-row` / `cursor-s` / `cursor-scroll` / `cursor-se` / `cursor-sw` / `cursor-text` / `cursor-vtext` / `cursor-w` / `cursor-wait`
|
|
770
|
+
|
|
771
|
+
#### Display mode <!-- notoc -->
|
|
772
|
+
|
|
773
|
+
`db` / `df` / `dg` / `di` / `dib` / `dif` / `dig` / `dn` / `dt` / `dtc` / `dtr`
|
|
774
|
+
|
|
775
|
+
#### Font families <!-- notoc -->
|
|
776
|
+
|
|
777
|
+
`monospace` / `sans-serif` / `serif` / `system` / `system-sans-serif` / `system-serif`
|
|
778
|
+
|
|
779
|
+
#### Font sizes <!-- notoc -->
|
|
780
|
+
|
|
781
|
+
`f-subtitle` / `f-title` / `f1` / `f2` / `f3` / `f4` / `f5` / `f6` / `f7`
|
|
782
|
+
|
|
783
|
+
#### Font style <!-- notoc -->
|
|
784
|
+
|
|
785
|
+
`italic`
|
|
607
786
|
|
|
608
787
|
#### Font variants <!-- notoc -->
|
|
609
788
|
|
|
610
789
|
`small-caps`
|
|
611
790
|
|
|
791
|
+
#### Font weights <!-- notoc -->
|
|
792
|
+
|
|
793
|
+
`b` / `fw100` / `fw200` / `fw300` / `fw400` / `fw500` / `fw600` / `fw700` / `fw800` / `fw900` / `normal`
|
|
794
|
+
|
|
795
|
+
#### Grid layout <!-- notoc -->
|
|
796
|
+
|
|
797
|
+
`align-items-center` / `align-items-end` / `align-items-start` / `align-items-stretch` / `align-self-center` / `align-self-end` / `align-self-start` / `align-self-stretch` / `gap-1px` / `gap-2px` / `gap-4px` / `gap-8px` / `gap0` / `gap1` / `gap2` / `gap3` / `gap4` / `gap5` / `grid-cols-1` / `grid-cols-10` / `grid-cols-2` / `grid-cols-3` / `grid-cols-4` / `grid-cols-5` / `grid-cols-6` / `grid-cols-7` / `grid-cols-8` / `grid-cols-9` / `grid-rows-1` / `grid-rows-10` / `grid-rows-2` / `grid-rows-3` / `grid-rows-4` / `grid-rows-5` / `grid-rows-6` / `grid-rows-7` / `grid-rows-8` / `grid-rows-9` / `justify-items-center` / `justify-items-end` / `justify-items-start` / `justify-items-stretch` / `justify-self-center` / `justify-self-end` / `justify-self-start` / `justify-self-stretch`
|
|
798
|
+
|
|
799
|
+
#### Height <!-- notoc -->
|
|
800
|
+
|
|
801
|
+
`h-10` / `h-100` / `h-16` / `h-17` / `h-20` / `h-25` / `h-30` / `h-33` / `h-34` / `h-40` / `h-50` / `h-60` / `h-66` / `h-67` / `h-70` / `h-75` / `h-80` / `h-83` / `h-84` / `h-90` / `h1` / `h2` / `h3` / `h4` / `h5`
|
|
802
|
+
|
|
803
|
+
#### Icons <!-- notoc -->
|
|
804
|
+
|
|
805
|
+
`icon-1` / `icon-2` / `icon-3` / `icon-4` / `icon-5` / `icon-6` / `icon-7` / `icon-subtitle` / `icon-title`
|
|
806
|
+
|
|
807
|
+
#### Letter spacing <!-- notoc -->
|
|
808
|
+
|
|
809
|
+
`ls--1` / `ls--2` / `ls-0` / `ls-1` / `ls-2` / `ls-3`
|
|
810
|
+
|
|
811
|
+
#### Line heights <!-- notoc -->
|
|
812
|
+
|
|
813
|
+
`lh-0` / `lh-copy` / `lh-double` / `lh-solid` / `lh-title`
|
|
814
|
+
|
|
815
|
+
#### Lists <!-- notoc -->
|
|
816
|
+
|
|
817
|
+
`list`
|
|
818
|
+
|
|
819
|
+
#### Margin <!-- notoc -->
|
|
820
|
+
|
|
821
|
+
`center` / `ma0` / `ma1` / `ma2` / `ma3` / `ma4` / `mb0` / `mb1` / `mb2` / `mb3` / `mb4` / `mh0` / `mh1` / `mh2` / `mh3` / `mh4` / `ml0` / `ml1` / `ml2` / `ml3` / `ml4` / `mr0` / `mr1` / `mr2` / `mr3` / `mr4` / `mt0` / `mt1` / `mt2` / `mt3` / `mt4` / `mv0` / `mv1` / `mv2` / `mv3` / `mv4`
|
|
822
|
+
|
|
823
|
+
#### Max. height <!-- notoc -->
|
|
824
|
+
|
|
825
|
+
`maxh-10` / `maxh-100` / `maxh-16` / `maxh-17` / `maxh-20` / `maxh-25` / `maxh-30` / `maxh-33` / `maxh-34` / `maxh-40` / `maxh-50` / `maxh-60` / `maxh-66` / `maxh-67` / `maxh-70` / `maxh-75` / `maxh-80` / `maxh-83` / `maxh-84` / `maxh-90` / `maxh1` / `maxh2` / `maxh3` / `maxh4` / `maxh5`
|
|
826
|
+
|
|
827
|
+
#### Max. width <!-- notoc -->
|
|
828
|
+
|
|
829
|
+
`maxw-10` / `maxw-100` / `maxw-16` / `maxw-17` / `maxw-20` / `maxw-25` / `maxw-30` / `maxw-33` / `maxw-34` / `maxw-40` / `maxw-50` / `maxw-60` / `maxw-66` / `maxw-67` / `maxw-70` / `maxw-75` / `maxw-80` / `maxw-83` / `maxw-84` / `maxw-90` / `maxw1` / `maxw2` / `maxw3` / `maxw4` / `maxw5`
|
|
830
|
+
|
|
831
|
+
#### Min. height <!-- notoc -->
|
|
832
|
+
|
|
833
|
+
`minh-10` / `minh-100` / `minh-16` / `minh-17` / `minh-20` / `minh-25` / `minh-30` / `minh-33` / `minh-34` / `minh-40` / `minh-50` / `minh-60` / `minh-66` / `minh-67` / `minh-70` / `minh-75` / `minh-80` / `minh-83` / `minh-84` / `minh-90` / `minh1` / `minh2` / `minh3` / `minh4` / `minh5`
|
|
834
|
+
|
|
835
|
+
#### Min. width <!-- notoc -->
|
|
836
|
+
|
|
837
|
+
`minw-10` / `minw-100` / `minw-16` / `minw-17` / `minw-20` / `minw-25` / `minw-30` / `minw-33` / `minw-34` / `minw-40` / `minw-50` / `minw-60` / `minw-66` / `minw-67` / `minw-70` / `minw-75` / `minw-80` / `minw-83` / `minw-84` / `minw-90` / `minw1` / `minw2` / `minw3` / `minw4` / `minw5`
|
|
838
|
+
|
|
839
|
+
#### Overflow <!-- notoc -->
|
|
840
|
+
|
|
841
|
+
`overflow-auto` / `overflow-hidden` / `overflow-scroll` / `overflow-visible` / `overflow-x-auto` / `overflow-x-hidden` / `overflow-x-scroll` / `overflow-x-visible` / `overflow-y-auto` / `overflow-y-hidden` / `overflow-y-scroll` / `overflow-y-visible`
|
|
842
|
+
|
|
843
|
+
#### Padding <!-- notoc -->
|
|
844
|
+
|
|
845
|
+
`pa0` / `pa1` / `pa2` / `pa3` / `pa4` / `pb0` / `pb1` / `pb2` / `pb3` / `pb4` / `ph0` / `ph1` / `ph2` / `ph3` / `ph4` / `pl0` / `pl1` / `pl2` / `pl3` / `pl4` / `pr0` / `pr1` / `pr2` / `pr3` / `pr4` / `pt0` / `pt1` / `pt2` / `pt3` / `pt4` / `pv0` / `pv1` / `pv2` / `pv3` / `pv4`
|
|
846
|
+
|
|
847
|
+
#### Positions <!-- notoc -->
|
|
848
|
+
|
|
849
|
+
`absolute` / `bottom--1` / `bottom--2` / `bottom-0` / `bottom-1` / `bottom-2` / `fixed` / `left--1` / `left--2` / `left-0` / `left-1` / `left-2` / `relative` / `right--1` / `right--2` / `right-0` / `right-1` / `right-2` / `static` / `sticky` / `top--1` / `top--2` / `top-0` / `top-1` / `top-2`
|
|
850
|
+
|
|
851
|
+
#### Selection <!-- notoc -->
|
|
852
|
+
|
|
853
|
+
`noselect`
|
|
854
|
+
|
|
855
|
+
#### Shadow <!-- notoc -->
|
|
856
|
+
|
|
857
|
+
`box-shadow-1` / `box-shadow-2` / `box-shadow-3` / `box-shadow-4` / `box-shadow-i-1` / `box-shadow-i-2` / `box-shadow-i-3` / `box-shadow-i-4` / `text-shadow-1` / `text-shadow-2` / `text-shadow-3` / `text-shadow-4` / `text-shadow-5` / `text-shadow-6` / `text-shadow-7` / `text-shadow-8` / `text-shadow-9`
|
|
858
|
+
|
|
859
|
+
#### Text align <!-- notoc -->
|
|
860
|
+
|
|
861
|
+
`tc` / `tj` / `tl` / `tr`
|
|
862
|
+
|
|
612
863
|
#### Text decorations <!-- notoc -->
|
|
613
864
|
|
|
614
865
|
`no-underline` / `strike` / `underline`
|
|
@@ -617,25 +868,29 @@ Currently available CSS classes in MetaCSS base v0.0.1:
|
|
|
617
868
|
|
|
618
869
|
`ttc` / `ttfsk` / `ttfw` / `tti` / `ttl` / `ttn` / `ttu`
|
|
619
870
|
|
|
620
|
-
####
|
|
871
|
+
#### Undefined <!-- notoc -->
|
|
621
872
|
|
|
622
|
-
`
|
|
873
|
+
`vh-100` / `vh-25` / `vh-50` / `vh-75` / `vw-100` / `vw-25` / `vw-50` / `vw-75`
|
|
623
874
|
|
|
624
875
|
#### Vertical align <!-- notoc -->
|
|
625
876
|
|
|
626
|
-
`v-btm` / `v-mid` / `v-top`
|
|
877
|
+
`v-base` / `v-btm` / `v-mid` / `v-top`
|
|
627
878
|
|
|
628
|
-
####
|
|
879
|
+
#### Visibility <!-- notoc -->
|
|
629
880
|
|
|
630
|
-
`
|
|
881
|
+
`hidden` / `visible`
|
|
631
882
|
|
|
632
883
|
#### Whitespace <!-- notoc -->
|
|
633
884
|
|
|
634
885
|
`ws-0` / `ws-1` / `ws-2`
|
|
635
886
|
|
|
636
|
-
####
|
|
887
|
+
#### Width <!-- notoc -->
|
|
637
888
|
|
|
638
|
-
`
|
|
889
|
+
`w-10` / `w-100` / `w-16` / `w-17` / `w-20` / `w-25` / `w-30` / `w-33` / `w-34` / `w-40` / `w-50` / `w-60` / `w-66` / `w-67` / `w-70` / `w-75` / `w-80` / `w-83` / `w-84` / `w-90` / `w1` / `w2` / `w3` / `w4` / `w5`
|
|
890
|
+
|
|
891
|
+
#### Z-indices <!-- notoc -->
|
|
892
|
+
|
|
893
|
+
`z-0` / `z-1` / `z-2` / `z-3` / `z-4` / `z-5` / `z-999` / `z-9999`
|
|
639
894
|
|
|
640
895
|
### Media queries
|
|
641
896
|
|
|
@@ -668,7 +923,7 @@ distributed as CLI bundle with **no runtime dependencies**. The following
|
|
|
668
923
|
dependencies are only shown for informational purposes and are (partially)
|
|
669
924
|
included in the bundle.
|
|
670
925
|
|
|
671
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 11.
|
|
926
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 11.38 KB
|
|
672
927
|
|
|
673
928
|
## Dependencies
|
|
674
929
|
|
|
@@ -696,216 +951,6 @@ directory is using this package:
|
|
|
696
951
|
|:-----------------------------------------------------------------------------------------------------------------------|:--------------------------------------|:------------------------------------------------------|:-----------------------------------------------------------------------------------|
|
|
697
952
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/meta-css-basics.png" width="240"/> | Basic thi.ng/meta-css usage & testbed | [Demo](https://demo.thi.ng/umbrella/meta-css-basics/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/meta-css-basics) |
|
|
698
953
|
|
|
699
|
-
## CLI
|
|
700
|
-
|
|
701
|
-
### Basic usage example
|
|
702
|
-
|
|
703
|
-
The `metacss` tool provides multiple commands. You can install & run it like so:
|
|
704
|
-
|
|
705
|
-
```text
|
|
706
|
-
npx @thi.ng/meta-css --help
|
|
707
|
-
|
|
708
|
-
█ █ █ │
|
|
709
|
-
██ █ │
|
|
710
|
-
█ █ █ █ █ █ █ █ │ @thi.ng/meta-css 0.0.1
|
|
711
|
-
█ █ █ █ █ █ █ █ █ │ Data-driven CSS component & framework codegen
|
|
712
|
-
█ │
|
|
713
|
-
█ █ │
|
|
714
|
-
|
|
715
|
-
Usage: metacss <cmd> [opts] input [...]
|
|
716
|
-
metacss <cmd> --help
|
|
717
|
-
|
|
718
|
-
Available commands:
|
|
719
|
-
|
|
720
|
-
convert : Transpile & bundle meta stylesheets to CSS
|
|
721
|
-
export : Export entire generated framework as CSS
|
|
722
|
-
generate : Generate framework rules from specs
|
|
723
|
-
|
|
724
|
-
Flags:
|
|
725
|
-
|
|
726
|
-
-v, --verbose Display extra process information
|
|
727
|
-
|
|
728
|
-
Main:
|
|
729
|
-
|
|
730
|
-
-o STR, --out STR Output file (or stdout)
|
|
731
|
-
```
|
|
732
|
-
|
|
733
|
-
### Generating framework code from bundled base definitions
|
|
734
|
-
|
|
735
|
-
To create our first framework, we first need to generate CSS utility classes
|
|
736
|
-
from given JSON generator specs. For simplicity the generated framework
|
|
737
|
-
definitions will be stored as JSON too and then used as lookup tables for actual
|
|
738
|
-
CSS translation in the next step.
|
|
739
|
-
|
|
740
|
-
```bash
|
|
741
|
-
# write generated CSS classes (in JSON)
|
|
742
|
-
metacss generate --out framework.json node_modules/@thi.ng/meta-css/specs
|
|
743
|
-
```
|
|
744
|
-
|
|
745
|
-
### Generating CSS from `.meta` stylesheets
|
|
746
|
-
|
|
747
|
-
#### *.meta stylesheets
|
|
748
|
-
|
|
749
|
-
The naming convention used by the [default framework
|
|
750
|
-
specs](https://github.com/thi-ng/umbrella/blob/develop/packages/meta-css/specs/)
|
|
751
|
-
is loosely based on [tachyons.io](https://tachyons.io), with the important
|
|
752
|
-
difference of media query handling. Using MetaCSS we don't have to pre-generate
|
|
753
|
-
mediaquery-specific versions, and any class ID/token can be prefixed with an
|
|
754
|
-
_arbitrary_ number of media query IDs (separated by `:`). These media queries
|
|
755
|
-
are defined as part of the framework JSON specs and when used as a prefix,
|
|
756
|
-
multiple query IDs can be combined freely. E.g. the token `dark:anim:bg-anim2`
|
|
757
|
-
will auto-create a merged CSS `@media`-query block for the query IDs `dark` and
|
|
758
|
-
`anim` and only emit the definition of `bg-anim2` for this combination (see
|
|
759
|
-
generated CSS further below).
|
|
760
|
-
|
|
761
|
-
readme.meta:
|
|
762
|
-
|
|
763
|
-
```text tangle:export/readme.meta
|
|
764
|
-
|
|
765
|
-
body { ma0 dark:bg-black dark:white bg-white black }
|
|
766
|
-
|
|
767
|
-
#app { ma3 }
|
|
768
|
-
|
|
769
|
-
.bt-group-v > a {
|
|
770
|
-
db w-100 l:w-50 ph3 pv2 bwb1
|
|
771
|
-
dark:bg-purple dark:white dark:b--black
|
|
772
|
-
light:bg-light-blue light:black light:b--white
|
|
773
|
-
{
|
|
774
|
-
:hover { bg-gold black anim:bg-anim2 }
|
|
775
|
-
:first-child { brt3 }
|
|
776
|
-
:last-child { brb3 bwb0 }
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
```
|
|
780
|
-
|
|
781
|
-
readme2.meta:
|
|
782
|
-
|
|
783
|
-
We will merge the definitions in this file with the ones from the file above
|
|
784
|
-
(i.e. adding & overriding some of the declarations, here: border radius):
|
|
785
|
-
|
|
786
|
-
```text tangle:export/readme2.meta
|
|
787
|
-
#app { pa2 }
|
|
788
|
-
|
|
789
|
-
.bt-group-v > a {
|
|
790
|
-
{
|
|
791
|
-
:first-child { brt4 }
|
|
792
|
-
:last-child { brb4 }
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
```
|
|
796
|
-
|
|
797
|
-
```bash
|
|
798
|
-
# if not out dir is specified writes result to stdout
|
|
799
|
-
# use previously generated specs for resolving all identifiers & media queries
|
|
800
|
-
metacss convert --pretty --specs framework.json readme.meta readme2.meta
|
|
801
|
-
```
|
|
802
|
-
|
|
803
|
-
#### Resulting CSS output
|
|
804
|
-
|
|
805
|
-
```css
|
|
806
|
-
/*! MetaCSS base v0.0.1 - generated by thi.ng/meta-css @ 2023-12-18T12:22:36.548Z */
|
|
807
|
-
body {
|
|
808
|
-
margin: 0rem;
|
|
809
|
-
background-color: #fff;
|
|
810
|
-
color: #000;
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
#app {
|
|
814
|
-
margin: 1rem;
|
|
815
|
-
padding: .5rem;
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
.bt-group-v > a {
|
|
819
|
-
display: block;
|
|
820
|
-
width: 100%;
|
|
821
|
-
padding-left: 1rem;
|
|
822
|
-
padding-right: 1rem;
|
|
823
|
-
padding-top: .5rem;
|
|
824
|
-
padding-bottom: .5rem;
|
|
825
|
-
border-bottom-style: solid;
|
|
826
|
-
border-bottom-width: .125rem;
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
.bt-group-v > a:hover {
|
|
830
|
-
background-color: #ffb700;
|
|
831
|
-
color: #000;
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
.bt-group-v > a:first-child {
|
|
835
|
-
border-top-left-radius: 1rem;
|
|
836
|
-
border-top-right-radius: 1rem;
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
.bt-group-v > a:last-child {
|
|
840
|
-
border-bottom-left-radius: 1rem;
|
|
841
|
-
border-bottom-right-radius: 1rem;
|
|
842
|
-
border-bottom-style: solid;
|
|
843
|
-
border-bottom-width: 0rem;
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
@media (prefers-color-scheme:dark) {
|
|
847
|
-
|
|
848
|
-
body {
|
|
849
|
-
background-color: #000;
|
|
850
|
-
color: #fff;
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
.bt-group-v > a {
|
|
854
|
-
background-color: #5e2ca5;
|
|
855
|
-
color: #fff;
|
|
856
|
-
border-color: #000;
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
@media (min-width:60rem) {
|
|
862
|
-
|
|
863
|
-
.bt-group-v > a {
|
|
864
|
-
width: 50%;
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
@media (prefers-color-scheme:light) {
|
|
870
|
-
|
|
871
|
-
.bt-group-v > a {
|
|
872
|
-
background-color: #96ccff;
|
|
873
|
-
color: #000;
|
|
874
|
-
border-color: #fff;
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
@media not (prefers-reduced-motion) {
|
|
880
|
-
|
|
881
|
-
.bt-group-v > a:hover {
|
|
882
|
-
transition: 0.2s background-color ease-in-out;
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
}
|
|
886
|
-
```
|
|
887
|
-
|
|
888
|
-
A simple HTML example using above MetaCSS styles:
|
|
889
|
-
|
|
890
|
-
#### index.html
|
|
891
|
-
|
|
892
|
-
```html tangle:export/index.html
|
|
893
|
-
<!doctype html>
|
|
894
|
-
<html>
|
|
895
|
-
<head>
|
|
896
|
-
<link rel="stylesheet" href="bundle.css"/>
|
|
897
|
-
</head>
|
|
898
|
-
<body>
|
|
899
|
-
<div id="app" class="bt-group-v">
|
|
900
|
-
<a href="#">One</a>
|
|
901
|
-
<a href="#">Two</a>
|
|
902
|
-
<a href="#">Three</a>
|
|
903
|
-
<a href="#">Four</a>
|
|
904
|
-
</div>
|
|
905
|
-
</body>
|
|
906
|
-
</html>
|
|
907
|
-
```
|
|
908
|
-
|
|
909
954
|
## Authors
|
|
910
955
|
|
|
911
956
|
- [Karsten Schmidt](https://thi.ng)
|