fractalstyler2 0.4.0 → 0.7.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.
Files changed (87) hide show
  1. package/README.md +114 -95
  2. package/dist/cli.js +105 -25
  3. package/dist/components/Accordion.svelte +44 -0
  4. package/dist/components/Accordion.svelte.d.ts +23 -0
  5. package/dist/components/AccordionItem.svelte +44 -0
  6. package/dist/components/AccordionItem.svelte.d.ts +21 -0
  7. package/dist/components/AppShell.svelte +86 -0
  8. package/dist/components/AppShell.svelte.d.ts +39 -0
  9. package/dist/components/ColorPicker.svelte +38 -0
  10. package/dist/components/ColorPicker.svelte.d.ts +6 -0
  11. package/dist/components/Hero.svelte +14 -0
  12. package/dist/components/Hero.svelte.d.ts +9 -0
  13. package/dist/components/LayoutPicker.svelte +34 -0
  14. package/dist/components/LayoutPicker.svelte.d.ts +6 -0
  15. package/dist/components/MotionPicker.svelte +34 -0
  16. package/dist/components/MotionPicker.svelte.d.ts +6 -0
  17. package/dist/components/PageShell.svelte +14 -0
  18. package/dist/components/PageShell.svelte.d.ts +9 -0
  19. package/dist/components/PageSplit.svelte +26 -0
  20. package/dist/components/PageSplit.svelte.d.ts +18 -0
  21. package/dist/components/ShapePicker.svelte +37 -0
  22. package/dist/components/ShapePicker.svelte.d.ts +6 -0
  23. package/dist/css/fractalstyler.css +10643 -0
  24. package/dist/css/fractalstyler.min.css +2 -0
  25. package/dist/index.d.ts +18 -6
  26. package/dist/index.js +30 -12
  27. package/dist/mcp/schemas/compile_fractals.json +3 -3
  28. package/dist/mcp/schemas/css_to_fractals.json +1 -1
  29. package/dist/mcp/schemas/generate_component.json +2 -2
  30. package/dist/mcp/schemas/instructions.md +41 -14
  31. package/dist/mcp/schemas/list_fractals.json +9 -7
  32. package/dist/mcp/schemas/validate_recipe.json +2 -2
  33. package/dist/mcp/server.d.ts +1 -1
  34. package/dist/mcp/server.js +334 -237
  35. package/dist/presets.core.d.ts +42 -0
  36. package/dist/presets.core.js +190 -0
  37. package/dist/presets.svelte.d.ts +6 -0
  38. package/dist/presets.svelte.js +21 -0
  39. package/dist/styles/_00_presets.sass +111 -0
  40. package/dist/styles/_00_themes.sass +1061 -0
  41. package/dist/styles/_00_tokens.sass +57 -17
  42. package/dist/styles/_01_config.sass +77 -70
  43. package/dist/styles/_02_dimensions.sass +174 -0
  44. package/dist/styles/_03_containers.sass +105 -0
  45. package/dist/styles/_04_layouts.sass +100 -0
  46. package/dist/styles/_05_shells.sass +374 -0
  47. package/dist/styles/_06_visuals.sass +236 -0
  48. package/dist/styles/_07_interactions.sass +112 -0
  49. package/dist/styles/_08_own.sass +4 -0
  50. package/dist/styles/canonical-markups.md +160 -0
  51. package/dist/styles/index.sass +11 -18
  52. package/dist/themes.d.ts +7 -0
  53. package/dist/themes.js +45 -0
  54. package/dist/version.d.ts +1 -0
  55. package/dist/version.js +2 -0
  56. package/package.json +26 -15
  57. package/plugin.json +11 -10
  58. package/registry.json +2002 -0
  59. package/skills/fractal-styler/SKILL.md +137 -50
  60. package/skills/fractal-styler/references/fractals.md +416 -28
  61. package/skills/fractal-styler/references/tokens.md +110 -36
  62. package/dist/styles/_02_fonts.sass +0 -13
  63. package/dist/styles/_03_responsive.sass +0 -31
  64. package/dist/styles/_04_atoms.sass +0 -155
  65. package/dist/styles/_05_molecules.sass +0 -97
  66. package/dist/styles/_06_recipes.sass +0 -189
  67. package/dist/styles/_07_base.sass +0 -44
  68. package/dist/styles/_08_blocks.sass +0 -433
  69. package/dist/styles/_09_utilities.sass +0 -208
  70. package/dist/styles/_10_layouts.sass +0 -373
  71. package/dist/styles/_11_own.sass +0 -21
  72. package/dist/styles/_fractals.sass +0 -14
  73. package/skills/style-migration/SKILL.md +0 -45
  74. package/templates/_00_tokens.sass +0 -136
  75. package/templates/_01_config.sass +0 -66
  76. package/templates/_02_fonts.sass +0 -13
  77. package/templates/_03_responsive.sass +0 -31
  78. package/templates/_04_atoms.sass +0 -155
  79. package/templates/_05_molecules.sass +0 -97
  80. package/templates/_06_recipes.sass +0 -189
  81. package/templates/_07_base.sass +0 -44
  82. package/templates/_08_blocks.sass +0 -433
  83. package/templates/_09_utilities.sass +0 -207
  84. package/templates/_10_layouts.sass +0 -373
  85. package/templates/_11_own.sass +0 -21
  86. package/templates/_fractals.sass +0 -14
  87. package/templates/index.sass +0 -18
