@42-central/ui-react 0.24.0 → 0.26.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/dist/{chunk-YWTOW7PZ.js → chunk-276RL7FX.js} +10 -10
- package/dist/{chunk-YWTOW7PZ.js.map → chunk-276RL7FX.js.map} +1 -1
- package/dist/{chunk-FUNTJZX7.js → chunk-2CL3FKEY.js} +3 -3
- package/dist/{chunk-FUNTJZX7.js.map → chunk-2CL3FKEY.js.map} +1 -1
- package/dist/{chunk-YPFSRZ3T.js → chunk-2NTCQIRP.js} +5 -5
- package/dist/{chunk-YPFSRZ3T.js.map → chunk-2NTCQIRP.js.map} +1 -1
- package/dist/{chunk-D3JYDAUZ.js → chunk-2TZU4LSX.js} +4 -4
- package/dist/{chunk-D3JYDAUZ.js.map → chunk-2TZU4LSX.js.map} +1 -1
- package/dist/{chunk-DJLNGWMM.js → chunk-6IRMKF5T.js} +3 -3
- package/dist/{chunk-DJLNGWMM.js.map → chunk-6IRMKF5T.js.map} +1 -1
- package/dist/{chunk-DT6LKNZF.js → chunk-7247WBTV.js} +5 -4
- package/dist/chunk-7247WBTV.js.map +1 -0
- package/dist/{chunk-F2FSHVO5.js → chunk-7B44J3CF.js} +7 -7
- package/dist/{chunk-F2FSHVO5.js.map → chunk-7B44J3CF.js.map} +1 -1
- package/dist/{chunk-6VYGK3Q3.js → chunk-7E7JNWOC.js} +16 -21
- package/dist/chunk-7E7JNWOC.js.map +1 -0
- package/dist/{chunk-7AQ4MN4M.js → chunk-7OGZT7U2.js} +14 -6
- package/dist/chunk-7OGZT7U2.js.map +1 -0
- package/dist/{chunk-UAYENYS2.js → chunk-AKXALCUN.js} +3 -3
- package/dist/{chunk-UAYENYS2.js.map → chunk-AKXALCUN.js.map} +1 -1
- package/dist/{chunk-BE2LWUHY.js → chunk-BMEJBY6H.js} +5 -3
- package/dist/chunk-BMEJBY6H.js.map +1 -0
- package/dist/{chunk-DHJB4UJD.js → chunk-DMI4KS32.js} +5 -5
- package/dist/{chunk-DHJB4UJD.js.map → chunk-DMI4KS32.js.map} +1 -1
- package/dist/{chunk-FB2G4LNH.js → chunk-DSZF2TW6.js} +7 -7
- package/dist/{chunk-FB2G4LNH.js.map → chunk-DSZF2TW6.js.map} +1 -1
- package/dist/{chunk-N66NC6QK.js → chunk-E3XLWMEB.js} +3 -3
- package/dist/{chunk-N66NC6QK.js.map → chunk-E3XLWMEB.js.map} +1 -1
- package/dist/{chunk-MXAACRWE.js → chunk-E52Z2FKU.js} +5 -5
- package/dist/{chunk-MXAACRWE.js.map → chunk-E52Z2FKU.js.map} +1 -1
- package/dist/chunk-F374BNL4.js +129 -0
- package/dist/chunk-F374BNL4.js.map +1 -0
- package/dist/{chunk-3L5GLI67.js → chunk-I4B3N3UX.js} +3 -3
- package/dist/{chunk-3L5GLI67.js.map → chunk-I4B3N3UX.js.map} +1 -1
- package/dist/{chunk-IPYHTCFL.js → chunk-IUK7OJXZ.js} +3 -3
- package/dist/{chunk-IPYHTCFL.js.map → chunk-IUK7OJXZ.js.map} +1 -1
- package/dist/{chunk-HRNWWL3Y.js → chunk-J2NW7JID.js} +61 -29
- package/dist/chunk-J2NW7JID.js.map +1 -0
- package/dist/{chunk-MRAJ45IM.js → chunk-JDPVD2YE.js} +5 -5
- package/dist/{chunk-MRAJ45IM.js.map → chunk-JDPVD2YE.js.map} +1 -1
- package/dist/{chunk-SZEOTXRZ.js → chunk-JFB6O7IY.js} +5 -5
- package/dist/{chunk-SZEOTXRZ.js.map → chunk-JFB6O7IY.js.map} +1 -1
- package/dist/{chunk-2MXWEIMD.js → chunk-KKLCHLCZ.js} +12 -11
- package/dist/chunk-KKLCHLCZ.js.map +1 -0
- package/dist/{chunk-6N6J2DOE.js → chunk-LIZWCWED.js} +3 -3
- package/dist/{chunk-6N6J2DOE.js.map → chunk-LIZWCWED.js.map} +1 -1
- package/dist/chunk-LJVIZNPE.js +9 -0
- package/dist/chunk-LJVIZNPE.js.map +1 -0
- package/dist/{chunk-HQPU73WV.js → chunk-LYGOFMXJ.js} +3 -3
- package/dist/{chunk-HQPU73WV.js.map → chunk-LYGOFMXJ.js.map} +1 -1
- package/dist/{chunk-JVG5ISPT.js → chunk-N42EFOML.js} +4 -4
- package/dist/{chunk-JVG5ISPT.js.map → chunk-N42EFOML.js.map} +1 -1
- package/dist/{chunk-C4NFRSOR.js → chunk-NF2PBGD3.js} +38 -25
- package/dist/chunk-NF2PBGD3.js.map +1 -0
- package/dist/{chunk-DA4QII2N.js → chunk-NLSJ6T7V.js} +4 -4
- package/dist/{chunk-DA4QII2N.js.map → chunk-NLSJ6T7V.js.map} +1 -1
- package/dist/{chunk-UT3TOV2Q.js → chunk-OVT2KZHY.js} +3 -3
- package/dist/{chunk-UT3TOV2Q.js.map → chunk-OVT2KZHY.js.map} +1 -1
- package/dist/{chunk-MW42XVPD.js → chunk-PBSVX5DB.js} +15 -5
- package/dist/chunk-PBSVX5DB.js.map +1 -0
- package/dist/{chunk-SVKN5ZHX.js → chunk-PEHFWGTT.js} +16 -13
- package/dist/chunk-PEHFWGTT.js.map +1 -0
- package/dist/{chunk-J44FJ7PH.js → chunk-PFZMB3US.js} +4 -4
- package/dist/{chunk-J44FJ7PH.js.map → chunk-PFZMB3US.js.map} +1 -1
- package/dist/{chunk-IRNF274I.js → chunk-PT22KEVD.js} +5 -5
- package/dist/{chunk-IRNF274I.js.map → chunk-PT22KEVD.js.map} +1 -1
- package/dist/{chunk-OZMSXYBX.js → chunk-QEAF57ZQ.js} +4 -4
- package/dist/{chunk-OZMSXYBX.js.map → chunk-QEAF57ZQ.js.map} +1 -1
- package/dist/{chunk-SWVUXEBT.js → chunk-SCXXJDKQ.js} +3 -3
- package/dist/{chunk-SWVUXEBT.js.map → chunk-SCXXJDKQ.js.map} +1 -1
- package/dist/{chunk-E5H3YWZV.js → chunk-SOUDKESO.js} +15 -8
- package/dist/chunk-SOUDKESO.js.map +1 -0
- package/dist/{chunk-4FEOMQYR.js → chunk-THGJLR5S.js} +6 -6
- package/dist/{chunk-4FEOMQYR.js.map → chunk-THGJLR5S.js.map} +1 -1
- package/dist/{chunk-TCFB23JT.js → chunk-WERJ44ZN.js} +3 -3
- package/dist/{chunk-TCFB23JT.js.map → chunk-WERJ44ZN.js.map} +1 -1
- package/dist/{chunk-QNKD2SQM.js → chunk-X3YIHN2U.js} +5 -5
- package/dist/{chunk-QNKD2SQM.js.map → chunk-X3YIHN2U.js.map} +1 -1
- package/dist/{chunk-VD6PB3VA.js → chunk-X6DESK37.js} +12 -3
- package/dist/chunk-X6DESK37.js.map +1 -0
- package/dist/{chunk-47LEAR6G.js → chunk-Y2G47ARQ.js} +6 -6
- package/dist/{chunk-47LEAR6G.js.map → chunk-Y2G47ARQ.js.map} +1 -1
- package/dist/{chunk-O7LS6OZR.js → chunk-YMVUQ2L7.js} +4 -4
- package/dist/{chunk-O7LS6OZR.js.map → chunk-YMVUQ2L7.js.map} +1 -1
- package/dist/{chunk-F342ZT7O.js → chunk-ZVECQBGG.js} +13 -7
- package/dist/chunk-ZVECQBGG.js.map +1 -0
- package/dist/components/action-icon/action-icon.d.ts.map +1 -1
- package/dist/components/action-icon/index.js +1 -1
- package/dist/components/alert/index.js +1 -1
- package/dist/components/ambient-background/index.js +14 -26
- package/dist/components/ambient-background/index.js.map +1 -1
- package/dist/components/ambient-background/starfield.d.ts.map +1 -1
- package/dist/components/app-shell/app-shell.d.ts +55 -10
- package/dist/components/app-shell/app-shell.d.ts.map +1 -1
- package/dist/components/app-shell/index.d.ts +1 -1
- package/dist/components/app-shell/index.d.ts.map +1 -1
- package/dist/components/app-shell/index.js +300 -39
- package/dist/components/app-shell/index.js.map +1 -1
- package/dist/components/autocomplete/index.js +5 -5
- package/dist/components/avatar/avatar.d.ts +1 -1
- package/dist/components/avatar/avatar.d.ts.map +1 -1
- package/dist/components/avatar/index.js +12 -3
- package/dist/components/avatar/index.js.map +1 -1
- package/dist/components/badge/badge.d.ts.map +1 -1
- package/dist/components/badge/index.js +1 -1
- package/dist/components/button/index.js +1 -1
- package/dist/components/button-group/button-group.d.ts +10 -2
- package/dist/components/button-group/button-group.d.ts.map +1 -1
- package/dist/components/button-group/index.js +1 -1
- package/dist/components/button-multi-select/index.js +4 -4
- package/dist/components/button-select/button-select-control.d.ts +4 -1
- package/dist/components/button-select/button-select-control.d.ts.map +1 -1
- package/dist/components/button-select/button-select.d.ts +4 -1
- package/dist/components/button-select/button-select.d.ts.map +1 -1
- package/dist/components/button-select/index.js +4 -4
- package/dist/components/calendar/index.js +4 -4
- package/dist/components/calendar-heatmap/index.js +2 -2
- package/dist/components/camera/index.js +12 -12
- package/dist/components/card/card.d.ts.map +1 -1
- package/dist/components/card/index.js +1 -1
- package/dist/components/carousel/index.js +2 -2
- package/dist/components/checkbox/checkbox.d.ts +3 -2
- package/dist/components/checkbox/checkbox.d.ts.map +1 -1
- package/dist/components/checkbox/index.js +2 -2
- package/dist/components/choice-card-group/index.js +2 -2
- package/dist/components/choice-card-group/index.js.map +1 -1
- package/dist/components/clipboard/index.js +3 -3
- package/dist/components/code-block/chrome.js +3 -3
- package/dist/components/code-block/code-block.d.ts +6 -3
- package/dist/components/code-block/code-block.d.ts.map +1 -1
- package/dist/components/code-block/highlighter.d.ts +16 -15
- package/dist/components/code-block/highlighter.d.ts.map +1 -1
- package/dist/components/code-block/index.d.ts +2 -1
- package/dist/components/code-block/index.d.ts.map +1 -1
- package/dist/components/code-block/index.js +85 -14
- package/dist/components/code-block/index.js.map +1 -1
- package/dist/components/code-block/languages.d.ts +61 -0
- package/dist/components/code-block/languages.d.ts.map +1 -0
- package/dist/components/code-block/static.d.ts +2 -1
- package/dist/components/code-block/static.d.ts.map +1 -1
- package/dist/components/code-block/static.js +99 -10
- package/dist/components/code-block/static.js.map +1 -1
- package/dist/components/combobox/index.js +5 -5
- package/dist/components/combobox-list/index.js +7 -7
- package/dist/components/compare/index.js +2 -2
- package/dist/components/data-table/index.js +32 -32
- package/dist/components/data-table/index.js.map +1 -1
- package/dist/components/date-picker/index.js +14 -14
- package/dist/components/download-button/index.js +2 -2
- package/dist/components/drawer/index.js +5 -5
- package/dist/components/field/field.d.ts +3 -0
- package/dist/components/field/field.d.ts.map +1 -1
- package/dist/components/field/index.js +1 -1
- package/dist/components/file-item/index.js +5 -5
- package/dist/components/file-preview/index.js +5 -5
- package/dist/components/file-trigger/index.js +2 -2
- package/dist/components/file-upload/index.js +6 -6
- package/dist/components/gallery/index.js +2 -2
- package/dist/components/geodesic/badge-frame.d.ts +13 -1
- package/dist/components/geodesic/badge-frame.d.ts.map +1 -1
- package/dist/components/geodesic/exam-badge.d.ts +4 -1
- package/dist/components/geodesic/exam-badge.d.ts.map +1 -1
- package/dist/components/geodesic/geometry.d.ts +14 -9
- package/dist/components/geodesic/geometry.d.ts.map +1 -1
- package/dist/components/geodesic/index.js +62 -23
- package/dist/components/geodesic/index.js.map +1 -1
- package/dist/components/geodesic/status.d.ts +8 -6
- package/dist/components/geodesic/status.d.ts.map +1 -1
- package/dist/components/geodesic/styles.css +15 -2
- package/dist/components/hover-card/index.js +2 -2
- package/dist/components/image-cropper/index.js +7 -7
- package/dist/components/indicator/index.js +24 -9
- package/dist/components/indicator/index.js.map +1 -1
- package/dist/components/indicator/indicator.d.ts +15 -6
- package/dist/components/indicator/indicator.d.ts.map +1 -1
- package/dist/components/input/index.js +2 -2
- package/dist/components/kbd/index.js +3 -3
- package/dist/components/kbd/kbd.d.ts.map +1 -1
- package/dist/components/lightbox/index.js +8 -8
- package/dist/components/menu/index.js +4 -4
- package/dist/components/modal/index.js +5 -5
- package/dist/components/multi-combobox-list/index.js +7 -7
- package/dist/components/multi-select/index.js +8 -8
- package/dist/components/nav-link/index.js +5 -1
- package/dist/components/nav-link/nav-link.d.ts.map +1 -1
- package/dist/components/nav-link/tanstack.js +5 -1
- package/dist/components/nav-link/tanstack.js.map +1 -1
- package/dist/components/number-input/index.js +5 -5
- package/dist/components/overlays/index.js +7 -7
- package/dist/components/password-input/index.js +3 -3
- package/dist/components/photo-capture/index.js +16 -16
- package/dist/components/pills-input/index.js +5 -5
- package/dist/components/pin-input/index.js +2 -2
- package/dist/components/popover/index.js +2 -2
- package/dist/components/radio-group/index.js +1 -1
- package/dist/components/rating/index.js +1 -1
- package/dist/components/schedule/index.js +7 -7
- package/dist/components/segment-group/index.js +4 -4
- package/dist/components/segment-group/segment-group.d.ts +6 -1
- package/dist/components/segment-group/segment-group.d.ts.map +1 -1
- package/dist/components/select/index.js +6 -6
- package/dist/components/slider/index.js +2 -2
- package/dist/components/spotlight/index.js +11 -11
- package/dist/components/switch/index.js +14 -19
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/switch/switch.d.ts +1 -0
- package/dist/components/switch/switch.d.ts.map +1 -1
- package/dist/components/table/index.js +1 -1
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/tabs/index.js +3 -3
- package/dist/components/tabs/tabs-data.d.ts +4 -1
- package/dist/components/tabs/tabs-data.d.ts.map +1 -1
- package/dist/components/tabs/tabs.d.ts +4 -1
- package/dist/components/tabs/tabs.d.ts.map +1 -1
- package/dist/components/tags-input/index.js +7 -7
- package/dist/components/text-input/index.js +2 -2
- package/dist/components/textarea/index.js +2 -2
- package/dist/components/theme-icon/index.js +1 -1
- package/dist/components/theme-icon/theme-icon.d.ts.map +1 -1
- package/dist/components/time-input/index.js +9 -9
- package/dist/components/tree-multi-select/index.js +8 -8
- package/dist/components/tree-select/index.js +5 -5
- package/dist/index.js +4 -4
- package/dist/lib/sidebar-rail.d.ts +21 -0
- package/dist/lib/sidebar-rail.d.ts.map +1 -0
- package/dist/theme.css +35 -35
- package/package.json +1 -1
- package/src/as-child.contract.test.tsx +6 -0
- package/src/components/action-icon/action-icon.tsx +3 -1
- package/src/components/ambient-background/starfield.tsx +18 -43
- package/src/components/app-shell/app-shell.test.tsx +430 -5
- package/src/components/app-shell/app-shell.tsx +484 -24
- package/src/components/app-shell/index.ts +2 -0
- package/src/components/avatar/avatar.test.tsx +12 -0
- package/src/components/avatar/avatar.tsx +9 -0
- package/src/components/badge/badge.tsx +11 -6
- package/src/components/button/button.tsx +1 -1
- package/src/components/button-group/button-group.test.tsx +24 -0
- package/src/components/button-group/button-group.tsx +21 -4
- package/src/components/button-multi-select/button-multi-select.test.tsx +15 -0
- package/src/components/button-select/button-select-control.tsx +5 -0
- package/src/components/button-select/button-select.test.tsx +25 -0
- package/src/components/button-select/button-select.tsx +13 -2
- package/src/components/card/card.tsx +10 -9
- package/src/components/checkbox/checkbox.test.tsx +17 -9
- package/src/components/checkbox/checkbox.tsx +26 -27
- package/src/components/choice-card-group/choice-card-group.tsx +3 -3
- package/src/components/code-block/code-block.tsx +7 -4
- package/src/components/code-block/highlighter.test.ts +79 -1
- package/src/components/code-block/highlighter.ts +76 -30
- package/src/components/code-block/index.ts +2 -0
- package/src/components/code-block/languages.ts +63 -0
- package/src/components/code-block/static.tsx +2 -1
- package/src/components/data-table/data-table-pagination.tsx +5 -5
- package/src/components/data-table/data-table-stack.tsx +2 -2
- package/src/components/field/field.tsx +14 -0
- package/src/components/geodesic/badge-frame.tsx +67 -13
- package/src/components/geodesic/exam-badge.tsx +8 -4
- package/src/components/geodesic/geometry.ts +8 -6
- package/src/components/geodesic/status.test.ts +11 -2
- package/src/components/geodesic/status.ts +11 -7
- package/src/components/geodesic/styles.css +15 -2
- package/src/components/indicator/indicator.test.tsx +45 -0
- package/src/components/indicator/indicator.tsx +40 -13
- package/src/components/kbd/kbd.tsx +2 -1
- package/src/components/nav-link/nav-link.test.tsx +121 -1
- package/src/components/nav-link/nav-link.tsx +78 -29
- package/src/components/segment-group/segment-group.test.tsx +22 -0
- package/src/components/segment-group/segment-group.tsx +35 -19
- package/src/components/switch/switch.test.tsx +15 -0
- package/src/components/switch/switch.tsx +27 -27
- package/src/components/table/table.test.tsx +1 -1
- package/src/components/table/table.tsx +14 -11
- package/src/components/tabs/tabs-data.tsx +5 -1
- package/src/components/tabs/tabs.test.tsx +28 -0
- package/src/components/tabs/tabs.tsx +14 -4
- package/src/components/theme-icon/theme-icon.tsx +46 -12
- package/src/lib/sidebar-rail.ts +24 -0
- package/src/theme.css +35 -35
- package/src/theme.test.ts +0 -1
- package/dist/chunk-2MXWEIMD.js.map +0 -1
- package/dist/chunk-6VYGK3Q3.js.map +0 -1
- package/dist/chunk-7AQ4MN4M.js.map +0 -1
- package/dist/chunk-7CNDZZZ6.js +0 -95
- package/dist/chunk-7CNDZZZ6.js.map +0 -1
- package/dist/chunk-BE2LWUHY.js.map +0 -1
- package/dist/chunk-C4NFRSOR.js.map +0 -1
- package/dist/chunk-DT6LKNZF.js.map +0 -1
- package/dist/chunk-E5H3YWZV.js.map +0 -1
- package/dist/chunk-F342ZT7O.js.map +0 -1
- package/dist/chunk-HRNWWL3Y.js.map +0 -1
- package/dist/chunk-MW42XVPD.js.map +0 -1
- package/dist/chunk-SVKN5ZHX.js.map +0 -1
- package/dist/chunk-VD6PB3VA.js.map +0 -1
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
2
|
+
HighlighterCore,
|
|
3
3
|
LanguageInput,
|
|
4
4
|
ShikiTransformer,
|
|
5
5
|
ShikiTransformerContext,
|
|
6
6
|
ThemeInput,
|
|
7
7
|
} from "shiki"
|
|
8
8
|
import type { Color } from "../../lib/colors"
|
|
9
|
+
import { devWarnOnce } from "../../lib/dev-warn"
|
|
9
10
|
import { type CodeBlockGutterColumn, resolveGutterColumns } from "./gutters"
|
|
11
|
+
import { type CodeBlockLanguage, languageLoader } from "./languages"
|
|
10
12
|
import { type ParsedNotation, parseNotation } from "./notation"
|
|
11
13
|
|
|
12
14
|
/** Structurally the same `Element` (hast) type `ShikiTransformer`'s own
|
|
@@ -20,33 +22,49 @@ type HastNode = LineHast["children"][number]
|
|
|
20
22
|
/**
|
|
21
23
|
* Module-level singleton — created lazily on first use, shared by every
|
|
22
24
|
* `CodeBlock` on the page (a docs page can render dozens).
|
|
25
|
+
*
|
|
26
|
+
* Built from Shiki's fine-grained core, never the bare `shiki` entry: that
|
|
27
|
+
* one's registries carry ~300 grammar/theme imports and the Oniguruma WASM,
|
|
28
|
+
* which every consumer's bundler would have to emit. The JavaScript regex
|
|
29
|
+
* engine replaces the WASM, the two default themes are the only themes
|
|
30
|
+
* loaded by name, and grammars come from the finite `LANGUAGES` map.
|
|
23
31
|
*/
|
|
24
32
|
const DEFAULT_THEMES = { light: "github-light", dark: "github-dark-default" } as const
|
|
25
33
|
|
|
26
|
-
let highlighterPromise: Promise<
|
|
34
|
+
let highlighterPromise: Promise<HighlighterCore> | null = null
|
|
27
35
|
|
|
28
|
-
function getHighlighter(): Promise<
|
|
36
|
+
function getHighlighter(): Promise<HighlighterCore> {
|
|
29
37
|
if (!highlighterPromise) {
|
|
30
|
-
highlighterPromise =
|
|
31
|
-
|
|
38
|
+
highlighterPromise = Promise.all([
|
|
39
|
+
import("shiki/core"),
|
|
40
|
+
import("shiki/engine/javascript"),
|
|
41
|
+
import("shiki/themes/github-light.mjs"),
|
|
42
|
+
import("shiki/themes/github-dark-default.mjs"),
|
|
43
|
+
]).then(([{ createHighlighterCore }, { createJavaScriptRegexEngine }, light, dark]) =>
|
|
44
|
+
createHighlighterCore({
|
|
45
|
+
themes: [light.default, dark.default],
|
|
46
|
+
langs: [],
|
|
47
|
+
engine: createJavaScriptRegexEngine(),
|
|
48
|
+
}),
|
|
32
49
|
)
|
|
33
50
|
}
|
|
34
51
|
return highlighterPromise
|
|
35
52
|
}
|
|
36
53
|
|
|
37
54
|
/**
|
|
38
|
-
* Register a
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* (e.g. at app startup) before rendering a `CodeBlock` that
|
|
55
|
+
* Register a TextMate grammar so `<CodeBlock language="...">` can reference
|
|
56
|
+
* it by name. Needed for any language outside the bundled `LANGUAGES` map,
|
|
57
|
+
* including Shiki's own: `registerLanguage((await import("shiki/langs/haskell.mjs")).default)`.
|
|
58
|
+
* Await this once (e.g. at app startup) before rendering a `CodeBlock` that
|
|
59
|
+
* uses it.
|
|
42
60
|
*/
|
|
43
61
|
export async function registerLanguage(lang: LanguageInput): Promise<void> {
|
|
44
62
|
const highlighter = await getHighlighter()
|
|
45
63
|
await highlighter.loadLanguage(lang)
|
|
46
64
|
}
|
|
47
65
|
|
|
48
|
-
/** Register a
|
|
49
|
-
*
|
|
66
|
+
/** Register a VS Code-style theme so `themes` can reference it by name.
|
|
67
|
+
* Only `github-light` and `github-dark-default` load without it. */
|
|
50
68
|
export async function registerTheme(theme: ThemeInput): Promise<void> {
|
|
51
69
|
const highlighter = await getHighlighter()
|
|
52
70
|
await highlighter.loadTheme(theme)
|
|
@@ -80,7 +98,7 @@ type CodeBlockStyle = {
|
|
|
80
98
|
export type CodeBlockTagStyle = CodeBlockStyle
|
|
81
99
|
|
|
82
100
|
export type HighlightOptions = {
|
|
83
|
-
lang?:
|
|
101
|
+
lang?: CodeBlockLanguage
|
|
84
102
|
themes?: { light: string; dark: string }
|
|
85
103
|
/** Notation-tag → styling lookup — see `CodeBlockTagStyle`. */
|
|
86
104
|
tags?: Record<string, CodeBlockTagStyle>
|
|
@@ -256,29 +274,57 @@ function buildCodeBlockTransformer(
|
|
|
256
274
|
}
|
|
257
275
|
}
|
|
258
276
|
|
|
259
|
-
/**
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
|
|
277
|
+
/** Shiki's built-in plain-text names: rendered without any grammar. */
|
|
278
|
+
const PLAIN_LANGUAGES = new Set(["text", "txt", "plain", "plaintext"])
|
|
279
|
+
|
|
280
|
+
/** Resolves `lang` to a name the highlighter can render: already loaded
|
|
281
|
+
* (bundled earlier, or registered), loadable from the `LANGUAGES` map, or
|
|
282
|
+
* else plain text, with a dev warning naming the fix. Unknown names used to
|
|
283
|
+
* reject inside `loadLanguage`, leaving the block unhighlighted for good. */
|
|
284
|
+
async function resolveLanguage(highlighter: HighlighterCore, lang: string): Promise<string> {
|
|
285
|
+
if (PLAIN_LANGUAGES.has(lang) || highlighter.getLoadedLanguages().includes(lang)) return lang
|
|
286
|
+
const loader = languageLoader(lang)
|
|
287
|
+
if (loader) {
|
|
288
|
+
await highlighter.loadLanguage((await loader()).default)
|
|
289
|
+
return lang
|
|
290
|
+
}
|
|
291
|
+
devWarnOnce(
|
|
292
|
+
`CodeBlock: unknown language "${lang}", rendering as plain text. Register its grammar with registerLanguage() first.`,
|
|
293
|
+
)
|
|
294
|
+
return "text"
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/** Resolves one theme slot to a loaded theme name. Only the two defaults are
|
|
298
|
+
* loaded up front; any other name has to come through `registerTheme`, or
|
|
299
|
+
* that slot falls back to its default, with a dev warning. */
|
|
300
|
+
function resolveTheme(
|
|
301
|
+
highlighter: HighlighterCore,
|
|
302
|
+
name: string,
|
|
303
|
+
slot: keyof typeof DEFAULT_THEMES,
|
|
304
|
+
): string {
|
|
305
|
+
if (highlighter.getLoadedThemes().includes(name)) return name
|
|
306
|
+
devWarnOnce(
|
|
307
|
+
`CodeBlock: unknown theme "${name}", using "${DEFAULT_THEMES[slot]}" instead. Register it with registerTheme() first.`,
|
|
308
|
+
)
|
|
309
|
+
return DEFAULT_THEMES[slot]
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** Highlights `code` as HTML via the shared Shiki singleton. The language
|
|
313
|
+
* loads on demand from the `LANGUAGES` map; a name registered through
|
|
314
|
+
* `registerLanguage`/`registerTheme` is recognized as already loaded via the
|
|
315
|
+
* highlighter's own `getLoadedLanguages`/`getLoadedThemes`. `lang` defaults
|
|
316
|
+
* to `"text"` (Shiki's built-in plaintext grammar — no dynamic import
|
|
317
|
+
* needed). Called with `defaultColor: false` so neither theme is inlined as
|
|
318
|
+
* a plain `color`/`background-color` — both live only in the
|
|
267
319
|
* `--shiki-light`/`--shiki-dark` custom properties consumed by
|
|
268
320
|
* `styles.css`, so the dark-mode CSS rule there needs no `!important`. */
|
|
269
321
|
export async function highlightCode(code: string, opts: HighlightOptions = {}): Promise<string> {
|
|
270
|
-
const lang = opts.lang ?? "text"
|
|
271
|
-
const themes = opts.themes ?? DEFAULT_THEMES
|
|
272
322
|
const highlighter = await getHighlighter()
|
|
273
323
|
const notation = opts.notation ?? parseNotation(code)
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
.map((t) => highlighter.loadTheme(t as never)),
|
|
279
|
-
)
|
|
280
|
-
if (!highlighter.getLoadedLanguages().includes(lang)) {
|
|
281
|
-
await highlighter.loadLanguage(lang as never)
|
|
324
|
+
const lang = await resolveLanguage(highlighter, opts.lang ?? "text")
|
|
325
|
+
const themes = {
|
|
326
|
+
light: resolveTheme(highlighter, opts.themes?.light ?? DEFAULT_THEMES.light, "light"),
|
|
327
|
+
dark: resolveTheme(highlighter, opts.themes?.dark ?? DEFAULT_THEMES.dark, "dark"),
|
|
282
328
|
}
|
|
283
329
|
|
|
284
330
|
return highlighter.codeToHtml(code, {
|
|
@@ -13,6 +13,7 @@ import type {
|
|
|
13
13
|
CodeBlockGutterColumn,
|
|
14
14
|
} from "./gutters"
|
|
15
15
|
import { type CodeBlockTagStyle, registerLanguage, registerTheme } from "./highlighter"
|
|
16
|
+
import type { CodeBlockLanguage } from "./languages"
|
|
16
17
|
import { highlight, lineNumbers } from "./presets"
|
|
17
18
|
// Extensionless, matching every other relative import in this package — the
|
|
18
19
|
// compiled output needs a `.js` suffix here (Node ESM, "type": "module", is
|
|
@@ -46,6 +47,7 @@ export {
|
|
|
46
47
|
type CodeBlockGutterColumn,
|
|
47
48
|
type CodeBlockIconSlot,
|
|
48
49
|
type CodeBlockIcons,
|
|
50
|
+
type CodeBlockLanguage,
|
|
49
51
|
type CodeBlockProps,
|
|
50
52
|
type CodeBlockStaticProps,
|
|
51
53
|
type CodeBlockTagStyle,
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { LanguageRegistration } from "shiki"
|
|
2
|
+
|
|
3
|
+
type LanguageLoader = () => Promise<{ default: LanguageRegistration[] }>
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The grammars `CodeBlock` can load by name — a deliberately finite map.
|
|
7
|
+
*
|
|
8
|
+
* Each entry is a separate dynamic import, so a consumer's bundler emits one
|
|
9
|
+
* chunk per grammar here and nothing more. Shiki's full bundle registers
|
|
10
|
+
* ~300 of them (plus the Oniguruma WASM), and every app depending on the kit
|
|
11
|
+
* paid to emit and parse all of them even when it highlighted two languages.
|
|
12
|
+
*
|
|
13
|
+
* Aliases point to the same loader as their grammar: loading it registers
|
|
14
|
+
* Shiki's own aliases too, so `ts` and `typescript` resolve to one grammar.
|
|
15
|
+
* Anything not listed is added by the caller through `registerLanguage`.
|
|
16
|
+
*/
|
|
17
|
+
export const LANGUAGES = {
|
|
18
|
+
c: () => import("shiki/langs/c.mjs"),
|
|
19
|
+
cpp: () => import("shiki/langs/cpp.mjs"),
|
|
20
|
+
"c++": () => import("shiki/langs/cpp.mjs"),
|
|
21
|
+
python: () => import("shiki/langs/python.mjs"),
|
|
22
|
+
py: () => import("shiki/langs/python.mjs"),
|
|
23
|
+
shellscript: () => import("shiki/langs/shellscript.mjs"),
|
|
24
|
+
bash: () => import("shiki/langs/shellscript.mjs"),
|
|
25
|
+
sh: () => import("shiki/langs/shellscript.mjs"),
|
|
26
|
+
shell: () => import("shiki/langs/shellscript.mjs"),
|
|
27
|
+
zsh: () => import("shiki/langs/shellscript.mjs"),
|
|
28
|
+
javascript: () => import("shiki/langs/javascript.mjs"),
|
|
29
|
+
js: () => import("shiki/langs/javascript.mjs"),
|
|
30
|
+
cjs: () => import("shiki/langs/javascript.mjs"),
|
|
31
|
+
mjs: () => import("shiki/langs/javascript.mjs"),
|
|
32
|
+
typescript: () => import("shiki/langs/typescript.mjs"),
|
|
33
|
+
ts: () => import("shiki/langs/typescript.mjs"),
|
|
34
|
+
cts: () => import("shiki/langs/typescript.mjs"),
|
|
35
|
+
mts: () => import("shiki/langs/typescript.mjs"),
|
|
36
|
+
jsx: () => import("shiki/langs/jsx.mjs"),
|
|
37
|
+
tsx: () => import("shiki/langs/tsx.mjs"),
|
|
38
|
+
json: () => import("shiki/langs/json.mjs"),
|
|
39
|
+
yaml: () => import("shiki/langs/yaml.mjs"),
|
|
40
|
+
yml: () => import("shiki/langs/yaml.mjs"),
|
|
41
|
+
markdown: () => import("shiki/langs/markdown.mjs"),
|
|
42
|
+
md: () => import("shiki/langs/markdown.mjs"),
|
|
43
|
+
html: () => import("shiki/langs/html.mjs"),
|
|
44
|
+
css: () => import("shiki/langs/css.mjs"),
|
|
45
|
+
sql: () => import("shiki/langs/sql.mjs"),
|
|
46
|
+
go: () => import("shiki/langs/go.mjs"),
|
|
47
|
+
rust: () => import("shiki/langs/rust.mjs"),
|
|
48
|
+
rs: () => import("shiki/langs/rust.mjs"),
|
|
49
|
+
java: () => import("shiki/langs/java.mjs"),
|
|
50
|
+
make: () => import("shiki/langs/make.mjs"),
|
|
51
|
+
makefile: () => import("shiki/langs/make.mjs"),
|
|
52
|
+
docker: () => import("shiki/langs/docker.mjs"),
|
|
53
|
+
dockerfile: () => import("shiki/langs/docker.mjs"),
|
|
54
|
+
diff: () => import("shiki/langs/diff.mjs"),
|
|
55
|
+
} satisfies Record<string, LanguageLoader>
|
|
56
|
+
|
|
57
|
+
/** A language `CodeBlock` resolves by name: a bundled id or alias, `"text"`,
|
|
58
|
+
* or any name registered through `registerLanguage`. */
|
|
59
|
+
export type CodeBlockLanguage = keyof typeof LANGUAGES | "text" | (string & {})
|
|
60
|
+
|
|
61
|
+
export function languageLoader(lang: string): LanguageLoader | undefined {
|
|
62
|
+
return Object.hasOwn(LANGUAGES, lang) ? LANGUAGES[lang as keyof typeof LANGUAGES] : undefined
|
|
63
|
+
}
|
|
@@ -14,11 +14,12 @@ import {
|
|
|
14
14
|
} from "./chrome"
|
|
15
15
|
import type { CodeBlockGutterColumn } from "./gutters"
|
|
16
16
|
import { type CodeBlockTagStyle, highlightCode } from "./highlighter"
|
|
17
|
+
import type { CodeBlockLanguage } from "./languages"
|
|
17
18
|
import { parseNotation } from "./notation"
|
|
18
19
|
|
|
19
20
|
export type CodeBlockStaticProps = WithTestId & {
|
|
20
21
|
code: string
|
|
21
|
-
language?:
|
|
22
|
+
language?: CodeBlockLanguage
|
|
22
23
|
themes?: { light: string; dark: string }
|
|
23
24
|
tags?: Record<string, CodeBlockTagStyle>
|
|
24
25
|
gutters?: CodeBlockGutterColumn[]
|
|
@@ -135,17 +135,17 @@ export function DataTablePagination<TEntity extends RowData>({
|
|
|
135
135
|
return (
|
|
136
136
|
<div
|
|
137
137
|
className={cn(
|
|
138
|
-
// Same
|
|
139
|
-
//
|
|
140
|
-
//
|
|
141
|
-
"bg-brand-50/90 dark:bg-
|
|
138
|
+
// Same fill as thead/tfoot — this is Table's third chrome band (it
|
|
139
|
+
// renders inside the same container): clear in the dark theme, where
|
|
140
|
+
// the frame carries the surface (Figma's pagination is the table's).
|
|
141
|
+
"bg-brand-50/90 dark:bg-transparent",
|
|
142
142
|
// `flex-wrap`: both groups are intrinsically sized, and this band sits
|
|
143
143
|
// *outside* Table's `overflow-auto` frame under an `overflow-hidden`
|
|
144
144
|
// root — so in a container too narrow for both (a `max-w-xs` card, say)
|
|
145
145
|
// a squeeze has nowhere to go and would silently clip the controls.
|
|
146
146
|
// Dropping the page controls to a second row degrades instead.
|
|
147
147
|
// `gap-2` already covers both axes.
|
|
148
|
-
"flex shrink-0 flex-wrap items-center justify-between gap-2 border-t border-brand-900/20 px-4 py-3 dark:border-white/
|
|
148
|
+
"flex shrink-0 flex-wrap items-center justify-between gap-2 border-t border-brand-900/20 px-4 py-3 dark:border-white/8",
|
|
149
149
|
className,
|
|
150
150
|
)}
|
|
151
151
|
>
|
|
@@ -295,7 +295,7 @@ export function DataTableStackOptions<TEntity extends RowData>({
|
|
|
295
295
|
)}
|
|
296
296
|
{sortableColumns.length > 0 && (
|
|
297
297
|
<>
|
|
298
|
-
<hr className="mt-6 mb-2 border-0 border-t border-brand-900/20 dark:border-white/
|
|
298
|
+
<hr className="mt-6 mb-2 border-0 border-t border-brand-900/20 dark:border-white/8" />
|
|
299
299
|
<div className="flex flex-col gap-3">
|
|
300
300
|
<div className="flex items-center justify-between">
|
|
301
301
|
<Text size="xs" c="muted" className="uppercase tracking-wide">
|
|
@@ -339,7 +339,7 @@ export function DataTableStackOptions<TEntity extends RowData>({
|
|
|
339
339
|
{filterableColumns.length > 0 && (
|
|
340
340
|
<>
|
|
341
341
|
{(sortableColumns.length > 0 || enableColumnVisibility) && (
|
|
342
|
-
<hr className="mt-6 mb-2 border-0 border-t border-brand-900/20 dark:border-white/
|
|
342
|
+
<hr className="mt-6 mb-2 border-0 border-t border-brand-900/20 dark:border-white/8" />
|
|
343
343
|
)}
|
|
344
344
|
<div className="flex flex-col gap-4">
|
|
345
345
|
<div className="flex items-center justify-between">
|
|
@@ -43,6 +43,20 @@ export const fieldRoot = cva("relative flex w-full flex-col", {
|
|
|
43
43
|
defaultVariants: { size: "md" },
|
|
44
44
|
})
|
|
45
45
|
|
|
46
|
+
// Root of an inline control (Switch, Checkbox) whose label carries a
|
|
47
|
+
// description or error: a two-column grid, so the control centers on the
|
|
48
|
+
// label's row alone instead of on the whole text stack, and the field (placed
|
|
49
|
+
// with `col-start-2`) hangs under the label. The row gap follows `fieldRoot`'s.
|
|
50
|
+
export const fieldInlineStack = cva(
|
|
51
|
+
"relative inline-grid grid-cols-[auto_1fr] items-center gap-x-2 select-none",
|
|
52
|
+
{
|
|
53
|
+
variants: {
|
|
54
|
+
size: { xs: "gap-y-1", sm: "gap-y-1", md: "gap-y-1.5", lg: "gap-y-1.5", xl: "gap-y-2" },
|
|
55
|
+
},
|
|
56
|
+
defaultVariants: { size: "md" },
|
|
57
|
+
},
|
|
58
|
+
)
|
|
59
|
+
|
|
46
60
|
export const fieldLabel = cva(
|
|
47
61
|
[
|
|
48
62
|
"inline-flex items-center font-medium select-none text-trim",
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
fillLevel,
|
|
12
12
|
type Hue,
|
|
13
13
|
hueOf,
|
|
14
|
+
inProgressShare,
|
|
14
15
|
liquidFadeWidth,
|
|
15
16
|
paint,
|
|
16
17
|
type Tone,
|
|
@@ -28,6 +29,8 @@ export type SolidData = {
|
|
|
28
29
|
readonly hidden: string
|
|
29
30
|
readonly hull: string
|
|
30
31
|
readonly details: string
|
|
32
|
+
/** The facet (index) a corner fill grows on, and the corner it grows from. */
|
|
33
|
+
readonly cap?: { readonly facet: number; readonly origin: readonly [number, number] }
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
export type BadgeTile =
|
|
@@ -63,6 +66,13 @@ type BadgeFrameProps = BadgeBaseProps & {
|
|
|
63
66
|
locked: "wire" | "silhouette"
|
|
64
67
|
/** Dotted connectors drawn between the solids (the social badge). */
|
|
65
68
|
links?: string
|
|
69
|
+
/**
|
|
70
|
+
* How progress fills the solid: `liquid` rises through every face from the
|
|
71
|
+
* bottom; `corner` grows a square on the solid's cap from its front corner
|
|
72
|
+
* (the exam), so its sides lengthen with progress. `corner` needs a solid
|
|
73
|
+
* with a `cap`.
|
|
74
|
+
*/
|
|
75
|
+
fill?: "liquid" | "corner"
|
|
66
76
|
}
|
|
67
77
|
|
|
68
78
|
const VIEWBOX = "0 0 64 64"
|
|
@@ -130,14 +140,14 @@ function Solid({
|
|
|
130
140
|
hue,
|
|
131
141
|
progress,
|
|
132
142
|
locked,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
143
|
+
fill,
|
|
144
|
+
}: SolidProps & { locked: "wire" | "silhouette"; fill: "liquid" | "corner" }) {
|
|
145
|
+
const lit =
|
|
146
|
+
fill === "corner" && solid.cap ? (
|
|
147
|
+
<CornerSolid solid={solid} status={status} hue={hue} progress={progress} />
|
|
148
|
+
) : (
|
|
149
|
+
<LiquidSolid solid={solid} status={status} hue={hue} progress={progress} />
|
|
150
|
+
)
|
|
141
151
|
if (locked === "wire") return lit
|
|
142
152
|
// The silhouette and the solid are both kept mounted and cross-faded, so
|
|
143
153
|
// locking and unlocking ease like every other status change.
|
|
@@ -168,9 +178,11 @@ function Wires({ solid, status, hue }: Omit<SolidProps, "progress">) {
|
|
|
168
178
|
const done = status === "done"
|
|
169
179
|
// Done glints over its own faces, the same on either page; the bare
|
|
170
180
|
// wireframe takes one step darker on a light page, just enough to show.
|
|
181
|
+
// Failed burns a deeper red, so the closed, glowing tile still reads as a
|
|
182
|
+
// fault rather than a pale "available".
|
|
171
183
|
const wire = done
|
|
172
184
|
? paint(hue, [200, 200], 50)
|
|
173
|
-
: paint(hue, status === "locked" ? [400, 400] : [200, 400])
|
|
185
|
+
: paint(hue, status === "locked" ? [400, 400] : status === "failed" ? [400, 500] : [200, 400])
|
|
174
186
|
return (
|
|
175
187
|
<>
|
|
176
188
|
{!done && solid.hidden && (
|
|
@@ -236,6 +248,44 @@ function LiquidSolid({ solid, status, hue, progress }: SolidProps) {
|
|
|
236
248
|
)
|
|
237
249
|
}
|
|
238
250
|
|
|
251
|
+
/**
|
|
252
|
+
* The corner fill: the faces light as a whole (in progress lights the sides
|
|
253
|
+
* and leaves the cap dim), and a copy of the cap, scaled from its front
|
|
254
|
+
* corner by progress, is the level — Figma's "Niveau" square. Scaling keeps
|
|
255
|
+
* it a square on the cap at every value, and its side, not its area, tracks
|
|
256
|
+
* progress. The first frame renders it at 0, so it grows when it appears.
|
|
257
|
+
*/
|
|
258
|
+
function CornerSolid({ solid, status, hue, progress }: SolidProps) {
|
|
259
|
+
const cap = solid.cap
|
|
260
|
+
const capFacet = cap && solid.facets[cap.facet]
|
|
261
|
+
const lit = status === "done" || status === "in-progress"
|
|
262
|
+
const share =
|
|
263
|
+
status === "done" ? 1 : status === "in-progress" ? inProgressShare(progress) / 100 : 0
|
|
264
|
+
const scale = useSettled(0, share)
|
|
265
|
+
if (!cap || !capFacet) return null
|
|
266
|
+
return (
|
|
267
|
+
<g>
|
|
268
|
+
{solid.facets.map((facet) => (
|
|
269
|
+
<polygon
|
|
270
|
+
key={facet.points}
|
|
271
|
+
points={facet.points}
|
|
272
|
+
fill={faceFill(hue, facet === capFacet && lit ? "available" : status, facet.tone)}
|
|
273
|
+
/>
|
|
274
|
+
))}
|
|
275
|
+
<polygon
|
|
276
|
+
className="geodesic-cap"
|
|
277
|
+
points={capFacet.points}
|
|
278
|
+
fill={faceFill(hue, lit ? status : "in-progress", capFacet.tone)}
|
|
279
|
+
style={{
|
|
280
|
+
transformOrigin: `${cap.origin[0]}px ${cap.origin[1]}px`,
|
|
281
|
+
transform: `scale(${scale})`,
|
|
282
|
+
}}
|
|
283
|
+
/>
|
|
284
|
+
<Wires solid={solid} status={status} hue={hue} />
|
|
285
|
+
</g>
|
|
286
|
+
)
|
|
287
|
+
}
|
|
288
|
+
|
|
239
289
|
/**
|
|
240
290
|
* Draws any statused badge: a tile, one or more solids, and what the status
|
|
241
291
|
* adds (lock, glow). The per-shape components only pick the geometry
|
|
@@ -254,16 +304,19 @@ export function BadgeFrame({
|
|
|
254
304
|
progress = 50,
|
|
255
305
|
locked,
|
|
256
306
|
links,
|
|
307
|
+
fill = "liquid",
|
|
257
308
|
}: BadgeFrameProps) {
|
|
258
309
|
const hue = hueOf(status, doneHue)
|
|
259
310
|
const done = status === "done"
|
|
311
|
+
// Done and failed are both over: a closed tile and a glow, in their own hue.
|
|
312
|
+
const closed = done || status === "failed"
|
|
260
313
|
const tileFill =
|
|
261
314
|
// Locked is a fully transparent tint, not `none`, so the fill can ease in.
|
|
262
|
-
paint(hue, [500, 500], status === "locked" ? 0 :
|
|
315
|
+
paint(hue, [500, 500], status === "locked" ? 0 : closed ? 20 : status === "available" ? 22 : 16)
|
|
263
316
|
const tileStroke =
|
|
264
317
|
status === "locked"
|
|
265
318
|
? paint("neutral", [500, 400])
|
|
266
|
-
:
|
|
319
|
+
: closed
|
|
267
320
|
? paint(hue, [400, 400])
|
|
268
321
|
: paint(hue, [400, 400], 65)
|
|
269
322
|
|
|
@@ -277,7 +330,7 @@ export function BadgeFrame({
|
|
|
277
330
|
width: size,
|
|
278
331
|
height: size,
|
|
279
332
|
flex: "none",
|
|
280
|
-
filter:
|
|
333
|
+
filter: closed ? `drop-shadow(0 0 ${size * 0.09}px ${tint(hue, 500, 55)})` : undefined,
|
|
281
334
|
...style,
|
|
282
335
|
}}
|
|
283
336
|
>
|
|
@@ -293,7 +346,7 @@ export function BadgeFrame({
|
|
|
293
346
|
fill={tileFill}
|
|
294
347
|
stroke={tileStroke}
|
|
295
348
|
strokeWidth={1}
|
|
296
|
-
strokeDasharray={
|
|
349
|
+
strokeDasharray={closed ? undefined : DASH}
|
|
297
350
|
strokeLinejoin="round"
|
|
298
351
|
/>
|
|
299
352
|
{links && (
|
|
@@ -315,6 +368,7 @@ export function BadgeFrame({
|
|
|
315
368
|
hue={hue}
|
|
316
369
|
progress={progress}
|
|
317
370
|
locked={locked}
|
|
371
|
+
fill={fill}
|
|
318
372
|
/>
|
|
319
373
|
))}
|
|
320
374
|
<Lock shown={status === "locked"} />
|
|
@@ -3,15 +3,19 @@ import { GEOMETRY } from "./geometry"
|
|
|
3
3
|
|
|
4
4
|
export type ExamBadgeProps = BadgeBaseProps
|
|
5
5
|
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* An exam: a square slab lying on a square tile. Progress grows a square on
|
|
8
|
+
* its top from the front corner; blue once passed, red when failed.
|
|
9
|
+
*/
|
|
7
10
|
export function ExamBadge(props: ExamBadgeProps) {
|
|
8
11
|
return (
|
|
9
12
|
<BadgeFrame
|
|
10
13
|
{...props}
|
|
11
|
-
tile={{ kind: "polygon", points: GEOMETRY.tiles.
|
|
14
|
+
tile={{ kind: "polygon", points: GEOMETRY.tiles.square }}
|
|
12
15
|
solids={[GEOMETRY.exam]}
|
|
13
|
-
doneHue="
|
|
14
|
-
locked="
|
|
16
|
+
doneHue="blue"
|
|
17
|
+
locked="wire"
|
|
18
|
+
fill="corner"
|
|
15
19
|
/>
|
|
16
20
|
)
|
|
17
21
|
}
|
|
@@ -66,15 +66,16 @@ export const GEOMETRY = {
|
|
|
66
66
|
},
|
|
67
67
|
exam: {
|
|
68
68
|
facets: [
|
|
69
|
-
{ points: "
|
|
70
|
-
{ points: "
|
|
71
|
-
{ points: "
|
|
69
|
+
{ points: "12.59,22.46 24.55,45.72 24.55,48.81 12.59,25.55", tone: 2, rank: 1 },
|
|
70
|
+
{ points: "12.59,22.46 39.45,12.11 51.41,35.37 24.55,45.72", tone: 3, rank: 2 },
|
|
71
|
+
{ points: "24.55,45.72 51.41,35.37 51.41,38.46 24.55,48.81", tone: 0, rank: 0 },
|
|
72
72
|
],
|
|
73
73
|
edges:
|
|
74
|
-
"
|
|
75
|
-
hidden: "",
|
|
76
|
-
hull: "
|
|
74
|
+
"M24.55 45.72L12.59 22.46M24.55 48.81L24.55 45.72M12.59 25.55L24.55 48.81M12.59 22.46L12.59 25.55M51.41 35.37L51.41 38.46M39.45 12.11L51.41 35.37M39.45 12.11L12.59 22.46M24.55 45.72L51.41 35.37M51.41 38.46L24.55 48.81",
|
|
75
|
+
hidden: "M39.45 15.2L39.45 12.11M51.41 38.46L39.45 15.2M12.59 25.55L39.45 15.2",
|
|
76
|
+
hull: "12.59,22.46 39.45,12.11 51.41,35.37 51.41,38.46 24.55,48.81 12.59,25.55",
|
|
77
77
|
details: "",
|
|
78
|
+
cap: { facet: 1, origin: [24.55, 45.72] },
|
|
78
79
|
},
|
|
79
80
|
activity: {
|
|
80
81
|
facets: [
|
|
@@ -363,5 +364,6 @@ export const GEOMETRY = {
|
|
|
363
364
|
pentagon: "32,4.5 59.58,24.54 49.05,56.96 14.95,56.96 4.42,24.54",
|
|
364
365
|
octagon: "43.1,5.21 58.79,20.9 58.79,43.1 43.1,58.79 20.9,58.79 5.21,43.1 5.21,20.9 20.9,5.21",
|
|
365
366
|
giftToken: "32,18 44.12,25 44.12,39 32,46 19.88,39 19.88,25",
|
|
367
|
+
square: "0.56,21.55 44.07,4.77 63.44,42.46 19.93,59.23",
|
|
366
368
|
},
|
|
367
369
|
} as const
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest"
|
|
2
|
-
import { faceLight, fillLevel, inProgressShare, MIN_IN_PROGRESS } from "./status"
|
|
2
|
+
import { faceLight, fillLevel, hueOf, inProgressShare, MIN_IN_PROGRESS } from "./status"
|
|
3
|
+
|
|
4
|
+
describe("hueOf", () => {
|
|
5
|
+
it("is red when failed, whatever the shape's done hue", () => {
|
|
6
|
+
expect(hueOf("failed", "green")).toBe("red")
|
|
7
|
+
expect(hueOf("failed", "blue")).toBe("red")
|
|
8
|
+
expect(hueOf("done", "blue")).toBe("blue")
|
|
9
|
+
})
|
|
10
|
+
})
|
|
3
11
|
|
|
4
12
|
describe("inProgressShare", () => {
|
|
5
13
|
it("maps 0–100 onto the floor–100", () => {
|
|
@@ -22,8 +30,9 @@ describe("fillLevel and faceLight", () => {
|
|
|
22
30
|
)
|
|
23
31
|
const total = (values: number[]) => values.reduce((a, b) => a + b, 0)
|
|
24
32
|
|
|
25
|
-
it("lights every face when done and none when locked or
|
|
33
|
+
it("lights every face when done and none when locked, available or failed", () => {
|
|
26
34
|
expect(lights("done", 0, 40)).toEqual(Array(40).fill(1))
|
|
35
|
+
expect(lights("failed", 100, 40)).toEqual(Array(40).fill(0))
|
|
27
36
|
expect(lights("locked", 100, 40)).toEqual(Array(40).fill(0))
|
|
28
37
|
expect(lights("available", 100, 40)).toEqual(Array(40).fill(0))
|
|
29
38
|
})
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
* levels": one colour per status, and the same progression on every shape —
|
|
4
4
|
* wireframe, then half lit, then full with a closed orbit.
|
|
5
5
|
*
|
|
6
|
-
* Only "done" varies by shape (a module is green, a
|
|
6
|
+
* Only "done" varies by shape (a module is green, a passed exam blue…), so
|
|
7
7
|
* each badge passes its own done hue and everything else comes from here.
|
|
8
|
+
* "failed" is red on every shape: the solid stays unlit like "available",
|
|
9
|
+
* but its tile closes and glows like "done" — the attempt is over.
|
|
8
10
|
*/
|
|
9
11
|
|
|
10
|
-
export type BadgeStatus = "locked" | "available" | "in-progress" | "done"
|
|
12
|
+
export type BadgeStatus = "locked" | "available" | "in-progress" | "done" | "failed"
|
|
11
13
|
|
|
12
14
|
/**
|
|
13
15
|
* A kit colour ramp, read as `--color-<hue>-<step>`, or `neutral`: the
|
|
@@ -76,6 +78,7 @@ const STATUS_HUE: Record<Exclude<BadgeStatus, "done">, Hue> = {
|
|
|
76
78
|
locked: "neutral",
|
|
77
79
|
available: "purple",
|
|
78
80
|
"in-progress": "pink",
|
|
81
|
+
failed: "red",
|
|
79
82
|
}
|
|
80
83
|
|
|
81
84
|
export function hueOf(status: BadgeStatus, doneHue: Hue): Hue {
|
|
@@ -106,12 +109,13 @@ const IN_PROGRESS_TONE_STEPS = { dark: [400, 300, 300, 200], light: [400, 300, 3
|
|
|
106
109
|
/**
|
|
107
110
|
* A facet's fill for its light bucket, per status and theme.
|
|
108
111
|
*
|
|
109
|
-
* Locked and
|
|
110
|
-
* drain out after a status change back down; a deep, see-through
|
|
111
|
-
* to the page keeps that drain from flashing coloured faces.
|
|
112
|
+
* Locked, available and failed light no facet, so theirs only shows while
|
|
113
|
+
* lit faces drain out after a status change back down; a deep, see-through
|
|
114
|
+
* step close to the page keeps that drain from flashing coloured faces.
|
|
112
115
|
*/
|
|
113
116
|
export function faceFill(hue: Hue, status: BadgeStatus, tone: Tone) {
|
|
114
|
-
if (status === "locked" || status === "available"
|
|
117
|
+
if (status === "locked" || status === "available" || status === "failed")
|
|
118
|
+
return paint(hue, [800, 100], 40)
|
|
115
119
|
const steps = status === "in-progress" ? IN_PROGRESS_TONE_STEPS : TONE_STEPS
|
|
116
120
|
return paint(hue, [steps.dark[tone], steps.light[tone]])
|
|
117
121
|
}
|
|
@@ -144,7 +148,7 @@ export function fadeWidth(facetCount: number) {
|
|
|
144
148
|
/**
|
|
145
149
|
* Where the fill stands, measured in faces along the bottom-up order: a face
|
|
146
150
|
* of rank `r` is lit by how far the level has passed it (see faceLight).
|
|
147
|
-
* Done is full, locked and
|
|
151
|
+
* Done is full, locked, available and failed are empty, and in progress maps
|
|
148
152
|
* `progress` through inProgressShare, so 0% still shows light.
|
|
149
153
|
*/
|
|
150
154
|
export function fillLevel(
|
|
@@ -134,13 +134,26 @@
|
|
|
134
134
|
transition: fill 300ms ease;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
/*
|
|
138
|
+
* The corner fill's level: the cap, scaled from its front corner (set
|
|
139
|
+
* inline, in viewBox units, hence the view-box transform box).
|
|
140
|
+
*/
|
|
141
|
+
.geodesic-cap {
|
|
142
|
+
transform-box: view-box;
|
|
143
|
+
transition:
|
|
144
|
+
transform 900ms cubic-bezier(0.4, 0, 0.2, 1),
|
|
145
|
+
fill 300ms ease;
|
|
146
|
+
}
|
|
147
|
+
|
|
137
148
|
:where(:root[data-motion="reduced"]) {
|
|
138
|
-
.geodesic-solid-smooth
|
|
149
|
+
.geodesic-solid-smooth,
|
|
150
|
+
.geodesic-cap {
|
|
139
151
|
transition: none;
|
|
140
152
|
}
|
|
141
153
|
}
|
|
142
154
|
@media (prefers-reduced-motion: reduce) {
|
|
143
|
-
.geodesic-solid-smooth
|
|
155
|
+
.geodesic-solid-smooth,
|
|
156
|
+
.geodesic-cap {
|
|
144
157
|
transition: none;
|
|
145
158
|
}
|
|
146
159
|
}
|