flet-box 1.0.8 → 1.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/README.md +3 -0
- package/bin/commands/checkUi.js +53 -3
- package/bin/commands/create.js +44 -19
- package/bin/utils/skills.js +59 -0
- package/bin/utils/templates.js +143 -511
- package/docs/README.md +3 -1
- package/docs/cli/README.md +1 -1
- package/docs/guides/README.md +3 -1
- package/docs/guides/clean-ui.md +35 -17
- package/docs/guides/mobile-and-platforms.md +31 -0
- package/docs/tools/theme.md +1 -0
- package/docs/widget/README.md +2 -0
- package/package.json +3 -2
- package/skills/fletbox-design/SKILL.md +573 -0
- package/skills/fletbox-memory/SKILL.md +134 -0
- package/skills/fletbox-motion/SKILL.md +168 -0
- package/skills/fletbox-rules/SKILL.md +154 -0
- package/src/utils/themes.js +64 -4
package/docs/README.md
CHANGED
|
@@ -4,6 +4,8 @@ FletBox is a tiny UI framework: you describe your screen with plain JavaScript *
|
|
|
4
4
|
|
|
5
5
|
This documentation is one continuous book. Start at **Chapter 0** and follow the "Continue reading" links at the bottom of every page; each page teaches you something real and links to the next.
|
|
6
6
|
|
|
7
|
+
> **Want to see before you read?** The [live widget gallery](https://kuko53348.github.io/flet-box-widgets-exemples/) runs in the browser: one page per widget, every example rendered, with the exact call printed under it and a light/dark toggle. It is the same code the chapters describe, so it doubles as the answer to "what does this look like when it is real?".
|
|
8
|
+
|
|
7
9
|
## The reading path
|
|
8
10
|
|
|
9
11
|
| # | Chapter | What you learn | Level |
|
|
@@ -14,7 +16,7 @@ This documentation is one continuous book. Start at **Chapter 0** and follow the
|
|
|
14
16
|
| 9 | [State, Router & Services](guides/state.md) | Shared state, navigation routes, storage, and HTTP | Intermediate |
|
|
15
17
|
| 10 | [Tools & Utilities](tools/README.md) | The helper functions that ship with the framework | Intermediate |
|
|
16
18
|
| 11 | [The CLI](cli/README.md) | Create, run, and build projects with `flet-box` | Intermediate |
|
|
17
|
-
| 12 | [Clean UI](guides/clean-ui.md) | The
|
|
19
|
+
| 12 | [Clean UI](guides/clean-ui.md) | The four skills every app ships with, the design system they hold, and the gate that enforces it | Intermediate |
|
|
18
20
|
| A | [Appendices](guides/minification-and-protection.md) | Minification, mobile, compatibility, embedding, online updates (OTA) | Advanced |
|
|
19
21
|
|
|
20
22
|
> **Levels.** *Beginner:* start here and read in order. *Intermediate:* continue in order — you are comfortable with widgets. *Advanced:* for when you ship, skip on a first read.
|
package/docs/cli/README.md
CHANGED
|
@@ -448,7 +448,7 @@ Capacitor template with different slots keeps working. It:
|
|
|
448
448
|
status bar style ignored.
|
|
449
449
|
|
|
450
450
|
The script is idempotent: running it twice leaves identical files. The brand
|
|
451
|
-
color `#
|
|
451
|
+
color `#18181b` is defined at the top of the script.
|
|
452
452
|
|
|
453
453
|
## Convert asset images to PNG
|
|
454
454
|
|
package/docs/guides/README.md
CHANGED
|
@@ -10,7 +10,9 @@ This directory is the **conceptual index** of FletBox: how to build apps, set up
|
|
|
10
10
|
- **[Frontend services](frontend-services.md)** — Chapter 9 · the practical walkthrough of the three storage layers (`RamStore`, `Session`, `Storage`) and the HTTP client.
|
|
11
11
|
- **[FletBox utilities](utilities.md)** — Chapter 10 · layout/theme/format helpers and validator tools.
|
|
12
12
|
- **[The CLI](../cli/README.md)** — Chapter 11 · create, run, and build projects with `flet-box`.
|
|
13
|
-
- **[Clean UI](clean-ui.md)** — Chapter 12 · the
|
|
13
|
+
- **[Clean UI](clean-ui.md)** — Chapter 12 · the four skills `flet-box create`
|
|
14
|
+
installs, the token scale, the 25 rules, and the `flet-box check-ui` gate that
|
|
15
|
+
enforces them.
|
|
14
16
|
- **[Widget structure](widget-structure.md)** — the canonical, modular shape every widget follows (and how new ones are added).
|
|
15
17
|
|
|
16
18
|
## Appendices (Advanced — for shipping)
|
package/docs/guides/clean-ui.md
CHANGED
|
@@ -5,8 +5,9 @@ defaults, and every later screen copies the screen before it. This page is the
|
|
|
5
5
|
contract that makes the copy look like one product — the numbers, the tokens,
|
|
6
6
|
and the two commands that prove a screen obeys them.
|
|
7
7
|
|
|
8
|
-
It is the published version of the
|
|
9
|
-
|
|
8
|
+
It is the published version of the `fletbox-design` skill — one of four files in
|
|
9
|
+
the framework's `skills/` folder that `flet-box create` copies into every app — so
|
|
10
|
+
the app's agent and the framework's documentation cannot disagree.
|
|
10
11
|
|
|
11
12
|
## The two gates
|
|
12
13
|
|
|
@@ -26,12 +27,24 @@ one replaces opening the page.
|
|
|
26
27
|
|
|
27
28
|
## Where the rules live
|
|
28
29
|
|
|
30
|
+
A generated app is handed four skills — one file per subject, in a visible
|
|
31
|
+
`skills/` folder at its root, mirrored byte for byte to `.claude/skills/` and
|
|
32
|
+
`.qoder/skills/` because that is where those assistants load a skill from, and
|
|
33
|
+
pointed at from one `.cursor/rules/<name>.mdc` each:
|
|
34
|
+
|
|
35
|
+
| Skill | What it owns |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| `fletbox-rules` | The working contract: FletBox syntax only, never invent an API and the four ways to look one up, the rem rule, aliases, cleanup, the two gates, the memory duty. |
|
|
38
|
+
| `fletbox-design` | The 25 numbered rules below — tokens, the scale, hierarchy, the four states, measured contrast, composition, the framework traps, the dated tells, density. |
|
|
39
|
+
| `fletbox-motion` | Whether a thing may move at all, and through which of `AnimatedBox`, `AnimatedText`, `ParallaxBox` or `animate`. |
|
|
40
|
+
| `fletbox-memory` | The `.fletbox/memory/` journal that hands progress from one AI to the next. |
|
|
41
|
+
|
|
29
42
|
| Home | What it holds |
|
|
30
43
|
| --- | --- |
|
|
31
|
-
|
|
|
44
|
+
| `skills/fletbox-design/SKILL.md` (framework) → `skills/…`, `.claude/skills/…`, `.qoder/skills/…` (app) | The rules as the agent reads them, in 25 numbered sections. The app's copies are generated; edit the framework file and regenerate, never the mirror. |
|
|
32
45
|
| `AGENTS.md` §4 of the app | The short version: one brand color per screen, no hex literals, spacing and radius only from the scale. |
|
|
33
46
|
| `src/tools/scale.js` in the framework | The tables themselves — `SPACING_SCALE`, `RADIUS_SCALE`, `TYPE_SCALE`, `TAP_MINIMUM`, `PILL`, `LABEL_TEXT`. |
|
|
34
|
-
| `bin/commands/checkUi.js` | The gate. It re-exports those same tables instead of keeping its own copy. |
|
|
47
|
+
| `bin/commands/checkUi.js` | The gate. It re-exports those same tables instead of keeping its own copy, and `scripts/check-skills.mjs` fails when a skill and the gate stop naming the same codes. |
|
|
35
48
|
|
|
36
49
|
That last line matters more than it looks. A gate that carries its own numbers
|
|
37
50
|
drifts from the widgets, and the app then gets told to be clean by values the
|
|
@@ -80,7 +93,7 @@ The framework keeps this honest with its own gate, `scripts/check-widget-scale.m
|
|
|
80
93
|
(part of `npm test`): a length written straight to `el.style.*` that is neither
|
|
81
94
|
`toREM(...)` nor measured geometry fails the build.
|
|
82
95
|
|
|
83
|
-
## The
|
|
96
|
+
## The 25 rules
|
|
84
97
|
|
|
85
98
|
When two of them conflict, take them in this order: **consistency · clarity ·
|
|
86
99
|
accessibility · usability · scalability · maintainability · conversion**.
|
|
@@ -104,10 +117,14 @@ accessibility · usability · scalability · maintainability · conversion**.
|
|
|
104
117
|
| 14 | Destructive actions designed last | A delete that is the closest, fastest, most colorful thing on the screen. |
|
|
105
118
|
| 15 | Reduce interaction cost | Taps, scrolls and keystrokes that carry no information. |
|
|
106
119
|
| 16 | Respect the platform | Fighting the browser's own conventions — back, scroll, text selection. |
|
|
107
|
-
| 17 |
|
|
108
|
-
| 18 |
|
|
109
|
-
| 19 |
|
|
110
|
-
| 20 |
|
|
120
|
+
| 17 | Composition starts as a sentence | A screen that begins as "a hero, then three cards, then a footer" instead of a decision the page carries. |
|
|
121
|
+
| 18 | The framework traps | `Container` assumed invisible, a `flex: 1` with no sibling, `alignItems: "center"` mistaken for centered text, absolute coordinates where a `Stack` belongs. |
|
|
122
|
+
| 19 | The dated tells | An eyebrow label, `01 · 02 · 03`, glass everywhere, resting shadows, a hairline `Divider` under every row, copy that says "seamless". |
|
|
123
|
+
| 20 | Density is one dial | Two rhythms in one screen — a gap, a padding and a body size chosen three different times. |
|
|
124
|
+
| 21 | The review | Shipping before reading your own diff as the user. |
|
|
125
|
+
| 22 | Where these books are wrong | Following a guideline that measurement disagrees with. |
|
|
126
|
+
| 23 | What no checker can see | Taste, hierarchy in the wild, whether the screen solves the problem. |
|
|
127
|
+
| 24 | The loop | Fixing the checker instead of the code, or leaving a rule you had to break undocumented. |
|
|
111
128
|
|
|
112
129
|
## What `flet-box check-ui` proves
|
|
113
130
|
|
|
@@ -123,12 +140,12 @@ judging yours. Each finding carries a code, and the code maps to a rule above.
|
|
|
123
140
|
| `OFF_SCALE_SPACING` | 07 | A padding, margin, gap or size off the spacing scale — including inside a `"12px 20px"` shorthand. |
|
|
124
141
|
| `OFF_SCALE_RADIUS` | 03 | A corner radius that is not a scale step. |
|
|
125
142
|
| `OFF_SCALE_TYPE` | 08 | A font size off the type scale. |
|
|
126
|
-
| `SMALL_TAP_TARGET` |
|
|
143
|
+
| `SMALL_TAP_TARGET` | 03 | A pressable widget under the Fitts floor, including a bare `Icon` with `onPress`. The floor is a scale value, so rule 03 owns it. |
|
|
127
144
|
| `LOW_CONTRAST` | 11 | Text measured below AA against the fill it actually sits on. |
|
|
128
145
|
| `UNLABELED_FIELD` | 13 | An `Input` or `Dropdown` with neither a `label` nor a `placeholder`. |
|
|
129
|
-
| `UNLABELED_TOGGLE` |
|
|
146
|
+
| `UNLABELED_TOGGLE` | 11 | A `Switch`, `Checkbox` or `Radio` with nothing to say what it toggles. |
|
|
130
147
|
| `DESTRUCTIVE_COLOR` | 14 | A delete/remove verb rendered in the brand fill instead of the danger one. |
|
|
131
|
-
| `UNREADABLE` |
|
|
148
|
+
| `UNREADABLE` | 00 | A file the scanner could not parse, reported rather than skipped — and nothing else in that file was judged. |
|
|
132
149
|
|
|
133
150
|
### Warnings (fail with `--strict`)
|
|
134
151
|
|
|
@@ -140,17 +157,17 @@ judging yours. Each finding carries a code, and the code maps to a rule above.
|
|
|
140
157
|
| `HAND_MIXED_COLOR` | 03 | `colors.primary + "22"` — a one-off shade no other screen can reuse. |
|
|
141
158
|
| `DEAD_ELEVATION` | 10 | A numeric `elevation` on a widget that never reads it: CSS drops the bare number and the box stays flat in silence. |
|
|
142
159
|
| `IMAGE_NO_ALT` | 11 | An `Image` with no `alt` — `alt: ""` is a decision, a missing prop is an oversight. |
|
|
143
|
-
| `ICON_ONLY_CONTROL` |
|
|
160
|
+
| `ICON_ONLY_CONTROL` | 11 | A pressable glyph with no name; wrap it in `Tooltip({ text, child })`. |
|
|
144
161
|
| `CENTERED_BODY_TEXT` | 08 | A paragraph centered; a paragraph needs a left edge to find the next line. |
|
|
145
|
-
| `GENERIC_ACTION_LABEL` |
|
|
162
|
+
| `GENERIC_ACTION_LABEL` | 14 | "OK", "Submit", "Click here" — a label that says nothing about what pressing it does. |
|
|
146
163
|
| `CONFIRM_ORDER` | 14 | A destructive button placed before Cancel in the same row. |
|
|
147
|
-
| `UNCONSTRAINED_FORM_WIDTH` |
|
|
164
|
+
| `UNCONSTRAINED_FORM_WIDTH` | 13 | A form block whose fields run to the full width of a desktop window. |
|
|
148
165
|
|
|
149
166
|
### Informational
|
|
150
167
|
|
|
151
168
|
| Code | Rule | What it says |
|
|
152
169
|
| --- | --- | --- |
|
|
153
|
-
| `SMALL_PRESET` |
|
|
170
|
+
| `SMALL_PRESET` | 03 | `size: "small"` on a control that is the screen's main action (~30px). |
|
|
154
171
|
| `CROWDED_FORM` | 06 | Many fields in one file: group them, or split the task. |
|
|
155
172
|
| `LIST_WITHOUT_STATE` | 12 | A list with no loading, empty or failed state in this file. |
|
|
156
173
|
| `MULTIPLE_PRIMARY_ACTIONS` | 04 | Several filled buttons on one screen. |
|
|
@@ -190,7 +207,8 @@ right twice, it is a defect in the scale, not in the app.
|
|
|
190
207
|
|
|
191
208
|
`check-ui` has no eyes. It cannot tell you that the screen is ugly, that the
|
|
192
209
|
hierarchy reads wrong at a glance, or that the flow does not solve the user's
|
|
193
|
-
problem. Those are rules 17
|
|
210
|
+
problem. Those are rules 17, 19, 21 and 23 — composition, the tells, the review
|
|
211
|
+
and this section — and they are the ones that need a person.
|
|
194
212
|
Run the gate, then open the page.
|
|
195
213
|
|
|
196
214
|
## Related pages
|
|
@@ -331,6 +331,37 @@ A PWA needs:
|
|
|
331
331
|
|
|
332
332
|
PWA installation depends on browser and platform support.
|
|
333
333
|
|
|
334
|
+
### The browser chrome follows the theme
|
|
335
|
+
|
|
336
|
+
Once installed, Android and iOS paint two more surfaces you do not control from
|
|
337
|
+
CSS: the status bar at the top and the navigation bar at the bottom. Chrome takes
|
|
338
|
+
both from `<meta name="theme-color">` in the document — a value it reads once per
|
|
339
|
+
page, unless the page rewrites it.
|
|
340
|
+
|
|
341
|
+
FletBox rewrites it. Every `setTheme`, `registerPalette` and system-preference
|
|
342
|
+
change updates that single meta tag with the live `colors.surface`, the color the
|
|
343
|
+
`AppBar` and the `BottomNavigation` are painted with, so the bars meet the app
|
|
344
|
+
instead of sitting against it. It also sets `color-scheme` on the root element,
|
|
345
|
+
which is what tells the operating system to draw dark scrollbars, dark form
|
|
346
|
+
controls and light status-bar glyphs on a dark page.
|
|
347
|
+
|
|
348
|
+
That means the colors in `manifest.json` are only the **splash screen** — the
|
|
349
|
+
plate shown while the app boots:
|
|
350
|
+
|
|
351
|
+
```json
|
|
352
|
+
{
|
|
353
|
+
"theme_color": "#18181b",
|
|
354
|
+
"background_color": "#18181b"
|
|
355
|
+
}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
Leave them at the brand color generated by `flet-box create` (the dark palette's
|
|
359
|
+
surface) and let the runtime handle the rest. There is no manifest field for a
|
|
360
|
+
per-theme bar color, and an installed app keeps the manifest copy it was
|
|
361
|
+
installed with, so editing these two lines does not recolor a home-screen icon
|
|
362
|
+
that is already there — reinstall, or let the first paint of the new version
|
|
363
|
+
update the document.
|
|
364
|
+
|
|
334
365
|
## Desktop options
|
|
335
366
|
|
|
336
367
|
Capacitor targets Android and iOS. For desktop packaging, consider a desktop shell such as Electron or Tauri around the same `dist` output.
|
package/docs/tools/theme.md
CHANGED
|
@@ -122,6 +122,7 @@ runApp(ThemeProvider({ children: ThemedApp() }), "root");
|
|
|
122
122
|
## Notes
|
|
123
123
|
|
|
124
124
|
- The shared palette tokens are updated across all widgets when you switch themes; widgets referencing `colors.*` at build time pick up the active palette.
|
|
125
|
+
- Switching a theme also repaints the browser's own chrome: the `<meta name="theme-color">` the installed PWA takes for its status and navigation bars, and the root `color-scheme` that decides how the OS draws scrollbars and form controls. Both read the live palette, so an app that changes `colors.surface` changes its system bars with it — see [Mobile and platforms](../guides/mobile-and-platforms.md#the-browser-chrome-follows-the-theme).
|
|
125
126
|
- `colors.glass` is genuinely see-through: its contrast depends on whatever is behind it, so use it over photography or gradients with a scrim, and keep body copy off the most colourful part of the backdrop. The dark token is a dark pane, not white glass.
|
|
126
127
|
- `watchSystemTheme()` and `applySystemTheme()` read `prefers-color-scheme`; both return/need cleanup to release listeners.
|
|
127
128
|
- `subscribeTheme(callback)` fires with the new palette object — remember to unsubscribe when a feature is destroyed.
|
package/docs/widget/README.md
CHANGED
|
@@ -13,6 +13,8 @@ If you have never used FletBox, begin with [Start here](START_HERE.md), then fol
|
|
|
13
13
|
|
|
14
14
|
Related guides: [Build your first FletBox app](../guides/app-templates.md) · [Routing with FletBox](../guides/router.md) · [FletBox CLI](../cli/README.md).
|
|
15
15
|
|
|
16
|
+
Every page here has a live twin: **[the widget gallery](https://kuko53348.github.io/flet-box-widgets-exemples/)** renders each example in the browser and prints the call that made it under the result, so you can read a property table and see the same prop move something.
|
|
17
|
+
|
|
16
18
|
## The reading path
|
|
17
19
|
|
|
18
20
|
### Chapter 1 · First steps: the core mental model
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flet-box",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Declarative, zero-dependency UI framework in vanilla JS — ship web, PWA, Android and iOS from one codebase",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"dev": "node bin/cli.js run --hot",
|
|
20
20
|
"build": "node bin/cli.js createBundle",
|
|
21
21
|
"release": "node bin/cli.js release",
|
|
22
|
-
"test": "node scripts/check-widgets.mjs && node scripts/check-widget-scale.mjs && node scripts/check-prop-registry.mjs && node scripts/check-docs-props.mjs && node scripts/check-api-surface.mjs && node scripts/check-api-propscan.mjs && node scripts/check-router-base.mjs && node scripts/check-clean-ui.mjs && node scripts/check-ota-assets.mjs && node scripts/check-pwa-shell.mjs && node scripts/check-cli-install.mjs && python3 tools/snippets-creator-flet-box/build_snippets.py --check && node scripts/check-snippets.mjs",
|
|
22
|
+
"test": "node scripts/check-widgets.mjs && node scripts/check-widget-scale.mjs && node scripts/check-prop-registry.mjs && node scripts/check-docs-props.mjs && node scripts/check-api-surface.mjs && node scripts/check-api-propscan.mjs && node scripts/check-router-base.mjs && node scripts/check-clean-ui.mjs && node scripts/check-skills.mjs && node scripts/check-ota-assets.mjs && node scripts/check-pwa-shell.mjs && node scripts/check-cli-install.mjs && python3 tools/snippets-creator-flet-box/build_snippets.py --check && node scripts/check-snippets.mjs",
|
|
23
23
|
"test:browser": "node scripts/run-browser-tests.mjs"
|
|
24
24
|
},
|
|
25
25
|
"keywords": [
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"bin/",
|
|
54
54
|
"src/",
|
|
55
55
|
"docs/",
|
|
56
|
+
"skills/",
|
|
56
57
|
"README.md",
|
|
57
58
|
"LICENSE"
|
|
58
59
|
],
|