@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.skf{container-type:inline-size;display:grid;gap:10px;min-width:0;--skf-sticky: 12px;--skf-card: var(--gemboss-surface, #ffffff);--skf-ink: var(--gemboss-text, #1b1c1e);--skf-muted: var(--gemboss-text-muted, #686b71);--skf-line: var(--gemboss-divider, #e5e7ea);--skf-line-2: var(--gemboss-chip-line, #cfd6ce);--skf-sunk: var(--gemboss-primary-soft, #f2f3f5);--skf-canvas: var(--gemboss-canvas, #ffffff);--skf-accent: var(--gemboss-accent, #5661f5);--skf-edge: color-mix(in srgb, var(--skf-muted) 72%, transparent);--skf-no: var(--gemboss-danger, #d72c0d);--skf-loop: var(--gemboss-warning, #9a6700);--skf-yes: var(--gemboss-success-strong, #0a6a4c);--skf-mono: ui-monospace, SFMono-Regular, Menlo, monospace}.skf [data-lane="0"]{--skf-ph: var(--gemboss-accent, #5661f5)}.skf [data-lane="1"]{--skf-ph: var(--gemboss-warning, #9a6700)}.skf [data-lane="2"]{--skf-ph: var(--gemboss-success, #007f5f)}.skf [data-lane="3"]{--skf-ph: var(--gemboss-text-muted, #686b71)}.skf [data-lane="4"]{--skf-ph: var(--gemboss-accent-strong, #3a44de)}.skf [data-lane="5"]{--skf-ph: var(--gemboss-danger, #d72c0d)}.skf-top{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:6px 16px}.skf-legend{display:flex;flex-wrap:wrap;gap:4px 14px;margin:0;padding:0;list-style:none;font-size:12px;color:var(--skf-muted)}.skf-legend li{display:inline-flex;align-items:center;gap:6px}.skf-hint{margin:0;font-size:12px;color:var(--skf-muted)}.skf-dot{display:inline-block;width:8px;height:8px;border-radius:2px;background:var(--skf-ph);flex:none}.skf-key{display:inline-block;width:14px;height:10px;border:1px solid var(--skf-line-2);border-radius:4px;background:var(--skf-card)}.skf-key--decision{width:16px;border:0;background:var(--skf-muted);clip-path:polygon(4px 0,calc(100% - 4px) 0,100% 50%,calc(100% - 4px) 100%,4px 100%,0 50%)}.skf-key--stop{border-color:var(--gemboss-warning-border, #f5d569);background:var(--gemboss-warning-soft, #fff8e0)}.skf-key--exit{border:1px dashed var(--skf-no);background:transparent}.skf-line{display:inline-block;width:18px;height:0;border-top:2px solid var(--skf-no)}.skf-line--loop{border-top:2px dashed var(--skf-loop)}.skf-note{margin:0;padding:8px 10px;border-radius:8px;font-size:12px;background:var(--skf-sunk);color:var(--skf-muted)}.skf-note--bad{background:var(--gemboss-danger-soft, #fff0e9);color:var(--gemboss-danger-strong, #b42318)}.skf__stage{position:relative;min-width:0}.skf__stage--wait{height:320px;border:1px solid var(--skf-line);border-radius:12px;background:var(--skf-sunk)}.skf__canvas{position:absolute;inset:0;overflow:hidden;border:1px solid var(--skf-line);border-radius:12px;background:var(--skf-canvas)}.skf__canvas:focus-visible{outline:2px solid var(--ui-focus, #5661f5);outline-offset:2px}.skf .react-flow{font-family:inherit;--xy-background-color: var(--skf-canvas);--xy-background-pattern-color: var(--skf-line);--xy-edge-stroke: var(--skf-edge);--xy-edge-stroke-width: 1.5;--xy-attribution-background-color: transparent}.skf .react-flow__attribution a{color:var(--skf-muted)}.skf .skf-h{opacity:0;width:1px;height:1px;min-width:0;min-height:0;border:0}.skf__tools{position:sticky;top:var(--skf-sticky);z-index:6;height:0;display:flex;justify-content:flex-end;align-items:flex-start;pointer-events:none}.skf-zoom{pointer-events:auto;display:flex;align-items:center;gap:2px;margin:10px 10px 0 0;padding:3px;border-radius:12px;border:1px solid var(--skf-line);background:var(--skf-card);box-shadow:var(--gemboss-shadow-raised, 0 4px 16px rgba(31, 30, 29, .1))}.skf-zoom .skf-zoom__btn{display:inline-flex;align-items:center;justify-content:center;gap:5px;min-width:30px;height:30px;padding:0 7px;border:0;border-radius:8px;background:transparent;color:var(--skf-ink);font:inherit;font-size:12px;font-weight:600;cursor:pointer}.skf-zoom .skf-zoom__btn:hover:not(:disabled),.skf-zoom .skf-zoom__btn:active:not(:disabled){background:var(--gemboss-hover, #eceef2);color:var(--skf-ink)}.skf-zoom .skf-zoom__btn:disabled{background:transparent;color:var(--skf-muted);opacity:.45;cursor:default}.skf-zoom .skf-zoom__btn:focus-visible{outline:2px solid var(--ui-focus, #5661f5);outline-offset:1px}.skf-zoom svg{width:15px;height:15px;flex:none}.skf-zoom__pct{min-width:44px;text-align:center;font-size:12px;font-weight:600;font-variant-numeric:tabular-nums;color:var(--skf-muted)}.skf-zoom__sep{width:1px;height:18px;margin:0 3px;background:var(--skf-line)}@media (pointer: coarse){.skf-zoom .skf-zoom__btn{min-width:38px;height:38px}}.skf .react-flow__node-band{pointer-events:none}.skf-band{position:relative;box-sizing:border-box;width:100%;height:100%;background:color-mix(in srgb,var(--skf-ph) 5%,transparent);border-top:1px solid color-mix(in srgb,var(--skf-ph) 22%,transparent)}.skf-band--lane{border:1px solid color-mix(in srgb,var(--skf-ph) 18%,transparent);border-radius:16px}.skf-band__label{position:absolute;left:12px;top:10px;font-size:11px;line-height:14px;font-weight:650;letter-spacing:.08em;text-transform:uppercase;color:color-mix(in srgb,var(--skf-ph) 80%,var(--skf-ink))}.skf-band:not(.skf-band--lane) .skf-band__label{left:9px;top:12px;writing-mode:vertical-rl;transform:rotate(180deg)}.skf-node{position:relative;isolation:isolate;box-sizing:border-box;width:100%;padding:8px 12px 8px 14px;border:1px solid var(--skf-line-2);border-radius:12px;background:var(--skf-card);color:var(--skf-ink);box-shadow:var(--gemboss-shadow-resting, 0 1px 2px rgba(31, 30, 29, .04), 0 2px 6px rgba(31, 30, 29, .06));cursor:pointer;display:flex;flex-direction:column;text-align:left;overflow:hidden}.skf-node:before{content:"";position:absolute;left:0;top:0;bottom:0;width:4px;background:var(--skf-ph)}.skf-node__eye{display:flex;align-items:center;gap:4px;margin-bottom:2px;font-size:11px;line-height:14px;font-weight:650;letter-spacing:.05em;text-transform:uppercase;color:color-mix(in srgb,var(--skf-ph) 78%,var(--skf-ink))}.skf-node__label{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;font-size:13px;line-height:18px;font-weight:600;overflow-wrap:anywhere}.skf-node__tools{display:flex;flex-wrap:wrap;gap:4px;margin-top:6px}.skf-node__tools code{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0 7px;border-radius:999px;font:500 11px/18px var(--skf-mono);background:var(--skf-sunk);color:var(--skf-muted)}.skf-node:hover{border-color:var(--skf-muted)}.skf-node[data-on]{border-color:var(--skf-accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--skf-accent) 22%,transparent)}.skf .react-flow__node:focus-visible .skf-node{outline:2px solid var(--ui-focus, #5661f5);outline-offset:2px}.skf-node--start,.skf-node--end{border-radius:999px;padding:8px 18px;align-items:center;text-align:center}.skf-node--start:before,.skf-node--end:before{display:none}.skf-node--start{border:1.5px solid var(--skf-ink)}.skf-node--start .skf-node__tools,.skf-node--end .skf-node__tools{justify-content:center}.skf-node--end{background:var(--gemboss-primary, #1b1c1e);border-color:var(--gemboss-primary, #1b1c1e);color:var(--gemboss-on-primary, #ffffff)}.skf-node--end .skf-node__eye{color:inherit;opacity:.75}.skf-node--stop{border-color:var(--gemboss-warning-border, #f5d569);background:color-mix(in srgb,var(--gemboss-warning-soft, #fff8e0) 70%,var(--skf-card))}.skf-node--stop .skf-node__eye{align-self:flex-start;padding:0 6px;border-radius:999px;background:var(--gemboss-warning-soft, #fff8e0);color:var(--gemboss-warning, #9a6700);box-shadow:inset 0 0 0 1px var(--gemboss-warning-border, #f5d569)}.skf-node--exit{border:1px dashed var(--skf-no);background:color-mix(in srgb,var(--gemboss-danger-soft, #fff0e9) 60%,var(--skf-card));box-shadow:none}.skf-node--exit:before{display:none}.skf-node--exit .skf-node__eye{color:var(--skf-no)}.skf-node--decision{border:0;background:none;box-shadow:none;padding:9px 22px;overflow:visible}.skf-node--decision:before,.skf-node--decision:after{content:"";position:absolute;z-index:-1;display:block;width:auto}.skf-node--decision:before{inset:0;background:var(--skf-ph);clip-path:polygon(14px 0,calc(100% - 14px) 0,100% 50%,calc(100% - 14px) 100%,14px 100%,0 50%)}.skf-node--decision:after{inset:1.5px;background:var(--skf-card);clip-path:polygon(13px 0,calc(100% - 13px) 0,100% 50%,calc(100% - 13px) 100%,13px 100%,0 50%)}.skf-node--decision[data-on]:before{background:var(--skf-accent)}.skf-node--decision[data-on]{box-shadow:none}.skf .skf-node[data-dim],.skf .skf-band[data-dim]{opacity:.4;transition:opacity .2s ease}.skf .skf-node[data-dim]:hover,.skf .skf-node[data-dim][data-on]{opacity:1}@media (prefers-reduced-motion: reduce){.skf .skf-node[data-dim],.skf .skf-band[data-dim]{transition:none}}.skf .skf-band[data-lit]{box-shadow:inset 0 0 0 2px var(--gemboss-primary, #1b1c1e)}.skf .react-flow__edge-path.skf-edge{stroke:var(--skf-edge);stroke-width:1.5}.skf .react-flow__edge-path.skf-edge--no{stroke:var(--skf-no)}.skf .react-flow__edge-path.skf-edge--loop{stroke:var(--skf-loop);stroke-dasharray:5 4}.skf .react-flow__edge.is-on .react-flow__edge-path.skf-edge{stroke-width:2.5}.skf .react-flow__edgelabel-renderer{z-index:1}.skf-elabel{position:absolute;left:0;top:0;pointer-events:all;white-space:nowrap;padding:1px 7px;border-radius:999px;font-size:11px;line-height:16px;font-weight:500;background:var(--skf-card);color:var(--skf-muted);box-shadow:inset 0 0 0 1px var(--skf-line)}.skf-elabel b{font-weight:700}.skf-elabel--yes b{color:var(--skf-yes)}.skf-elabel--no{color:var(--skf-no);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--skf-no) 35%,transparent)}.skf-elabel--loop{color:var(--skf-loop);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--skf-loop) 35%,transparent)}.skf__float{position:absolute;top:0;right:0;bottom:0;width:384px;padding:56px 12px 12px;box-sizing:border-box;pointer-events:none}.skf__float .skf-panel{position:sticky;top:calc(var(--skf-sticky) + 48px);pointer-events:auto;max-height:min(100%,calc(100dvh - 160px));overflow:auto;box-shadow:var(--gemboss-shadow-raised, 0 4px 16px rgba(31, 30, 29, .1))}.skf-panel{box-sizing:border-box;margin:0;padding:12px 14px 14px;border:1px solid var(--skf-line);border-radius:12px;background:var(--skf-card);color:var(--skf-ink);font-size:13px;line-height:1.5}.skf-panel--empty{color:var(--skf-muted);font-size:12px}.skf-panel__head{display:flex;align-items:center;justify-content:space-between;gap:8px}.skf-panel__eye{display:flex;align-items:center;gap:6px;margin:0;font-size:11px;font-weight:650;letter-spacing:.06em;text-transform:uppercase;color:var(--skf-muted)}.skf-panel .skf-panel__x{border:0;background:transparent;font:inherit;font-size:18px;line-height:1;padding:2px 4px;color:var(--skf-muted);cursor:pointer;border-radius:6px}.skf-panel .skf-panel__x:hover,.skf-panel .skf-panel__x:active{background:var(--gemboss-hover, #eceef2);color:var(--skf-ink)}.skf-panel h4{margin:4px 0 6px;font-size:15px;line-height:1.35;font-weight:650}.skf-panel__detail{margin:0;color:var(--skf-ink)}.skf-panel__h{margin:12px 0 6px;font-size:11px;font-weight:650;letter-spacing:.06em;text-transform:uppercase;color:var(--skf-muted)}.skf-panel__h span{margin-left:6px;font-weight:500;letter-spacing:0;text-transform:none}.skf-panel__tools{display:flex;flex-wrap:wrap;gap:4px}.skf-panel__tools code{padding:0 7px;border-radius:999px;font:500 11px/20px var(--skf-mono);background:var(--skf-sunk);color:var(--skf-ink)}.skf-panel__next{margin:0;padding:0;list-style:none;display:grid;gap:4px}.skf-panel .skf-panel__go,.skf-panel .skf-panel__back{font:inherit;color:inherit;background:transparent;border:0;padding:0;cursor:pointer;text-align:left}.skf-panel .skf-panel__go{display:flex;align-items:baseline;gap:8px;width:100%;padding:5px 6px;margin:0 -6px;border-radius:8px}.skf-panel .skf-panel__go:hover,.skf-panel .skf-panel__go:active{background:var(--gemboss-hover, #eceef2);color:inherit}.skf-panel .skf-panel__back:hover,.skf-panel .skf-panel__back:active{background:transparent;color:var(--skf-ink)}.skf-panel__next em{font-style:normal;color:var(--skf-muted)}.skf-panel__from{margin:10px 0 0;font-size:12px;color:var(--skf-muted)}.skf-panel .skf-panel__back{text-decoration:underline;text-underline-offset:2px}.skf-panel button:focus-visible{outline:2px solid var(--ui-focus, #5661f5);outline-offset:1px}.skf-chip{flex:none;min-width:34px;text-align:center;padding:0 6px;border-radius:999px;font-size:11px;line-height:16px;font-weight:700;background:var(--skf-sunk);color:var(--skf-muted)}.skf-chip--yes{color:var(--skf-yes);background:var(--gemboss-success-soft, #e3f1df)}.skf-chip--no{color:var(--skf-no);background:var(--gemboss-danger-soft, #fff0e9)}.skf-chip--loop{color:var(--skf-loop);background:var(--gemboss-warning-soft, #fff8e0)}.skf-panel__ex{display:grid;gap:8px;grid-template-columns:minmax(0,1fr)}.skf-ex{min-width:0;padding:8px 10px 10px;border:1px solid var(--skf-line);border-radius:8px;background:var(--skf-card)}.skf-ex--good{border-color:var(--gemboss-success-border, #b7dfcd)}.skf-ex--bad{border-color:var(--gemboss-danger-border, #f5c9bc)}.skf-ex--tool{background:var(--skf-sunk)}.skf-ex__head{display:flex;align-items:baseline;gap:8px;margin:0 0 4px;font-size:12px;font-weight:650}.skf-ex__kind{flex:none;padding:0 6px;border-radius:999px;font-size:11px;line-height:16px;font-weight:700;letter-spacing:.03em;background:var(--skf-sunk);color:var(--skf-muted)}.skf-ex--good .skf-ex__kind{background:var(--gemboss-success-soft, #e3f1df);color:var(--skf-yes)}.skf-ex--bad .skf-ex__kind{background:var(--gemboss-danger-soft, #fff0e9);color:var(--skf-no)}.skf-ex--tool .skf-ex__kind{background:var(--skf-card);color:var(--skf-ink)}.skf-ex--input .skf-ex__kind,.skf-ex--output .skf-ex__kind{background:color-mix(in srgb,var(--skf-accent) 12%,var(--skf-card));color:var(--gemboss-accent-strong, #3a44de)}.skf-ex__md{font-size:12px;line-height:1.5;min-width:0;overflow-wrap:anywhere}.skf-ex__md>:first-child{margin-top:0}.skf-ex__md>:last-child{margin-bottom:0}.skf-ex__md :is(p,ul,ol,blockquote){margin:4px 0}.skf-ex__md :is(ul,ol){padding-left:18px}.skf-ex__md pre{margin:4px 0;padding:6px 8px;border-radius:6px;overflow-x:auto;white-space:pre;font-size:11px;background:var(--skf-card);border:1px solid var(--skf-line)}.skf-ex__md blockquote{padding-left:8px;border-left:2px solid var(--skf-line-2);color:var(--skf-muted)}.skf-ex__md :not(pre)>code{padding:0 4px;border-radius:4px;font:500 11px/16px var(--skf-mono);background:var(--skf-sunk)}@media (min-width: 48em){dialog.ui-modal.ui-reader.skf-pop{width:98vw;max-width:98vw;height:96dvh}}.skf--full{flex:1 1 auto;min-height:0;display:flex;flex-direction:column;gap:8px;padding:10px 12px 12px;box-sizing:border-box;--skf-sticky: 0px}.skf--full .skf__stage{flex:1 1 auto;min-height:0}.skf--full .skf__float .skf-panel{position:static;max-height:100%}.skf--full>.skf-panel{flex:none;max-height:42%;overflow:auto}@media (max-width: 47.9975em){.skf--full{padding:8px}.skf--full .skf-legend{display:none}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ui-skillstats{display:grid;gap:18px;min-width:0;color:var(--gemboss-text, #1b1c1e);font-size:13px;line-height:20px}.ui-skillstats__nums{display:grid;grid-template-columns:repeat(auto-fill,minmax(120px,1fr));gap:12px;margin:0}.ui-skillstats__num{display:grid;gap:2px;padding-top:8px;border-top:1px solid var(--gemboss-divider, #e5e7ea);min-width:0}.ui-skillstats__num dt{font-size:12px;line-height:16px;color:var(--gemboss-text-muted, #686b71)}.ui-skillstats__num dd{margin:0;font-size:22px;line-height:28px;font-weight:650;font-variant-numeric:tabular-nums}.ui-skillstats__last{margin:-8px 0 0;font-size:12px;color:var(--gemboss-text-muted, #686b71)}.ui-skillstats__sec{display:grid;gap:8px;min-width:0}.ui-skillstats__h{margin:0;font-size:12px;line-height:16px;font-weight:650;letter-spacing:.06em;text-transform:uppercase;color:var(--gemboss-text-muted, #686b71)}.ui-skillstats__one{margin:0;font-size:12px;color:var(--gemboss-text-muted, #686b71)}.ui-skillstats__legend,.ui-skillstats__outs{display:flex;flex-wrap:wrap;gap:4px 16px;margin:0;padding:0;list-style:none}.ui-skillstats__key,.ui-skillstats__out{display:inline-flex;align-items:center;gap:6px;font-size:12px}.ui-skillstats__key span,.ui-skillstats__out span{color:var(--gemboss-text-muted, #686b71);font-variant-numeric:tabular-nums}.ui-skillstats__key>i{width:8px;height:8px;border-radius:2px;background:var(--c)}.ui-skillstats__key--s1{--c: var(--ui-series-1, #5661f5)}.ui-skillstats__key--s2{--c: var(--ui-series-2, #0f9f8f)}.ui-skillstats__key--s3{--c: var(--ui-series-3, #d9822b)}.ui-skillstats__key--s4{--c: var(--ui-series-4, #c2417a)}.ui-skillstats__key--neutral{--c: var(--ui-text-muted, #686b71)}.ui-skillstats__out>i{width:7px;height:7px;box-sizing:border-box;border-radius:50%;border:1.5px solid var(--c);background:var(--c)}.ui-skillstats__out--done{--c: var(--gemboss-success, #007f5f)}.ui-skillstats__out--stopped{--c: var(--gemboss-chip-line, #cfd6ce)}.ui-skillstats__out--stopped>i{background:transparent}.ui-skillstats__out--blocked{--c: var(--gemboss-warning, #9a6700)}.ui-skillstats__out--error{--c: var(--gemboss-danger, #d72c0d)}.ui-skillstats__top{margin:0;font-size:12px;color:var(--gemboss-text-muted, #686b71)}.ui-skillstats__top code{padding:0 6px;border-radius:6px;font:600 11px/18px ui-monospace,SFMono-Regular,Menlo,monospace;background:var(--gemboss-primary-soft, #f2f3f5);color:var(--gemboss-text, #1b1c1e)}.ui-skillstats__vwrap{overflow-x:auto;max-width:100%}.ui-skillstats__versions{border-collapse:collapse;min-width:320px;width:100%;font-size:12px;font-variant-numeric:tabular-nums}.ui-skillstats__versions :is(th,td){padding:6px 10px;text-align:right;border-bottom:1px solid var(--gemboss-divider, #e5e7ea)}.ui-skillstats__versions :is(th,td):first-child{text-align:left;padding-left:0}.ui-skillstats__versions thead th{font-size:12px;font-weight:550;color:var(--gemboss-text-muted, #686b71)}.ui-skillstats__versions tbody th{font-weight:600}.ui-skillstats--empty{padding:20px;border:1px dashed var(--gemboss-divider, #e5e7ea);border-radius:12px}.ui-skillstats__empty{display:grid;gap:2px;margin:0}.ui-skillstats__empty b{font-size:14px;font-weight:600}.ui-skillstats__empty span{font-size:12px;color:var(--gemboss-text-muted, #686b71)}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SkillStats — @gemboss/ui, unreleased (03/11/2026, the shared skills UI, plan "Clone cả store" S5 + S7). How one skill is used,
|
|
3
|
+
* drawn from ONE entry of the usage read both products answer the same way:
|
|
4
|
+
*
|
|
5
|
+
* GET …/skills/usage?days=30 → { days, generated_at, skills: [{ skill_id, pack, version, runs, runs_7d, stores?,
|
|
6
|
+
* by_engine: { claude_subscription, codex_subscription, byok, gemboss_key, unknown }, outcomes: { done, stopped, blocked, error },
|
|
7
|
+
* top_blocked_by: [{ guard, count }], avg_fidelity, published_rate, last_used_at, by_version: [{ version, runs, avg_fidelity,
|
|
8
|
+
* published_rate }] }] }
|
|
9
|
+
*
|
|
10
|
+
* What it draws, quietest first (Chris's rules: few words, one accent, status as small dots, empty things hidden):
|
|
11
|
+
* - the runs in the window, the last 7 days, and the stores (when the surface counts them);
|
|
12
|
+
* - who ran it: one split bar over the engines that ran it at least once, each named with its share. An engine at 0 is not drawn
|
|
13
|
+
* (content-radar only ever has Claude, and later Codex); a single engine is one full bar and "All on Claude", no legend;
|
|
14
|
+
* - how runs ended: a dot, a word and a count per outcome that happened;
|
|
15
|
+
* - the rule that blocked it most, the average fidelity and the published share, each only when known;
|
|
16
|
+
* - versions side by side when there are two or more.
|
|
17
|
+
* No runs (or no entry): one quiet line, never a zero dressed as data. The numbers are the surface's: it never fakes one.
|
|
18
|
+
* Server-renderable (no state, no effect). `skill-stats.css` is its own entry; the bar is the kit's ShareBar (minichart.css).
|
|
19
|
+
*/
|
|
20
|
+
import "./skill-stats.css";
|
|
21
|
+
import React from "react";
|
|
22
|
+
import { ShareBar, type ShareTone } from "./minichart";
|
|
23
|
+
|
|
24
|
+
const cx = (...p: Array<string | false | null | undefined>) => p.filter(Boolean).join(" ");
|
|
25
|
+
|
|
26
|
+
export type SkillEngine = "claude_subscription" | "codex_subscription" | "byok" | "gemboss_key" | "unknown";
|
|
27
|
+
export type SkillOutcome = "done" | "stopped" | "blocked" | "error";
|
|
28
|
+
|
|
29
|
+
/** One skill's entry of the usage read. Every field may be missing on an older answer; the component draws what is there. */
|
|
30
|
+
export interface SkillUsage {
|
|
31
|
+
skill_id: string;
|
|
32
|
+
pack?: string;
|
|
33
|
+
version?: number | string | null;
|
|
34
|
+
runs: number;
|
|
35
|
+
runs_7d?: number;
|
|
36
|
+
stores?: number | null;
|
|
37
|
+
by_engine?: Partial<Record<SkillEngine, number>>;
|
|
38
|
+
outcomes?: Partial<Record<SkillOutcome, number>>;
|
|
39
|
+
top_blocked_by?: ReadonlyArray<{ guard: string; count: number }>;
|
|
40
|
+
avg_fidelity?: number | null;
|
|
41
|
+
published_rate?: number | null;
|
|
42
|
+
last_used_at?: string | null;
|
|
43
|
+
by_version?: ReadonlyArray<{ version: number | string; runs: number; avg_fidelity?: number | null; published_rate?: number | null }>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface SkillStatsLabels {
|
|
47
|
+
runs: (days: number) => string;
|
|
48
|
+
last7: string;
|
|
49
|
+
stores: string;
|
|
50
|
+
engines: string;
|
|
51
|
+
engine: Record<SkillEngine, string>;
|
|
52
|
+
allOn: (engine: string) => string;
|
|
53
|
+
outcomes: string;
|
|
54
|
+
outcome: Record<SkillOutcome, string>;
|
|
55
|
+
topBlock: string;
|
|
56
|
+
fidelity: string;
|
|
57
|
+
published: string;
|
|
58
|
+
versions: string;
|
|
59
|
+
versionRow: string;
|
|
60
|
+
lastUsed: (when: string) => string;
|
|
61
|
+
empty: string;
|
|
62
|
+
emptyLine: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const SKILL_STATS_LABELS: SkillStatsLabels = {
|
|
66
|
+
runs: (days) => `Runs · ${days} days`,
|
|
67
|
+
last7: "Last 7 days",
|
|
68
|
+
stores: "Stores",
|
|
69
|
+
engines: "Who ran it",
|
|
70
|
+
engine: { claude_subscription: "Claude", codex_subscription: "Codex", byok: "Own key", gemboss_key: "GemBoss key", unknown: "Unknown" },
|
|
71
|
+
allOn: (engine) => `All on ${engine}`,
|
|
72
|
+
outcomes: "How runs ended",
|
|
73
|
+
outcome: { done: "Done", stopped: "Stopped", blocked: "Blocked", error: "Error" },
|
|
74
|
+
topBlock: "Blocked most by",
|
|
75
|
+
fidelity: "Avg fidelity",
|
|
76
|
+
published: "Published",
|
|
77
|
+
versions: "Versions",
|
|
78
|
+
versionRow: "Version",
|
|
79
|
+
lastUsed: (when) => `Last used ${when}`,
|
|
80
|
+
empty: "No runs yet",
|
|
81
|
+
emptyLine: "Numbers show here once this skill has run.",
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/** The engines in a FIXED order with a fixed tone each: a colour follows its engine, never its rank (a filter that drops one
|
|
85
|
+
* engine does not repaint the others). Unknown is the neutral grey, not a hue. */
|
|
86
|
+
export const SKILL_ENGINES: ReadonlyArray<{ key: SkillEngine; tone: ShareTone }> = [
|
|
87
|
+
{ key: "claude_subscription", tone: "series-1" },
|
|
88
|
+
{ key: "codex_subscription", tone: "series-2" },
|
|
89
|
+
{ key: "byok", tone: "series-3" },
|
|
90
|
+
{ key: "gemboss_key", tone: "series-4" },
|
|
91
|
+
{ key: "unknown", tone: "neutral" },
|
|
92
|
+
];
|
|
93
|
+
const OUTCOMES: readonly SkillOutcome[] = ["done", "stopped", "blocked", "error"];
|
|
94
|
+
const OUTCOME_CLASS: Record<SkillOutcome, string> = {
|
|
95
|
+
done: "ui-skillstats__out ui-skillstats__out--done",
|
|
96
|
+
stopped: "ui-skillstats__out ui-skillstats__out--stopped",
|
|
97
|
+
blocked: "ui-skillstats__out ui-skillstats__out--blocked",
|
|
98
|
+
error: "ui-skillstats__out ui-skillstats__out--error",
|
|
99
|
+
};
|
|
100
|
+
const TONE_CLASS: Record<string, string> = {
|
|
101
|
+
"series-1": "ui-skillstats__key ui-skillstats__key--s1", "series-2": "ui-skillstats__key ui-skillstats__key--s2",
|
|
102
|
+
"series-3": "ui-skillstats__key ui-skillstats__key--s3", "series-4": "ui-skillstats__key ui-skillstats__key--s4",
|
|
103
|
+
neutral: "ui-skillstats__key ui-skillstats__key--neutral",
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const n0 = (v: unknown) => (typeof v === "number" && Number.isFinite(v) && v > 0 ? v : 0);
|
|
107
|
+
/** A share 0…1 (or 0…100) printed as a whole percent; null when unknown. */
|
|
108
|
+
export const pct = (v: number | null | undefined): string | null => {
|
|
109
|
+
if (typeof v !== "number" || !Number.isFinite(v)) return null;
|
|
110
|
+
const p = v <= 1 ? v * 100 : v;
|
|
111
|
+
return `${Math.round(Math.max(0, Math.min(100, p)))}%`;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/** The engines that ran it at least once, in the fixed order, each with its share of the runs they add up to. */
|
|
115
|
+
export function engineParts(by: SkillUsage["by_engine"]): Array<{ key: SkillEngine; tone: ShareTone; runs: number; share: number }> {
|
|
116
|
+
const parts = SKILL_ENGINES.map((e) => ({ ...e, runs: n0(by?.[e.key]) })).filter((e) => e.runs > 0);
|
|
117
|
+
const total = parts.reduce((a, p) => a + p.runs, 0);
|
|
118
|
+
return parts.map((p) => ({ ...p, share: total ? p.runs / total : 0 }));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface SkillStatsProps {
|
|
122
|
+
/** One skill's entry, or null / undefined when the read has nothing for it. */
|
|
123
|
+
usage?: SkillUsage | null;
|
|
124
|
+
/** The window the read covered (its `days`). */
|
|
125
|
+
days?: number;
|
|
126
|
+
/** The read's last-used date, already worded by the surface ("2 days ago"). */
|
|
127
|
+
lastUsed?: string | null;
|
|
128
|
+
labels?: Partial<SkillStatsLabels>;
|
|
129
|
+
className?: string;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function SkillStats({ usage, days = 30, lastUsed, labels, className }: SkillStatsProps) {
|
|
133
|
+
const L = { ...SKILL_STATS_LABELS, ...labels };
|
|
134
|
+
const runs = n0(usage?.runs);
|
|
135
|
+
if (!usage || !runs) {
|
|
136
|
+
return (
|
|
137
|
+
<div className={cx("ui-skillstats ui-skillstats--empty", className)}>
|
|
138
|
+
<p className="ui-skillstats__empty"><b>{L.empty}</b><span>{L.emptyLine}</span></p>
|
|
139
|
+
</div>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
const engines = engineParts(usage.by_engine);
|
|
143
|
+
const outs = OUTCOMES.map((k) => ({ k, n: n0(usage.outcomes?.[k]) })).filter((o) => o.n > 0);
|
|
144
|
+
const top = (usage.top_blocked_by ?? []).filter((b) => b && b.guard && n0(b.count) > 0).sort((a, b) => b.count - a.count)[0];
|
|
145
|
+
const fidelity = pct(usage.avg_fidelity);
|
|
146
|
+
const published = pct(usage.published_rate);
|
|
147
|
+
const versions = (usage.by_version ?? []).filter((v) => v && v.version !== undefined && v.version !== null);
|
|
148
|
+
const stores = typeof usage.stores === "number" && usage.stores >= 0 ? usage.stores : null;
|
|
149
|
+
const nums: Array<[string, string]> = [
|
|
150
|
+
[L.runs(days), String(runs)],
|
|
151
|
+
...(typeof usage.runs_7d === "number" ? [[L.last7, String(n0(usage.runs_7d))] as [string, string]] : []),
|
|
152
|
+
...(stores !== null ? [[L.stores, String(stores)] as [string, string]] : []),
|
|
153
|
+
...(fidelity ? [[L.fidelity, fidelity] as [string, string]] : []),
|
|
154
|
+
...(published ? [[L.published, published] as [string, string]] : []),
|
|
155
|
+
];
|
|
156
|
+
return (
|
|
157
|
+
<div className={cx("ui-skillstats", className)}>
|
|
158
|
+
<dl className="ui-skillstats__nums">
|
|
159
|
+
{nums.map(([k, v]) => <div key={k} className="ui-skillstats__num"><dt>{k}</dt><dd>{v}</dd></div>)}
|
|
160
|
+
</dl>
|
|
161
|
+
{lastUsed ? <p className="ui-skillstats__last">{L.lastUsed(lastUsed)}</p> : null}
|
|
162
|
+
|
|
163
|
+
{engines.length ? (
|
|
164
|
+
<section className="ui-skillstats__sec" aria-label={L.engines}>
|
|
165
|
+
<h4 className="ui-skillstats__h">{L.engines}</h4>
|
|
166
|
+
<ShareBar parts={engines.map((e) => ({ key: e.key, label: L.engine[e.key], value: e.runs, tone: e.tone }))} label={L.engines} />
|
|
167
|
+
{engines.length === 1 ? (
|
|
168
|
+
<p className="ui-skillstats__one">{L.allOn(L.engine[engines[0]!.key])}</p>
|
|
169
|
+
) : (
|
|
170
|
+
<ul className="ui-skillstats__legend">
|
|
171
|
+
{engines.map((e) => (
|
|
172
|
+
<li key={e.key} className={TONE_CLASS[e.tone]}>
|
|
173
|
+
<i aria-hidden="true" />{L.engine[e.key]}<span>{e.runs} · {pct(e.share)}</span>
|
|
174
|
+
</li>
|
|
175
|
+
))}
|
|
176
|
+
</ul>
|
|
177
|
+
)}
|
|
178
|
+
</section>
|
|
179
|
+
) : null}
|
|
180
|
+
|
|
181
|
+
{outs.length ? (
|
|
182
|
+
<section className="ui-skillstats__sec" aria-label={L.outcomes}>
|
|
183
|
+
<h4 className="ui-skillstats__h">{L.outcomes}</h4>
|
|
184
|
+
<ul className="ui-skillstats__outs">
|
|
185
|
+
{outs.map((o) => <li key={o.k} className={OUTCOME_CLASS[o.k]}><i aria-hidden="true" />{L.outcome[o.k]}<span>{o.n}</span></li>)}
|
|
186
|
+
</ul>
|
|
187
|
+
{top ? <p className="ui-skillstats__top">{L.topBlock} <code>{top.guard}</code> <span>· {top.count}</span></p> : null}
|
|
188
|
+
</section>
|
|
189
|
+
) : null}
|
|
190
|
+
|
|
191
|
+
{versions.length > 1 ? (
|
|
192
|
+
<section className="ui-skillstats__sec" aria-label={L.versions}>
|
|
193
|
+
<h4 className="ui-skillstats__h">{L.versions}</h4>
|
|
194
|
+
<div className="ui-skillstats__vwrap">
|
|
195
|
+
<table className="ui-skillstats__versions">
|
|
196
|
+
<thead><tr><th scope="col">{L.versionRow}</th><th scope="col">{L.runs(days)}</th><th scope="col">{L.fidelity}</th><th scope="col">{L.published}</th></tr></thead>
|
|
197
|
+
<tbody>
|
|
198
|
+
{versions.map((v) => (
|
|
199
|
+
<tr key={String(v.version)}>
|
|
200
|
+
<th scope="row">v{v.version}</th>
|
|
201
|
+
<td>{n0(v.runs)}</td>
|
|
202
|
+
<td>{pct(v.avg_fidelity) ?? "–"}</td>
|
|
203
|
+
<td>{pct(v.published_rate) ?? "–"}</td>
|
|
204
|
+
</tr>
|
|
205
|
+
))}
|
|
206
|
+
</tbody>
|
|
207
|
+
</table>
|
|
208
|
+
</div>
|
|
209
|
+
</section>
|
|
210
|
+
) : null}
|
|
211
|
+
</div>
|
|
212
|
+
);
|
|
213
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ui-skillview{--skf-sticky: 56px;display:flex;flex-direction:column;gap:16px;min-width:0;color:var(--gemboss-text, #1b1c1e)}.ui-skillview>*{flex:none}dialog.ui-modal.ui-reader .ui-reader__scroll.ui-skillview{padding-top:16px}.ui-skillview-pop .ui-modal__head .ui-skillview__back{flex:none;display:inline-flex;align-items:center;gap:6px;height:28px;padding:0 10px 0 6px;margin-right:4px;border:0;border-radius:8px;background:transparent;color:var(--gemboss-text, #1b1c1e);font:inherit;font-size:13px;font-weight:550;cursor:pointer;white-space:nowrap}.ui-skillview-pop .ui-modal__head .ui-skillview__back:hover,.ui-skillview-pop .ui-modal__head .ui-skillview__back:active{background:var(--gemboss-hover, #eceef2);color:var(--gemboss-text, #1b1c1e)}.ui-skillview-pop .ui-modal__head .ui-skillview__back:focus-visible{outline:2px solid var(--ui-focus, #5661f5);outline-offset:2px}.ui-skillview__hero{display:flex;align-items:flex-start;gap:14px;max-width:72ch}.ui-skillview__hero--art{align-items:center;gap:16px;max-width:820px}.ui-skillview__art{flex:none;display:grid;place-items:center;min-width:var(--ui-skillview-art, auto);min-height:var(--ui-skillview-art, auto)}.ui-skillview__icon{flex:none;display:grid;place-items:center;width:44px;height:44px;border-radius:12px;background:var(--gemboss-accent-soft, #eef0fe);color:var(--gemboss-accent, #5661f5)}.ui-skillview__icon svg{width:22px;height:22px}.ui-skillview__lead{display:grid;gap:8px;min-width:0}.ui-skillview__intro{margin:0;font-size:14px;line-height:21px}.ui-skillview__facts,.ui-skillview__badges{display:flex;flex-wrap:wrap;gap:6px;margin:0;padding:0;list-style:none}.ui-skillview__badges>.ui-badge{white-space:normal;max-width:100%}:where(.ui-skillview__intro,.ui-skillview__callout,.ui-skillview__note) p{margin:0}.ui-skillview__callout{padding:6px 9px;border-radius:8px;font-size:12.5px;line-height:19px;background:var(--gemboss-warning-soft, #fff8e0);color:var(--gemboss-text, #1b1c1e)}.ui-skillview__callout>:not(.ui-skillview__calloutlabel){display:block}.ui-skillview__calloutlabel{float:left;margin-right:4px;font-size:10.5px;line-height:18px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--gemboss-warning, #9a6700)}.ui-skillview__fact{padding:0 8px;border:1px solid var(--gemboss-divider, #e5e7ea);border-radius:999px;font-size:12px;line-height:20px;color:var(--gemboss-text-muted, #686b71);font-variant-numeric:tabular-nums}.ui-skillview__why{font-size:13px;color:var(--gemboss-text-muted, #686b71)}.ui-skillview__why>summary{width:fit-content;cursor:pointer;font-weight:550;color:var(--gemboss-text, #1b1c1e);list-style-position:inside}.ui-skillview__why>summary:focus-visible{outline:2px solid var(--ui-focus, #5661f5);outline-offset:2px;border-radius:4px}.ui-skillview__whytext{margin-top:6px;line-height:20px}.ui-skillview__error{margin:0;padding:8px 12px;border-radius:8px;font-size:13px;background:var(--gemboss-danger-soft, #fff0e9);color:var(--gemboss-danger-strong, #b42318)}.ui-skillview__loading{margin:0;font-size:13px;color:var(--gemboss-text-muted, #686b71)}.ui-skillview .ui-skillview__tabs{position:sticky;top:0;z-index:8;background:var(--gemboss-surface, #ffffff)}.ui-reader__scroll.ui-skillview .ui-skillview__tabs{top:-16px;margin:0 -32px;padding:0 32px}.ui-skillview__count{min-width:18px;padding:0 5px;border-radius:999px;font-size:11px;line-height:16px;text-align:center;background:var(--gemboss-primary-soft, #f2f3f5);color:var(--gemboss-text-muted, #686b71);font-variant-numeric:tabular-nums}@media (max-width: 47.9975em){.ui-reader__scroll.ui-skillview .ui-skillview__tabs{margin:0 -16px;padding:0 16px}}.ui-skillview__panel{display:grid;gap:20px;min-width:0}.ui-skillview__panel:focus{outline:none}.ui-skillview__sec{display:grid;gap:8px;min-width:0}.ui-skillview__h{margin:0;font-size:12px;line-height:16px;font-weight:650;letter-spacing:.06em;text-transform:uppercase;color:var(--gemboss-text-muted, #686b71)}.ui-skillview__note{margin:0;font-size:13px;line-height:19px;color:var(--gemboss-text-muted, #686b71);max-width:72ch}.ui-skillview__rules{display:grid;margin:0;padding:0;list-style:none;border:1px solid var(--gemboss-divider, #e5e7ea);border-radius:12px}.ui-skillview__rule{display:flex;align-items:flex-start;gap:12px;padding:10px 14px;min-width:0}.ui-skillview__rule+.ui-skillview__rule{border-top:1px solid var(--gemboss-divider, #e5e7ea)}.ui-skillview__code{flex:none;min-width:28px;padding:0 6px;border-radius:6px;font:600 11px/20px ui-monospace,SFMono-Regular,Menlo,monospace;text-align:center;background:var(--gemboss-primary-soft, #f2f3f5);color:var(--gemboss-text, #1b1c1e)}.ui-skillview__rulebody{display:grid;gap:2px;flex:1 1 auto;min-width:0}.ui-skillview__ruletitle{font-size:13px;line-height:20px;font-weight:600}.ui-skillview__ruleline{font-size:12px;line-height:18px;color:var(--gemboss-text-muted, #686b71)}.ui-skillview__hold{flex:none;display:inline-flex;align-items:center;gap:6px;font-size:12px;line-height:20px;color:var(--gemboss-text-muted, #686b71);white-space:nowrap}.ui-skillview__hold>i{width:7px;height:7px;box-sizing:border-box;border-radius:50%;border:1.5px solid currentColor}.ui-skillview__hold--checked>i{border-color:var(--gemboss-success, #007f5f);background:var(--gemboss-success, #007f5f)}.ui-skillview__hold--seeded>i{border-color:var(--gemboss-accent, #5661f5);background:var(--gemboss-accent, #5661f5)}.ui-skillview__hold--declared>i{border-color:var(--gemboss-chip-line, #cfd6ce)}@media (max-width: 47.9975em){.ui-skillview__rule{flex-wrap:wrap;row-gap:4px;padding:10px 12px}.ui-skillview__hold{flex-basis:100%;padding-left:40px}}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* SkillView — @gemboss/ui, unreleased (03/11/2026, the shared skills UI, plan "Clone cả store" S5). One skill, read in a popup over
|
|
5
|
+
* the list it came from: content-radar's skill popup (SkillDialog + SkillView, 24–26/10/2026) as a kit shell, so GemBoss's
|
|
6
|
+
* Assistant › Skills and content-radar's /v2/skills draw the same thing.
|
|
7
|
+
*
|
|
8
|
+
* It is the kit's ReaderDialog with a head (an icon, one short line, a few facts, the long reason behind "Why?") and a row of tabs.
|
|
9
|
+
* The tabs are SLOTS: the surface fills each one (a Flow canvas, its rules, its history, its stats) and a tab whose content is
|
|
10
|
+
* null is not drawn, so a skill with no flow simply has no Flow tab. Props only: no fetching, no routing; the surface keeps the open
|
|
11
|
+
* tab if it wants it in its URL (`tab` + `onTab`), or lets the popup keep it (`defaultTab`).
|
|
12
|
+
*
|
|
13
|
+
* 04/11/2026 (Chris: "Kit thêm slot, giữ giao diện content-radar"): the body is `SkillViewBody`, drawn without the dialog too
|
|
14
|
+
* (content-radar shows a skill in its writer popup's Skill pane and beside the chat of "Edit with AI"), and the head took
|
|
15
|
+
* content-radar's: a picture of its own (`iconSize`, a 96px mascot), lines of any shape in `intro` (English and a muted Vietnamese
|
|
16
|
+
* line under it), a tinted `callout` with its small-caps `calloutLabel` ("Kitchen"), `badges` (the kit's filled badges) and a quiet
|
|
17
|
+
* `note` ("Suggested when: …"). Every one optional: GemBoss's Assistant › Skills draws what it drew before.
|
|
18
|
+
*
|
|
19
|
+
* The tab bar is the kit's `ui-tabs` (button tabs, arrow keys move between them) and stays at the top while the body scrolls; a
|
|
20
|
+
* Flow canvas inside reads `--skf-sticky` so its zoom bar sticks under the tabs, not under them. `back` puts "← <label>" first in
|
|
21
|
+
* the head (Chris's popups: the way back top left); ✕ and Escape still close it. skill-view.css is its own entry.
|
|
22
|
+
*/
|
|
23
|
+
import "./skill-view.css";
|
|
24
|
+
import React, { useId, useRef, useState, type ReactNode } from "react";
|
|
25
|
+
import { ReaderDialog } from "./reader-dialog";
|
|
26
|
+
|
|
27
|
+
const cx = (...p: Array<string | false | null | undefined>) => p.filter(Boolean).join(" ");
|
|
28
|
+
|
|
29
|
+
/** The tabs in the order both products show them. A surface may add its own; these keys keep their place. */
|
|
30
|
+
export const SKILL_VIEW_TABS = [
|
|
31
|
+
{ key: "overview", label: "Overview" },
|
|
32
|
+
{ key: "flow", label: "Flow" },
|
|
33
|
+
{ key: "rules", label: "Rules" },
|
|
34
|
+
{ key: "history", label: "History" },
|
|
35
|
+
{ key: "lessons", label: "Lessons" },
|
|
36
|
+
{ key: "stats", label: "Stats" },
|
|
37
|
+
] as const;
|
|
38
|
+
|
|
39
|
+
export interface SkillViewTab {
|
|
40
|
+
key: string;
|
|
41
|
+
label: string;
|
|
42
|
+
/** A small number after the label (7 rules). Hidden when absent or 0. */
|
|
43
|
+
count?: number;
|
|
44
|
+
/** The tab's body. null / undefined: the tab is not drawn. */
|
|
45
|
+
content?: ReactNode;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** What a skill shows: its head and its tabs. SkillView puts it in a ReaderDialog; a surface may draw it anywhere else. */
|
|
49
|
+
export interface SkillViewBodyProps {
|
|
50
|
+
/** The skill's picture: a kit icon on a tile, or with `iconSize` a picture of its own. */
|
|
51
|
+
icon?: ReactNode;
|
|
52
|
+
/** The picture's size in px when it is not a kit icon (content-radar's 96px mascot): it stands bare, no tile. */
|
|
53
|
+
iconSize?: number;
|
|
54
|
+
/** What it does, one short line. Any shape: two lines (a translation under it, muted) fit. */
|
|
55
|
+
intro?: ReactNode;
|
|
56
|
+
/** A tinted box under the intro (content-radar's "Kitchen" line), its `calloutLabel` in small caps before the first line. */
|
|
57
|
+
callout?: ReactNode;
|
|
58
|
+
calloutLabel?: ReactNode;
|
|
59
|
+
/** A few facts as quiet chips (a version, a count of rules). Empty ones are dropped. */
|
|
60
|
+
facts?: readonly ReactNode[];
|
|
61
|
+
/** Traits as the kit's filled badges (a voice, a style, "EN 500–600 words"), after the facts. Empty ones are dropped. */
|
|
62
|
+
badges?: readonly ReactNode[];
|
|
63
|
+
/** A quiet line or two under the badges ("Suggested when: …"). */
|
|
64
|
+
note?: ReactNode;
|
|
65
|
+
/** The longer reason, folded behind "Why?". */
|
|
66
|
+
why?: ReactNode;
|
|
67
|
+
whyLabel?: string;
|
|
68
|
+
tabs: readonly SkillViewTab[];
|
|
69
|
+
/** Controlled tab; with `onTab`. */
|
|
70
|
+
tab?: string;
|
|
71
|
+
onTab?: (key: string) => void;
|
|
72
|
+
defaultTab?: string;
|
|
73
|
+
/** The tab row's name for a screen reader. */
|
|
74
|
+
tabsLabel?: string;
|
|
75
|
+
/** While the skill's details load: a quiet line instead of the tabs' bodies. */
|
|
76
|
+
loading?: boolean;
|
|
77
|
+
loadingLabel?: string;
|
|
78
|
+
/** A read that failed, said in the body. */
|
|
79
|
+
error?: ReactNode;
|
|
80
|
+
className?: string;
|
|
81
|
+
tabIndex?: number;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface SkillViewProps extends Omit<SkillViewBodyProps, "className" | "tabIndex"> {
|
|
85
|
+
open: boolean;
|
|
86
|
+
onClose: () => void;
|
|
87
|
+
title: ReactNode;
|
|
88
|
+
/** One line under the title: "advertorial · v2 · updated 28 Oct". */
|
|
89
|
+
subtitle?: ReactNode;
|
|
90
|
+
/** Beside the title, before ✕: "Use this skill". */
|
|
91
|
+
actions?: ReactNode;
|
|
92
|
+
/** "← Skills" first in the head. `onClick` defaults to closing. */
|
|
93
|
+
back?: { label: string; onClick?: () => void };
|
|
94
|
+
/** The popup's class (the body is the kit's). */
|
|
95
|
+
className?: string;
|
|
96
|
+
closeLabel?: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const present = (f: ReactNode) => f !== null && f !== undefined && f !== false && f !== "";
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* A skill's head and tabs, without the dialog: in a ReaderDialog give it `className="ui-reader__scroll"` (SkillView does), so it is
|
|
103
|
+
* the popup's scroller and its tab row sticks to the popup's top edge; anywhere else it is a column whose tab row sticks to the top
|
|
104
|
+
* of whatever scrolls round it.
|
|
105
|
+
*/
|
|
106
|
+
export function SkillViewBody({
|
|
107
|
+
icon, iconSize, intro, callout, calloutLabel, facts = [], badges = [], note, why, whyLabel = "Why?", tabs, tab, onTab, defaultTab,
|
|
108
|
+
tabsLabel = "Skill sections", loading = false, loadingLabel = "Loading…", error, className, tabIndex,
|
|
109
|
+
}: SkillViewBodyProps) {
|
|
110
|
+
const shown = tabs.filter((t) => t.content !== null && t.content !== undefined && t.content !== false);
|
|
111
|
+
const [own, setOwn] = useState<string | undefined>(defaultTab);
|
|
112
|
+
const want = tab ?? own;
|
|
113
|
+
const cur = shown.find((t) => t.key === want) ?? shown[0];
|
|
114
|
+
const pick = (key: string) => { if (tab === undefined) setOwn(key); onTab?.(key); };
|
|
115
|
+
const base = useId();
|
|
116
|
+
const tabsRef = useRef<HTMLDivElement>(null);
|
|
117
|
+
const chips = facts.filter(present);
|
|
118
|
+
const tags = badges.filter(present);
|
|
119
|
+
// Arrow keys move along the tabs and pick (the kit's tabs are a tablist; Home / End go to the ends).
|
|
120
|
+
const onKeyDown = (e: React.KeyboardEvent) => {
|
|
121
|
+
const i = shown.findIndex((t) => t.key === cur?.key);
|
|
122
|
+
const to = e.key === "ArrowRight" ? i + 1 : e.key === "ArrowLeft" ? i - 1 : e.key === "Home" ? 0 : e.key === "End" ? shown.length - 1 : null;
|
|
123
|
+
if (to === null || !shown.length) return;
|
|
124
|
+
e.preventDefault();
|
|
125
|
+
const next = shown[(to + shown.length) % shown.length]!;
|
|
126
|
+
pick(next.key);
|
|
127
|
+
tabsRef.current?.querySelector<HTMLButtonElement>(`[data-tab="${next.key}"]`)?.focus();
|
|
128
|
+
};
|
|
129
|
+
const art = typeof iconSize === "number" && iconSize > 0;
|
|
130
|
+
return (
|
|
131
|
+
<div className={cx(className, "ui-skillview")} tabIndex={tabIndex}>
|
|
132
|
+
{icon || intro || callout || chips.length || tags.length || note || why ? (
|
|
133
|
+
<header className={art ? "ui-skillview__hero ui-skillview__hero--art" : "ui-skillview__hero"}>
|
|
134
|
+
{icon ? (art
|
|
135
|
+
? <span className="ui-skillview__art" aria-hidden="true" style={{ ["--ui-skillview-art" as string]: `${iconSize}px` } as React.CSSProperties}>{icon}</span>
|
|
136
|
+
: <span className="ui-skillview__icon" aria-hidden="true">{icon}</span>) : null}
|
|
137
|
+
<div className="ui-skillview__lead">
|
|
138
|
+
{intro ? <div className="ui-skillview__intro">{intro}</div> : null}
|
|
139
|
+
{callout ? (
|
|
140
|
+
<div className="ui-skillview__callout">
|
|
141
|
+
{calloutLabel ? <span className="ui-skillview__calloutlabel">{calloutLabel} · </span> : null}
|
|
142
|
+
{callout}
|
|
143
|
+
</div>
|
|
144
|
+
) : null}
|
|
145
|
+
{chips.length ? <ul className="ui-skillview__facts">{chips.map((f, i) => <li key={i} className="ui-skillview__fact">{f}</li>)}</ul> : null}
|
|
146
|
+
{tags.length ? <ul className="ui-skillview__badges">{tags.map((f, i) => <li key={i} className="ui-badge">{f}</li>)}</ul> : null}
|
|
147
|
+
{note ? <div className="ui-skillview__note">{note}</div> : null}
|
|
148
|
+
{why ? (
|
|
149
|
+
<details className="ui-skillview__why">
|
|
150
|
+
<summary>{whyLabel}</summary>
|
|
151
|
+
<div className="ui-skillview__whytext">{why}</div>
|
|
152
|
+
</details>
|
|
153
|
+
) : null}
|
|
154
|
+
</div>
|
|
155
|
+
</header>
|
|
156
|
+
) : null}
|
|
157
|
+
{error ? <p className="ui-skillview__error" role="alert">{error}</p> : null}
|
|
158
|
+
{shown.length > 1 ? (
|
|
159
|
+
<div className="ui-tabs ui-skillview__tabs" role="tablist" aria-label={tabsLabel} ref={tabsRef} onKeyDown={onKeyDown}>
|
|
160
|
+
{shown.map((t) => (
|
|
161
|
+
<button key={t.key} type="button" role="tab" id={`${base}-t-${t.key}`} data-tab={t.key} aria-selected={cur?.key === t.key}
|
|
162
|
+
aria-controls={`${base}-p-${t.key}`} tabIndex={cur?.key === t.key ? 0 : -1} onClick={() => pick(t.key)}>
|
|
163
|
+
{t.label}{t.count ? <span className="ui-skillview__count">{t.count}</span> : null}
|
|
164
|
+
</button>
|
|
165
|
+
))}
|
|
166
|
+
</div>
|
|
167
|
+
) : null}
|
|
168
|
+
{loading ? <p className="ui-skillview__loading">{loadingLabel}</p> : cur ? (
|
|
169
|
+
<div className="ui-skillview__panel" role={shown.length > 1 ? "tabpanel" : undefined} id={`${base}-p-${cur.key}`}
|
|
170
|
+
aria-labelledby={shown.length > 1 ? `${base}-t-${cur.key}` : undefined} data-tab={cur.key}>
|
|
171
|
+
{cur.content}
|
|
172
|
+
</div>
|
|
173
|
+
) : null}
|
|
174
|
+
</div>
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** One skill in the kit's ReaderDialog: the head's title, subtitle, actions and "← Back", over SkillViewBody. */
|
|
179
|
+
export function SkillView({ open, onClose, title, subtitle, actions, back, className, closeLabel, ...body }: SkillViewProps) {
|
|
180
|
+
return (
|
|
181
|
+
// The popup itself takes the focus on opening (as Sheet does), not "← Back": a ring on the way out is the first thing a mouse
|
|
182
|
+
// reader saw, and the arrow keys and Page Down read the skill from there.
|
|
183
|
+
<ReaderDialog open={open} onClose={onClose} title={title} subtitle={subtitle} actions={actions} closeLabel={closeLabel} focusPanel
|
|
184
|
+
className={cx("ui-skillview-pop", className)}
|
|
185
|
+
lead={back ? (
|
|
186
|
+
<button type="button" className="ui-skillview__back" onClick={back.onClick ?? onClose}>
|
|
187
|
+
<span aria-hidden="true">←</span> {back.label}
|
|
188
|
+
</button>
|
|
189
|
+
) : undefined}>
|
|
190
|
+
<SkillViewBody {...body} className="ui-reader__scroll" tabIndex={-1} />
|
|
191
|
+
</ReaderDialog>
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** How a rule is held, as the Rules tab says it: by the system before work starts, at the finish, at publish, measured, put on
|
|
196
|
+
* the page from the start, or only declared (the skill asks, nothing checks). The surface writes the words. */
|
|
197
|
+
export type SkillRuleHold = "door" | "gate" | "finish" | "publish" | "measured" | "seeded" | "declared";
|
|
198
|
+
export interface SkillRule {
|
|
199
|
+
key: string;
|
|
200
|
+
/** "P1", "C5": the rule's code in its pack. */
|
|
201
|
+
code?: string;
|
|
202
|
+
title: ReactNode;
|
|
203
|
+
/** One short line. Longer words go behind the surface's own "Why?". */
|
|
204
|
+
line?: ReactNode;
|
|
205
|
+
hold: SkillRuleHold;
|
|
206
|
+
/** The chip's words for `hold` ("Checked at publish"). */
|
|
207
|
+
holdLabel: ReactNode;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const HOLD_CLASS: Record<SkillRuleHold, string> = {
|
|
211
|
+
door: "ui-skillview__hold ui-skillview__hold--checked", gate: "ui-skillview__hold ui-skillview__hold--checked",
|
|
212
|
+
finish: "ui-skillview__hold ui-skillview__hold--checked", publish: "ui-skillview__hold ui-skillview__hold--checked",
|
|
213
|
+
measured: "ui-skillview__hold ui-skillview__hold--checked", seeded: "ui-skillview__hold ui-skillview__hold--seeded",
|
|
214
|
+
declared: "ui-skillview__hold ui-skillview__hold--declared",
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/** A skill's rules, one row each: the code, the rule, one line, and how it is held as a chip (a filled dot when the system checks
|
|
218
|
+
* it, an empty ring when it is only declared). */
|
|
219
|
+
export function SkillRuleList({ rules, className }: { rules: readonly SkillRule[]; className?: string }) {
|
|
220
|
+
if (!rules.length) return null;
|
|
221
|
+
return (
|
|
222
|
+
<ul className={cx("ui-skillview__rules", className)}>
|
|
223
|
+
{rules.map((r) => (
|
|
224
|
+
<li key={r.key} className="ui-skillview__rule">
|
|
225
|
+
{r.code ? <code className="ui-skillview__code">{r.code}</code> : null}
|
|
226
|
+
<span className="ui-skillview__rulebody">
|
|
227
|
+
<b className="ui-skillview__ruletitle">{r.title}</b>
|
|
228
|
+
{r.line ? <span className="ui-skillview__ruleline">{r.line}</span> : null}
|
|
229
|
+
</span>
|
|
230
|
+
<span className={HOLD_CLASS[r.hold] ?? HOLD_CLASS.declared}><i aria-hidden="true" />{r.holdLabel}</span>
|
|
231
|
+
</li>
|
|
232
|
+
))}
|
|
233
|
+
</ul>
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* One block of a tab: a small heading, an optional one-line note, then the body. The pieces every tab is made of, so the surfaces
|
|
239
|
+
* write their Rules and History the same way.
|
|
240
|
+
*/
|
|
241
|
+
export function SkillViewSection({ title, note, children, className }: { title?: ReactNode; note?: ReactNode; children?: ReactNode; className?: string }) {
|
|
242
|
+
return (
|
|
243
|
+
<section className={cx("ui-skillview__sec", className)}>
|
|
244
|
+
{title ? <h3 className="ui-skillview__h">{title}</h3> : null}
|
|
245
|
+
{note ? <p className="ui-skillview__note">{note}</p> : null}
|
|
246
|
+
{children}
|
|
247
|
+
</section>
|
|
248
|
+
);
|
|
249
|
+
}
|
package/src/theme-dark.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
:root[data-theme=dark]{color-scheme:dark;--gemboss-primary: #f2f3f5;--gemboss-primary-dark: #ffffff;--gemboss-primary-soft: #23242a;--gemboss-on-primary: #0d0d12;--gemboss-accent: #7c84ff;--gemboss-accent-strong: #a3a9ff;--gemboss-accent-soft: #1f2140;--gemboss-accent-wash: #181a33;--gemboss-accent-tint: #2a2e5c;--gemboss-accent-mid: #3b4180;--gemboss-text-strong: #f2f3f5;--gemboss-text: #e3e4e8;--gemboss-text-muted: #9a9ca6;--gemboss-surface: #16171d;--gemboss-canvas: #0d0d12;--gemboss-app-bg: #0d0d12;--gemboss-rail-bg: #0d0d12;--gemboss-panel-bg: #16171d;--gemboss-topbar-bg: rgba(13, 13, 18, .96);--gemboss-nav-bg: #0d0d12;--gemboss-nav-hover: rgba(255, 255, 255, .06);--gemboss-divider: #2a2b33;--gemboss-divider-soft: #22232a;--gemboss-hover: #22232b;--gemboss-active-bg: #262833;--gemboss-active-fg: #f2f3f5;--gemboss-field-bg: #121318;--gemboss-field-bg-hover: #17181e;--gemboss-field-ink: #e3e4e8;--gemboss-field-placeholder: #8a8c96;--gemboss-field-line: #3a3c46;--gemboss-field-line-hover: #50525e;--gemboss-field-line-active: #c9cbd3;--gemboss-chip-ink: #d6d8de;--gemboss-chip-line: #3a3c46;--gemboss-chip-line-hover: #50525e;--gemboss-chip-bg-hover: #22232b;--gemboss-success: #34c38f;--gemboss-success-strong: #5fd6a8;--gemboss-success-soft: #13291f;--gemboss-success-border: #22533e;--gemboss-warning: #e0b341;--gemboss-warning-soft: #2b2412;--gemboss-warning-border: #5a4a1d;--gemboss-danger: #ff6b5a;--gemboss-danger-strong: #ff8a7c;--gemboss-danger-soft: #2e1714;--gemboss-danger-border: #5c2a24;--ui-accent-fg: #0d0d12;--ui-warning-fg: #e8c063;--ui-card-shadow: none;--gb-brand-ink: #f2f3f5}:root[data-theme=dark] .gb-avatar[data-tone]{background:color-mix(in srgb,var(--gb-tone) 30%,#16171d);color:color-mix(in srgb,var(--gb-tone) 35%,#ffffff)}:root[data-theme=dark] body{background:var(--gemboss-app-bg);color:var(--gemboss-text)}:root[data-theme=dark] .gb-leaderboard-row.is-first .gb-leaderboard-value,:root[data-theme=dark] .gb-podium-slot--1 .gb-podium-value{color:#e0b341}
|
|
1
|
+
:root[data-theme=dark]{color-scheme:dark;--gemboss-primary: #f2f3f5;--gemboss-primary-dark: #ffffff;--gemboss-primary-soft: #23242a;--gemboss-on-primary: #0d0d12;--gemboss-accent: #7c84ff;--gemboss-accent-strong: #a3a9ff;--gemboss-accent-soft: #1f2140;--gemboss-accent-wash: #181a33;--gemboss-accent-tint: #2a2e5c;--gemboss-accent-mid: #3b4180;--gemboss-text-strong: #f2f3f5;--gemboss-text: #e3e4e8;--gemboss-text-muted: #9a9ca6;--gemboss-surface: #16171d;--gemboss-canvas: #0d0d12;--gemboss-app-bg: #0d0d12;--gemboss-rail-bg: #0d0d12;--gemboss-panel-bg: #16171d;--gemboss-topbar-bg: rgba(13, 13, 18, .96);--gemboss-nav-bg: #0d0d12;--gemboss-nav-hover: rgba(255, 255, 255, .06);--gemboss-divider: #2a2b33;--gemboss-divider-soft: #22232a;--gemboss-hover: #22232b;--gemboss-active-bg: #262833;--gemboss-active-fg: #f2f3f5;--gemboss-fill-tertiary: #2a2b33;--gemboss-fill-tertiary-hover: #33353f;--gemboss-fill-tertiary-active: #3a3c46;--gemboss-field-bg: #121318;--gemboss-field-bg-hover: #17181e;--gemboss-field-ink: #e3e4e8;--gemboss-field-placeholder: #8a8c96;--gemboss-field-line: #3a3c46;--gemboss-field-line-hover: #50525e;--gemboss-field-line-active: #c9cbd3;--gemboss-chip-ink: #d6d8de;--gemboss-chip-line: #3a3c46;--gemboss-chip-line-hover: #50525e;--gemboss-chip-bg-hover: #22232b;--gemboss-success: #34c38f;--gemboss-success-strong: #5fd6a8;--gemboss-success-soft: #13291f;--gemboss-success-border: #22533e;--gemboss-warning: #e0b341;--gemboss-warning-soft: #2b2412;--gemboss-warning-border: #5a4a1d;--gemboss-danger: #ff6b5a;--gemboss-danger-strong: #ff8a7c;--gemboss-danger-soft: #2e1714;--gemboss-danger-border: #5c2a24;--ui-accent-fg: #0d0d12;--ui-warning-fg: #e8c063;--ui-card-shadow: none;--gb-brand-ink: #f2f3f5}:root[data-theme=dark] .gb-avatar[data-tone]{background:color-mix(in srgb,var(--gb-tone) 30%,#16171d);color:color-mix(in srgb,var(--gb-tone) 35%,#ffffff)}:root[data-theme=dark] body{background:var(--gemboss-app-bg);color:var(--gemboss-text)}:root[data-theme=dark] .gb-leaderboard-row.is-first .gb-leaderboard-value,:root[data-theme=dark] .gb-podium-slot--1 .gb-podium-value{color:#e0b341}
|