@thi.ng/meta-css 0.1.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 +32 -0
- package/LICENSE +201 -0
- package/README.md +426 -0
- package/bin/metacss +12 -0
- package/index.js +15 -0
- package/package.json +107 -0
- package/specs/_info.json +26 -0
- package/specs/anim.json +12 -0
- package/specs/borders.json +46 -0
- package/specs/colors.json +141 -0
- package/specs/cursor.json +48 -0
- package/specs/dimensions.json +55 -0
- package/specs/display.json +24 -0
- package/specs/grid.json +41 -0
- package/specs/lists.json +11 -0
- package/specs/margins.json +23 -0
- package/specs/overflow.json +28 -0
- package/specs/positions.json +31 -0
- package/specs/typography.json +127 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
- **Last updated**: 2023-12-18T13:41:19Z
|
|
4
|
+
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
|
+
|
|
6
|
+
All notable changes to this project will be documented in this file.
|
|
7
|
+
See [Conventional Commits](https://conventionalcommits.org/) for commit guidelines.
|
|
8
|
+
|
|
9
|
+
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
|
+
and/or version bumps of transitive dependencies.
|
|
11
|
+
|
|
12
|
+
## [0.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/meta-css@0.1.0) (2023-12-18)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- import as new pkg ([08628b3](https://github.com/thi-ng/umbrella/commit/08628b3))
|
|
17
|
+
- switch generated framework output to JSON, simplify ([8850cae](https://github.com/thi-ng/umbrella/commit/8850cae))
|
|
18
|
+
- merge media query refs from all inputs ([34047c9](https://github.com/thi-ng/umbrella/commit/34047c9))
|
|
19
|
+
- dedupe & merge all selectors & decls ([fd333c8](https://github.com/thi-ng/umbrella/commit/fd333c8))
|
|
20
|
+
- add input file watching ([717dbe1](https://github.com/thi-ng/umbrella/commit/717dbe1))
|
|
21
|
+
- add error handling for watch mode ([3b8dab9](https://github.com/thi-ng/umbrella/commit/3b8dab9))
|
|
22
|
+
- add support for line comments in .meta files ([a6273c8](https://github.com/thi-ng/umbrella/commit/a6273c8))
|
|
23
|
+
- add export cmd, update other cmds & arg handling ([f8b326a](https://github.com/thi-ng/umbrella/commit/f8b326a))
|
|
24
|
+
- add pretty printing for generate cmd ([2c27c9b](https://github.com/thi-ng/umbrella/commit/2c27c9b))
|
|
25
|
+
- add convert option to force include CSS classes ([9932e91](https://github.com/thi-ng/umbrella/commit/9932e91))
|
|
26
|
+
- update generate & convert cmds ([15daa6e](https://github.com/thi-ng/umbrella/commit/15daa6e))
|
|
27
|
+
- support reading force includes from file ([f92456b](https://github.com/thi-ng/umbrella/commit/f92456b))
|
|
28
|
+
- update convert cmd flag spec ([606a585](https://github.com/thi-ng/umbrella/commit/606a585))
|
|
29
|
+
|
|
30
|
+
#### 🩹 Bug fixes
|
|
31
|
+
|
|
32
|
+
- resolve out file path ([6e7f7dd](https://github.com/thi-ng/umbrella/commit/6e7f7dd))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright {yyyy} {name of copyright owner}
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
<!-- This file is generated - DO NOT EDIT! -->
|
|
2
|
+
<!-- Please see: https://github.com/thi-ng/umbrella/blob/develop/CONTRIBUTING.md#changes-to-readme-files -->
|
|
3
|
+
|
|
4
|
+
# 
|
|
5
|
+
|
|
6
|
+
[](https://www.npmjs.com/package/@thi.ng/meta-css)
|
|
7
|
+

|
|
8
|
+
[](https://mastodon.thi.ng/@toxi)
|
|
9
|
+
|
|
10
|
+
This project is part of the
|
|
11
|
+
[@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo and anti-framework.
|
|
12
|
+
|
|
13
|
+
- [About](#about)
|
|
14
|
+
- [Generate](#generate)
|
|
15
|
+
- [Convert](#convert)
|
|
16
|
+
- [Export](#export)
|
|
17
|
+
- [Framework generation rules](#framework-generation-rules)
|
|
18
|
+
- [Status](#status)
|
|
19
|
+
- [Related packages](#related-packages)
|
|
20
|
+
- [Installation](#installation)
|
|
21
|
+
- [Dependencies](#dependencies)
|
|
22
|
+
- [Usage examples](#usage-examples)
|
|
23
|
+
- [CLI](#cli)
|
|
24
|
+
- [Basic usage example](#basic-usage-example)
|
|
25
|
+
- [Generating framework code from bundled base definitions](#generating-framework-code-from-bundled-base-definitions)
|
|
26
|
+
- [Generating CSS from `.meta` stylesheets](#generating-css-from-meta-stylesheets)
|
|
27
|
+
- [*.meta stylesheets](#meta-stylesheets)
|
|
28
|
+
- [Resulting CSS output](#resulting-css-output)
|
|
29
|
+
- [index.html](#indexhtml)
|
|
30
|
+
- [Authors](#authors)
|
|
31
|
+
- [License](#license)
|
|
32
|
+
|
|
33
|
+
## About
|
|
34
|
+
|
|
35
|
+
Data-driven CSS component & framework codegen.
|
|
36
|
+
|
|
37
|
+
This package provides a CLI multi-tool to:
|
|
38
|
+
|
|
39
|
+
### Generate
|
|
40
|
+
|
|
41
|
+
The `generate` command is used to generate custom CSS frameworks from a number
|
|
42
|
+
of JSON rule specs. This process creates all desired, combinatorial versions of
|
|
43
|
+
various rules/declarations and exports them to another JSON file used as
|
|
44
|
+
intermediatary for the other commands provided by this toolchain. The
|
|
45
|
+
syntax/format of the generator rules is explained further on. These rules can be
|
|
46
|
+
split up into multiple files, can incude arbitrary media query criteria (all
|
|
47
|
+
later combinable), shared lookup tables for colors, margins, sizes, timings etc.
|
|
48
|
+
|
|
49
|
+
The package provides generator specs for a basic, configurable,
|
|
50
|
+
[tachyons.io](https://tachyons.io)-derived CSS framework in the
|
|
51
|
+
[/specs](https://github.com/thi-ng/umbrella/blob/develop/packages/meta-css/specs/)
|
|
52
|
+
directory. These specs are used for some example projects in this repo, but are
|
|
53
|
+
intended to be used as basic starting point for other custom frameworks.
|
|
54
|
+
|
|
55
|
+
```text
|
|
56
|
+
metacss generate --help
|
|
57
|
+
|
|
58
|
+
Usage: metacss generate [opts] input-dir
|
|
59
|
+
|
|
60
|
+
Flags:
|
|
61
|
+
|
|
62
|
+
-p, --pretty Pretty print output
|
|
63
|
+
-v, --verbose Display extra process information
|
|
64
|
+
|
|
65
|
+
Main:
|
|
66
|
+
|
|
67
|
+
-o STR, --out STR Output file (or stdout)
|
|
68
|
+
--prec INT Number of fractional digits (default: 3)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Convert
|
|
72
|
+
|
|
73
|
+
The `convert` command is used to compile & bundle actual CSS from user-provided
|
|
74
|
+
MetaCSS stylesheets (`*.meta` files) and the JSON framework specs created by the
|
|
75
|
+
`generate` command. The meta-stylesheets support any CSS selectors, are nestable
|
|
76
|
+
and compose full CSS declarations from lists of the utility classes in the
|
|
77
|
+
generated framework. Each item (aka utility class name) can be prefixed with an
|
|
78
|
+
arbitrary number of media query IDs (also custom defined in the framework).
|
|
79
|
+
Selectors, declarations and media query criteria will be deduplicated and merged
|
|
80
|
+
from multiple input files. The resulting CSS will only contain referenced rules
|
|
81
|
+
and can be generated in minified or pretty printed formats (it's also possible
|
|
82
|
+
to force include CSS classes which are otherwise unreferenced, using the
|
|
83
|
+
`--force` CLI arg). Additionally, multiple .meta files can be watched for
|
|
84
|
+
changes, their definitions will be merged, and existing CSS files can be
|
|
85
|
+
included (prepended) in the bundled outout too.
|
|
86
|
+
|
|
87
|
+
```text
|
|
88
|
+
metacss convert --help
|
|
89
|
+
|
|
90
|
+
Usage: metacss convert [opts] input [...]
|
|
91
|
+
|
|
92
|
+
Flags:
|
|
93
|
+
|
|
94
|
+
--no-header Don't emit generated header comment
|
|
95
|
+
-p, --pretty Pretty print output
|
|
96
|
+
-v, --verbose Display extra process information
|
|
97
|
+
-w, --watch Watch input files for changes
|
|
98
|
+
|
|
99
|
+
Main:
|
|
100
|
+
|
|
101
|
+
--force STR[,..] [multiple] CSS classes to force include (wildcards are
|
|
102
|
+
supported, @-prefix will read from file)
|
|
103
|
+
-I STR, --include STR [multiple] Include CSS files (prepend)
|
|
104
|
+
-o STR, --out STR Output file (or stdout)
|
|
105
|
+
-s STR, --specs STR [required] Path to generated JSON defs
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Export
|
|
109
|
+
|
|
110
|
+
The `export` command is intended for those who're only interested in the CSS
|
|
111
|
+
framework generation aspect of this toolchain. This command merely takes an
|
|
112
|
+
existing generated framework JSON file and serializes it to a single CSS file,
|
|
113
|
+
e.g. to be then used with other CSS tooling (e.g. `postcss`). Users can choose
|
|
114
|
+
to generate variations of all defined utility classes for any of the defined
|
|
115
|
+
media query IDs. This will create suffixed versions of all classes (with their
|
|
116
|
+
appropriate media query wrappers) and cause a potentially massive output
|
|
117
|
+
(depending on the overall number/complexity of the generated classes).
|
|
118
|
+
|
|
119
|
+
As with the `convert` command, additional CSS files can be included (prepended)
|
|
120
|
+
in the output file.
|
|
121
|
+
|
|
122
|
+
```text
|
|
123
|
+
metacss export --help
|
|
124
|
+
|
|
125
|
+
Usage: metacss export [opts] input
|
|
126
|
+
|
|
127
|
+
Flags:
|
|
128
|
+
|
|
129
|
+
--no-header Don't emit generated header comment
|
|
130
|
+
-p, --pretty Pretty print output
|
|
131
|
+
-v, --verbose Display extra process information
|
|
132
|
+
|
|
133
|
+
Main:
|
|
134
|
+
|
|
135
|
+
-I STR, --include STR [multiple] Include CSS files (prepend)
|
|
136
|
+
-m STR, --media STR Media query IDs (use 'ALL' for all)
|
|
137
|
+
-o STR, --out STR Output file (or stdout)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Note: In all cases, final CSS generation itself is handled by
|
|
141
|
+
[thi.ng/hiccup-css](https://github.com/thi-ng/umbrella/blob/develop/packages/hiccup-css/)
|
|
142
|
+
|
|
143
|
+
**👷🏻 This is all WIP!** See example below for basic example usage...
|
|
144
|
+
|
|
145
|
+
## Framework generation rules
|
|
146
|
+
|
|
147
|
+
TODO — for now please see bundled example specs in
|
|
148
|
+
[/specs](https://github.com/thi-ng/umbrella/blob/develop/packages/meta-css/specs/)...
|
|
149
|
+
|
|
150
|
+
## Status
|
|
151
|
+
|
|
152
|
+
**ALPHA** - bleeding edge / work-in-progress
|
|
153
|
+
|
|
154
|
+
[Search or submit any issues for this package](https://github.com/thi-ng/umbrella/issues?q=%5Bmeta-css%5D+in%3Atitle)
|
|
155
|
+
|
|
156
|
+
## Related packages
|
|
157
|
+
|
|
158
|
+
- [@thi.ng/hiccup-css](https://github.com/thi-ng/umbrella/tree/develop/packages/hiccup-css) - CSS from nested JS data structures
|
|
159
|
+
|
|
160
|
+
## Installation
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
npx @thi.ng/meta-css --help
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
[Bun](https://bun.sh) is required instead of Node JS. The toolchain itself is
|
|
167
|
+
distributed as CLI bundle with **no runtime dependencies**. The following
|
|
168
|
+
dependencies are only shown for informational purposes and are (partially)
|
|
169
|
+
included in the bundle.
|
|
170
|
+
|
|
171
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 11.25 KB
|
|
172
|
+
|
|
173
|
+
## Dependencies
|
|
174
|
+
|
|
175
|
+
- [@thi.ng/api](https://github.com/thi-ng/umbrella/tree/develop/packages/api)
|
|
176
|
+
- [@thi.ng/args](https://github.com/thi-ng/umbrella/tree/develop/packages/args)
|
|
177
|
+
- [@thi.ng/arrays](https://github.com/thi-ng/umbrella/tree/develop/packages/arrays)
|
|
178
|
+
- [@thi.ng/checks](https://github.com/thi-ng/umbrella/tree/develop/packages/checks)
|
|
179
|
+
- [@thi.ng/compose](https://github.com/thi-ng/umbrella/tree/develop/packages/compose)
|
|
180
|
+
- [@thi.ng/errors](https://github.com/thi-ng/umbrella/tree/develop/packages/errors)
|
|
181
|
+
- [@thi.ng/file-io](https://github.com/thi-ng/umbrella/tree/develop/packages/file-io)
|
|
182
|
+
- [@thi.ng/hiccup-css](https://github.com/thi-ng/umbrella/tree/develop/packages/hiccup-css)
|
|
183
|
+
- [@thi.ng/logger](https://github.com/thi-ng/umbrella/tree/develop/packages/logger)
|
|
184
|
+
- [@thi.ng/rstream](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream)
|
|
185
|
+
- [@thi.ng/strings](https://github.com/thi-ng/umbrella/tree/develop/packages/strings)
|
|
186
|
+
- [@thi.ng/text-format](https://github.com/thi-ng/umbrella/tree/develop/packages/text-format)
|
|
187
|
+
- [@thi.ng/transducers](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers)
|
|
188
|
+
|
|
189
|
+
## Usage examples
|
|
190
|
+
|
|
191
|
+
One project in this repo's
|
|
192
|
+
[/examples](https://github.com/thi-ng/umbrella/tree/develop/examples)
|
|
193
|
+
directory is using this package:
|
|
194
|
+
|
|
195
|
+
| Screenshot | Description | Live demo | Source |
|
|
196
|
+
|:-----------------------------------------------------------------------------------------------------------------------|:--------------------------------------|:------------------------------------------------------|:-----------------------------------------------------------------------------------|
|
|
197
|
+
| <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) |
|
|
198
|
+
|
|
199
|
+
## CLI
|
|
200
|
+
|
|
201
|
+
### Basic usage example
|
|
202
|
+
|
|
203
|
+
The `metacss` tool provides multiple commands. You can install & run it like so:
|
|
204
|
+
|
|
205
|
+
```text
|
|
206
|
+
npx @thi.ng/meta-css --help
|
|
207
|
+
|
|
208
|
+
█ █ █ │
|
|
209
|
+
██ █ │
|
|
210
|
+
█ █ █ █ █ █ █ █ │ @thi.ng/meta-css 0.0.1
|
|
211
|
+
█ █ █ █ █ █ █ █ █ │ Data-driven CSS component & framework codegen
|
|
212
|
+
█ │
|
|
213
|
+
█ █ │
|
|
214
|
+
|
|
215
|
+
Usage: metacss <cmd> [opts] input [...]
|
|
216
|
+
metacss <cmd> --help
|
|
217
|
+
|
|
218
|
+
Available commands:
|
|
219
|
+
|
|
220
|
+
convert : Transpile & bundle meta stylesheets to CSS
|
|
221
|
+
export : Export entire generated framework as CSS
|
|
222
|
+
generate : Generate framework rules from specs
|
|
223
|
+
|
|
224
|
+
Flags:
|
|
225
|
+
|
|
226
|
+
-v, --verbose Display extra process information
|
|
227
|
+
|
|
228
|
+
Main:
|
|
229
|
+
|
|
230
|
+
-o STR, --out STR Output file (or stdout)
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Generating framework code from bundled base definitions
|
|
234
|
+
|
|
235
|
+
To create our first framework, we first need to generate CSS utility classes
|
|
236
|
+
from given JSON generator specs. For simplicity the generated framework
|
|
237
|
+
definitions will be stored as JSON too and then used as lookup tables for actual
|
|
238
|
+
CSS translation in the next step.
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
# write generated CSS classes (in JSON)
|
|
242
|
+
metacss generate --out framework.json node_modules/@thi.ng/meta-css/specs
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Generating CSS from `.meta` stylesheets
|
|
246
|
+
|
|
247
|
+
#### *.meta stylesheets
|
|
248
|
+
|
|
249
|
+
The naming convention used by the [default framework
|
|
250
|
+
specs](https://github.com/thi-ng/umbrella/blob/develop/packages/meta-css/specs/)
|
|
251
|
+
is loosely based on [tachyons.io](https://tachyons.io), with the important
|
|
252
|
+
difference of media query handling. Using MetaCSS we don't have to pre-generate
|
|
253
|
+
mediaquery-specific versions, and any class ID/token can be prefixed with an
|
|
254
|
+
_arbitrary_ number of media query IDs (separated by `:`). These media queries
|
|
255
|
+
are defined as part of the framework JSON specs and when used as a prefix,
|
|
256
|
+
multiple query IDs can be combined freely. E.g. the token `dark:anim:bg-anim2`
|
|
257
|
+
will auto-create a merged CSS `@media`-query block for the query IDs `dark` and
|
|
258
|
+
`anim` and only emit the definition of `bg-anim2` for this combination (see
|
|
259
|
+
generated CSS further below).
|
|
260
|
+
|
|
261
|
+
readme.meta:
|
|
262
|
+
|
|
263
|
+
```text tangle:export/readme.meta
|
|
264
|
+
|
|
265
|
+
body { ma0 dark:bg-black dark:white bg-white black }
|
|
266
|
+
|
|
267
|
+
#app { ma3 }
|
|
268
|
+
|
|
269
|
+
.bt-group-v > a {
|
|
270
|
+
db w100 l:w50 ph3 pv2 bwb1
|
|
271
|
+
dark:bg-purple dark:white dark:b--black
|
|
272
|
+
light:bg-light-blue light:black light:b--white
|
|
273
|
+
{
|
|
274
|
+
:hover { bg-gold black anim:bg-anim2 }
|
|
275
|
+
:first-child { brt3 }
|
|
276
|
+
:last-child { brb3 bwb0 }
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
readme2.meta:
|
|
282
|
+
|
|
283
|
+
We will merge the definitions in this file with the ones from the file above
|
|
284
|
+
(i.e. adding & overriding some of the declarations, here: border radius):
|
|
285
|
+
|
|
286
|
+
```text tangle:export/readme2.meta
|
|
287
|
+
#app { pa2 }
|
|
288
|
+
|
|
289
|
+
.bt-group-v > a {
|
|
290
|
+
{
|
|
291
|
+
:first-child { brt4 }
|
|
292
|
+
:last-child { brb4 }
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
# if not out dir is specified writes result to stdout
|
|
299
|
+
# use previously generated specs for resolving all identifiers & media queries
|
|
300
|
+
metacss convert --pretty --specs framework.json readme.meta readme2.meta
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
#### Resulting CSS output
|
|
304
|
+
|
|
305
|
+
```css
|
|
306
|
+
/*! MetaCSS base v0.0.1 - generated by thi.ng/meta-css @ 2023-12-18T12:22:36.548Z */
|
|
307
|
+
body {
|
|
308
|
+
margin: 0rem;
|
|
309
|
+
background-color: #fff;
|
|
310
|
+
color: #000;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
#app {
|
|
314
|
+
margin: 1rem;
|
|
315
|
+
padding: .5rem;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.bt-group-v > a {
|
|
319
|
+
display: block;
|
|
320
|
+
width: 100%;
|
|
321
|
+
padding-left: 1rem;
|
|
322
|
+
padding-right: 1rem;
|
|
323
|
+
padding-top: .5rem;
|
|
324
|
+
padding-bottom: .5rem;
|
|
325
|
+
border-bottom-style: solid;
|
|
326
|
+
border-bottom-width: .125rem;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.bt-group-v > a:hover {
|
|
330
|
+
background-color: #ffb700;
|
|
331
|
+
color: #000;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.bt-group-v > a:first-child {
|
|
335
|
+
border-top-left-radius: 1rem;
|
|
336
|
+
border-top-right-radius: 1rem;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.bt-group-v > a:last-child {
|
|
340
|
+
border-bottom-left-radius: 1rem;
|
|
341
|
+
border-bottom-right-radius: 1rem;
|
|
342
|
+
border-bottom-style: solid;
|
|
343
|
+
border-bottom-width: 0rem;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
@media (prefers-color-scheme:dark) {
|
|
347
|
+
|
|
348
|
+
body {
|
|
349
|
+
background-color: #000;
|
|
350
|
+
color: #fff;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
.bt-group-v > a {
|
|
354
|
+
background-color: #5e2ca5;
|
|
355
|
+
color: #fff;
|
|
356
|
+
border-color: #000;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
@media (min-width:60rem) {
|
|
362
|
+
|
|
363
|
+
.bt-group-v > a {
|
|
364
|
+
width: 50%;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
@media (prefers-color-scheme:light) {
|
|
370
|
+
|
|
371
|
+
.bt-group-v > a {
|
|
372
|
+
background-color: #96ccff;
|
|
373
|
+
color: #000;
|
|
374
|
+
border-color: #fff;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
@media not (prefers-reduced-motion) {
|
|
380
|
+
|
|
381
|
+
.bt-group-v > a:hover {
|
|
382
|
+
transition: 0.2s background-color ease-in-out;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
}
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
A simple HTML example using above MetaCSS styles:
|
|
389
|
+
|
|
390
|
+
#### index.html
|
|
391
|
+
|
|
392
|
+
```html tangle:export/index.html
|
|
393
|
+
<!doctype html>
|
|
394
|
+
<html>
|
|
395
|
+
<head>
|
|
396
|
+
<link rel="stylesheet" href="bundle.css"/>
|
|
397
|
+
</head>
|
|
398
|
+
<body>
|
|
399
|
+
<div id="app" class="bt-group-v">
|
|
400
|
+
<a href="#">One</a>
|
|
401
|
+
<a href="#">Two</a>
|
|
402
|
+
<a href="#">Three</a>
|
|
403
|
+
<a href="#">Four</a>
|
|
404
|
+
</div>
|
|
405
|
+
</body>
|
|
406
|
+
</html>
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
## Authors
|
|
410
|
+
|
|
411
|
+
- [Karsten Schmidt](https://thi.ng)
|
|
412
|
+
|
|
413
|
+
If this project contributes to an academic publication, please cite it as:
|
|
414
|
+
|
|
415
|
+
```bibtex
|
|
416
|
+
@misc{thing-meta-css,
|
|
417
|
+
title = "@thi.ng/meta-css",
|
|
418
|
+
author = "Karsten Schmidt",
|
|
419
|
+
note = "https://thi.ng/meta-css",
|
|
420
|
+
year = 2023
|
|
421
|
+
}
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
## License
|
|
425
|
+
|
|
426
|
+
© 2023 Karsten Schmidt // Apache License 2.0
|
package/bin/metacss
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# https://stackoverflow.com/a/246128/294515
|
|
4
|
+
SOURCE="${BASH_SOURCE[0]}"
|
|
5
|
+
while [ -h "$SOURCE" ]; do
|
|
6
|
+
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
|
|
7
|
+
SOURCE="$(readlink "$SOURCE")"
|
|
8
|
+
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
|
|
9
|
+
done
|
|
10
|
+
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
|
|
11
|
+
|
|
12
|
+
/usr/bin/env bun run "$DIR/../index.js" "$@"
|