@@ -1,83 +1,170 @@
1
1
  ---
2
2
  name: fractal-styler
3
- description: Design, compose, and build UI components and page layouts using the fractalstyler2 SASS mixin system and fluid design tokens in SvelteKit. Use when authoring components, applying design tokens, styling layouts, or compiling fractal recipes.
3
+ description: Compose UI components and page layouts with the fractalstyler2 class registry — fluid tokens, container primitives, harmonic grids, and canonical application shells. Use when authoring components, applying design tokens, styling layouts, or reviewing markup for a fractalstyler2 project.
4
4
  ---
5
5
 
6
6
  # Fractal Styler (fractalstyler2)
7
7
 
8
- `fractalstyler2` is a fractal-composition styling system for SvelteKit and modern web applications. Every styling decision is a reusable SASS mixin ("a fractal"), and components and layouts are clean recipes composed of smaller fractals.
8
+ `fractalstyler2` is a composition styling system. **The class registry is the
9
+ entire public API.** You compose in markup; you do not author CSS.
10
+
11
+ It ships as plain CSS and as editable SASS, from one source. Which one a
12
+ project took changes nothing you do: the classes, tokens, 41 themes and four
13
+ preset axes are identical either way. Check for `fractalstyler.css` or a
14
+ `src/lib/styles/` directory to know which you are in — and never assume a SASS
15
+ toolchain exists.
16
+
17
+ The system defines no authoring mixins and no SASS functions. If you find
18
+ yourself reaching for `+stack`, `+surface`, `+gap()`, `space()` or `radius()`,
19
+ you are inventing an API: none of them exist. The only two mixins in the source
20
+ are internal theme generators you never call.
21
+
22
+ Full class list: `references/fractals.md`. Tokens: `references/tokens.md`.
23
+ Both are generated from the stylesheet, so they cannot be stale.
9
24
 
10
25
  ---
11
26
 
12
- ## The Four Tiers of Composition
27
+ ## The Prohibition
28
+
29
+ This is the rule the system is most often broken by, so it comes first.
30
+
31
+ **Do not create new classes.** Not in `_08_own.sass`, not in a component
32
+ `<style>` block, not anywhere. Compose from the registry in the `class`
33
+ attribute instead.
34
+
35
+ `_08_own.sass` exists for third-party widget overrides — a code editor, an
36
+ embedded chart, a map library that ships its own DOM. It is not for your
37
+ layout, your card, your sidebar, or your spacing. A module that adds hundreds
38
+ of lines there has not used the system; it has bypassed it.
39
+
40
+ Before you write a single custom declaration, run this checklist from
41
+ `docs/13-cookbook.md`:
42
+
43
+ 1. Can it be composed with `.box` or `.row`?
44
+ 2. Can `.gap-*` and `.pad-*` provide all the breathing room?
45
+ 3. Can `.surface`, `.raised` or `.panel` provide the background?
46
+ 4. Can `.border` or `.border-bottom` provide the dividing line?
47
+ 5. Can `.button`, `.badge`, `.input` or `.select` handle the interactive state?
13
48
 
