@gemboss/ui 0.57.0 → 0.59.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 +221 -0
- package/README.md +238 -0
- package/catalog/editor.html +1 -1
- package/catalog/index.html +4 -4
- package/gemboss-ui.css +3 -3
- package/node/skill-flow/layout.js +194 -0
- package/node/skill-flow/model.js +279 -0
- package/package.json +31 -1
- package/parts/components.css +1 -1
- package/parts/core.css +1 -1
- package/parts/shell.css +1 -1
- package/src/assistant/host.tsx +21 -5
- package/src/assistant/sessions.tsx +36 -18
- package/src/auth-sso-plain.js +1 -1
- package/src/auth.tsx +2 -0
- package/src/collections.css +1 -1
- package/src/collections.tsx +5 -2
- package/src/dialog.tsx +4 -1
- package/src/editor/controls.tsx +18 -7
- package/src/editor/index.ts +1 -1
- package/src/editor/picker.tsx +9 -3
- package/src/editor/repeater.tsx +26 -14
- package/src/editor/swatch.ts +86 -0
- package/src/editor-color.css +1 -1
- package/src/editor-picker.css +1 -1
- package/src/editor-plain.js +1 -1
- package/src/editor-popover.css +1 -1
- package/src/editor.css +1 -1
- package/src/index.ts +17 -0
- package/src/job-card.css +1 -0
- package/src/job-card.tsx +130 -0
- package/src/list-page.css +1 -1
- package/src/members-data.ts +278 -0
- package/src/members.css +1 -0
- package/src/members.tsx +868 -0
- package/src/menu-extras.css +1 -1
- package/src/menu-select.css +1 -0
- package/src/menu.tsx +39 -12
- package/src/narration.css +1 -0
- package/src/save-bar.css +1 -0
- package/src/save-bar.tsx +50 -0
- package/src/skill-card.css +1 -0
- package/src/skill-card.tsx +146 -0
- package/src/skill-flow/canvas.tsx +593 -0
- package/src/skill-flow/index.ts +12 -0
- package/src/skill-flow/layout.ts +238 -0
- package/src/skill-flow/model.ts +412 -0
- package/src/skill-flow.css +1 -0
- package/src/skill-stats.css +1 -0
- package/src/skill-stats.tsx +213 -0
- package/src/skill-view.css +1 -0
- package/src/skill-view.tsx +249 -0
- package/src/theme-dark.css +1 -1
package/src/menu-extras.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.ui-menu__busy{width:16px;height:16px;box-sizing:border-box;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:ui-menu-busy .8s linear infinite}@keyframes ui-menu-busy{to{transform:rotate(360deg)}}@media (prefers-reduced-motion: reduce){.ui-menu__busy{animation-duration:2s}}.ui-menu__list{max-width:calc(100vw - 16px)}.ui-menu__item{flex-wrap:wrap}.ui-menu__hint{max-width:32ch;white-space:normal;text-align:right}.ui-menu:not([open])>.ui-menu__list{display:none}.ui-menu__check{display:inline-flex;flex:none;width:16px;height:16px;visibility:hidden}.ui-menu__item[aria-checked=true]>.ui-menu__check{visibility:visible}.ui-menu__item[aria-checked=true]{font-weight:600}.ui-menu__group-title{padding:6px 6px 2px;color:var(--ui-text-muted);font-size:var(--ui-fs-caption);line-height:16px}@media (pointer: coarse),(max-width: 47.9975em){.ui-menu__group-title{padding:8px 16px 4px}}
|
|
1
|
+
.ui-menu__busy{width:16px;height:16px;box-sizing:border-box;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:ui-menu-busy .8s linear infinite}@keyframes ui-menu-busy{to{transform:rotate(360deg)}}@media (prefers-reduced-motion: reduce){.ui-menu__busy{animation-duration:2s}}.ui-menu__list{max-width:calc(100vw - 16px)}.ui-menu__item{flex-wrap:wrap}.ui-menu__hint{max-width:32ch;white-space:normal;text-align:right}.ui-menu:not([open])>.ui-menu__list{display:none}.ui-menu__check{display:inline-flex;flex:none;width:16px;height:16px;visibility:hidden}.ui-menu__item[aria-checked=true]>.ui-menu__check{visibility:visible}.ui-menu__item[aria-checked=true]{font-weight:600}.ui-menu__group-title{padding:6px 6px 2px;color:var(--ui-text-muted);font-size:var(--ui-fs-caption);line-height:16px}@media (pointer: coarse),(max-width: 47.9975em){.ui-menu__group-title{padding:8px 16px 4px}}.ui-menu__trigger{height:auto;min-height:24px;padding:0;gap:4px;border-color:transparent;background:transparent;color:var(--gemboss-accent-strong, #3a44de);font-size:var(--ui-fs-body);font-weight:600}.ui-menu__trigger:hover{background:transparent;text-decoration:underline}.ui-menu__trigger-icon,.ui-menu__icon{display:inline-flex;flex:none;align-items:center;justify-content:center}.ui-menu__trigger-icon svg{width:16px;height:16px;fill:currentColor}.ui-menu__icon{width:20px;color:var(--ui-text-muted)}.ui-menu__icon svg{width:16px;height:16px;fill:currentColor}.ui-menu__text{display:flex;flex:1 1 auto;flex-direction:column;min-width:0;padding-block:2px;white-space:normal}.ui-menu__label{overflow-wrap:anywhere}.ui-menu__desc{color:var(--ui-text-muted);font-size:var(--ui-fs-caption);line-height:16px}.ui-menu__group-title--overline{padding-top:8px;font-size:11px;font-weight:600;letter-spacing:.06em;text-transform:uppercase}@media (pointer: coarse),(max-width: 47.9975em){.ui-menu__trigger{min-height:44px}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ui-menu--select{display:block}.ui-menu__select{display:flex;align-items:center;gap:8px;min-height:32px;padding:0 8px 0 12px;box-sizing:border-box;border:1px solid var(--gemboss-field-line);border-radius:var(--ui-radius-sm);background:var(--gemboss-field-bg);color:var(--gemboss-field-ink);font-size:var(--ui-fs-body)}.ui-menu__select:hover{border-color:var(--gemboss-field-line-hover);background:var(--gemboss-field-bg-hover)}.ui-menu__select:focus-visible{outline:2px solid var(--ui-focus, #5661f5);outline-offset:1px}.ui-menu__choice{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ui-menu__chevron{flex:none;color:var(--ui-text-muted)}.ui-menu--select>.ui-menu__list{min-width:280px;max-width:min(420px,calc(100vw - 16px))}@media (pointer: coarse),(max-width: 47.9975em){.ui-menu__select{min-height:44px}}
|
package/src/menu.tsx
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
// goes on; one menu open at a time. Its CSS is its own file (./menu.css), so a surface without the core (the admin) draws it.
|
|
15
15
|
import "./menu.css";
|
|
16
16
|
import "./menu-extras.css";
|
|
17
|
+
import "./menu-select.css";
|
|
17
18
|
import React, { useEffect, useRef } from "react";
|
|
18
19
|
import { Icon } from "./icons";
|
|
19
20
|
import { canFloatMenus, floatMenu, listenForDetachedMenus, sinkMenu } from "./menu-layer";
|
|
@@ -21,10 +22,17 @@ import { chooseRow, closeMenu, focusRow, menuKeyDown, menuRows, openMenu, regist
|
|
|
21
22
|
|
|
22
23
|
/** The trigger is an icon button (`label` is its accessible name, and the menu's). `end` aligns the list to the right edge.
|
|
23
24
|
* `disabled`: the ⋯ takes no click and no key and leaves the Tab order (a row's work runs). `loading`: a ring in place of the
|
|
24
|
-
* dots, `aria-busy`, and disabled the same way (what it started runs: a rename, a duplicate).
|
|
25
|
-
|
|
25
|
+
* dots, `aria-busy`, and disabled the same way (what it started runs: a rename, a duplicate).
|
|
26
|
+
* `text` (04/11/2026): a text trigger instead, the words after `icon` in the link colour ("+ Add a condition"); the words are
|
|
27
|
+
* its name, `label` still names the list.
|
|
28
|
+
* `select` (04/11/2026, GemX New moment ubm-PZ-4w / 4t): a FIELD trigger instead, as wide as its column, the current choice and a
|
|
29
|
+
* chevron: a choice whose rows say more than an `<option>` can (parts, a mark, a line under the words, a row off with "Later").
|
|
30
|
+
* Named "label: choice" when the choice is words. */
|
|
31
|
+
export function Menu({ label, icon, text, select, end, children, className, disabled, loading }: {
|
|
26
32
|
label: string;
|
|
27
33
|
icon?: React.ReactNode;
|
|
34
|
+
text?: React.ReactNode;
|
|
35
|
+
select?: React.ReactNode;
|
|
28
36
|
end?: boolean;
|
|
29
37
|
children?: React.ReactNode;
|
|
30
38
|
className?: string;
|
|
@@ -66,15 +74,25 @@ export function Menu({ label, icon, end, children, className, disabled, loading
|
|
|
66
74
|
enter(el, "first");
|
|
67
75
|
};
|
|
68
76
|
return (
|
|
69
|
-
<details ref={ref} className={["ui-menu", end ? "ui-menu--end" : "", className ?? ""].filter(Boolean).join(" ")}
|
|
77
|
+
<details ref={ref} className={["ui-menu", end ? "ui-menu--end" : "", select !== undefined ? "ui-menu--select" : "", className ?? ""].filter(Boolean).join(" ")}
|
|
70
78
|
onKeyDown={(e) => { if (ref.current && !off) menuKeyDown(ref.current, e, { entry: enter }); }}
|
|
71
79
|
// Opened while off by anything but its button (find-in-page opens a closed details that holds a match, a script):
|
|
72
80
|
// closed again.
|
|
73
81
|
onToggle={(e) => { if (off && e.currentTarget.open) e.currentTarget.open = false; }}>
|
|
74
|
-
|
|
75
|
-
aria-
|
|
76
|
-
|
|
77
|
-
|
|
82
|
+
{select !== undefined ? (
|
|
83
|
+
<summary className="ui-menu__select" aria-label={typeof select === "string" ? `${label}: ${select}` : label} aria-haspopup="menu" onClick={onSummary}
|
|
84
|
+
aria-disabled={off || undefined} aria-busy={loading || undefined} tabIndex={off ? -1 : undefined}>
|
|
85
|
+
<span className="ui-menu__choice">{select}</span>
|
|
86
|
+
<svg className="ui-menu__chevron" viewBox="0 0 20 20" width="16" height="16" aria-hidden="true"><path d="M6 8l4 4 4-4" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" /></svg>
|
|
87
|
+
</summary>
|
|
88
|
+
) : (
|
|
89
|
+
<summary className={text ? "ui-btn ui-menu__trigger" : "ui-btn ui-btn--icon"} aria-label={text ? undefined : label} title={text ? undefined : label}
|
|
90
|
+
aria-haspopup="menu" onClick={onSummary} aria-disabled={off || undefined} aria-busy={loading || undefined} tabIndex={off ? -1 : undefined}>
|
|
91
|
+
{loading ? <span className="ui-menu__busy" aria-hidden="true" />
|
|
92
|
+
: text ? <>{icon ? <span className="ui-menu__trigger-icon" aria-hidden="true">{icon}</span> : null}{text}</>
|
|
93
|
+
: (icon ?? <Icon name="more" />)}
|
|
94
|
+
</summary>
|
|
95
|
+
)}
|
|
78
96
|
<div className="ui-menu__list gemboss-popover-surface" role="menu" aria-label={label}>{children}</div>
|
|
79
97
|
</details>
|
|
80
98
|
);
|
|
@@ -93,8 +111,12 @@ function enter(el: HTMLDetailsElement, which: "first" | "last"): void {
|
|
|
93
111
|
if (on) on.focus(); else focusRow(el, which);
|
|
94
112
|
}
|
|
95
113
|
|
|
96
|
-
export function MenuItem({ href, danger, hint, children, className, disabled, onClick, linkAs, checked, ...rest }: {
|
|
114
|
+
export function MenuItem({ href, danger, hint, icon, description, children, className, disabled, onClick, linkAs, checked, ...rest }: {
|
|
97
115
|
href?: string;
|
|
116
|
+
/** A mark before the label (04/11/2026). */
|
|
117
|
+
icon?: React.ReactNode;
|
|
118
|
+
/** A second line under the label, muted: what the row is, in a few words (04/11/2026, Audiences' "+ Add a condition"). */
|
|
119
|
+
description?: React.ReactNode;
|
|
98
120
|
/** A choice among others (in a MenuGroup): `menuitemradio`, a check before the one that is on. Left out: a plain row. */
|
|
99
121
|
checked?: boolean;
|
|
100
122
|
linkAs?: React.ElementType;
|
|
@@ -109,7 +131,10 @@ export function MenuItem({ href, danger, hint, children, className, disabled, on
|
|
|
109
131
|
const body = <>{checked === undefined ? null : <span className="ui-menu__check" aria-hidden="true"><Icon name="check" size={16} /></span>}
|
|
110
132
|
{/* A space before the hint, so its words are read apart from the row's ("Duplicate List is full", not "DuplicateList is
|
|
111
133
|
full"); the row is a flex box, which draws no space. */}
|
|
112
|
-
{
|
|
134
|
+
{icon ? <span className="ui-menu__icon" aria-hidden="true">{icon}</span> : null}
|
|
135
|
+
{/* The label over its description, a space between them for the same reason as the hint's. */}
|
|
136
|
+
{description ? <span className="ui-menu__text"><span className="ui-menu__label">{children}</span>{" "}<span className="ui-menu__desc">{description}</span></span> : children}
|
|
137
|
+
{hint ? <>{" "}<span className="ui-menu__hint">{hint}</span></> : null}</>;
|
|
113
138
|
// Every row closes its menu once chosen, a link too (a new tab, an anchor, a client router leave the page as it was).
|
|
114
139
|
// Focus is back on ⋯ before the row's handler runs (./menu-keys chooseRow).
|
|
115
140
|
const choose: React.MouseEventHandler<HTMLElement> = (e) => {
|
|
@@ -125,11 +150,13 @@ export function MenuItem({ href, danger, hint, children, className, disabled, on
|
|
|
125
150
|
}
|
|
126
151
|
|
|
127
152
|
/** Rows that are choices of one kind (Products' Auto-refresh: Daily, Off), named: `role="group"` with the title as its name,
|
|
128
|
-
* and the title shown above them. Its rows are MenuItems with `checked`.
|
|
129
|
-
|
|
153
|
+
* and the title shown above them. Its rows are MenuItems with `checked`. `overline` (04/11/2026): the title as a section's
|
|
154
|
+
* overline, small capitals, for a menu of actions in parts (Audiences' "+ Add a condition": known before the page shows,
|
|
155
|
+
* checked in the browser, from your apps, your own). */
|
|
156
|
+
export function MenuGroup({ title, overline, children }: { title: string; overline?: boolean; children?: React.ReactNode }) {
|
|
130
157
|
return (
|
|
131
158
|
<div className="ui-menu__group" role="group" aria-label={title}>
|
|
132
|
-
<div className="ui-menu__group-title" aria-hidden="true">{title}</div>
|
|
159
|
+
<div className={overline ? "ui-menu__group-title ui-menu__group-title--overline" : "ui-menu__group-title"} aria-hidden="true">{title}</div>
|
|
133
160
|
{children}
|
|
134
161
|
</div>
|
|
135
162
|
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.gemboss-narr-link{font:inherit;color:inherit;background:none;border:0;padding:0 4px;margin:0 -4px;border-radius:4px;text-align:start;cursor:pointer;min-height:24px}.gemboss-narr-link:hover,.gemboss-narr-link:focus-visible{text-decoration:underline;text-underline-offset:2px}.gemboss-narr-link:active{background:var(--gemboss-active-bg)}.gemboss-narr-link:focus-visible{outline:2px solid var(--ui-focus, #5661f5);outline-offset:0}.gemboss-narr-undo{margin-inline-start:auto;flex:0 0 auto;font:inherit;font-size:var(--gemboss-fs-caption);color:var(--gemboss-text-muted);background:none;border:0;padding:0 4px;border-radius:4px;min-height:24px;cursor:pointer;opacity:0;pointer-events:none}.gemboss-narr-row:hover .gemboss-narr-undo,.gemboss-narr-row:focus-within .gemboss-narr-undo,.gemboss-narr-undo[aria-busy=true]{opacity:1;pointer-events:auto}.gemboss-narr-undo:hover{color:var(--gemboss-text);text-decoration:underline;text-underline-offset:2px}.gemboss-narr-undo:active{background:var(--gemboss-active-bg)}.gemboss-narr-undo:focus-visible{outline:2px solid var(--ui-focus, #5661f5);outline-offset:0}.gemboss-narr-undo:disabled{cursor:default}.gemboss-narr-row:has(>.gemboss-narr-undo-said){flex-wrap:wrap}.gemboss-narr-undo-said{flex:1 0 100%;padding-inline-start:24px;font-size:var(--gemboss-fs-caption);color:var(--gemboss-text-muted)}@media (pointer: coarse),(max-width:47.9975em){.gemboss-narr-undo{opacity:1;pointer-events:auto;min-height:44px}}.gemboss-narr-plan{list-style:none;margin:0;padding:8px 12px;border:1px solid var(--gemboss-divider);border-radius:8px;background:var(--gemboss-surface, #fff)}.gemboss-narr-plan-head{margin:0 0 4px;font-size:var(--gemboss-fs-caption);font-weight:600;color:var(--gemboss-text)}.gemboss-narr-plan-count{font-weight:400;color:var(--gemboss-text-muted)}.gemboss-narr-plan-steps{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:4px}.gemboss-narr-plan-step{display:flex;gap:8px;align-items:baseline;font-size:var(--gemboss-fs-caption);color:var(--gemboss-text-muted)}.gemboss-narr-plan-step.done{color:var(--gemboss-text)}.gemboss-narr-plan-step.current{color:var(--gemboss-text);font-weight:600}.gemboss-narr-plan-mark{flex:0 0 16px;text-align:center}.gemboss-narr-plan-wait,.gemboss-narr-steer-note{font-weight:400;color:var(--gemboss-text-muted)}.gemboss-narr-row.steer.failed .gemboss-narr-steer-note{color:var(--gemboss-danger)}
|
package/src/save-bar.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ui-savebar{position:sticky;top:0;z-index:2;display:flex;flex-wrap:wrap;align-items:center;gap:8px;min-height:44px;box-sizing:border-box;padding:6px 8px 6px 16px;border-radius:var(--ui-radius-lg);background:var(--ui-text-strong);color:var(--ui-surface);font-weight:650}.ui-savebar__msg{min-width:0}.ui-savebar__error{min-width:0;font-weight:450;opacity:.85}.ui-savebar__actions{display:flex;align-items:center;gap:8px;margin-left:auto}.ui-savebar__btn{display:inline-flex;align-items:center;min-height:32px;padding:0 12px;border:1px solid color-mix(in srgb,var(--ui-surface) 30%,transparent);border-radius:var(--ui-radius-md);background:transparent;color:inherit;font:inherit;font-size:12px;font-weight:550;cursor:pointer}.ui-savebar__btn--save{border-color:var(--ui-surface);background:var(--ui-surface);color:var(--ui-text-strong)}.ui-savebar__btn:disabled{opacity:.6;cursor:default}.ui-savebar__btn:focus-visible{outline:2px solid var(--ui-surface);outline-offset:2px}@media (pointer: coarse){.ui-savebar__btn{min-height:44px}}
|
package/src/save-bar.tsx
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Save bar (unreleased, after 0.57.0; KIT-004, canvas frame-save-toast). The one bar for a form that holds what it has not saved: most
|
|
3
|
+
* screens write a draft as each field changes and need none, but a form saved on its own route (a plugin's service, GemSeel's box) keeps
|
|
4
|
+
* its edits until Save. It stands above the form while there is something to save, says so, and offers Discard beside Save; with
|
|
5
|
+
* nothing to save it is not drawn at all, so it never says "Saved" in place of a toast. What a press did is the surface's to say (a
|
|
6
|
+
* toast, whose ✕ dismisses it): the bar only holds the two buttons and, when the last Save was refused, the reason (`error`).
|
|
7
|
+
*
|
|
8
|
+
* The admin's Focus frame drew it first as its own part (`FocusSaveBar`, backlog/frame.md); this takes its place, same words, same
|
|
9
|
+
* behaviour: both buttons are off while a save runs, and Save reads "Saving…".
|
|
10
|
+
*
|
|
11
|
+
* Presentational and controlled: no state of its own, so it renders on the server. Its stylesheet travels with it (`save-bar.css`, own
|
|
12
|
+
* entry; `@gemboss/ui/save-bar.css` for a plain-HTML surface that writes the same classes).
|
|
13
|
+
*/
|
|
14
|
+
import "./save-bar.css";
|
|
15
|
+
import React, { type ReactNode } from "react";
|
|
16
|
+
|
|
17
|
+
const cx = (...p: Array<string | false | null | undefined>) => p.filter(Boolean).join(" ");
|
|
18
|
+
|
|
19
|
+
export interface SaveBarProps {
|
|
20
|
+
/** Something waits to be saved. False draws nothing. */
|
|
21
|
+
dirty: boolean;
|
|
22
|
+
/** A save is running: both buttons are off, and Save says so. */
|
|
23
|
+
saving?: boolean;
|
|
24
|
+
onSave: () => void;
|
|
25
|
+
onDiscard: () => void;
|
|
26
|
+
/** The words on the left, and the region's name. Default "Unsaved changes". */
|
|
27
|
+
message?: string;
|
|
28
|
+
saveLabel?: string;
|
|
29
|
+
discardLabel?: string;
|
|
30
|
+
/** Why the last Save did not take, in the person's words ("Only the Owner or a Manager can change this."). Said in the bar, as an
|
|
31
|
+
* alert, until the surface clears it; the edits stay, so Save can be pressed again. */
|
|
32
|
+
error?: ReactNode;
|
|
33
|
+
className?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function SaveBar({ dirty, saving = false, onSave, onDiscard, message = "Unsaved changes", saveLabel = "Save", discardLabel = "Discard", error, className }: SaveBarProps) {
|
|
37
|
+
if (!dirty) return null;
|
|
38
|
+
return (
|
|
39
|
+
<div className={cx("ui-savebar", className)} role="region" aria-label={message}>
|
|
40
|
+
<span className="ui-savebar__msg">{message}</span>
|
|
41
|
+
{error ? <span className="ui-savebar__error" role="alert">{error}</span> : null}
|
|
42
|
+
<span className="ui-savebar__actions">
|
|
43
|
+
<button type="button" className="ui-savebar__btn" disabled={saving} onClick={onDiscard}>{discardLabel}</button>
|
|
44
|
+
<button type="button" className="ui-savebar__btn ui-savebar__btn--save" disabled={saving} aria-busy={saving || undefined} onClick={onSave}>
|
|
45
|
+
{saving ? "Saving…" : saveLabel}
|
|
46
|
+
</button>
|
|
47
|
+
</span>
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ui-skillgroup{display:grid;gap:12px;min-width:0}.ui-skillgroup+.ui-skillgroup{margin-top:28px}.ui-skillgroup__head{display:grid;gap:2px}.ui-skillgroup__title{margin:0;font-size:14px;line-height:20px;font-weight:650;color:var(--gemboss-text, #1b1c1e)}.ui-skillgroup__mark{display:inline-block;width:10px;height:10px;margin-right:8px;border-radius:3px}.ui-skillgroup__aside{margin-left:8px;font-size:12px;font-weight:500;color:var(--gemboss-text-muted, #686b71)}.ui-skillgroup__line{margin:0;font-size:13px;line-height:19px;color:var(--gemboss-text-muted, #686b71)}.ui-skillgroup__grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,var(--ui-skillgroup-min, 220px)),1fr));gap:12px}.ui-skillcard{display:flex;flex-direction:column;align-items:stretch;gap:6px;min-width:0;box-sizing:border-box;margin:0;padding:14px;border:1px solid var(--gemboss-divider, #e5e7ea);border-radius:12px;background:var(--gemboss-surface, #ffffff);color:var(--gemboss-text, #1b1c1e);font:inherit;text-align:left;text-decoration:none;cursor:pointer;transition:border-color .12s ease,box-shadow .12s ease}.ui-skillcard:hover,.ui-skillcard:active{border-color:var(--gemboss-chip-line, #cfd6ce);background:var(--gemboss-surface, #ffffff);color:var(--gemboss-text, #1b1c1e);box-shadow:var(--gemboss-shadow-resting, 0 1px 2px rgba(31, 30, 29, .04), 0 2px 6px rgba(31, 30, 29, .06))}.ui-skillcard:focus-visible{outline:2px solid var(--ui-focus, #5661f5);outline-offset:2px}@media (prefers-reduced-motion: reduce){.ui-skillcard{transition:none}}.ui-skillcard__top{display:flex;align-items:flex-start;justify-content:space-between;gap:8px;margin-bottom:4px}.ui-skillcard__icon{display:grid;place-items:center;width:32px;height:32px;border-radius:8px;background:var(--gemboss-accent-soft, #eef0fe);color:var(--gemboss-accent, #5661f5)}.ui-skillcard__icon svg{width:18px;height:18px}.ui-skillcard__art{flex:none;display:grid;place-items:center;min-width:var(--ui-skillcard-art, auto);min-height:var(--ui-skillcard-art, auto)}.ui-skillcard__badge{padding:0 8px;border-radius:999px;font-size:11px;line-height:20px;font-weight:600;background:var(--gemboss-accent-soft, #eef0fe);color:var(--gemboss-accent-strong, #3a44de)}.ui-skillcard__badge--ready{background:var(--gemboss-success-soft, #e3f1df);color:var(--gemboss-success-strong, #0a6a4c)}.ui-skillcard__badge--beta{background:var(--gemboss-warning-soft, #fff8e0);color:var(--gemboss-warning, #9a6700)}.ui-skillcard__badge--plain{background:var(--gemboss-primary-soft, #f2f3f5);color:var(--gemboss-text-muted, #686b71)}.ui-skillcard__title{font-size:14px;line-height:19px;font-weight:600}.ui-skillcard__aside{font-size:.82em}.ui-skillcard__line{font-size:12px;line-height:18px;color:var(--gemboss-text-muted, #686b71)}.ui-skillcard__foot{display:flex;flex-wrap:wrap;align-items:baseline;justify-content:space-between;gap:2px 8px;margin-top:auto;padding-top:6px}.ui-skillcard__about{display:flex;flex-wrap:wrap;align-items:center;gap:4px 10px;min-width:0}.ui-skillcard__meta{font:500 11px/16px ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--gemboss-text-muted, #686b71)}.ui-skillcard__extra{display:inline-flex;flex-wrap:wrap;align-items:center;gap:4px 10px;font-size:12px;line-height:16px;color:var(--gemboss-text-muted, #686b71)}.ui-skillcard__stat{font-size:12px;line-height:16px;color:var(--gemboss-text-muted, #686b71);font-variant-numeric:tabular-nums}.ui-skillcard--split{padding:0;gap:0;overflow:hidden;cursor:auto}.ui-skillcard__open{display:flex;flex-direction:column;gap:6px;flex:1 1 auto;min-width:0;margin:0;padding:14px;border:0;border-radius:0;background:none;color:inherit;font:inherit;text-align:left;text-decoration:none;cursor:pointer}.ui-skillcard__open:hover,.ui-skillcard__open:active{background:none;color:inherit}.ui-skillcard__open:focus-visible{outline:2px solid var(--ui-focus, #5661f5);outline-offset:-2px}.ui-skillcard__bar{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;padding:10px 14px 12px;border-top:1px solid var(--gemboss-divider, #e5e7ea)}.ui-skillcard__bar>.ui-skillcard__about{flex:1 1 0}.ui-skillcard__bar .ui-skillcard__meta{white-space:nowrap}.ui-skillcard__actions{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-left:auto}.ui-skillcard--lg{gap:12px;padding:18px 18px 14px;border-radius:16px}.ui-skillcard--lg.ui-skillcard--split{padding:0}.ui-skillcard--lg .ui-skillcard__open{gap:12px;padding:18px 18px 14px}.ui-skillcard--lg .ui-skillcard__bar{padding:12px 18px 14px}.ui-skillcard--lg .ui-skillcard__top{margin-bottom:0}.ui-skillcard--lg .ui-skillcard__title{font-size:16px;line-height:22px}.ui-skillcard--lg .ui-skillcard__line{margin-top:-8px;font-size:13px;line-height:19px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* SkillGroup and SkillCard — @gemboss/ui (03/11/2026, the shared skills UI; their own file and entry, skill-card.css, since
|
|
5
|
+
* 04/11/2026). The list a skill's popup (SkillView) opens from: a group per job, a card per skill.
|
|
6
|
+
*
|
|
7
|
+
* 04/11/2026 (Chris: "Kit thêm slot, giữ giao diện content-radar"): content-radar's /v2/skills draws its cards and family groups with
|
|
8
|
+
* these, so they gained its slots, every one optional (GemBoss's Assistant › Skills draws what it drew before):
|
|
9
|
+
* a card: `iconSize` (a picture of its own, a 72px mascot, bare instead of the iris tile), `badgeTone` (Ready / Beta / Research /
|
|
10
|
+
* Later), `aside` (a second name), `children` (a framework's steps under the line), `extra` (more of the foot: style · voice),
|
|
11
|
+
* `actions` (a row under the card, OUTSIDE its link: a button cannot sit inside a link) and `size="lg"` (content-radar's room);
|
|
12
|
+
* a group: `mark` (a coloured square before the name), `aside` (its second name) and `minCardWidth`.
|
|
13
|
+
*/
|
|
14
|
+
import "./skill-card.css";
|
|
15
|
+
import React, { type CSSProperties, type ReactNode } from "react";
|
|
16
|
+
|
|
17
|
+
const cx = (...p: Array<string | false | null | undefined>) => p.filter(Boolean).join(" ");
|
|
18
|
+
/** A custom property in a React style (the box sizes below). */
|
|
19
|
+
const cssVar = (name: string, px: number | undefined): CSSProperties | undefined =>
|
|
20
|
+
(typeof px === "number" && px > 0 ? ({ [name]: `${px}px` } as CSSProperties) : undefined);
|
|
21
|
+
|
|
22
|
+
/** A skill's state as its badge says it: `new` is the kit's iris (the default), `ready` green, `beta` amber, `research` and
|
|
23
|
+
* `later` grey (content-radar's Ready / Beta / Research / Later). */
|
|
24
|
+
export type SkillBadgeTone = "new" | "ready" | "beta" | "research" | "later";
|
|
25
|
+
// Written whole, never built from the tone: a search for a class finds where it is drawn.
|
|
26
|
+
const BADGE_CLASS: Record<SkillBadgeTone, string> = {
|
|
27
|
+
new: "ui-skillcard__badge",
|
|
28
|
+
ready: "ui-skillcard__badge ui-skillcard__badge--ready",
|
|
29
|
+
beta: "ui-skillcard__badge ui-skillcard__badge--beta",
|
|
30
|
+
research: "ui-skillcard__badge ui-skillcard__badge--plain",
|
|
31
|
+
later: "ui-skillcard__badge ui-skillcard__badge--plain",
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export interface SkillCardProps {
|
|
35
|
+
title: ReactNode;
|
|
36
|
+
/** A second name after the title, a little smaller (content-radar: " · Mẫu số chung" after "Common Ground"). */
|
|
37
|
+
aside?: ReactNode;
|
|
38
|
+
line?: ReactNode;
|
|
39
|
+
/** A kit icon (drawn on the 32px iris tile), or with `iconSize` a picture of its own. */
|
|
40
|
+
icon?: ReactNode;
|
|
41
|
+
/** The picture's size in px when it is not a kit icon (content-radar's 72px mascot): it stands bare, no tile. */
|
|
42
|
+
iconSize?: number;
|
|
43
|
+
/** "advertorial · v2". */
|
|
44
|
+
meta?: ReactNode;
|
|
45
|
+
/** More of the foot after `meta`, in its quiet type (content-radar: a style's icon and name, the voice). */
|
|
46
|
+
extra?: ReactNode;
|
|
47
|
+
/** "12 runs · 30 days": only when there is a number. */
|
|
48
|
+
stat?: ReactNode;
|
|
49
|
+
/** One word in the corner ("New", "Ready"). */
|
|
50
|
+
badge?: ReactNode;
|
|
51
|
+
badgeTone?: SkillBadgeTone;
|
|
52
|
+
/** Under the line, inside the card (a framework's steps, a usage line): part of what opens the skill. */
|
|
53
|
+
children?: ReactNode;
|
|
54
|
+
/** Buttons for this skill ("Write"): a bar under the card with `meta` and `extra`, OUTSIDE the card's link or button. */
|
|
55
|
+
actions?: ReactNode;
|
|
56
|
+
/** "lg": content-radar's room (18px in, 16px corners, a 16px title, the line at most two lines). */
|
|
57
|
+
size?: "lg";
|
|
58
|
+
href?: string;
|
|
59
|
+
onOpen?: () => void;
|
|
60
|
+
className?: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A skill on the list: a kit icon on a tile (or a picture of its own, `iconSize`), its title by the job it does, one short line, a
|
|
65
|
+
* quiet foot ("advertorial · v2") and, when the surface has it, how often it ran. A button (or a link with `href`, the press handled
|
|
66
|
+
* by `onOpen` unless a modifier asks for a new tab). With `actions` the card is a frame: its body is the link, and the actions sit in
|
|
67
|
+
* a bar under it with the foot's words. Hover and press states are its own, so an app's bare `button:hover` cannot paint it.
|
|
68
|
+
*/
|
|
69
|
+
export function SkillCard({
|
|
70
|
+
title, aside, line, icon, iconSize, meta, extra, stat, badge, badgeTone = "new", children, actions, size, href, onOpen, className,
|
|
71
|
+
}: SkillCardProps) {
|
|
72
|
+
const art = typeof iconSize === "number" && iconSize > 0;
|
|
73
|
+
const metaEl = meta ? <span className="ui-skillcard__meta">{meta}</span> : null;
|
|
74
|
+
// meta and extra side by side, as one item of the foot (the stat keeps the far end).
|
|
75
|
+
const about = extra ? <span className="ui-skillcard__about">{metaEl}<span className="ui-skillcard__extra">{extra}</span></span> : metaEl;
|
|
76
|
+
const split = actions !== null && actions !== undefined && actions !== false;
|
|
77
|
+
const body = (
|
|
78
|
+
<>
|
|
79
|
+
<span className="ui-skillcard__top">
|
|
80
|
+
{icon ? (art
|
|
81
|
+
? <span className="ui-skillcard__art" aria-hidden="true" style={cssVar("--ui-skillcard-art", iconSize)}>{icon}</span>
|
|
82
|
+
: <span className="ui-skillcard__icon" aria-hidden="true">{icon}</span>) : null}
|
|
83
|
+
{badge ? <span className={BADGE_CLASS[badgeTone] ?? BADGE_CLASS.new}>{badge}</span> : null}
|
|
84
|
+
</span>
|
|
85
|
+
<b className="ui-skillcard__title">{title}{aside ? <span className="ui-skillcard__aside"> · {aside}</span> : null}</b>
|
|
86
|
+
{line ? <span className="ui-skillcard__line">{line}</span> : null}
|
|
87
|
+
{children}
|
|
88
|
+
{split ? (stat ? <span className="ui-skillcard__stat">{stat}</span> : null) : about || stat ? (
|
|
89
|
+
<span className="ui-skillcard__foot">
|
|
90
|
+
{about}
|
|
91
|
+
{stat ? <span className="ui-skillcard__stat">{stat}</span> : null}
|
|
92
|
+
</span>
|
|
93
|
+
) : null}
|
|
94
|
+
</>
|
|
95
|
+
);
|
|
96
|
+
const onLink = (e: React.MouseEvent) => { if (!onOpen || e.metaKey || e.ctrlKey || e.shiftKey || e.button !== 0) return; e.preventDefault(); onOpen(); };
|
|
97
|
+
const cls = cx("ui-skillcard", size === "lg" && "ui-skillcard--lg", split && "ui-skillcard--split", className);
|
|
98
|
+
if (!split) {
|
|
99
|
+
return href
|
|
100
|
+
? <a href={href} className={cls} onClick={onLink}>{body}</a>
|
|
101
|
+
: <button type="button" className={cls} onClick={onOpen}>{body}</button>;
|
|
102
|
+
}
|
|
103
|
+
return (
|
|
104
|
+
<div className={cls}>
|
|
105
|
+
{href
|
|
106
|
+
? <a href={href} className="ui-skillcard__open" onClick={onLink}>{body}</a>
|
|
107
|
+
: <button type="button" className="ui-skillcard__open" onClick={onOpen}>{body}</button>}
|
|
108
|
+
<div className="ui-skillcard__bar">
|
|
109
|
+
<span className="ui-skillcard__about">{metaEl}{extra ? <span className="ui-skillcard__extra">{extra}</span> : null}</span>
|
|
110
|
+
<span className="ui-skillcard__actions">{actions}</span>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface SkillGroupProps {
|
|
117
|
+
title: ReactNode;
|
|
118
|
+
/** A second name after the title, quieter (content-radar: the family's Vietnamese name). */
|
|
119
|
+
aside?: ReactNode;
|
|
120
|
+
line?: ReactNode;
|
|
121
|
+
/** A coloured square before the name: any CSS colour ("var(--gemboss-success)", a family's banner colour). */
|
|
122
|
+
mark?: string;
|
|
123
|
+
/** The narrowest a card gets before the grid drops a column, in px (default 220; content-radar's list 270). */
|
|
124
|
+
minCardWidth?: number;
|
|
125
|
+
children?: ReactNode;
|
|
126
|
+
className?: string;
|
|
127
|
+
id?: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Skills that do one job, under its name and one line, as a grid of cards. Nothing in it: nothing drawn. */
|
|
131
|
+
export function SkillGroup({ title, aside, line, mark, minCardWidth, children, className, id }: SkillGroupProps) {
|
|
132
|
+
if (!React.Children.toArray(children).length) return null;
|
|
133
|
+
return (
|
|
134
|
+
<section className={cx("ui-skillgroup", className)} aria-labelledby={id ? `${id}-h` : undefined}>
|
|
135
|
+
<div className="ui-skillgroup__head">
|
|
136
|
+
<h2 className="ui-skillgroup__title" id={id ? `${id}-h` : undefined}>
|
|
137
|
+
{mark ? <i className="ui-skillgroup__mark" aria-hidden="true" style={{ background: mark }} /> : null}
|
|
138
|
+
{title}
|
|
139
|
+
{aside ? <span className="ui-skillgroup__aside">{aside}</span> : null}
|
|
140
|
+
</h2>
|
|
141
|
+
{line ? <p className="ui-skillgroup__line">{line}</p> : null}
|
|
142
|
+
</div>
|
|
143
|
+
<div className="ui-skillgroup__grid" style={cssVar("--ui-skillgroup-min", minCardWidth)}>{children}</div>
|
|
144
|
+
</section>
|
|
145
|
+
);
|
|
146
|
+
}
|