@fractaldesign/fractalstyler 0.0.0-stage → 0.9.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/LICENSE +19 -0
- package/README.md +123 -2
- package/cli/main.mjs +141 -0
- package/cli/scaffold.mjs +406 -0
- package/data/recipes.json +61 -0
- package/dist/asset.d.ts +3 -0
- package/dist/css/fractalstyler.css +2453 -0
- package/dist/css/fractalstyler.min.css +2 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/styles/_00_config.sass +29 -0
- package/dist/styles/_00_fonts.sass +58 -0
- package/dist/styles/_00_tokens.sass +211 -0
- package/dist/styles/_01_base.sass +58 -0
- package/dist/styles/_02_dimensions.sass +70 -0
- package/dist/styles/_03_typography.sass +170 -0
- package/dist/styles/_04_containers.sass +173 -0
- package/dist/styles/_05_layouts.sass +104 -0
- package/dist/styles/_06_shells.sass +135 -0
- package/dist/styles/_07_interactions.sass +212 -0
- package/dist/styles/_08_visuals.sass +136 -0
- package/dist/styles/_09_own.sass +174 -0
- package/dist/styles/colorpacks.sass +119 -0
- package/dist/styles/index.sass +14 -0
- package/dist/styles/themeplates.sass +159 -0
- package/docs/REGISTRY.api.md +477 -0
- package/docs/REGISTRY.md +14 -0
- package/docs/references/configurations-api.md +220 -0
- package/docs/references/configurations.md +258 -0
- package/lint/browser.mjs +79 -0
- package/lint/cli.mjs +212 -0
- package/lint/lib/agent-reporter.mjs +51 -0
- package/lint/lib/fuzzy.mjs +45 -0
- package/lint/lib/registry.mjs +107 -0
- package/lint/lib/sass-linter.mjs +71 -0
- package/lint/lib/svelte-linter.mjs +116 -0
- package/lint/lib/token-linter.mjs +97 -0
- package/package.json +112 -5
- package/registry.json +3999 -0
- package/scripts/class-vocab.js +197 -0
- package/scripts/update-registry.js +934 -0
- package/skills/fractal-styler/references/fractals.md +630 -0
- package/skills/fractal-styler/references/tokens.md +226 -0
- package/skills/fractalstyler/SKILL.md +59 -0
- package/skills/fractalstyler/references/fractals.md +630 -0
- package/skills/fractalstyler/references/tokens.md +226 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2026 Amritanshu Pandey
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,124 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Fractalstyler
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A composition styling system — the class registry is the public API: compose
|
|
4
|
+
in markup, write no stylesheet. Ships as editable SASS and as plain compiled
|
|
5
|
+
CSS. MIT © [Fractal Mandala](https://github.com/fractalmandala)
|
|
6
|
+
|
|
7
|
+
**This library is a work in constant progress and breaking changes each bump.**
|
|
8
|
+
|
|
9
|
+
- Registry: [`REGISTRY.md`](REGISTRY.md) · [`docs/REGISTRY.api.md`](docs/REGISTRY.api.md)
|
|
10
|
+
- Configuration, the *why/how*: [`docs/references/configurations.md`](docs/references/configurations.md) · the *what*: [`docs/references/configurations-api.md`](docs/references/configurations-api.md)
|
|
11
|
+
- Agent skill: [`skills/fractal-styler/SKILL.md`](skills/fractalstyler/SKILL.md)
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Using it in a project
|
|
16
|
+
|
|
17
|
+
Two ways to hold the styles, and an IDE layer you can add to either.
|
|
18
|
+
|
|
19
|
+
### 1. Install and use — track the package; upgrades come from npm
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
pnpm add -D @fractaldesign/fractalstyler
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```sass
|
|
26
|
+
@use '@fractaldesign/fractalstyler/styles' as *
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Plain CSS consumers need no SASS toolchain:
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
import '@fractaldesign/fractalstyler/css'; // dist/css/fractalstyler.css
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The classes are active once the import is in place. To keep the registry and
|
|
36
|
+
the configuration docs greppable inside your project, run:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
npx @fractaldesign/fractalstyler init --track --docs
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
which places `REGISTRY.md`, `REGISTRY.api.md` and
|
|
43
|
+
`references/configurations{,-api}.md` into a `fractalstyler/` folder at your
|
|
44
|
+
project root (`--docs-dir` to choose another). Docs are snapshots — re-run
|
|
45
|
+
`init` after upgrading to refresh them.
|
|
46
|
+
|
|
47
|
+
### 2. Eject — the files become yours
|
|
48
|
+
|
|
49
|
+
Copies every styles layer, the palette modules and the registry builder into
|
|
50
|
+
your project, where you may edit them freely (including the `$`-variables in
|
|
51
|
+
`_00_config.sass`, in place):
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
npx @fractaldesign/fractalstyler eject
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
That leaves you `src/lib/styles/` (11 layers + a seeded `_09_own.sass`),
|
|
58
|
+
`src/lib/palette/`, and `scripts/build-registry.mjs`. Import your local tree,
|
|
59
|
+
regenerate your own registry after edits (`node scripts/build-registry.mjs`,
|
|
60
|
+
Node only), and the linter keeps enforcing the contract against your copy:
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
npx @fractaldesign/fractalstyler lint src/
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Nothing existing is ever overwritten — on a name conflict your file is kept
|
|
67
|
+
and reported. Delete a kept file and re-run `eject` to re-place it.
|
|
68
|
+
|
|
69
|
+
> **Drift warning**: an ejected copy no longer tracks the package — upgrades
|
|
70
|
+
> stop coming from npm. This is the less advisable mode; it exists so a
|
|
71
|
+
> project that must own its styles can still start from the whole system.
|
|
72
|
+
|
|
73
|
+
### 3. Either mode, with or without the IDE extension
|
|
74
|
+
|
|
75
|
+
Both `init` and `eject` accept `--intellisense` / `--no-intellisense`. With it
|
|
76
|
+
on, the CLI writes the workspace settings read by the
|
|
77
|
+
[Styles IntelliSense](https://github.com/fractalmandala/styles-intellisense)
|
|
78
|
+
VS Code extension — class completions and hovers inside `class="…"`, token
|
|
79
|
+
completions on `--custom-properties` — pointing at wherever your styles now
|
|
80
|
+
live (`node_modules/…/dist/styles` in track mode, your local folder in eject
|
|
81
|
+
mode), plus the copied `REGISTRY.api.md` as the description source. It also
|
|
82
|
+
checks the extension is installed and prints how to get it if not.
|
|
83
|
+
|
|
84
|
+
`npx @fractaldesign/fractalstyler init` with no flags asks the three questions
|
|
85
|
+
interactively; `--yes` takes the defaults (track + docs + intellisense).
|
|
86
|
+
|
|
87
|
+
## CLI reference
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
npx @fractaldesign/fractalstyler init # scaffold: mode, docs, intellisense
|
|
91
|
+
npx @fractaldesign/fractalstyler eject # copy styles + palettes + builder
|
|
92
|
+
npx @fractaldesign/fractalstyler lint # contract linter (self or <dir>)
|
|
93
|
+
npx @fractaldesign/fractalstyler help # all options
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
| Option | Default | Meaning |
|
|
97
|
+
|---|---|---|
|
|
98
|
+
| `--track` / `--eject` | track | How the styles are held |
|
|
99
|
+
| `--docs` / `--no-docs` | docs | Copy registry + configuration docs |
|
|
100
|
+
| `--docs-dir <dir>` | `fractalstyler/` | Where docs land |
|
|
101
|
+
| `--styles-dir <dir>` | `src/lib/styles` | Eject target for the layers |
|
|
102
|
+
| `--palette-dir <dir>` | `src/lib/palette` | Eject target for the palettes |
|
|
103
|
+
| `--scripts-dir <dir>` | `scripts` | Eject target for the registry builder |
|
|
104
|
+
| `--intellisense` / `--no-intellisense` | ask | VS Code extension settings + check |
|
|
105
|
+
| `--yes` / `-y` | — | Non-interactive, take the defaults |
|
|
106
|
+
|
|
107
|
+
`lint` needs the Sass compiler (an optional peer of this package):
|
|
108
|
+
`pnpm add -D sass`. Its own flags (`--json`, `--own <file>`, `--registry <f>`)
|
|
109
|
+
pass through unchanged.
|
|
110
|
+
|
|
111
|
+
## Developing this package
|
|
112
|
+
|
|
113
|
+
```sh
|
|
114
|
+
pnpm registry # regenerate registry.json, REGISTRY.md, docs, skill references
|
|
115
|
+
pnpm vocab # regenerate docs/REGISTRY.api.md
|
|
116
|
+
pnpm browser # regenerate docs/browser.html
|
|
117
|
+
pnpm lint # contract linter (self mode)
|
|
118
|
+
pnpm check # validate-deck + svelte-check
|
|
119
|
+
pnpm css # rebuild dist/css
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Architecture: **L0 (Tokens) → L1 (Dimensions) → L2 (Containers) → L3
|
|
123
|
+
(Layouts) → L4 (Shells) → L5 (Visuals & Interactions)** — the layer map and
|
|
124
|
+
the edit recipes are in [`docs/references/configurations.md`](docs/references/configurations.md).
|
package/cli/main.mjs
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// =============================================================================
|
|
3
|
+
// fractalstyler — the consumer-facing CLI.
|
|
4
|
+
//
|
|
5
|
+
// npx @fractaldesign/fractalstyler init scaffold: track or eject, docs,
|
|
6
|
+
// intellisense (interactive, or flags)
|
|
7
|
+
// npx @fractaldesign/fractalstyler eject copy the styles + palettes +
|
|
8
|
+
// registry builder into your project
|
|
9
|
+
// npx @fractaldesign/fractalstyler lint contract linter (self or <dir>)
|
|
10
|
+
//
|
|
11
|
+
// Zero dependencies beyond Node itself.
|
|
12
|
+
// ============================================================================
|
|
13
|
+
|
|
14
|
+
import { spawnSync } from 'node:child_process';
|
|
15
|
+
import { createRequire } from 'node:module';
|
|
16
|
+
import { dirname, join } from 'node:path';
|
|
17
|
+
import { fileURLToPath } from 'node:url';
|
|
18
|
+
import { runInit, runEject } from './scaffold.mjs';
|
|
19
|
+
|
|
20
|
+
const PKG_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');
|
|
21
|
+
|
|
22
|
+
const USAGE = `fractalstyler — the composition styling system, as a CLI
|
|
23
|
+
|
|
24
|
+
Usage:
|
|
25
|
+
fractalstyler init [options] Scaffold a project (default command)
|
|
26
|
+
fractalstyler eject [options] Copy the styles sources into your project
|
|
27
|
+
fractalstyler lint [dir] [flags] Contract linter (self mode, or a target dir)
|
|
28
|
+
fractalstyler help This message
|
|
29
|
+
|
|
30
|
+
init options:
|
|
31
|
+
--track Track the package: styles stay in node_modules,
|
|
32
|
+
upgrades come from npm (default)
|
|
33
|
+
--eject Eject: the style files become yours (see eject)
|
|
34
|
+
--docs / --no-docs Copy the registry + configurations docs into the
|
|
35
|
+
project (default: yes)
|
|
36
|
+
--docs-dir <dir> Where docs land (default: fractalstyler/)
|
|
37
|
+
--intellisense / --no-intellisense
|
|
38
|
+
Write .vscode settings for the Styles IntelliSense
|
|
39
|
+
extension and check it is installed (default: ask;
|
|
40
|
+
--yes takes yes)
|
|
41
|
+
--yes / -y Non-interactive: take the defaults above
|
|
42
|
+
|
|
43
|
+
eject options (same docs/intellisense flags, plus):
|
|
44
|
+
--styles-dir <dir> Target for the style layers (default: src/lib/styles)
|
|
45
|
+
--palette-dir <dir> Target for the palette modules (default: src/lib/palette)
|
|
46
|
+
--scripts-dir <dir> Target for the registry builder (default: scripts)
|
|
47
|
+
|
|
48
|
+
Never overwrites an existing file: on a name conflict the existing file is
|
|
49
|
+
kept and yours is reported. Delete a kept file and re-run to re-place it.
|
|
50
|
+
|
|
51
|
+
How the styles activate:
|
|
52
|
+
track: pnpm add -D @fractaldesign/fractalstyler
|
|
53
|
+
@use '@fractaldesign/fractalstyler/styles' as *
|
|
54
|
+
(or plain CSS: import '@fractaldesign/fractalstyler/css')
|
|
55
|
+
eject: the copy lands in src/lib/styles/ — import it from your own tree and
|
|
56
|
+
regenerate your registry after edits with node scripts/build-registry.mjs
|
|
57
|
+
(Node only, no Sass needed).`;
|
|
58
|
+
|
|
59
|
+
function fail(message) {
|
|
60
|
+
console.error(`✕ ${message}\n`);
|
|
61
|
+
console.error('Run `fractalstyler help` for usage.');
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const args = process.argv.slice(2);
|
|
66
|
+
const command = args[0] && !args[0].startsWith('-') ? args[0] : 'init';
|
|
67
|
+
const rest = args[0] && !args[0].startsWith('-') ? args.slice(1) : args;
|
|
68
|
+
|
|
69
|
+
function parseOptions(rest) {
|
|
70
|
+
const opts = {
|
|
71
|
+
mode: null,
|
|
72
|
+
docs: null,
|
|
73
|
+
intellisense: null,
|
|
74
|
+
docsDir: 'fractalstyler',
|
|
75
|
+
stylesDir: 'src/lib/styles',
|
|
76
|
+
paletteDir: 'src/lib/palette',
|
|
77
|
+
scriptsDir: 'scripts',
|
|
78
|
+
yes: false
|
|
79
|
+
};
|
|
80
|
+
for (let i = 0; i < rest.length; i++) {
|
|
81
|
+
const arg = rest[i];
|
|
82
|
+
switch (arg) {
|
|
83
|
+
case '--track': opts.mode = 'track'; break;
|
|
84
|
+
case '--eject': opts.mode = 'eject'; break;
|
|
85
|
+
case '--docs': opts.docs = true; break;
|
|
86
|
+
case '--no-docs': opts.docs = false; break;
|
|
87
|
+
case '--intellisense': opts.intellisense = true; break;
|
|
88
|
+
case '--no-intellisense': opts.intellisense = false; break;
|
|
89
|
+
case '--yes': case '-y': opts.yes = true; break;
|
|
90
|
+
case '--docs-dir': case '--styles-dir': case '--palette-dir': case '--scripts-dir': {
|
|
91
|
+
const value = rest[++i];
|
|
92
|
+
if (!value) fail(`${arg} needs a value.`);
|
|
93
|
+
opts[arg.slice(2) + 'Dir'] = value.replace(/[/\\]+$/, '');
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
default:
|
|
97
|
+
fail(`unknown option: ${arg}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return opts;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
switch (command) {
|
|
104
|
+
case 'init': {
|
|
105
|
+
const opts = parseOptions(rest);
|
|
106
|
+
await runInit(opts, PKG_ROOT);
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
case 'eject': {
|
|
110
|
+
const opts = parseOptions(rest);
|
|
111
|
+
opts.mode = 'eject';
|
|
112
|
+
await runEject(opts, PKG_ROOT);
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
case 'lint': {
|
|
116
|
+
// Delegate to the contract linter verbatim — it already understands
|
|
117
|
+
// self mode (no args) and consumer mode (`lint <dir>`), plus its own
|
|
118
|
+
// flags (--json, --own, --registry). The linter compiles the stylesheet
|
|
119
|
+
// for exact matching, so it needs `sass` — an optional peer of this
|
|
120
|
+
// package. Check up front and say how to get it, instead of letting the
|
|
121
|
+
// consumer watch a module-resolution crash.
|
|
122
|
+
const require = createRequire(import.meta.url);
|
|
123
|
+
try {
|
|
124
|
+
require.resolve('sass', { paths: [process.cwd(), PKG_ROOT] });
|
|
125
|
+
} catch {
|
|
126
|
+
console.error('✕ lint needs the Sass compiler, which is not installed here.');
|
|
127
|
+
console.error(' It is an optional peer of this package — add it, then re-run:');
|
|
128
|
+
console.error(' pnpm add -D sass (or: npm i -D sass)');
|
|
129
|
+
process.exit(1);
|
|
130
|
+
}
|
|
131
|
+
const lint = join(PKG_ROOT, 'lint', 'cli.mjs');
|
|
132
|
+
const result = spawnSync(process.execPath, [lint, ...rest], { stdio: 'inherit' });
|
|
133
|
+
process.exit(result.status ?? 1);
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
case 'help': case '--help': case '-h':
|
|
137
|
+
console.log(USAGE);
|
|
138
|
+
break;
|
|
139
|
+
default:
|
|
140
|
+
fail(`unknown command: ${command}`);
|
|
141
|
+
}
|