14
- | Tier | Role | Examples |
15
- | :--- | :--- | :--- |
16
- | **1. Tokens & Config** | Fluid Utopia scales & resolvers | `space(m)` → `var(--space-m)`, `radius(12)` → `var(--radius-12)` |
17
- | **2. Atoms** | Single layout/styling decisions | `+box`, `+row`, `+gap(s)`, `+pad(m)`, `+border`, `+radius(12)`, `+bg(surface)`, `+ink(primary)` |
18
- | **3. Molecules** | Compositions of atoms | `+stack(s)`, `+cluster(xs)`, `+surface(surface, s, 12)`, `+cover(80vh)`, `+frame(16/9)`, `+with-sidebar` |
19
- | **4. Components & Layouts** | Recipes of molecules | `.card`, `.panel`, `.button`, `.badge` · `.grid-3`, `.card-grid`, `.hero`, `.holy-grail`, `.docs`, `.app-shell` |
49
+ Five yeses means it belongs in the markup. That is nearly always the answer —
50
+ the cookbook composes segmented controls, tab strips, search bars, metric
51
+ tiles, activity feeds, dialogs and dropdowns with zero custom CSS.
52
+
53
+ Do **not** replace a composed class string with a "cleaner" semantic class.
54
+ `class="row ycenter xbetween gap-sm pad-md surface border"` is the finished
55
+ state, not an intermediate one to tidy away.
20
56
 
21
57
  ---
22
58
 
23
- ## Golden Rules for Agents
59
+ ## The Six Layers
60
+
61
+ Each layer is built from the one below it. Naming follows all the way down.
24
62
 
25
- 1. **Never hardcode values that tokens cover**: Use `+gap(m)`, `+radius(12)`, `+bg(surface)` instead of arbitrary pixel values.
26
- 2. **Compose fractals; don't write raw CSS**: Raw CSS is strictly for unique lines that no fractal covers.
27
- 3. **State on `data-*` / `aria-*` attributes**: Never use modifier classes like `.is-active` or `.btn--primary`. Use `&[data-elevated]`, `&[data-variant='primary']`.
28
- 4. **Markup stays semantic**: Prefer `<article class="card">` over 20 nested utility classes.
29
- 5. **Mobile-first**: Define base layout first, grow with `+at(md/lg/xl)` and `+cols()`.
63
+ | Layer | What it is | Reach for |
64
+ |:---|:---|:---|
65
+ | **L0** Tokens | Fluid scales and 31 colour roles | `--space-md`, `--text-lg`, `--bg-surface` |
66
+ | **L1** Dimensions | Space, size, radius | `.gap-sm`, `.pad-x-md`, `.marg--xs`, `.w-240`, `.min0` |
67
+ | **L2** Containers | Flow and alignment | `.box`, `.row`, `.grid`, `.xcenter`, `.ycenter`, `.grow` |
68
+ | **L3** Layouts | Grids, measures, frames | `.grid-3`, `.card-grid`, `.prose`, `.frame-16-9`, `.reel` |
69
+ | **L4** Shells | Page and app scaffolding | `.app-shell`, `.sidebar-left`, `.drawer`, `.dialog` |
70
+ | **L5** Visuals | Surfaces, ink, controls | `.surface`, `.text-muted`, `.border`, `.button.primary` |
30
71
 
31
72
  ---
32
73
 
33
- ## How to Author a Svelte 5 Component
74
+ ## Rules That Actually Bite
75
+
76
+ **1. Every token is also a class.** `--space-md` implies `.gap-md`, `.pad-md`,
77
+ `.marg-md`. Never invent a second vocabulary.
78
+
79
+ **2. `x` is always horizontal, `y` is always vertical — in every container.**
80
+ This is the system's central convenience. `.xcenter` centres horizontally on
81
+ `.box`, on `.row`, and on `.grid`, even though the underlying property differs
82
+ each time. Never reason about `justify-content` vs `align-items`.
83
+
84
+ Not every combination exists, because not every one is meaningful:
85
+ `.box` has no `x`-distribution (`xbetween`, `xevenly`, `xaround`), and
86
+ `.row` has no `y`-distribution. Check `references/fractals.md` rather than
87
+ guessing.
88
+
89
+ **3. Grids step through divisors only.** `.grid-6` goes 6 → 3 → 2 → 1 and
90
+ never 5 or 4, so no row is ever left holding one card. Use `.grid-N` when you
91
+ know the count at authoring time; use `.card-grid` when you do not (a query
92
+ result, a feed) and let it auto-fit.
93
+
94
+ **4. A shell class without its canonical markup is half a definition.** L4
95
+ classes assume a specific structure. Copy it from
96
+ `docs/08-shells-and-markups.md` or `styles/canonical-markups.md` verbatim —
97
+ the responsive behaviour (right rail retracts at 1280, left rail becomes a
98
+ drawer at 1024) is a consequence of that structure, and you get it for free
99
+ only by following it.
100
+
101
+ **5. Prefer preset steps to literals.** `.gap-sm` over `.gap-16`. Literals are
102
+ the sanctioned escape hatch for exact requirements — a 16px icon box, a 1px
103
+ rule — not the default. They come from a discrete ladder, not any integer:
104
+ `0, 1, 2, 4, 6, 8, 12`, then every multiple of 8 — up to 64px for `gap`, `pad`,
105
+ `marg` and `radius`, up to 512px for `w`, `h` and `square`.
106
+
107
+ **6. Responsive without media queries.** Append `-mob` (below 768px) or
108
+ `-desk` (768px and above) to any dimension class: `pad-xs-mob pad-lg-desk`.
109
+
110
+ **7. Visual toggles ride classes; semantics stay native.** `.open`, `.active`
111
+ for JS-driven looks; `[disabled]`, `[aria-expanded]`, `:focus-visible` keep
112
+ their own meaning.
113
+
114
+ ---
115
+
116
+ ## Authoring a Component
34
117
 
