staffa 0.4.0 → 0.4.1
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 +29 -22
- package/dist/components/buttonGroup.d.ts +3 -3
- package/dist/components/buttonGroup.js +3 -3
- package/dist/components/menu.d.ts +1 -1
- package/dist/components/menu.js +1 -1
- package/package.json +1 -1
- package/src/components/buttonGroup.ts +3 -3
- package/src/components/menu.ts +1 -1
package/README.md
CHANGED
|
@@ -8,21 +8,19 @@ import * as S from "staffa";
|
|
|
8
8
|
|
|
9
9
|
const $user = A.proxy({ name: "", email: "" });
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
});
|
|
11
|
+
S.main({
|
|
12
|
+
title: "Sign up",
|
|
13
|
+
maxWidth: "40rem",
|
|
14
|
+
content: () => {
|
|
15
|
+
S.form({
|
|
16
|
+
submit: () => console.log(A.unproxy($user)),
|
|
17
|
+
content: () => {
|
|
18
|
+
S.textline({ label: "Name", required: true, bind: A.ref($user, "name") });
|
|
19
|
+
S.textline({ label: "Email", type: "email", bind: A.ref($user, "email") });
|
|
20
|
+
},
|
|
21
|
+
actions: () => S.button({ content: "Create account", type: "submit" }),
|
|
22
|
+
});
|
|
23
|
+
},
|
|
26
24
|
});
|
|
27
25
|
```
|
|
28
26
|
|
|
@@ -43,7 +41,7 @@ Aberdeen is a peer dependency. Staffa is published as ESM with TypeScript types.
|
|
|
43
41
|
Every component takes a single typed options object and draws DOM via Aberdeen. No classes, no web components. The `S` object collects all component functions:
|
|
44
42
|
|
|
45
43
|
```ts
|
|
46
|
-
S.button({
|
|
44
|
+
S.button({ content: "Save", disabled: false });
|
|
47
45
|
S.box({ header: "Settings", content: () => { ... } });
|
|
48
46
|
```
|
|
49
47
|
|
|
@@ -52,7 +50,7 @@ S.box({ header: "Settings", content: () => { ... } });
|
|
|
52
50
|
All components get their options in a typed object. The object may be an Aberdeen proxy, if you want to update the component in-place.
|
|
53
51
|
|
|
54
52
|
```ts
|
|
55
|
-
const $btn = A.proxy({
|
|
53
|
+
const $btn = A.proxy({ content: "Save", disabled: false });
|
|
56
54
|
S.button($btn);
|
|
57
55
|
// ...later:
|
|
58
56
|
$btn.disabled = true; // button updates instantly
|
|
@@ -63,7 +61,7 @@ $btn.disabled = true; // button updates instantly
|
|
|
63
61
|
Anywhere a component takes content, a `label`, `header`, button `text`, dialog body, etc, you can pass either a string or a `() => void` draw function. Strings render as **rich text**: `*italic*`, `**bold**`, `` `code` ``, `[link](/path)`. All text is safely escaped.
|
|
64
62
|
|
|
65
63
|
```ts
|
|
66
|
-
S.button({
|
|
64
|
+
S.button({ content: "Save **now**" });
|
|
67
65
|
S.box({ header: "See the [docs](/docs)", content: () => { ... } });
|
|
68
66
|
```
|
|
69
67
|
|
|
@@ -78,7 +76,7 @@ Staffa builds on **surfaces**: elements marked with `.s-s` that have their own b
|
|
|
78
76
|
Components are built from these (`S.button` is a `.s-s.primary.filled`, `S.box` a `.s-s.panel`, etc.). Because component options include an optional `attrs` string, which has Aberdeen `A()` string semantics, you can easily override it:
|
|
79
77
|
|
|
80
78
|
```ts
|
|
81
|
-
S.button({
|
|
79
|
+
S.button({ content: "Delete", attrs: ".danger" });
|
|
82
80
|
S.box({ attrs: ".raised.outlined", content: () => { ... } });
|
|
83
81
|
```
|
|
84
82
|
|
|
@@ -120,7 +118,7 @@ If you need further customization, just add some CSS to override the default sty
|
|
|
120
118
|
A.insertGlobalCss({".s-s.my-surface": "--s-a:white --s-b:#ef6b00"});
|
|
121
119
|
|
|
122
120
|
S.button({
|
|
123
|
-
|
|
121
|
+
content: "You'll want to click me",
|
|
124
122
|
attrs: ".my-surface",
|
|
125
123
|
click: () => S.alert("Good work!", {attrs: ".my-surface"})
|
|
126
124
|
});
|
|
@@ -184,7 +182,7 @@ import { sparkles, bell } from "staffa/icons.js";
|
|
|
184
182
|
Each icon is a draw function usable anywhere a slot is accepted (e.g. a button `icon`), or called directly. Customize per call, or globally via `setDefaults()`:
|
|
185
183
|
|
|
186
184
|
```ts
|
|
187
|
-
S.button({
|
|
185
|
+
S.button({ content: "Save", icon: bell });
|
|
188
186
|
sparkles({ size: "1.5em", color: "var(--s-primary)", strokeWidth: 1.5 });
|
|
189
187
|
```
|
|
190
188
|
|
|
@@ -280,4 +278,13 @@ To use this, it is recommended to symlink the skill into your project's `.claude
|
|
|
280
278
|
```sh
|
|
281
279
|
mkdir -p .claude/skills
|
|
282
280
|
ln -s ../../node_modules/staffa/skill .claude/skills/staffa
|
|
283
|
-
```
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
## Breaking changes
|
|
284
|
+
|
|
285
|
+
- **0.4**
|
|
286
|
+
- There is no default export anymore: replace `import S from "staffa"` with `import * as S from "staffa"`.
|
|
287
|
+
- `S.button` no longer has a `text` option: use `content` instead (it accepts a string or a draw function).
|
|
288
|
+
- The `Content` type is gone: use `Slot` instead. The `Styling` type alias is now exported as `Attributes`.
|
|
289
|
+
- `S.buttonChooser` uses `undefined` instead of `null` for "nothing selected" (in `bind` and with `allowDeselect`).
|
|
290
|
+
|
|
@@ -22,9 +22,9 @@ export interface ButtonGroupOptions extends ContentOptions {
|
|
|
22
22
|
* @example
|
|
23
23
|
* ```ts
|
|
24
24
|
* S.buttonGroup({ buttons: [
|
|
25
|
-
* {
|
|
26
|
-
* {
|
|
27
|
-
* {
|
|
25
|
+
* { content: "Day", attrs: ".neutral .outlined" },
|
|
26
|
+
* { content: "Week", attrs: ".neutral .outlined" },
|
|
27
|
+
* { content: "Month", attrs: ".neutral .outlined" },
|
|
28
28
|
* ]});
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
@@ -25,9 +25,9 @@ A.insertGlobalCss({
|
|
|
25
25
|
* @example
|
|
26
26
|
* ```ts
|
|
27
27
|
* S.buttonGroup({ buttons: [
|
|
28
|
-
* {
|
|
29
|
-
* {
|
|
30
|
-
* {
|
|
28
|
+
* { content: "Day", attrs: ".neutral .outlined" },
|
|
29
|
+
* { content: "Week", attrs: ".neutral .outlined" },
|
|
30
|
+
* { content: "Month", attrs: ".neutral .outlined" },
|
|
31
31
|
* ]});
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
@@ -106,7 +106,7 @@ export declare function showFloatingMenu(opts: FloatingMenuOptions): () => void;
|
|
|
106
106
|
* @example
|
|
107
107
|
* ```ts
|
|
108
108
|
* S.menuButton({
|
|
109
|
-
* button: {
|
|
109
|
+
* button: { content: "Actions", attrs: ".neutral .outlined" },
|
|
110
110
|
* items: [
|
|
111
111
|
* { label: "Edit", icon: () => A("#✎"), click: () => edit() },
|
|
112
112
|
* { separator: true },
|
package/dist/components/menu.js
CHANGED
|
@@ -187,7 +187,7 @@ export function showFloatingMenu(opts) {
|
|
|
187
187
|
* @example
|
|
188
188
|
* ```ts
|
|
189
189
|
* S.menuButton({
|
|
190
|
-
* button: {
|
|
190
|
+
* button: { content: "Actions", attrs: ".neutral .outlined" },
|
|
191
191
|
* items: [
|
|
192
192
|
* { label: "Edit", icon: () => A("#✎"), click: () => edit() },
|
|
193
193
|
* { separator: true },
|
package/package.json
CHANGED
|
@@ -44,9 +44,9 @@ A.insertGlobalCss({
|
|
|
44
44
|
* @example
|
|
45
45
|
* ```ts
|
|
46
46
|
* S.buttonGroup({ buttons: [
|
|
47
|
-
* {
|
|
48
|
-
* {
|
|
49
|
-
* {
|
|
47
|
+
* { content: "Day", attrs: ".neutral .outlined" },
|
|
48
|
+
* { content: "Week", attrs: ".neutral .outlined" },
|
|
49
|
+
* { content: "Month", attrs: ".neutral .outlined" },
|
|
50
50
|
* ]});
|
|
51
51
|
* ```
|
|
52
52
|
*/
|
package/src/components/menu.ts
CHANGED
|
@@ -260,7 +260,7 @@ export function showFloatingMenu(opts: FloatingMenuOptions): () => void {
|
|
|
260
260
|
* @example
|
|
261
261
|
* ```ts
|
|
262
262
|
* S.menuButton({
|
|
263
|
-
* button: {
|
|
263
|
+
* button: { content: "Actions", attrs: ".neutral .outlined" },
|
|
264
264
|
* items: [
|
|
265
265
|
* { label: "Edit", icon: () => A("#✎"), click: () => edit() },
|
|
266
266
|
* { separator: true },
|