@bridgebrew/ui 0.0.0-stage → 0.1.9
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/LICENSE +21 -0
- package/README.md +39 -2
- package/SOURCE.md +182 -0
- package/dist/build.js +871 -0
- package/dist/theme-css.js +896 -0
- package/dist/themes.js +69 -0
- package/dist/types/build/stylesheet.d.ts +31 -0
- package/dist/types/components/composite/command/command.d.ts +94 -0
- package/dist/types/components/composite/command/index.d.ts +2 -0
- package/dist/types/components/composite/draft-bar/draft-bar.d.ts +12 -0
- package/dist/types/components/composite/draft-bar/index.d.ts +2 -0
- package/dist/types/components/composite/image-field/image-field.d.ts +33 -0
- package/dist/types/components/composite/image-field/index.d.ts +2 -0
- package/dist/types/components/composite/list/index.d.ts +3 -0
- package/dist/types/components/composite/list/list-swipe.d.ts +28 -0
- package/dist/types/components/composite/list/list.d.ts +95 -0
- package/dist/types/components/composite/picker/index.d.ts +2 -0
- package/dist/types/components/composite/picker/picker.d.ts +44 -0
- package/dist/types/components/composite/prompt-field/index.d.ts +2 -0
- package/dist/types/components/composite/prompt-field/prompt-field.d.ts +18 -0
- package/dist/types/components/composite/properties/index.d.ts +2 -0
- package/dist/types/components/composite/properties/properties.d.ts +24 -0
- package/dist/types/components/composite/snooze-menu/index.d.ts +4 -0
- package/dist/types/components/composite/snooze-menu/presets.d.ts +36 -0
- package/dist/types/components/composite/snooze-menu/snooze-menu.d.ts +27 -0
- package/dist/types/components/composite/tag-input/index.d.ts +2 -0
- package/dist/types/components/composite/tag-input/tag-input.d.ts +22 -0
- package/dist/types/components/composite/wizard/index.d.ts +2 -0
- package/dist/types/components/composite/wizard/wizard.d.ts +53 -0
- package/dist/types/components/core/avatar/avatar.d.ts +16 -0
- package/dist/types/components/core/avatar/index.d.ts +2 -0
- package/dist/types/components/core/badge/badge.d.ts +8 -0
- package/dist/types/components/core/badge/index.d.ts +2 -0
- package/dist/types/components/core/breadcrumb/breadcrumb.d.ts +21 -0
- package/dist/types/components/core/breadcrumb/index.d.ts +2 -0
- package/dist/types/components/core/bullets/bullets.d.ts +15 -0
- package/dist/types/components/core/bullets/index.d.ts +2 -0
- package/dist/types/components/core/button/button.d.ts +14 -0
- package/dist/types/components/core/button/index.d.ts +2 -0
- package/dist/types/components/core/card/card.d.ts +16 -0
- package/dist/types/components/core/card/index.d.ts +2 -0
- package/dist/types/components/core/checkbox/checkbox.d.ts +15 -0
- package/dist/types/components/core/checkbox/index.d.ts +2 -0
- package/dist/types/components/core/cluster/cluster.d.ts +5 -0
- package/dist/types/components/core/cluster/index.d.ts +1 -0
- package/dist/types/components/core/code-block/code-block.d.ts +18 -0
- package/dist/types/components/core/code-block/index.d.ts +2 -0
- package/dist/types/components/core/collapsible/collapsible.d.ts +8 -0
- package/dist/types/components/core/collapsible/index.d.ts +1 -0
- package/dist/types/components/core/colour-picker/colour-picker.d.ts +25 -0
- package/dist/types/components/core/colour-picker/index.d.ts +4 -0
- package/dist/types/components/core/combobox/combobox.d.ts +63 -0
- package/dist/types/components/core/combobox/index.d.ts +2 -0
- package/dist/types/components/core/detail/detail.d.ts +12 -0
- package/dist/types/components/core/detail/index.d.ts +1 -0
- package/dist/types/components/core/dialog/dialog.d.ts +43 -0
- package/dist/types/components/core/dialog/drag.d.ts +4 -0
- package/dist/types/components/core/dialog/index.d.ts +2 -0
- package/dist/types/components/core/drop-zone/drop-zone.d.ts +23 -0
- package/dist/types/components/core/drop-zone/index.d.ts +2 -0
- package/dist/types/components/core/dropdown-menu/dropdown-menu.d.ts +78 -0
- package/dist/types/components/core/dropdown-menu/index.d.ts +2 -0
- package/dist/types/components/core/editable-field/editable-field.d.ts +42 -0
- package/dist/types/components/core/editable-field/index.d.ts +2 -0
- package/dist/types/components/core/empty-state/empty-state.d.ts +11 -0
- package/dist/types/components/core/empty-state/index.d.ts +2 -0
- package/dist/types/components/core/field/field.d.ts +31 -0
- package/dist/types/components/core/field/index.d.ts +2 -0
- package/dist/types/components/core/icon/icon-sets.d.ts +38 -0
- package/dist/types/components/core/icon/icon.d.ts +14 -0
- package/dist/types/components/core/icon/index.d.ts +2 -0
- package/dist/types/components/core/input/index.d.ts +4 -0
- package/dist/types/components/core/input/input.d.ts +22 -0
- package/dist/types/components/core/input/textarea.d.ts +8 -0
- package/dist/types/components/core/kbd/index.d.ts +2 -0
- package/dist/types/components/core/kbd/kbd.d.ts +7 -0
- package/dist/types/components/core/label/index.d.ts +2 -0
- package/dist/types/components/core/label/label.d.ts +13 -0
- package/dist/types/components/core/main-content/index.d.ts +2 -0
- package/dist/types/components/core/main-content/main-content.d.ts +18 -0
- package/dist/types/components/core/pane/index.d.ts +1 -0
- package/dist/types/components/core/pane/pane.d.ts +12 -0
- package/dist/types/components/core/pick-menu/index.d.ts +4 -0
- package/dist/types/components/core/pick-menu/pick-menu.d.ts +57 -0
- package/dist/types/components/core/pick-menu/tag-menu.d.ts +19 -0
- package/dist/types/components/core/popover/index.d.ts +2 -0
- package/dist/types/components/core/popover/popover.d.ts +22 -0
- package/dist/types/components/core/progress/index.d.ts +2 -0
- package/dist/types/components/core/progress/progress.d.ts +13 -0
- package/dist/types/components/core/resizable/index.d.ts +2 -0
- package/dist/types/components/core/resizable/resizable.d.ts +15 -0
- package/dist/types/components/core/resizable/use-remembered-layout.d.ts +31 -0
- package/dist/types/components/core/screen-link/index.d.ts +2 -0
- package/dist/types/components/core/screen-link/screen-link.d.ts +52 -0
- package/dist/types/components/core/scroll-area/index.d.ts +2 -0
- package/dist/types/components/core/scroll-area/scroll-area.d.ts +13 -0
- package/dist/types/components/core/scroll-area/steps.d.ts +5 -0
- package/dist/types/components/core/section/index.d.ts +2 -0
- package/dist/types/components/core/section/section.d.ts +16 -0
- package/dist/types/components/core/segment-group/index.d.ts +2 -0
- package/dist/types/components/core/segment-group/segment-group.d.ts +24 -0
- package/dist/types/components/core/select/index.d.ts +2 -0
- package/dist/types/components/core/select/select.d.ts +39 -0
- package/dist/types/components/core/skeleton/index.d.ts +2 -0
- package/dist/types/components/core/skeleton/skeleton.d.ts +13 -0
- package/dist/types/components/core/slider/index.d.ts +2 -0
- package/dist/types/components/core/slider/slider.d.ts +9 -0
- package/dist/types/components/core/sortable/index.d.ts +2 -0
- package/dist/types/components/core/sortable/sortable.d.ts +53 -0
- package/dist/types/components/core/split-view/index.d.ts +2 -0
- package/dist/types/components/core/split-view/split-view.d.ts +28 -0
- package/dist/types/components/core/status-icon/index.d.ts +2 -0
- package/dist/types/components/core/status-icon/status-icon.d.ts +13 -0
- package/dist/types/components/core/table/collapsible-rows.d.ts +7 -0
- package/dist/types/components/core/table/expand-toggle.d.ts +10 -0
- package/dist/types/components/core/table/group-header.d.ts +14 -0
- package/dist/types/components/core/table/index.d.ts +8 -0
- package/dist/types/components/core/table/table.d.ts +31 -0
- package/dist/types/components/core/tabs/index.d.ts +2 -0
- package/dist/types/components/core/tabs/tabs.d.ts +20 -0
- package/dist/types/components/core/tag-pill/index.d.ts +2 -0
- package/dist/types/components/core/tag-pill/tag-pill.d.ts +25 -0
- package/dist/types/components/core/thumbnail/index.d.ts +2 -0
- package/dist/types/components/core/thumbnail/thumbnail.d.ts +23 -0
- package/dist/types/components/core/toast/index.d.ts +2 -0
- package/dist/types/components/core/toast/toast.d.ts +88 -0
- package/dist/types/components/core/toggle/index.d.ts +2 -0
- package/dist/types/components/core/toggle/toggle.d.ts +9 -0
- package/dist/types/components/core/toggle-group/index.d.ts +2 -0
- package/dist/types/components/core/toggle-group/toggle-group.d.ts +21 -0
- package/dist/types/components/core/tooltip/index.d.ts +2 -0
- package/dist/types/components/core/tooltip/tooltip.d.ts +33 -0
- package/dist/types/components/layout/multi-pane/index.d.ts +4 -0
- package/dist/types/components/layout/multi-pane/list-detail.d.ts +17 -0
- package/dist/types/components/layout/multi-pane/multi-pane.d.ts +34 -0
- package/dist/types/components/layout/single-pane/index.d.ts +2 -0
- package/dist/types/components/layout/single-pane/single-pane.d.ts +11 -0
- package/dist/types/components/shell/app-shell/app-shell.d.ts +12 -0
- package/dist/types/components/shell/app-shell/index.d.ts +2 -0
- package/dist/types/components/shell/sidebar/index.d.ts +2 -0
- package/dist/types/components/shell/sidebar/sidebar-group.d.ts +45 -0
- package/dist/types/components/shell/sidebar/sidebar-item.d.ts +19 -0
- package/dist/types/components/shell/sidebar/sidebar-resize-handle.d.ts +17 -0
- package/dist/types/components/shell/sidebar/sidebar-tree.d.ts +42 -0
- package/dist/types/components/shell/sidebar/sidebar.d.ts +27 -0
- package/dist/types/components/template/address-book-template/address-book-template.d.ts +15 -0
- package/dist/types/components/template/address-book-template/index.d.ts +2 -0
- package/dist/types/components/template/mail-template/index.d.ts +2 -0
- package/dist/types/components/template/mail-template/mail-template.d.ts +11 -0
- package/dist/types/components/template/use-narrow.d.ts +3 -0
- package/dist/types/index.d.ts +149 -0
- package/dist/types/kit/check-rendering.d.ts +3 -0
- package/dist/types/kit/kit.d.ts +76 -0
- package/dist/types/lib/clipboard.d.ts +5 -0
- package/dist/types/lib/dates.d.ts +9 -0
- package/dist/types/lib/json.d.ts +26 -0
- package/dist/types/lib/keys.d.ts +15 -0
- package/dist/types/lib/utils.d.ts +2 -0
- package/dist/types/lib/view-scope.d.ts +22 -0
- package/dist/types/profile/profile.d.ts +34 -0
- package/dist/types/theme/appearance.d.ts +31 -0
- package/dist/types/theme/boot.d.ts +3 -0
- package/dist/types/theme/client-appearance-react.d.ts +3 -0
- package/dist/types/theme/client-appearance.d.ts +69 -0
- package/dist/types/theme/generate-tokens.d.ts +45 -0
- package/dist/types/theme/pack-themes-react.d.ts +24 -0
- package/dist/types/theme/palette.d.ts +111 -0
- package/dist/types/theme/semantic-mapping.d.ts +28 -0
- package/dist/types/theme/set-theme.d.ts +30 -0
- package/dist/types/theme/theme-colours.d.ts +14 -0
- package/dist/types/theme/theme-css.d.ts +3 -0
- package/dist/types/theme/themes.d.ts +63 -0
- package/dist/types/theme/wallpaper-sheet.d.ts +16 -0
- package/dist/types/theme/wallpaper-theme-react.d.ts +7 -0
- package/dist/types/theme/wallpaper-theme.d.ts +37 -0
- package/package.json +87 -3
- package/src/build/stylesheet.ts +128 -0
- package/src/components/composite/command/command.meta.yaml +74 -0
- package/src/components/composite/command/command.tsx +939 -0
- package/src/components/composite/command/index.ts +17 -0
- package/src/components/composite/draft-bar/draft-bar.meta.yaml +19 -0
- package/src/components/composite/draft-bar/draft-bar.tsx +57 -0
- package/src/components/composite/draft-bar/index.ts +2 -0
- package/src/components/composite/image-field/image-field.meta.yaml +69 -0
- package/src/components/composite/image-field/image-field.tsx +267 -0
- package/src/components/composite/image-field/index.ts +2 -0
- package/src/components/composite/list/index.ts +18 -0
- package/src/components/composite/list/list-swipe.tsx +163 -0
- package/src/components/composite/list/list.meta.yaml +238 -0
- package/src/components/composite/list/list.tsx +868 -0
- package/src/components/composite/picker/index.ts +2 -0
- package/src/components/composite/picker/picker.meta.yaml +103 -0
- package/src/components/composite/picker/picker.tsx +276 -0
- package/src/components/composite/prompt-field/index.ts +2 -0
- package/src/components/composite/prompt-field/prompt-field.meta.yaml +60 -0
- package/src/components/composite/prompt-field/prompt-field.tsx +81 -0
- package/src/components/composite/properties/index.ts +9 -0
- package/src/components/composite/properties/properties.meta.yaml +56 -0
- package/src/components/composite/properties/properties.tsx +132 -0
- package/src/components/composite/snooze-menu/index.ts +11 -0
- package/src/components/composite/snooze-menu/presets.ts +169 -0
- package/src/components/composite/snooze-menu/snooze-menu.meta.yaml +58 -0
- package/src/components/composite/snooze-menu/snooze-menu.tsx +146 -0
- package/src/components/composite/tag-input/index.ts +2 -0
- package/src/components/composite/tag-input/tag-input.meta.yaml +51 -0
- package/src/components/composite/tag-input/tag-input.tsx +404 -0
- package/src/components/composite/wizard/index.ts +2 -0
- package/src/components/composite/wizard/wizard.meta.yaml +73 -0
- package/src/components/composite/wizard/wizard.tsx +256 -0
- package/src/components/core/avatar/avatar.meta.yaml +71 -0
- package/src/components/core/avatar/avatar.tsx +92 -0
- package/src/components/core/avatar/index.ts +2 -0
- package/src/components/core/badge/badge.meta.yaml +34 -0
- package/src/components/core/badge/badge.tsx +23 -0
- package/src/components/core/badge/index.ts +2 -0
- package/src/components/core/breadcrumb/breadcrumb.meta.yaml +45 -0
- package/src/components/core/breadcrumb/breadcrumb.tsx +110 -0
- package/src/components/core/breadcrumb/index.ts +2 -0
- package/src/components/core/bullets/bullets.meta.yaml +37 -0
- package/src/components/core/bullets/bullets.tsx +60 -0
- package/src/components/core/bullets/index.ts +2 -0
- package/src/components/core/button/button.meta.yaml +91 -0
- package/src/components/core/button/button.tsx +93 -0
- package/src/components/core/button/index.ts +2 -0
- package/src/components/core/card/card.meta.yaml +94 -0
- package/src/components/core/card/card.tsx +54 -0
- package/src/components/core/card/index.ts +2 -0
- package/src/components/core/checkbox/checkbox.meta.yaml +59 -0
- package/src/components/core/checkbox/checkbox.tsx +106 -0
- package/src/components/core/checkbox/index.ts +2 -0
- package/src/components/core/cluster/cluster.meta.yaml +4 -0
- package/src/components/core/cluster/cluster.tsx +17 -0
- package/src/components/core/cluster/index.ts +1 -0
- package/src/components/core/code-block/code-block.meta.yaml +30 -0
- package/src/components/core/code-block/code-block.tsx +93 -0
- package/src/components/core/code-block/index.ts +2 -0
- package/src/components/core/collapsible/collapsible.meta.yaml +34 -0
- package/src/components/core/collapsible/collapsible.tsx +54 -0
- package/src/components/core/collapsible/index.ts +1 -0
- package/src/components/core/colour-picker/colour-picker.meta.yaml +52 -0
- package/src/components/core/colour-picker/colour-picker.tsx +314 -0
- package/src/components/core/colour-picker/index.ts +4 -0
- package/src/components/core/combobox/combobox.meta.yaml +75 -0
- package/src/components/core/combobox/combobox.tsx +288 -0
- package/src/components/core/combobox/index.ts +2 -0
- package/src/components/core/detail/detail.meta.yaml +13 -0
- package/src/components/core/detail/detail.tsx +73 -0
- package/src/components/core/detail/index.ts +1 -0
- package/src/components/core/dialog/dialog.meta.yaml +95 -0
- package/src/components/core/dialog/dialog.tsx +254 -0
- package/src/components/core/dialog/drag.ts +40 -0
- package/src/components/core/dialog/index.ts +25 -0
- package/src/components/core/drop-zone/drop-zone.meta.yaml +55 -0
- package/src/components/core/drop-zone/drop-zone.tsx +146 -0
- package/src/components/core/drop-zone/index.ts +2 -0
- package/src/components/core/dropdown-menu/dropdown-menu.meta.yaml +118 -0
- package/src/components/core/dropdown-menu/dropdown-menu.tsx +407 -0
- package/src/components/core/dropdown-menu/index.ts +32 -0
- package/src/components/core/editable-field/editable-field.meta.yaml +120 -0
- package/src/components/core/editable-field/editable-field.tsx +346 -0
- package/src/components/core/editable-field/index.ts +2 -0
- package/src/components/core/empty-state/empty-state.meta.yaml +21 -0
- package/src/components/core/empty-state/empty-state.tsx +42 -0
- package/src/components/core/empty-state/index.ts +2 -0
- package/src/components/core/field/field.meta.yaml +37 -0
- package/src/components/core/field/field.tsx +100 -0
- package/src/components/core/field/index.ts +9 -0
- package/src/components/core/icon/curated-names.json +107 -0
- package/src/components/core/icon/icon-sets.ts +109 -0
- package/src/components/core/icon/icon.meta.yaml +30 -0
- package/src/components/core/icon/icon.tsx +93 -0
- package/src/components/core/icon/index.ts +2 -0
- package/src/components/core/input/index.ts +4 -0
- package/src/components/core/input/input.meta.yaml +98 -0
- package/src/components/core/input/input.tsx +133 -0
- package/src/components/core/input/textarea.meta.yaml +79 -0
- package/src/components/core/input/textarea.tsx +63 -0
- package/src/components/core/kbd/index.ts +2 -0
- package/src/components/core/kbd/kbd.meta.yaml +12 -0
- package/src/components/core/kbd/kbd.tsx +29 -0
- package/src/components/core/label/index.ts +2 -0
- package/src/components/core/label/label.meta.yaml +55 -0
- package/src/components/core/label/label.tsx +72 -0
- package/src/components/core/main-content/index.ts +2 -0
- package/src/components/core/main-content/main-content.meta.yaml +23 -0
- package/src/components/core/main-content/main-content.tsx +49 -0
- package/src/components/core/pane/index.ts +1 -0
- package/src/components/core/pane/pane.meta.yaml +13 -0
- package/src/components/core/pane/pane.tsx +64 -0
- package/src/components/core/pick-menu/index.ts +4 -0
- package/src/components/core/pick-menu/pick-menu.meta.yaml +36 -0
- package/src/components/core/pick-menu/pick-menu.tsx +348 -0
- package/src/components/core/pick-menu/tag-menu.meta.yaml +7 -0
- package/src/components/core/pick-menu/tag-menu.tsx +79 -0
- package/src/components/core/popover/index.ts +2 -0
- package/src/components/core/popover/popover.meta.yaml +16 -0
- package/src/components/core/popover/popover.tsx +66 -0
- package/src/components/core/progress/index.ts +2 -0
- package/src/components/core/progress/progress.meta.yaml +47 -0
- package/src/components/core/progress/progress.tsx +56 -0
- package/src/components/core/resizable/index.ts +13 -0
- package/src/components/core/resizable/resizable.meta.yaml +110 -0
- package/src/components/core/resizable/resizable.tsx +125 -0
- package/src/components/core/resizable/use-remembered-layout.ts +261 -0
- package/src/components/core/screen-link/index.ts +2 -0
- package/src/components/core/screen-link/screen-link.meta.yaml +34 -0
- package/src/components/core/screen-link/screen-link.tsx +100 -0
- package/src/components/core/scroll-area/index.ts +2 -0
- package/src/components/core/scroll-area/scroll-area.meta.yaml +72 -0
- package/src/components/core/scroll-area/scroll-area.tsx +95 -0
- package/src/components/core/scroll-area/steps.tsx +72 -0
- package/src/components/core/section/index.ts +2 -0
- package/src/components/core/section/section.meta.yaml +72 -0
- package/src/components/core/section/section.tsx +93 -0
- package/src/components/core/segment-group/index.ts +2 -0
- package/src/components/core/segment-group/segment-group.meta.yaml +71 -0
- package/src/components/core/segment-group/segment-group.tsx +166 -0
- package/src/components/core/select/index.ts +20 -0
- package/src/components/core/select/select.meta.yaml +48 -0
- package/src/components/core/select/select.tsx +226 -0
- package/src/components/core/skeleton/index.ts +2 -0
- package/src/components/core/skeleton/skeleton.meta.yaml +50 -0
- package/src/components/core/skeleton/skeleton.tsx +71 -0
- package/src/components/core/slider/index.ts +2 -0
- package/src/components/core/slider/slider.meta.yaml +55 -0
- package/src/components/core/slider/slider.tsx +46 -0
- package/src/components/core/sortable/index.ts +16 -0
- package/src/components/core/sortable/sortable.meta.yaml +125 -0
- package/src/components/core/sortable/sortable.tsx +471 -0
- package/src/components/core/split-view/index.ts +2 -0
- package/src/components/core/split-view/split-view.meta.yaml +85 -0
- package/src/components/core/split-view/split-view.tsx +193 -0
- package/src/components/core/status-icon/index.ts +2 -0
- package/src/components/core/status-icon/status-icon.meta.yaml +64 -0
- package/src/components/core/status-icon/status-icon.tsx +94 -0
- package/src/components/core/table/collapsible-rows.tsx +30 -0
- package/src/components/core/table/expand-toggle.tsx +58 -0
- package/src/components/core/table/group-header.tsx +35 -0
- package/src/components/core/table/index.ts +26 -0
- package/src/components/core/table/table.meta.yaml +67 -0
- package/src/components/core/table/table.tsx +166 -0
- package/src/components/core/tabs/index.ts +2 -0
- package/src/components/core/tabs/tabs.meta.yaml +57 -0
- package/src/components/core/tabs/tabs.tsx +74 -0
- package/src/components/core/tag-pill/index.ts +2 -0
- package/src/components/core/tag-pill/tag-pill.meta.yaml +19 -0
- package/src/components/core/tag-pill/tag-pill.tsx +102 -0
- package/src/components/core/thumbnail/index.ts +2 -0
- package/src/components/core/thumbnail/thumbnail.meta.yaml +59 -0
- package/src/components/core/thumbnail/thumbnail.tsx +162 -0
- package/src/components/core/toast/index.ts +12 -0
- package/src/components/core/toast/toast.meta.yaml +93 -0
- package/src/components/core/toast/toast.tsx +763 -0
- package/src/components/core/toggle/index.ts +2 -0
- package/src/components/core/toggle/toggle.meta.yaml +53 -0
- package/src/components/core/toggle/toggle.tsx +44 -0
- package/src/components/core/toggle-group/index.ts +2 -0
- package/src/components/core/toggle-group/toggle-group.meta.yaml +59 -0
- package/src/components/core/toggle-group/toggle-group.tsx +68 -0
- package/src/components/core/tooltip/index.ts +7 -0
- package/src/components/core/tooltip/tooltip.meta.yaml +93 -0
- package/src/components/core/tooltip/tooltip.tsx +198 -0
- package/src/components/layout/multi-pane/index.ts +4 -0
- package/src/components/layout/multi-pane/list-detail.tsx +45 -0
- package/src/components/layout/multi-pane/multi-pane.meta.yaml +67 -0
- package/src/components/layout/multi-pane/multi-pane.tsx +158 -0
- package/src/components/layout/single-pane/index.ts +2 -0
- package/src/components/layout/single-pane/single-pane.meta.yaml +35 -0
- package/src/components/layout/single-pane/single-pane.tsx +48 -0
- package/src/components/shell/app-shell/app-shell.meta.yaml +65 -0
- package/src/components/shell/app-shell/app-shell.tsx +61 -0
- package/src/components/shell/app-shell/index.ts +2 -0
- package/src/components/shell/sidebar/index.ts +35 -0
- package/src/components/shell/sidebar/sidebar-group.tsx +254 -0
- package/src/components/shell/sidebar/sidebar-item.tsx +88 -0
- package/src/components/shell/sidebar/sidebar-resize-handle.tsx +101 -0
- package/src/components/shell/sidebar/sidebar-tree.tsx +325 -0
- package/src/components/shell/sidebar/sidebar.meta.yaml +126 -0
- package/src/components/shell/sidebar/sidebar.tsx +142 -0
- package/src/components/template/address-book-template/address-book-template.meta.yaml +22 -0
- package/src/components/template/address-book-template/address-book-template.tsx +201 -0
- package/src/components/template/address-book-template/index.ts +2 -0
- package/src/components/template/mail-template/index.ts +2 -0
- package/src/components/template/mail-template/mail-template.meta.yaml +22 -0
- package/src/components/template/mail-template/mail-template.tsx +731 -0
- package/src/components/template/use-narrow.ts +18 -0
- package/src/index.ts +505 -0
- package/src/kit/check-rendering.tsx +130 -0
- package/src/kit/kit.tsx +177 -0
- package/src/lib/clipboard.ts +27 -0
- package/src/lib/dates.ts +13 -0
- package/src/lib/json.ts +59 -0
- package/src/lib/keys.ts +54 -0
- package/src/lib/utils.ts +12 -0
- package/src/lib/view-scope.tsx +60 -0
- package/src/profile/profile.ts +238 -0
- package/src/theme/appearance.ts +198 -0
- package/src/theme/boot.ts +6 -0
- package/src/theme/client-appearance-react.ts +14 -0
- package/src/theme/client-appearance.ts +284 -0
- package/src/theme/generate-tokens.ts +658 -0
- package/src/theme/pack-themes-react.ts +107 -0
- package/src/theme/palette.ts +301 -0
- package/src/theme/semantic-mapping.ts +165 -0
- package/src/theme/set-theme.ts +162 -0
- package/src/theme/theme-colours.ts +60 -0
- package/src/theme/theme-css.ts +15 -0
- package/src/theme/themes.ts +133 -0
- package/src/theme/wallpaper-sheet.ts +58 -0
- package/src/theme/wallpaper-theme-react.ts +60 -0
- package/src/theme/wallpaper-theme.ts +231 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// Browser-only half of the theme list (Bridge addition): themes.ts stays free of the DOM, since the
|
|
2
|
+
// host's Node process imports it through the generator. The boot kernel applies the same rule (`resolveTheme`, which it
|
|
3
|
+
// bundles) before the first mount (packages/browser-boot/src/theme.ts).
|
|
4
|
+
// The theme shown (research-028): in the mode (light, dark, system: the user's, client-wide, kept with the client's
|
|
5
|
+
// appearance, ./client-appearance.ts: this browser's, or the desktop app's for every instance), this page's own theme
|
|
6
|
+
// (a page of the kit outside Bridge: `setTheme`), else the workspace's proposed pair (`<html data-workspace-light-theme|-dark-theme>`, set by the shell
|
|
7
|
+
// for the workspace shown, and by the boot page for the one it opens), else the Bridge default (`<html
|
|
8
|
+
// data-default-theme>`), else T3 Code.
|
|
9
|
+
import * as React from "react";
|
|
10
|
+
import { getClientAppearance, setPreference, subscribeClientAppearance } from "./client-appearance";
|
|
11
|
+
import {
|
|
12
|
+
knownThemeId,
|
|
13
|
+
THEME_STORAGE_KEY,
|
|
14
|
+
modeOfTheme,
|
|
15
|
+
resolveTheme,
|
|
16
|
+
type Mode,
|
|
17
|
+
type ThemeSources,
|
|
18
|
+
} from "./themes";
|
|
19
|
+
|
|
20
|
+
// A former id (`light`, `dark`) counts as the pack theme it names now (./themes.ts `knownThemeId`).
|
|
21
|
+
const isTheme = (id: string | null): id is string => knownThemeId(id) !== undefined;
|
|
22
|
+
const isMode = (mode: string | null): mode is "light" | "dark" | "system" =>
|
|
23
|
+
mode === "light" || mode === "dark" || mode === "system";
|
|
24
|
+
|
|
25
|
+
// A theme storage refused stays on the page in `<html data-theme-choice>`, where the boot kernel reads it too: a system
|
|
26
|
+
// light/dark change must not override it. (A mode the client could not keep holds in its store for the page's life.)
|
|
27
|
+
const root = () => document.documentElement.dataset;
|
|
28
|
+
const stored = (key: string) => {
|
|
29
|
+
try {
|
|
30
|
+
return localStorage.getItem(key);
|
|
31
|
+
} catch {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
/** Remembers `value` under `key`, else on the page (`choice`, a dataset key) until it reloads. */
|
|
36
|
+
const remember = (key: string, choice: "themeChoice", value: string) => {
|
|
37
|
+
try {
|
|
38
|
+
localStorage.setItem(key, value);
|
|
39
|
+
delete root()[choice];
|
|
40
|
+
} catch {
|
|
41
|
+
// Storage blocked or full: the choice lasts until the page reloads.
|
|
42
|
+
root()[choice] = value;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/** The mode the user chose (client-wide), if any. */
|
|
47
|
+
const modePreference = () => {
|
|
48
|
+
const mode = getClientAppearance().prefs.mode;
|
|
49
|
+
return typeof mode === "string" ? mode : undefined;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** What decides the theme now (./themes.ts `resolveTheme`), read from the page and this browser's storage. */
|
|
53
|
+
export function themeSources(): ThemeSources {
|
|
54
|
+
const data = root();
|
|
55
|
+
return {
|
|
56
|
+
mode: modePreference(),
|
|
57
|
+
own: data.themeChoice ?? stored(THEME_STORAGE_KEY),
|
|
58
|
+
proposal: { light: data.workspaceLightTheme, dark: data.workspaceDarkTheme },
|
|
59
|
+
bridge: data.defaultTheme,
|
|
60
|
+
systemDark: matchMedia("(prefers-color-scheme: dark)").matches,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Shows the theme its sources give now (a mode, a choice, a proposal or a default changed). */
|
|
65
|
+
export function refreshTheme(): void {
|
|
66
|
+
root().theme = resolveTheme(themeSources()).id;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** This browser's theme: the stored one ("system" too), else the Bridge default (`<html data-default-theme>`), else
|
|
70
|
+
* "system" (an unknown or unreadable one counts as none). */
|
|
71
|
+
export function getTheme(): string {
|
|
72
|
+
const inPage = root().themeChoice;
|
|
73
|
+
if (inPage !== undefined) return inPage;
|
|
74
|
+
const own = stored(THEME_STORAGE_KEY);
|
|
75
|
+
if (own === "system") return own;
|
|
76
|
+
return knownThemeId(own) ?? knownThemeId(root().defaultTheme) ?? "system";
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Whether this browser chose a theme of its own (one that wins over the workspace's proposal). */
|
|
80
|
+
export const hasOwnTheme = () => isTheme(root().themeChoice ?? stored(THEME_STORAGE_KEY));
|
|
81
|
+
|
|
82
|
+
/** Shows a v0 theme ("system": the page's theme for the system's mode) without remembering it. */
|
|
83
|
+
export function applyTheme(id: string): void {
|
|
84
|
+
if (id !== "system" && !isTheme(id)) throw new Error(`unknown theme "${id}"`);
|
|
85
|
+
root().theme =
|
|
86
|
+
id === "system"
|
|
87
|
+
? resolveTheme({ ...themeSources(), mode: "system", own: undefined }).id
|
|
88
|
+
: (knownThemeId(id) ?? id);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Chooses a v0 theme for this browser and remembers it, its mode with it (the theme shows); "system" drops the theme
|
|
92
|
+
* chosen and follows the system's mode. It wins over the workspace's proposal and the Bridge default. Throws on an
|
|
93
|
+
* unknown id. A storage failure leaves it chosen for this page only. */
|
|
94
|
+
export function setTheme(id: string): void {
|
|
95
|
+
if (id !== "system" && !isTheme(id)) throw new Error(`unknown theme "${id}"`);
|
|
96
|
+
remember(THEME_STORAGE_KEY, "themeChoice", id === "system" ? id : (knownThemeId(id) ?? id));
|
|
97
|
+
void setPreference("mode", id === "system" ? "system" : modeOfTheme(id));
|
|
98
|
+
refreshTheme();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** This browser's mode: the one chosen, else the one its theme or the Bridge default gives (`modeOf`), as a choice
|
|
102
|
+
* ("system" when it follows the system). */
|
|
103
|
+
export function getModeChoice(): "light" | "dark" | "system" {
|
|
104
|
+
const { mode, own, bridge } = themeSources();
|
|
105
|
+
if (isMode(mode ?? null)) return mode as "light" | "dark" | "system";
|
|
106
|
+
return isTheme(own ?? null)
|
|
107
|
+
? modeOfTheme(own)
|
|
108
|
+
: own !== "system" && isTheme(bridge ?? null)
|
|
109
|
+
? modeOfTheme(bridge)
|
|
110
|
+
: "system";
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Chooses the user's mode (client-wide: every workspace's, in the app every instance's): the theme of the pair, and
|
|
114
|
+
* every light/dark value, follow it. Answers why it is not kept, if it is not (it holds for this page). */
|
|
115
|
+
export function setMode(mode: "light" | "dark" | "system"): Promise<string | undefined> {
|
|
116
|
+
if (!isMode(mode)) throw new Error(`unknown mode "${String(mode)}"`);
|
|
117
|
+
const kept = setPreference("mode", mode);
|
|
118
|
+
refreshTheme();
|
|
119
|
+
return kept;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// The mode chosen elsewhere (another tab, another instance's page in the app): shown here too. A system light/dark
|
|
123
|
+
// change too, after the boot kernel's listener: its bundled copy of the store does not see this page's writes.
|
|
124
|
+
if (typeof document !== "undefined") {
|
|
125
|
+
subscribeClientAppearance(refreshTheme);
|
|
126
|
+
if (typeof matchMedia === "function")
|
|
127
|
+
matchMedia("(prefers-color-scheme: dark)").addEventListener("change", refreshTheme);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** The mode of the theme shown (`<html data-theme>`), as it changes. */
|
|
131
|
+
export const getColourMode = (): Mode => modeOfTheme(root().theme);
|
|
132
|
+
const subscribeTheme = (onChange: () => void) => {
|
|
133
|
+
const observer = new MutationObserver(onChange);
|
|
134
|
+
observer.observe(document.documentElement, { attributes: true, attributeFilter: ["data-theme"] });
|
|
135
|
+
return () => observer.disconnect();
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
/** The mode shown, re-rendering the caller when it changes (a mode, a theme, the system). */
|
|
139
|
+
export function useColourMode(): Mode {
|
|
140
|
+
return React.useSyncExternalStore(subscribeTheme, getColourMode, () => "light");
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const subscribePage = (onChange: () => void) => {
|
|
144
|
+
const observer = new MutationObserver(onChange);
|
|
145
|
+
observer.observe(document.documentElement, { attributes: true });
|
|
146
|
+
return () => observer.disconnect();
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/** The theme the page shows in `mode` (the one shown now, or the other of its pair), re-rendering the caller when a
|
|
150
|
+
* choice, a proposal or a default changes: a value left to the theme draws in it (`<span data-theme>`). `bridge`: the
|
|
151
|
+
* one a workspace proposing none gets, the Bridge default's (or T3 Code), whatever this browser or workspace chose. */
|
|
152
|
+
export function useThemeOfMode(mode: Mode, layer: "page" | "bridge" = "page"): string {
|
|
153
|
+
const read = () =>
|
|
154
|
+
resolveTheme({
|
|
155
|
+
...themeSources(),
|
|
156
|
+
mode,
|
|
157
|
+
...(layer === "bridge" && { own: undefined, proposal: undefined }),
|
|
158
|
+
}).id;
|
|
159
|
+
return React.useSyncExternalStore(subscribePage, read, () =>
|
|
160
|
+
mode === "dark" ? "t3-code-dark" : "t3-code-light",
|
|
161
|
+
);
|
|
162
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// The theme's colours a colour of the look is offered (the kit's `ColourPicker`), as references to its tokens: the look
|
|
2
|
+
// stores `var(--accent)`, so it follows the theme. Pure, no DOM: the kernel's test checks a look may hold each.
|
|
3
|
+
|
|
4
|
+
/** A colour offered: its value as stored (a CSS colour, `var(--accent)`), its name. */
|
|
5
|
+
export interface ColourSwatch {
|
|
6
|
+
value: string;
|
|
7
|
+
name: string;
|
|
8
|
+
}
|
|
9
|
+
/** Colours offered together in the popover, under `label`. */
|
|
10
|
+
export interface ColourGroup {
|
|
11
|
+
label: string;
|
|
12
|
+
swatches: readonly ColourSwatch[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const token = (name: string, label: string): ColourSwatch => ({
|
|
16
|
+
value: `var(--${name})`,
|
|
17
|
+
name: label,
|
|
18
|
+
});
|
|
19
|
+
/** The theme's accents: what a colour of the look is offered first. */
|
|
20
|
+
export const THEME_COLOURS: readonly ColourSwatch[] = [
|
|
21
|
+
token("accent-subtle", "Light accent"),
|
|
22
|
+
token("accent", "Accent"),
|
|
23
|
+
token("accent-hover", "Deep accent"),
|
|
24
|
+
];
|
|
25
|
+
/** The theme's other colours, by group (never its text or its background: a paint or a tile in them would not read). */
|
|
26
|
+
export const THEME_COLOUR_GROUPS: readonly ColourGroup[] = [
|
|
27
|
+
{
|
|
28
|
+
label: "Paint",
|
|
29
|
+
swatches: [token("paint-c1", "First paint colour"), token("paint-c2", "Second paint colour")],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
label: "Status",
|
|
33
|
+
swatches: [
|
|
34
|
+
token("success", "Success"),
|
|
35
|
+
token("warning", "Warning"),
|
|
36
|
+
token("destructive", "Error"),
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
label: "Labels",
|
|
41
|
+
swatches: [
|
|
42
|
+
token("label-bug-dot", "Bug label"),
|
|
43
|
+
token("label-feature-dot", "Feature label"),
|
|
44
|
+
token("label-improvement-dot", "Improvement label"),
|
|
45
|
+
token("label-bug-bg", "Bug label background"),
|
|
46
|
+
token("label-feature-bg", "Feature label background"),
|
|
47
|
+
token("label-improvement-bg", "Improvement label background"),
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
label: "Neutrals",
|
|
52
|
+
swatches: [
|
|
53
|
+
token("bg-surface", "Surface"),
|
|
54
|
+
token("bg-sidebar", "Sidebar"),
|
|
55
|
+
token("bg-active", "Active"),
|
|
56
|
+
token("border", "Border"),
|
|
57
|
+
token("fg-muted", "Muted text"),
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Node-side entry of @bridge/ui (`@bridge/ui/theme-css`), for the host only: the theme CSS generator
|
|
2
|
+
// and the kit's source directory, which the host's Tailwind build scans. Never a browser module (a
|
|
3
|
+
// plugin importing it is refused: only `@bridge/ui` itself is shared).
|
|
4
|
+
import { existsSync } from "node:fs";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
|
|
8
|
+
export { generateThemeCss, packTheme, type PackThemeInfo } from "./generate-tokens.ts";
|
|
9
|
+
|
|
10
|
+
/** The kit's folder: the nearest one up with a `package.json`, from its sources or from its built `dist/`. */
|
|
11
|
+
const packageRoot = (dir: string): string =>
|
|
12
|
+
existsSync(join(dir, "package.json")) ? dir : packageRoot(dirname(dir));
|
|
13
|
+
|
|
14
|
+
/** Absolute path of the kit's sources (`<kit>/src`), which a published copy keeps. */
|
|
15
|
+
export const kitSources = join(packageRoot(dirname(fileURLToPath(import.meta.url))), "src");
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// Bridge's own themes: its default (the `themes-default` pack's palettes, compiled into the kit's stylesheet at host
|
|
2
|
+
// start, one `[data-theme="<id>"]` block each) and the wallpaper's, drawn in the page. Every other theme comes from a
|
|
3
|
+
// pack (research-038). Switching theme is `<html data-theme>`, with no engine in the page.
|
|
4
|
+
|
|
5
|
+
export interface ThemeInfo {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
type: "light" | "dark";
|
|
9
|
+
/** Drawn in the page from the workspace's wallpaper (./wallpaper-theme.ts): never Bridge's default theme. */
|
|
10
|
+
wallpaper?: true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const THEMES: readonly ThemeInfo[] = [
|
|
14
|
+
{ id: "bridge-light", label: "Bridge Light", type: "light" },
|
|
15
|
+
{ id: "bridge-dark", label: "Bridge Dark", type: "dark" },
|
|
16
|
+
{ id: "wallpaper-light", label: "Wallpaper Light", type: "light", wallpaper: true },
|
|
17
|
+
{ id: "wallpaper-dark", label: "Wallpaper Dark", type: "dark", wallpaper: true },
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
/** The themes Bridge's default may be (Admin): not those of a workspace's wallpaper. */
|
|
21
|
+
export const BRIDGE_THEMES = THEMES.filter((theme) => !theme.wallpaper);
|
|
22
|
+
|
|
23
|
+
/** The theme when none is chosen: Bridge's, light or dark following the system. */
|
|
24
|
+
export const DEFAULT_THEME = { light: "bridge-light", dark: "bridge-dark" } as const;
|
|
25
|
+
|
|
26
|
+
/** Ids the kit's themes had before they became packs (research-038), read as the pack theme's id now: a choice saved
|
|
27
|
+
* then shows that pack's theme when it is installed, else falls through to the next source. */
|
|
28
|
+
const RENAMED: Readonly<Record<string, string>> = { light: "linear-light", dark: "linear-dark" };
|
|
29
|
+
|
|
30
|
+
/** Where the page keeps the chosen theme; the boot kernel reads it before the first mount. */
|
|
31
|
+
export const THEME_STORAGE_KEY = "bridge.theme";
|
|
32
|
+
|
|
33
|
+
/** A colour mode: which theme of a pair shows, which value of a light/dark setting applies. */
|
|
34
|
+
export type Mode = "light" | "dark";
|
|
35
|
+
/** A theme pair (research-028 A9): the theme shown in light mode and the one shown in dark mode. */
|
|
36
|
+
export interface ThemePair {
|
|
37
|
+
light?: string | undefined;
|
|
38
|
+
dark?: string | undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The themes the page's packs bring (research-038), as the host lists them: none until told. */
|
|
42
|
+
let packThemes: readonly ThemeInfo[] = [];
|
|
43
|
+
/** Dispatched on `window` when the pack themes change, for the lists of themes to draw again. */
|
|
44
|
+
export const PACK_THEMES_EVENT = "bridge:pack-themes";
|
|
45
|
+
|
|
46
|
+
/** Sets the themes the workspace's packs bring (the boot kernel from `<html data-pack-themes>`, the shell from the
|
|
47
|
+
* workspace's status); an id of Bridge's own is skipped. */
|
|
48
|
+
export function setPackThemes(themes: readonly ThemeInfo[]): void {
|
|
49
|
+
const next = themes.filter(({ id }) => !THEMES.some((theme) => theme.id === id));
|
|
50
|
+
if (JSON.stringify(next) === JSON.stringify(packThemes)) return;
|
|
51
|
+
packThemes = next;
|
|
52
|
+
if (typeof window !== "undefined") window.dispatchEvent(new Event(PACK_THEMES_EVENT));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** The pack themes `<html data-pack-themes="<id>:<type> …">` names (the boot page's), labelled by their id until the
|
|
56
|
+
* host's list says better. */
|
|
57
|
+
export function packThemesOfAttribute(value: string | undefined): ThemeInfo[] {
|
|
58
|
+
return (value ?? "")
|
|
59
|
+
.split(" ")
|
|
60
|
+
.map((each) => each.split(":"))
|
|
61
|
+
.filter(
|
|
62
|
+
(pair): pair is [string, "light" | "dark"] =>
|
|
63
|
+
/^[a-z0-9-]+$/.test(pair[0] ?? "") && (pair[1] === "light" || pair[1] === "dark"),
|
|
64
|
+
)
|
|
65
|
+
.map(([id, type]) => ({ id, label: id, type }));
|
|
66
|
+
}
|
|
67
|
+
// The page's kit knows the boot page's pack themes from its first import, with or without a shell to ask the host.
|
|
68
|
+
if (typeof document !== "undefined")
|
|
69
|
+
packThemes = packThemesOfAttribute(document.documentElement.dataset.packThemes);
|
|
70
|
+
|
|
71
|
+
/** Every theme the page can show: Bridge's own, then its packs'. */
|
|
72
|
+
export const allThemes = (): readonly ThemeInfo[] => [...THEMES, ...packThemes];
|
|
73
|
+
|
|
74
|
+
/** The id the page knows `id` by now (a former id read as its pack theme's, research-038), if it knows it at all. */
|
|
75
|
+
export const knownThemeId = (id: string | null | undefined): string | undefined => themeOf(id)?.id;
|
|
76
|
+
|
|
77
|
+
/** The theme `id`, if the page knows it. */
|
|
78
|
+
const themeOf = (id: string | null | undefined) => {
|
|
79
|
+
const current = (id && RENAMED[id]) ?? id;
|
|
80
|
+
return allThemes().find((theme) => theme.id === current);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/** The theme of `mode` that goes with `id`: `id` itself when it is of that mode, else its counterpart (its id with light
|
|
84
|
+
* and dark swapped, as the theme menu's toggle had it); `undefined` for an unknown id or one without counterpart. */
|
|
85
|
+
export function themeOfMode(id: string | null | undefined, mode: Mode): string | undefined {
|
|
86
|
+
const theme = themeOf(id);
|
|
87
|
+
if (!theme) return undefined;
|
|
88
|
+
if (theme.type === mode) return theme.id;
|
|
89
|
+
// Only the last `-light`/`-dark` (or the whole id): `daylight-light` pairs with `daylight-dark`.
|
|
90
|
+
const stemOf = (id: string) => id.replace(/(?:^|-)(?:light|dark)$/, "");
|
|
91
|
+
const stem = stemOf(theme.id);
|
|
92
|
+
return allThemes().find((each) => each.type === mode && stemOf(each.id) === stem)?.id;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** What decides the theme shown (research-028 resolution): the user's mode (client-wide), this page's own theme (stored,
|
|
96
|
+
* or kept by the page when storage refused it: the kit outside Bridge), the workspace's pair (its proposal, with the
|
|
97
|
+
* user's Mine over it), the Bridge default theme, the system's mode. */
|
|
98
|
+
export interface ThemeSources {
|
|
99
|
+
/** "light", "dark", "system", or nothing chosen. */
|
|
100
|
+
mode?: string | null | undefined;
|
|
101
|
+
/** A theme id, "system" (no theme chosen), or nothing chosen. */
|
|
102
|
+
own?: string | null | undefined;
|
|
103
|
+
proposal?: ThemePair | undefined;
|
|
104
|
+
/** The Bridge default: a theme id, or "system"/nothing. */
|
|
105
|
+
bridge?: string | null | undefined;
|
|
106
|
+
systemDark: boolean;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** The mode shown: the browser's mode; none chosen, the mode of the theme it chose (a browser from before modes), else of
|
|
110
|
+
* the Bridge default's theme (so a Bridge set to a dark theme stays dark), else the system's. */
|
|
111
|
+
export function modeOf({ mode, own, bridge, systemDark }: ThemeSources): Mode {
|
|
112
|
+
if (mode === "light" || mode === "dark") return mode;
|
|
113
|
+
if (mode !== "system") {
|
|
114
|
+
const chosen = themeOf(own)?.type ?? (own === "system" ? undefined : themeOf(bridge)?.type);
|
|
115
|
+
if (chosen) return chosen;
|
|
116
|
+
}
|
|
117
|
+
return systemDark ? "dark" : "light";
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** The theme shown and its mode: in the mode shown, the browser's theme (or its counterpart), else the workspace's
|
|
121
|
+
* proposal for that mode, else the Bridge default's (or its counterpart), else T3 Code. */
|
|
122
|
+
export function resolveTheme(sources: ThemeSources): { id: string; mode: Mode } {
|
|
123
|
+
const mode = modeOf(sources);
|
|
124
|
+
const id =
|
|
125
|
+
themeOfMode(sources.own, mode) ??
|
|
126
|
+
themeOfMode(sources.proposal?.[mode], mode) ??
|
|
127
|
+
themeOfMode(sources.bridge, mode) ??
|
|
128
|
+
DEFAULT_THEME[mode];
|
|
129
|
+
return { id, mode };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** The mode of the theme `id` (`<html data-theme>`), light for an unknown one. */
|
|
133
|
+
export const modeOfTheme = (id: string | null | undefined): Mode => themeOf(id)?.type ?? "light";
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// The theme "From wallpaper" in the page (./wallpaper-theme.ts): its two rules (light, dark) drawn from the workspace's
|
|
2
|
+
// images, in one constructed style sheet (the page's CSP refuses inline styles) shared with the boot kernel, which lays
|
|
3
|
+
// the rules last drawn for the workspace before the first paint; no image: the kit's own blocks (T3 Code's look).
|
|
4
|
+
|
|
5
|
+
import { isRecord } from "../lib/json.ts";
|
|
6
|
+
|
|
7
|
+
/** Where the rules last drawn are kept, by workspace: the images they come from, the CSS. */
|
|
8
|
+
export const WALLPAPER_THEME_KEY = "bridge.wallpaper-theme";
|
|
9
|
+
type Kept = Record<string, { images: string; css: string }>;
|
|
10
|
+
|
|
11
|
+
/** Is `value` a kept rule: an `images` and a `css` string? (a hand edit, another tab: only what is sound keeps). */
|
|
12
|
+
const isKeptRules = (value: unknown): value is Kept[string] =>
|
|
13
|
+
isRecord(value) && typeof value.images === "string" && typeof value.css === "string";
|
|
14
|
+
|
|
15
|
+
export const keptWallpaperRules = (): Kept => {
|
|
16
|
+
try {
|
|
17
|
+
const value: unknown = JSON.parse(localStorage.getItem(WALLPAPER_THEME_KEY) ?? "{}");
|
|
18
|
+
if (!isRecord(value)) return {};
|
|
19
|
+
return Object.fromEntries(
|
|
20
|
+
Object.entries(value).filter((entry): entry is [string, Kept[string]] =>
|
|
21
|
+
isKeptRules(entry[1]),
|
|
22
|
+
),
|
|
23
|
+
);
|
|
24
|
+
} catch {
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** The page's one sheet for these rules (on `window`: the boot kernel's bundle and the kit's share it). */
|
|
30
|
+
export function layWallpaperRules(css: string) {
|
|
31
|
+
const page = window as { bridgeWallpaperSheet?: CSSStyleSheet };
|
|
32
|
+
const sheet = (page.bridgeWallpaperSheet ??= new CSSStyleSheet());
|
|
33
|
+
sheet.replaceSync(css);
|
|
34
|
+
if (!document.adoptedStyleSheets.includes(sheet))
|
|
35
|
+
document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
|
|
36
|
+
window.dispatchEvent(new Event(WALLPAPER_RULES_EVENT));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Sent on `window` when the rules change: what reads the page's colours reads them again. */
|
|
40
|
+
export const WALLPAPER_RULES_EVENT = "bridge-wallpaper-rules";
|
|
41
|
+
|
|
42
|
+
/** The rules last drawn for `slug`, laid (the boot kernel, before the first paint). */
|
|
43
|
+
export function layKeptWallpaperRules(slug: string) {
|
|
44
|
+
const css = keptWallpaperRules()[slug]?.css;
|
|
45
|
+
if (css) layWallpaperRules(css);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Keeps `value` (none: forgets) as `slug`'s rules. */
|
|
49
|
+
export const keepWallpaperRules = (slug: string, value: Kept[string] | undefined) => {
|
|
50
|
+
try {
|
|
51
|
+
const all = keptWallpaperRules();
|
|
52
|
+
if (value) all[slug] = value;
|
|
53
|
+
else delete all[slug];
|
|
54
|
+
localStorage.setItem(WALLPAPER_THEME_KEY, JSON.stringify(all));
|
|
55
|
+
} catch {
|
|
56
|
+
// storage blocked or full: drawn again next time
|
|
57
|
+
}
|
|
58
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// The theme "From wallpaper" drawn in the page (./wallpaper-sheet.ts) from the workspace's images: React's side.
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import {
|
|
4
|
+
WALLPAPER_THEME_VERSION,
|
|
5
|
+
wallpaperColours,
|
|
6
|
+
wallpaperThemeRule,
|
|
7
|
+
type WallpaperColours,
|
|
8
|
+
} from "./wallpaper-theme.ts";
|
|
9
|
+
import { keepWallpaperRules, keptWallpaperRules, layWallpaperRules } from "./wallpaper-sheet.ts";
|
|
10
|
+
|
|
11
|
+
/** An image's colours: drawn small (48 px wide) on a canvas, read back. Same-origin or `blob:` images only. */
|
|
12
|
+
async function coloursOf(url: string): Promise<WallpaperColours | undefined> {
|
|
13
|
+
const image = new Image();
|
|
14
|
+
image.src = url;
|
|
15
|
+
await image.decode();
|
|
16
|
+
const width = 48;
|
|
17
|
+
const height = Math.max(1, Math.round((image.naturalHeight / image.naturalWidth) * width));
|
|
18
|
+
const context = Object.assign(document.createElement("canvas"), { width, height }).getContext(
|
|
19
|
+
"2d",
|
|
20
|
+
{ willReadFrequently: true },
|
|
21
|
+
);
|
|
22
|
+
if (!context) return undefined;
|
|
23
|
+
context.drawImage(image, 0, 0, width, height);
|
|
24
|
+
return wallpaperColours(context.getImageData(0, 0, width, height).data);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Draws the theme from `images` (each mode's image URL; none: the kit's own blocks) for workspace `slug`, kept for the
|
|
28
|
+
* next page by `named` (what names the images: their URL may be the page's own, a `blob:`) and the derivation's version;
|
|
29
|
+
* again when either changes. */
|
|
30
|
+
export function useWallpaperTheme(
|
|
31
|
+
slug: string | undefined,
|
|
32
|
+
images: { light?: string | undefined; dark?: string | undefined },
|
|
33
|
+
named: string,
|
|
34
|
+
) {
|
|
35
|
+
const key = `${WALLPAPER_THEME_VERSION}:${named}`;
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
if (slug === undefined) return;
|
|
38
|
+
const all = keptWallpaperRules();
|
|
39
|
+
if (all[slug]?.images === key) return layWallpaperRules(all[slug].css);
|
|
40
|
+
if (images.light === undefined && images.dark === undefined) {
|
|
41
|
+
layWallpaperRules("");
|
|
42
|
+
return keepWallpaperRules(slug, undefined);
|
|
43
|
+
}
|
|
44
|
+
let live = true;
|
|
45
|
+
void Promise.all(
|
|
46
|
+
[images.light, images.dark].map((url) =>
|
|
47
|
+
url === undefined ? Promise.resolve(undefined) : coloursOf(url).catch(() => null),
|
|
48
|
+
),
|
|
49
|
+
).then(([light, dark]) => {
|
|
50
|
+
if (!live) return;
|
|
51
|
+
const css = `${wallpaperThemeRule(light ?? undefined, "light")}\n${wallpaperThemeRule(dark ?? undefined, "dark")}`;
|
|
52
|
+
layWallpaperRules(css);
|
|
53
|
+
// An image that failed to read (the network, a decode) is read again next time, not kept as the fallback.
|
|
54
|
+
if (light !== null && dark !== null) keepWallpaperRules(slug, { images: key, css });
|
|
55
|
+
});
|
|
56
|
+
return () => {
|
|
57
|
+
live = false;
|
|
58
|
+
};
|
|
59
|
+
}, [slug, key]);
|
|
60
|
+
}
|