35
118
  ```svelte
36
119
  <script lang="ts">
37
- let {
38
- title = 'Pricing Tier',
39
- price = '$29',
40
- highlighted = false,
41
- children
42
- } = $props();
120
+ let { title = 'Pricing', price = '$29', highlighted = false, children } = $props();
43
121
  </script>
44
122
 
45
- <article class="pricing-card" data-highlighted={highlighted || undefined}>
46
- <div class="row ycenter xbetween">
47
- <h3 class="text-xl">{title}</h3>
48
- {#if highlighted}
49
- <span class="badge" data-variant="theme">Popular</span>
50
- {/if}
123
+ <article class="card box gap-md pad-md surface border radius-md" class:active={highlighted}>
124
+ <div class="row ycenter xbetween gap-sm">
125
+ <h3 class="text-lg weight-600 marg-0">{title}</h3>
126
+ {#if highlighted}<span class="badge">Popular</span>{/if}
51
127
  </div>
52
- <div class="row ycenter gap-2xs">
53
- <span class="text-4xl font-bold">{price}</span>
54
- <span class="muted">/month</span>
128
+
129
+ <div class="row ybot gap-2xs">
130
+ <span class="text-3xl weight-700 text-primary">{price}</span>
131
+ <span class="text-xs text-muted">/month</span>
55
132
  </div>
56
- {#if children}
57
- {@render children()}
58
- {/if}
133
+
134
+ {#if children}{@render children()}{/if}
135
+
136
+ <button class="button primary wfull">Choose plan</button>
59
137
  </article>
138
+ ```
139
+
140
+ No `<style>` block. That is the expected outcome, not an unusual one.
141
+
142
+ ---
60
143
 
61
- <style lang="sass">
62
- @use '$lib/styles/fractals' as *
144
+ ## Presets
63
145
 
64
- .pricing-card
65
- +surface(surface, m, 16)
66
- +stack(m)
67
- transition: transform 150ms ease, box-shadow 150ms ease
146
+ Four axes, applied as attributes on `<html>` — or on any element, to scope a
147
+ themed region:
68
148
 
69
- &[data-highlighted]
70
- +border(all, var(--theme))
71
- +shadow(lg)
72
- </style>
149
+ ```html
150
+ <html data-shape="sharp" data-layout="tight" data-color="vibrant" data-motion="springy">
73
151
  ```
74
152
 
153
+ An absent attribute means that axis's default. Values are in
154
+ `references/tokens.md`. Presets remap tokens only; they never require a markup
155
+ change.
156
+
75
157
  ---
76
158
 
77
- ## MCP Tools Integration
159
+ ## MCP Tools
160
+
161
+ If the host connects the `fractalstyler2` MCP server:
162
+
163
+ - `list_fractals` — the class registry, filterable by layer (`L0`..`L5`)
164
+ - `get_design_tokens` — space, type, radius and colour scales
165
+ - `css_to_fractals` — translate raw CSS declarations into registry classes
166
+ - `snap_to_tokens` — snap arbitrary pixel values to the nearest token step
167
+ - `validate_recipe` — lint markup against these rules
168
+ - `compile_fractals` — compile the stylesheet and verify output
78
169
 
79
- If the host environment connects to the `fractalstyler2` MCP server, use the available tools:
80
- * `get_design_tokens`: Query available space, typography, and radius steps.
81
- * `compile_fractals`: Compile SASS mixin recipes to verify CSS output.
82
- * `snap_to_tokens`: Snap canvas pixel values to tokens.
83
- * `validate_recipe`: Lint SASS/Svelte against the golden rules.
170
+ Query `list_fractals` before naming any class you are not certain of.