@dxos/ui-theme 0.8.4-main.fbb7a13 → 0.8.4-main.fcc0d83b33
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/lib/browser/index.mjs +762 -2803
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +762 -2803
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/plugin/node-cjs/main.css +1561 -0
- package/dist/plugin/node-cjs/main.css.map +7 -0
- package/dist/plugin/node-cjs/meta.json +1 -1
- package/dist/plugin/node-cjs/plugins/ThemePlugin.cjs +137 -0
- package/dist/plugin/node-cjs/plugins/ThemePlugin.cjs.map +7 -0
- package/dist/plugin/node-esm/main.css +1561 -0
- package/dist/plugin/node-esm/main.css.map +7 -0
- package/dist/plugin/node-esm/meta.json +1 -1
- package/dist/plugin/node-esm/plugins/ThemePlugin.mjs +105 -0
- package/dist/plugin/node-esm/plugins/ThemePlugin.mjs.map +7 -0
- package/dist/types/src/Theme.stories.d.ts +27 -0
- package/dist/types/src/Theme.stories.d.ts.map +1 -0
- package/dist/types/src/defs.d.ts +21 -0
- package/dist/types/src/defs.d.ts.map +1 -0
- package/dist/types/src/fragments/density.d.ts +4 -0
- package/dist/types/src/fragments/density.d.ts.map +1 -0
- package/dist/types/src/fragments/disabled.d.ts.map +1 -0
- package/dist/types/src/fragments/hover.d.ts +10 -0
- package/dist/types/src/fragments/hover.d.ts.map +1 -0
- package/dist/types/src/fragments/index.d.ts +5 -0
- package/dist/types/src/fragments/index.d.ts.map +1 -0
- package/dist/types/src/fragments/text.d.ts +2 -0
- package/dist/types/src/fragments/text.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -10
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/plugins/ThemePlugin.d.ts +16 -0
- package/dist/types/src/plugins/ThemePlugin.d.ts.map +1 -0
- package/dist/types/src/plugins/dark-mode.d.ts +1 -0
- package/dist/types/src/plugins/dark-mode.d.ts.map +1 -0
- package/dist/types/src/theme/components/avatar.d.ts.map +1 -0
- package/dist/types/src/theme/components/breadcrumb.d.ts.map +1 -0
- package/dist/types/src/theme/components/button.d.ts +15 -0
- package/dist/types/src/theme/components/button.d.ts.map +1 -0
- package/dist/types/src/theme/components/card.d.ts +12 -0
- package/dist/types/src/theme/components/card.d.ts.map +1 -0
- package/dist/types/src/{styles → theme}/components/dialog.d.ts +2 -0
- package/dist/types/src/theme/components/dialog.d.ts.map +1 -0
- package/dist/types/src/theme/components/focus.d.ts +6 -0
- package/dist/types/src/theme/components/focus.d.ts.map +1 -0
- package/dist/types/src/{styles → theme}/components/icon-button.d.ts +1 -0
- package/dist/types/src/theme/components/icon-button.d.ts.map +1 -0
- package/dist/types/src/{styles → theme}/components/icon.d.ts +3 -0
- package/dist/types/src/theme/components/icon.d.ts.map +1 -0
- package/dist/types/src/{styles → theme}/components/index.d.ts +4 -1
- package/dist/types/src/theme/components/index.d.ts.map +1 -0
- package/dist/types/src/{styles → theme}/components/input.d.ts +31 -27
- package/dist/types/src/theme/components/input.d.ts.map +1 -0
- package/dist/types/src/theme/components/link.d.ts.map +1 -0
- package/dist/types/src/theme/components/list.d.ts.map +1 -0
- package/dist/types/src/{styles → theme}/components/main.d.ts +2 -7
- package/dist/types/src/theme/components/main.d.ts.map +1 -0
- package/dist/types/src/{styles → theme}/components/menu.d.ts +1 -1
- package/dist/types/src/theme/components/menu.d.ts.map +1 -0
- package/dist/types/src/{styles → theme}/components/message.d.ts +1 -0
- package/dist/types/src/theme/components/message.d.ts.map +1 -0
- package/dist/types/src/{styles → theme}/components/popover.d.ts +1 -1
- package/dist/types/src/theme/components/popover.d.ts.map +1 -0
- package/dist/types/src/theme/components/scroll-area.d.ts +32 -0
- package/dist/types/src/theme/components/scroll-area.d.ts.map +1 -0
- package/dist/types/src/theme/components/select.d.ts.map +1 -0
- package/dist/types/src/theme/components/separator.d.ts.map +1 -0
- package/dist/types/src/theme/components/skeleton.d.ts +7 -0
- package/dist/types/src/theme/components/skeleton.d.ts.map +1 -0
- package/dist/types/src/theme/components/splitter.d.ts +4 -0
- package/dist/types/src/theme/components/splitter.d.ts.map +1 -0
- package/dist/types/src/{styles → theme}/components/status.d.ts +1 -1
- package/dist/types/src/theme/components/status.d.ts.map +1 -0
- package/dist/types/src/theme/components/tag.d.ts.map +1 -0
- package/dist/types/src/theme/components/toast.d.ts.map +1 -0
- package/dist/types/src/theme/components/toolbar.d.ts +11 -0
- package/dist/types/src/theme/components/toolbar.d.ts.map +1 -0
- package/dist/types/src/theme/components/tooltip.d.ts.map +1 -0
- package/dist/types/src/theme/components/treegrid.d.ts.map +1 -0
- package/dist/types/src/theme/index.d.ts +4 -0
- package/dist/types/src/theme/index.d.ts.map +1 -0
- package/dist/types/src/theme/primitives/column.d.ts +29 -0
- package/dist/types/src/theme/primitives/column.d.ts.map +1 -0
- package/dist/types/src/theme/primitives/index.d.ts +3 -0
- package/dist/types/src/theme/primitives/index.d.ts.map +1 -0
- package/dist/types/src/theme/primitives/panel.d.ts +13 -0
- package/dist/types/src/theme/primitives/panel.d.ts.map +1 -0
- package/dist/types/src/theme/theme.d.ts +5 -0
- package/dist/types/src/theme/theme.d.ts.map +1 -0
- package/dist/types/src/{styles/fragments → util}/elevation.d.ts +0 -6
- package/dist/types/src/util/elevation.d.ts.map +1 -0
- package/dist/types/src/util/hash-styles.d.ts +8 -5
- package/dist/types/src/util/hash-styles.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +3 -0
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/mx.d.ts +56 -0
- package/dist/types/src/util/mx.d.ts.map +1 -1
- package/dist/types/src/util/size.d.ts +27 -0
- package/dist/types/src/util/size.d.ts.map +1 -0
- package/dist/types/src/util/valence.d.ts +4 -0
- package/dist/types/src/util/valence.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +25 -35
- package/src/Theme.stories.tsx +224 -0
- package/src/css/base/base.css +43 -0
- package/src/{styles/layers → css/base}/typography.css +3 -5
- package/src/{styles/layers → css/components}/button.css +23 -14
- package/src/{styles/layers → css/components}/checkbox.css +12 -8
- package/src/{styles/layers → css/components}/dialog.css +16 -15
- package/src/{styles/layers/focus-ring.css → css/components/focus.css} +60 -41
- package/src/css/components/icon.css +9 -0
- package/src/css/components/link.css +9 -0
- package/src/css/components/panel.css +117 -0
- package/src/css/components/scrollbar.css +24 -0
- package/src/css/components/selected.css +30 -0
- package/src/css/components/surface.css +34 -0
- package/src/css/components/tag.css +132 -0
- package/src/css/components/text.css +124 -0
- package/src/css/integrations/codemirror.css +34 -0
- package/src/css/integrations/tldraw.css +14 -0
- package/src/css/layout/main.css +205 -0
- package/src/{styles/layers → css/layout}/native.css +6 -4
- package/src/css/layout/positioning.css +19 -0
- package/src/{styles/layers → css/layout}/size.css +129 -108
- package/src/css/theme/animation.css +260 -0
- package/src/css/theme/border.css +23 -0
- package/src/css/theme/palette.css +36 -0
- package/src/css/theme/semantic.css +116 -0
- package/src/css/theme/spacing.css +147 -0
- package/src/css/theme/styles.css +145 -0
- package/src/css/theme/text.css +37 -0
- package/src/css/utilities.css +118 -0
- package/src/defs.ts +48 -0
- package/src/fragments/AUDIT.md +57 -0
- package/src/fragments/density.ts +16 -0
- package/src/fragments/hover.ts +18 -0
- package/src/fragments/index.ts +10 -0
- package/src/fragments/text.ts +6 -0
- package/src/index.ts +3 -14
- package/src/main.css +87 -0
- package/src/plugins/ThemePlugin.ts +125 -0
- package/src/plugins/dark-mode.ts +22 -0
- package/src/plugins/main.css +45 -0
- package/src/{styles → theme}/components/avatar.ts +12 -13
- package/src/theme/components/button.ts +48 -0
- package/src/theme/components/card.ts +102 -0
- package/src/{styles → theme}/components/dialog.ts +19 -10
- package/src/theme/components/focus.ts +33 -0
- package/src/{styles → theme}/components/icon-button.ts +6 -5
- package/src/theme/components/icon.ts +28 -0
- package/src/{styles → theme}/components/index.ts +4 -1
- package/src/theme/components/input.ts +171 -0
- package/src/{styles → theme}/components/link.ts +3 -4
- package/src/{styles → theme}/components/list.ts +5 -5
- package/src/{styles → theme}/components/main.ts +2 -6
- package/src/{styles → theme}/components/menu.ts +11 -21
- package/src/{styles → theme}/components/message.ts +11 -7
- package/src/{styles → theme}/components/popover.ts +13 -12
- package/src/theme/components/scroll-area.ts +115 -0
- package/src/{styles → theme}/components/select.ts +8 -16
- package/src/{styles → theme}/components/separator.ts +3 -3
- package/src/theme/components/skeleton.ts +23 -0
- package/src/theme/components/splitter.ts +20 -0
- package/src/{styles → theme}/components/status.ts +7 -7
- package/src/{styles → theme}/components/tag.ts +1 -1
- package/src/{styles → theme}/components/toast.ts +6 -8
- package/src/theme/components/toolbar.ts +35 -0
- package/src/{styles → theme}/components/tooltip.ts +4 -6
- package/src/{styles → theme}/components/treegrid.ts +9 -9
- package/src/{styles → theme}/index.ts +2 -2
- package/src/theme/primitives/column.ts +71 -0
- package/src/theme/primitives/index.ts +6 -0
- package/src/theme/primitives/panel.ts +43 -0
- package/src/{styles → theme}/theme.ts +27 -9
- package/src/typings.d.ts +3 -1
- package/src/{styles/fragments → util}/elevation.ts +6 -8
- package/src/util/hash-styles.ts +118 -98
- package/src/util/index.ts +3 -0
- package/src/util/mx.ts +165 -43
- package/src/util/size.ts +103 -0
- package/src/util/valence.ts +33 -0
- package/dist/plugin/node-cjs/chunk-UUMDOU7E.cjs +0 -79
- package/dist/plugin/node-cjs/chunk-UUMDOU7E.cjs.map +0 -7
- package/dist/plugin/node-cjs/chunk-ZVALPM6U.cjs +0 -1619
- package/dist/plugin/node-cjs/chunk-ZVALPM6U.cjs.map +0 -7
- package/dist/plugin/node-cjs/config/tailwind.cjs +0 -29
- package/dist/plugin/node-cjs/config/tailwind.cjs.map +0 -7
- package/dist/plugin/node-cjs/plugins/esbuild-plugin.cjs +0 -90
- package/dist/plugin/node-cjs/plugins/esbuild-plugin.cjs.map +0 -7
- package/dist/plugin/node-cjs/plugins/plugin.cjs +0 -124
- package/dist/plugin/node-cjs/plugins/plugin.cjs.map +0 -7
- package/dist/plugin/node-cjs/theme.css +0 -1418
- package/dist/plugin/node-cjs/theme.css.map +0 -7
- package/dist/plugin/node-esm/chunk-AFRHJHP4.mjs +0 -49
- package/dist/plugin/node-esm/chunk-AFRHJHP4.mjs.map +0 -7
- package/dist/plugin/node-esm/chunk-HJE6EZWE.mjs +0 -1614
- package/dist/plugin/node-esm/chunk-HJE6EZWE.mjs.map +0 -7
- package/dist/plugin/node-esm/config/tailwind.mjs +0 -8
- package/dist/plugin/node-esm/config/tailwind.mjs.map +0 -7
- package/dist/plugin/node-esm/plugins/esbuild-plugin.mjs +0 -63
- package/dist/plugin/node-esm/plugins/esbuild-plugin.mjs.map +0 -7
- package/dist/plugin/node-esm/plugins/plugin.mjs +0 -98
- package/dist/plugin/node-esm/plugins/plugin.mjs.map +0 -7
- package/dist/plugin/node-esm/theme.css +0 -1418
- package/dist/plugin/node-esm/theme.css.map +0 -7
- package/dist/types/src/Tokens.stories.d.ts +0 -10
- package/dist/types/src/Tokens.stories.d.ts.map +0 -1
- package/dist/types/src/config/index.d.ts +0 -3
- package/dist/types/src/config/index.d.ts.map +0 -1
- package/dist/types/src/config/tailwind.d.ts +0 -9
- package/dist/types/src/config/tailwind.d.ts.map +0 -1
- package/dist/types/src/config/tokens/alias-colors.d.ts +0 -21
- package/dist/types/src/config/tokens/alias-colors.d.ts.map +0 -1
- package/dist/types/src/config/tokens/index.d.ts +0 -486
- package/dist/types/src/config/tokens/index.d.ts.map +0 -1
- package/dist/types/src/config/tokens/lengths.d.ts +0 -139
- package/dist/types/src/config/tokens/lengths.d.ts.map +0 -1
- package/dist/types/src/config/tokens/physical-colors.d.ts +0 -23
- package/dist/types/src/config/tokens/physical-colors.d.ts.map +0 -1
- package/dist/types/src/config/tokens/semantic-colors.d.ts +0 -187
- package/dist/types/src/config/tokens/semantic-colors.d.ts.map +0 -1
- package/dist/types/src/config/tokens/sememes-calls.d.ts +0 -3
- package/dist/types/src/config/tokens/sememes-calls.d.ts.map +0 -1
- package/dist/types/src/config/tokens/sememes-codemirror.d.ts +0 -43
- package/dist/types/src/config/tokens/sememes-codemirror.d.ts.map +0 -1
- package/dist/types/src/config/tokens/sememes-hue.d.ts +0 -4
- package/dist/types/src/config/tokens/sememes-hue.d.ts.map +0 -1
- package/dist/types/src/config/tokens/sememes-sheet.d.ts +0 -58
- package/dist/types/src/config/tokens/sememes-sheet.d.ts.map +0 -1
- package/dist/types/src/config/tokens/sememes-system.d.ts +0 -99
- package/dist/types/src/config/tokens/sememes-system.d.ts.map +0 -1
- package/dist/types/src/config/tokens/sizes.d.ts +0 -7
- package/dist/types/src/config/tokens/sizes.d.ts.map +0 -1
- package/dist/types/src/config/tokens/types.d.ts +0 -5
- package/dist/types/src/config/tokens/types.d.ts.map +0 -1
- package/dist/types/src/plugins/esbuild-plugin.d.ts +0 -9
- package/dist/types/src/plugins/esbuild-plugin.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin.d.ts +0 -20
- package/dist/types/src/plugins/plugin.d.ts.map +0 -1
- package/dist/types/src/plugins/resolveContent.d.ts +0 -2
- package/dist/types/src/plugins/resolveContent.d.ts.map +0 -1
- package/dist/types/src/styles/components/anchored-overflow.d.ts +0 -6
- package/dist/types/src/styles/components/anchored-overflow.d.ts.map +0 -1
- package/dist/types/src/styles/components/avatar.d.ts.map +0 -1
- package/dist/types/src/styles/components/breadcrumb.d.ts.map +0 -1
- package/dist/types/src/styles/components/button.d.ts +0 -19
- package/dist/types/src/styles/components/button.d.ts.map +0 -1
- package/dist/types/src/styles/components/dialog.d.ts.map +0 -1
- package/dist/types/src/styles/components/icon-button.d.ts.map +0 -1
- package/dist/types/src/styles/components/icon.d.ts.map +0 -1
- package/dist/types/src/styles/components/index.d.ts.map +0 -1
- package/dist/types/src/styles/components/input.d.ts.map +0 -1
- package/dist/types/src/styles/components/link.d.ts.map +0 -1
- package/dist/types/src/styles/components/list.d.ts.map +0 -1
- package/dist/types/src/styles/components/main.d.ts.map +0 -1
- package/dist/types/src/styles/components/menu.d.ts.map +0 -1
- package/dist/types/src/styles/components/message.d.ts.map +0 -1
- package/dist/types/src/styles/components/popover.d.ts.map +0 -1
- package/dist/types/src/styles/components/scroll-area.d.ts +0 -9
- package/dist/types/src/styles/components/scroll-area.d.ts.map +0 -1
- package/dist/types/src/styles/components/select.d.ts.map +0 -1
- package/dist/types/src/styles/components/separator.d.ts.map +0 -1
- package/dist/types/src/styles/components/status.d.ts.map +0 -1
- package/dist/types/src/styles/components/tag.d.ts.map +0 -1
- package/dist/types/src/styles/components/toast.d.ts.map +0 -1
- package/dist/types/src/styles/components/toolbar.d.ts +0 -11
- package/dist/types/src/styles/components/toolbar.d.ts.map +0 -1
- package/dist/types/src/styles/components/tooltip.d.ts.map +0 -1
- package/dist/types/src/styles/components/treegrid.d.ts.map +0 -1
- package/dist/types/src/styles/fragments/density.d.ts +0 -13
- package/dist/types/src/styles/fragments/density.d.ts.map +0 -1
- package/dist/types/src/styles/fragments/dimension.d.ts +0 -5
- package/dist/types/src/styles/fragments/dimension.d.ts.map +0 -1
- package/dist/types/src/styles/fragments/disabled.d.ts.map +0 -1
- package/dist/types/src/styles/fragments/elevation.d.ts.map +0 -1
- package/dist/types/src/styles/fragments/focus.d.ts +0 -6
- package/dist/types/src/styles/fragments/focus.d.ts.map +0 -1
- package/dist/types/src/styles/fragments/group.d.ts +0 -5
- package/dist/types/src/styles/fragments/group.d.ts.map +0 -1
- package/dist/types/src/styles/fragments/hover.d.ts +0 -17
- package/dist/types/src/styles/fragments/hover.d.ts.map +0 -1
- package/dist/types/src/styles/fragments/index.d.ts +0 -17
- package/dist/types/src/styles/fragments/index.d.ts.map +0 -1
- package/dist/types/src/styles/fragments/layout.d.ts +0 -3
- package/dist/types/src/styles/fragments/layout.d.ts.map +0 -1
- package/dist/types/src/styles/fragments/motion.d.ts +0 -2
- package/dist/types/src/styles/fragments/motion.d.ts.map +0 -1
- package/dist/types/src/styles/fragments/ornament.d.ts +0 -5
- package/dist/types/src/styles/fragments/ornament.d.ts.map +0 -1
- package/dist/types/src/styles/fragments/selected.d.ts +0 -13
- package/dist/types/src/styles/fragments/selected.d.ts.map +0 -1
- package/dist/types/src/styles/fragments/shimmer.d.ts +0 -3
- package/dist/types/src/styles/fragments/shimmer.d.ts.map +0 -1
- package/dist/types/src/styles/fragments/size.d.ts +0 -9
- package/dist/types/src/styles/fragments/size.d.ts.map +0 -1
- package/dist/types/src/styles/fragments/surface.d.ts +0 -9
- package/dist/types/src/styles/fragments/surface.d.ts.map +0 -1
- package/dist/types/src/styles/fragments/text.d.ts +0 -7
- package/dist/types/src/styles/fragments/text.d.ts.map +0 -1
- package/dist/types/src/styles/fragments/valence.d.ts +0 -13
- package/dist/types/src/styles/fragments/valence.d.ts.map +0 -1
- package/dist/types/src/styles/index.d.ts +0 -4
- package/dist/types/src/styles/index.d.ts.map +0 -1
- package/dist/types/src/styles/theme.d.ts +0 -5
- package/dist/types/src/styles/theme.d.ts.map +0 -1
- package/dist/types/src/tailwind.d.ts +0 -3
- package/dist/types/src/tailwind.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -3
- package/dist/types/src/types.d.ts.map +0 -1
- package/dist/types/src/util/withLogical.d.ts +0 -164
- package/dist/types/src/util/withLogical.d.ts.map +0 -1
- package/src/Tokens.stories.tsx +0 -88
- package/src/config/index.ts +0 -6
- package/src/config/tailwind.ts +0 -264
- package/src/config/tokens/alias-colors.ts +0 -39
- package/src/config/tokens/index.ts +0 -92
- package/src/config/tokens/lengths.ts +0 -97
- package/src/config/tokens/physical-colors.ts +0 -125
- package/src/config/tokens/semantic-colors.ts +0 -27
- package/src/config/tokens/sememes-calls.ts +0 -17
- package/src/config/tokens/sememes-codemirror.ts +0 -50
- package/src/config/tokens/sememes-hue.ts +0 -54
- package/src/config/tokens/sememes-sheet.ts +0 -62
- package/src/config/tokens/sememes-system.ts +0 -302
- package/src/config/tokens/sizes.ts +0 -10
- package/src/config/tokens/types.ts +0 -9
- package/src/docs/theme.drawio.svg +0 -635
- package/src/plugins/esbuild-plugin.ts +0 -65
- package/src/plugins/plugin.ts +0 -130
- package/src/plugins/resolveContent.ts +0 -51
- package/src/styles/components/README.md +0 -6
- package/src/styles/components/anchored-overflow.ts +0 -20
- package/src/styles/components/button.ts +0 -48
- package/src/styles/components/icon.ts +0 -19
- package/src/styles/components/input.ts +0 -177
- package/src/styles/components/scroll-area.ts +0 -43
- package/src/styles/components/toolbar.ts +0 -29
- package/src/styles/fragments/density.ts +0 -17
- package/src/styles/fragments/dimension.ts +0 -8
- package/src/styles/fragments/focus.ts +0 -16
- package/src/styles/fragments/group.ts +0 -12
- package/src/styles/fragments/hover.ts +0 -25
- package/src/styles/fragments/index.ts +0 -20
- package/src/styles/fragments/layout.ts +0 -7
- package/src/styles/fragments/motion.ts +0 -6
- package/src/styles/fragments/ornament.ts +0 -10
- package/src/styles/fragments/selected.ts +0 -45
- package/src/styles/fragments/shimmer.ts +0 -9
- package/src/styles/fragments/size.ts +0 -117
- package/src/styles/fragments/surface.ts +0 -29
- package/src/styles/fragments/text.ts +0 -12
- package/src/styles/fragments/valence.ts +0 -46
- package/src/styles/layers/README.md +0 -15
- package/src/styles/layers/anchored-overflow.css +0 -9
- package/src/styles/layers/animation.css +0 -17
- package/src/styles/layers/attention.css +0 -8
- package/src/styles/layers/base.css +0 -25
- package/src/styles/layers/can-scroll.css +0 -26
- package/src/styles/layers/drag-preview.css +0 -18
- package/src/styles/layers/hues.css +0 -110
- package/src/styles/layers/index.css +0 -26
- package/src/styles/layers/main.css +0 -227
- package/src/styles/layers/positioning.css +0 -23
- package/src/styles/layers/surfaces.css +0 -31
- package/src/styles/layers/tag.css +0 -132
- package/src/styles/layers/tldraw.css +0 -91
- package/src/styles/layers/tokens.css +0 -46
- package/src/tailwind.ts +0 -7
- package/src/theme.css +0 -9
- package/src/types.ts +0 -7
- package/src/util/withLogical.ts +0 -114
- /package/dist/types/src/{styles/fragments → fragments}/disabled.d.ts +0 -0
- /package/dist/types/src/{styles → theme}/components/avatar.d.ts +0 -0
- /package/dist/types/src/{styles → theme}/components/breadcrumb.d.ts +0 -0
- /package/dist/types/src/{styles → theme}/components/link.d.ts +0 -0
- /package/dist/types/src/{styles → theme}/components/list.d.ts +0 -0
- /package/dist/types/src/{styles → theme}/components/select.d.ts +0 -0
- /package/dist/types/src/{styles → theme}/components/separator.d.ts +0 -0
- /package/dist/types/src/{styles → theme}/components/tag.d.ts +0 -0
- /package/dist/types/src/{styles → theme}/components/toast.d.ts +0 -0
- /package/dist/types/src/{styles → theme}/components/tooltip.d.ts +0 -0
- /package/dist/types/src/{styles → theme}/components/treegrid.d.ts +0 -0
- /package/src/{styles/fragments → fragments}/disabled.ts +0 -0
- /package/src/{styles → theme}/components/breadcrumb.ts +0 -0
package/src/util/hash-styles.ts
CHANGED
|
@@ -6,163 +6,183 @@ import { type ChromaticPalette } from '@dxos/ui-types';
|
|
|
6
6
|
|
|
7
7
|
export type Hue = ChromaticPalette | 'neutral';
|
|
8
8
|
|
|
9
|
-
// TODO(burdon):
|
|
9
|
+
// TODO(burdon): Reconcile with ui-theme/theme/roles.css
|
|
10
10
|
export type ColorStyles = {
|
|
11
11
|
hue: Hue;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
border: string;
|
|
12
|
+
fill: string; // -fill
|
|
13
|
+
surface: string; // -surface
|
|
14
|
+
surfaceText: string; // -surface-text
|
|
15
|
+
text: string; // -text
|
|
16
|
+
border: string; // -border
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
const
|
|
19
|
+
const neutral: ColorStyles = {
|
|
20
20
|
hue: 'neutral',
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
border: 'border-
|
|
21
|
+
fill: 'bg-neutral-fill',
|
|
22
|
+
surface: 'bg-neutral-surface',
|
|
23
|
+
surfaceText: 'text-neutral-surface-text',
|
|
24
|
+
text: 'text-neutral-text',
|
|
25
|
+
border: 'border-neutral-border',
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
// NOTE:
|
|
29
|
-
// NOTE: Cordinated with `tag.css`.
|
|
28
|
+
// NOTE: Coordinated with `tag.css`.
|
|
30
29
|
// https://github.com/dxos/dxos/blob/main/packages/ui/react-ui-theme/src/styles/layers/tag.css
|
|
31
|
-
|
|
30
|
+
const styles: ColorStyles[] = [
|
|
31
|
+
{
|
|
32
|
+
hue: 'red',
|
|
33
|
+
fill: 'bg-red-fill',
|
|
34
|
+
surface: 'bg-red-surface',
|
|
35
|
+
surfaceText: 'text-red-surface-text',
|
|
36
|
+
text: 'text-red-text',
|
|
37
|
+
border: 'border-red-border',
|
|
38
|
+
},
|
|
32
39
|
{
|
|
33
40
|
hue: 'orange',
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
border: 'border-
|
|
41
|
+
fill: 'bg-orange-fill',
|
|
42
|
+
surface: 'bg-orange-surface',
|
|
43
|
+
surfaceText: 'text-orange-surface-text',
|
|
44
|
+
text: 'text-orange-text',
|
|
45
|
+
border: 'border-orange-border',
|
|
39
46
|
},
|
|
40
47
|
{
|
|
41
48
|
hue: 'amber',
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
border: 'border-
|
|
49
|
+
fill: 'bg-amber-fill',
|
|
50
|
+
surface: 'bg-amber-surface',
|
|
51
|
+
surfaceText: 'text-amber-surface-text',
|
|
52
|
+
text: 'text-amber-text',
|
|
53
|
+
border: 'border-amber-border',
|
|
47
54
|
},
|
|
48
55
|
{
|
|
49
56
|
hue: 'yellow',
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
border: 'border-
|
|
57
|
+
fill: 'bg-yellow-fill',
|
|
58
|
+
surface: 'bg-yellow-surface',
|
|
59
|
+
surfaceText: 'text-yellow-surface-text',
|
|
60
|
+
text: 'text-yellow-text',
|
|
61
|
+
border: 'border-yellow-border',
|
|
55
62
|
},
|
|
56
63
|
{
|
|
57
64
|
hue: 'lime',
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
border: 'border-
|
|
65
|
+
fill: 'bg-lime-fill',
|
|
66
|
+
surface: 'bg-lime-surface',
|
|
67
|
+
surfaceText: 'text-lime-surface-text',
|
|
68
|
+
text: 'text-lime-text',
|
|
69
|
+
border: 'border-lime-border',
|
|
63
70
|
},
|
|
64
71
|
{
|
|
65
72
|
hue: 'green',
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
border: 'border-
|
|
73
|
+
fill: 'bg-green-fill',
|
|
74
|
+
surface: 'bg-green-surface',
|
|
75
|
+
surfaceText: 'text-green-surface-text',
|
|
76
|
+
text: 'text-green-text',
|
|
77
|
+
border: 'border-green-border',
|
|
71
78
|
},
|
|
72
79
|
{
|
|
73
80
|
hue: 'emerald',
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
border: 'border-
|
|
81
|
+
fill: 'bg-emerald-fill',
|
|
82
|
+
surface: 'bg-emerald-surface',
|
|
83
|
+
surfaceText: 'text-emerald-surface-text',
|
|
84
|
+
text: 'text-emerald-text',
|
|
85
|
+
border: 'border-emerald-border',
|
|
79
86
|
},
|
|
80
87
|
{
|
|
81
88
|
hue: 'teal',
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
border: 'border-
|
|
89
|
+
fill: 'bg-teal-fill',
|
|
90
|
+
surface: 'bg-teal-surface',
|
|
91
|
+
surfaceText: 'text-teal-surface-text',
|
|
92
|
+
text: 'text-teal-text',
|
|
93
|
+
border: 'border-teal-border',
|
|
87
94
|
},
|
|
88
95
|
{
|
|
89
96
|
hue: 'cyan',
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
border: 'border-
|
|
97
|
+
fill: 'bg-cyan-fill',
|
|
98
|
+
surface: 'bg-cyan-surface',
|
|
99
|
+
surfaceText: 'text-cyan-surface-text',
|
|
100
|
+
text: 'text-cyan-text',
|
|
101
|
+
border: 'border-cyan-border',
|
|
95
102
|
},
|
|
96
103
|
{
|
|
97
104
|
hue: 'sky',
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
border: 'border-
|
|
105
|
+
fill: 'bg-sky-fill',
|
|
106
|
+
surface: 'bg-sky-surface',
|
|
107
|
+
surfaceText: 'text-sky-surface-text',
|
|
108
|
+
text: 'text-sky-text',
|
|
109
|
+
border: 'border-sky-border',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
hue: 'blue',
|
|
113
|
+
fill: 'bg-blue-fill',
|
|
114
|
+
surface: 'bg-blue-surface',
|
|
115
|
+
surfaceText: 'text-blue-surface-text',
|
|
116
|
+
text: 'text-blue-text',
|
|
117
|
+
border: 'border-blue-border',
|
|
103
118
|
},
|
|
104
119
|
{
|
|
105
120
|
hue: 'indigo',
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
border: 'border-
|
|
121
|
+
fill: 'bg-indigo-fill',
|
|
122
|
+
surface: 'bg-indigo-surface',
|
|
123
|
+
surfaceText: 'text-indigo-surface-text',
|
|
124
|
+
text: 'text-indigo-text',
|
|
125
|
+
border: 'border-indigo-border',
|
|
111
126
|
},
|
|
112
127
|
{
|
|
113
128
|
hue: 'violet',
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
border: 'border-
|
|
129
|
+
fill: 'bg-violet-fill',
|
|
130
|
+
surface: 'bg-violet-surface',
|
|
131
|
+
surfaceText: 'text-violet-surface-text',
|
|
132
|
+
text: 'text-violet-text',
|
|
133
|
+
border: 'border-violet-border',
|
|
119
134
|
},
|
|
120
135
|
{
|
|
121
136
|
hue: 'purple',
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
border: 'border-
|
|
137
|
+
fill: 'bg-purple-fill',
|
|
138
|
+
surface: 'bg-purple-surface',
|
|
139
|
+
surfaceText: 'text-purple-surface-text',
|
|
140
|
+
text: 'text-purple-text',
|
|
141
|
+
border: 'border-purple-border',
|
|
127
142
|
},
|
|
128
143
|
{
|
|
129
144
|
hue: 'fuchsia',
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
border: 'border-
|
|
145
|
+
fill: 'bg-fuchsia-fill',
|
|
146
|
+
surface: 'bg-fuchsia-surface',
|
|
147
|
+
surfaceText: 'text-fuchsia-surface-text',
|
|
148
|
+
text: 'text-fuchsia-text',
|
|
149
|
+
border: 'border-fuchsia-border',
|
|
135
150
|
},
|
|
136
151
|
{
|
|
137
|
-
hue: '
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
border: 'border-
|
|
152
|
+
hue: 'pink',
|
|
153
|
+
fill: 'bg-pink-fill',
|
|
154
|
+
surface: 'bg-pink-surface',
|
|
155
|
+
surfaceText: 'text-pink-surface-text',
|
|
156
|
+
text: 'text-pink-text',
|
|
157
|
+
border: 'border-pink-border',
|
|
143
158
|
},
|
|
144
159
|
{
|
|
145
|
-
hue: '
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
border: 'border-
|
|
160
|
+
hue: 'rose',
|
|
161
|
+
fill: 'bg-rose-fill',
|
|
162
|
+
surface: 'bg-rose-surface',
|
|
163
|
+
surfaceText: 'text-rose-surface-text',
|
|
164
|
+
text: 'text-rose-text',
|
|
165
|
+
border: 'border-rose-border',
|
|
151
166
|
},
|
|
152
167
|
];
|
|
153
168
|
|
|
154
|
-
export const
|
|
155
|
-
|
|
169
|
+
export const palette = {
|
|
170
|
+
neutral,
|
|
171
|
+
hues: styles,
|
|
156
172
|
};
|
|
157
173
|
|
|
158
|
-
|
|
159
|
-
|
|
174
|
+
// TODO(burdon): Rename getClassNames.
|
|
175
|
+
export const getStyles = (hue: string): ColorStyles => {
|
|
176
|
+
return styles.find((color) => color.hue === hue) || neutral;
|
|
160
177
|
};
|
|
161
178
|
|
|
162
179
|
// TODO(thure): Reconcile with `to-fallback.ts` which exports `toHue` which overlaps a lot.
|
|
163
180
|
export const getHashStyles = (id: string | undefined): ColorStyles => {
|
|
164
|
-
|
|
165
|
-
|
|
181
|
+
return getStyles(getHashHue(id));
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export const getHashHue = (id: string | undefined): Hue => {
|
|
185
|
+
return id ? styles[getHash(id) % styles.length].hue : 'neutral';
|
|
166
186
|
};
|
|
167
187
|
|
|
168
188
|
const getHash = (id: string): number => id.split('').reduce((acc, char) => acc + char.charCodeAt(0), 0);
|
package/src/util/index.ts
CHANGED
package/src/util/mx.ts
CHANGED
|
@@ -2,50 +2,172 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import {
|
|
6
|
+
Children,
|
|
7
|
+
createElement,
|
|
8
|
+
forwardRef,
|
|
9
|
+
type ForwardRefExoticComponent,
|
|
10
|
+
type ForwardedRef,
|
|
11
|
+
type HTMLAttributes,
|
|
12
|
+
isValidElement,
|
|
13
|
+
type ReactNode,
|
|
14
|
+
type RefAttributes,
|
|
15
|
+
CSSProperties,
|
|
16
|
+
} from 'react';
|
|
5
17
|
import { extendTailwindMerge, validators } from 'tailwind-merge';
|
|
6
18
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
19
|
+
import { log } from '@dxos/log';
|
|
20
|
+
import { ThemedClassName, type ComposableProps, type SlottableProps } from '@dxos/ui-types';
|
|
21
|
+
|
|
22
|
+
type AdditionalClassGroups = 'density' | 'dx-focus-ring';
|
|
23
|
+
|
|
24
|
+
export const mx = extendTailwindMerge<AdditionalClassGroups>({
|
|
25
|
+
extend: {
|
|
26
|
+
classGroups: {
|
|
27
|
+
'font-family': ['font-body', 'font-mono'],
|
|
28
|
+
'font-weight': [
|
|
29
|
+
// App weights
|
|
30
|
+
'font-thin',
|
|
31
|
+
'font-extralight',
|
|
32
|
+
'font-light',
|
|
33
|
+
'font-normal',
|
|
34
|
+
'font-medium',
|
|
35
|
+
'font-semibold',
|
|
36
|
+
'font-bold',
|
|
37
|
+
'font-extrabold',
|
|
38
|
+
'font-black',
|
|
39
|
+
// Arbitrary numbers
|
|
40
|
+
validators.isArbitraryNumber,
|
|
41
|
+
],
|
|
42
|
+
|
|
43
|
+
density: ['dx-density-fine', 'dx-density-coarse'],
|
|
44
|
+
|
|
45
|
+
'dx-focus-ring': [
|
|
46
|
+
'dx-focus-ring',
|
|
47
|
+
'dx-focus-ring-inset',
|
|
48
|
+
'dx-focus-ring-always',
|
|
49
|
+
'dx-focus-ring-inset-always',
|
|
50
|
+
'dx-focus-ring-group',
|
|
51
|
+
'dx-focus-ring-group-x',
|
|
52
|
+
'dx-focus-ring-group-y',
|
|
53
|
+
'dx-focus-ring-group-always',
|
|
54
|
+
'dx-focus-ring-group-x-always',
|
|
55
|
+
'dx-focus-ring-group-y-always',
|
|
56
|
+
'dx-focus-ring-inset-over-all',
|
|
57
|
+
'dx-focus-ring-inset-over-all-always',
|
|
58
|
+
'dx-focus-ring-main',
|
|
59
|
+
'dx-focus-ring-main-always',
|
|
60
|
+
],
|
|
48
61
|
},
|
|
49
62
|
},
|
|
50
|
-
|
|
51
|
-
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Reconciles className properties from a parent slot.
|
|
67
|
+
* - `className` is set by the Slot merge mechanism.
|
|
68
|
+
* - `classNames` is the consumer-facing prop for theming overrides.
|
|
69
|
+
* Use `composableProps` to reconcile both into a single `className`.
|
|
70
|
+
*/
|
|
71
|
+
// TODO(burdon): Move to react-ui.
|
|
72
|
+
export const composableProps = <P extends HTMLElement = HTMLElement>(
|
|
73
|
+
{ className, classNames, role, style, ...props }: ComposableProps,
|
|
74
|
+
{ classNames: defaultClassNames, ...defaults }: ThemedClassName<Partial<HTMLAttributes<P>>> | undefined = {},
|
|
75
|
+
) => ({
|
|
76
|
+
// Default props.
|
|
77
|
+
...(defaults as object),
|
|
78
|
+
|
|
79
|
+
// Spread supplied props.
|
|
80
|
+
...props,
|
|
81
|
+
|
|
82
|
+
// Prefer explicit role, then defaults role, then 'none'.
|
|
83
|
+
role: role ?? defaults.role ?? 'none',
|
|
84
|
+
|
|
85
|
+
// Merge styles.
|
|
86
|
+
style: { ...defaults.style, ...style } as CSSProperties,
|
|
87
|
+
|
|
88
|
+
// Compose classnames.
|
|
89
|
+
className: mx(defaultClassNames, className, classNames),
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
/** Symbol used to mark components created by `composable()` or `slottable()`. */
|
|
93
|
+
const COMPOSABLE = Symbol.for('dxos.composable');
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Factory for slottable components.
|
|
97
|
+
* The implementation receives full `HTMLAttributes<E>` so it can destructure `role`, `style`, etc.
|
|
98
|
+
* Consumers see only `SlottableProps<P>` — a narrow type exposing `classNames`, `className`,
|
|
99
|
+
* `children`, `asChild`, and the custom props `P`.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```tsx
|
|
103
|
+
* const MyPanel = slottable<HTMLDivElement, { border?: boolean }>(
|
|
104
|
+
* ({ children, asChild, border, ...props }, forwardedRef) => {
|
|
105
|
+
* const Comp = asChild ? Slot : Primitive.div;
|
|
106
|
+
* return (
|
|
107
|
+
* <Comp {...composableProps(props, { classNames: border && 'border' })} ref={forwardedRef}>
|
|
108
|
+
* {children}
|
|
109
|
+
* </Comp>
|
|
110
|
+
* );
|
|
111
|
+
* },
|
|
112
|
+
* );
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
export function slottable<E extends HTMLElement, P extends object = {}>(
|
|
116
|
+
render: (props: SlottableProps<P> & HTMLAttributes<E>, forwardedRef: ForwardedRef<E>) => ReactNode,
|
|
117
|
+
): ForwardRefExoticComponent<SlottableProps<P> & RefAttributes<E>> {
|
|
118
|
+
const wrapped = (props: SlottableProps<P> & HTMLAttributes<E>, forwardedRef: ForwardedRef<E>) => {
|
|
119
|
+
let warn = false;
|
|
120
|
+
if (props.asChild) {
|
|
121
|
+
try {
|
|
122
|
+
const child = Children.only(props.children);
|
|
123
|
+
if (isValidElement(child) && typeof child.type !== 'string' && !(child.type as any)[COMPOSABLE]) {
|
|
124
|
+
warn = true;
|
|
125
|
+
log.warn('slot child is not composable; create it with composable() or slottable()', {
|
|
126
|
+
child: (child.type as any).displayName ?? (child.type as any).name,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
} catch {
|
|
130
|
+
// Children.only throws if not exactly one child — Slot handles this.
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const result = render(props, forwardedRef);
|
|
135
|
+
if (warn) {
|
|
136
|
+
return createElement('div', { role: 'none', className: 'dx-slot-warning' }, result);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return result;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const component = forwardRef(wrapped as any) as any;
|
|
143
|
+
(component as any)[COMPOSABLE] = true;
|
|
144
|
+
return component;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Factory for composable (leaf) components.
|
|
149
|
+
* The implementation receives full `HTMLAttributes<E>` so it can destructure `role`, `style`, etc.
|
|
150
|
+
* Consumers see only `ComposableProps<P>` — a narrow type exposing `classNames`, `className`,
|
|
151
|
+
* `children`, and the custom props `P`.
|
|
152
|
+
*
|
|
153
|
+
* For generic components, use `any` for the type parameter inside `composable` and
|
|
154
|
+
* cast the result to restore the generic signature for consumers.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```tsx
|
|
158
|
+
* const Leaf = composable<HTMLButtonElement>(({ children, ...props }, forwardedRef) => {
|
|
159
|
+
* return (
|
|
160
|
+
* <button {...composableProps(props, { classNames: 'btn' })} ref={forwardedRef}>
|
|
161
|
+
* {children}
|
|
162
|
+
* </button>
|
|
163
|
+
* );
|
|
164
|
+
* });
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
export function composable<E extends HTMLElement, P extends object = {}>(
|
|
168
|
+
render: (props: ComposableProps<P> & HTMLAttributes<E>, forwardedRef: ForwardedRef<E>) => ReactNode,
|
|
169
|
+
): ForwardRefExoticComponent<ComposableProps<P> & RefAttributes<E>> {
|
|
170
|
+
const component = forwardRef(render as any) as any;
|
|
171
|
+
(component as any)[COMPOSABLE] = true;
|
|
172
|
+
return component;
|
|
173
|
+
}
|
package/src/util/size.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type CSSProperties } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type Size } from '@dxos/ui-types';
|
|
8
|
+
|
|
9
|
+
import { mx } from '../util';
|
|
10
|
+
|
|
11
|
+
// NOTE: Class names must be fully-specified string literals so Tailwind's static scanner can detect them.
|
|
12
|
+
const sizeMap: Record<string, { w: string; h: string }> = {
|
|
13
|
+
0: { w: 'w-0', h: 'h-0' },
|
|
14
|
+
px: { w: 'w-px', h: 'h-px' },
|
|
15
|
+
0.5: { w: 'w-0.5', h: 'h-0.5' },
|
|
16
|
+
1: { w: 'w-1', h: 'h-1' },
|
|
17
|
+
1.5: { w: 'w-1.5', h: 'h-1.5' },
|
|
18
|
+
2: { w: 'w-2', h: 'h-2' },
|
|
19
|
+
2.5: { w: 'w-2.5', h: 'h-2.5' },
|
|
20
|
+
3: { w: 'w-3', h: 'h-3' },
|
|
21
|
+
3.5: { w: 'w-3.5', h: 'h-3.5' },
|
|
22
|
+
4: { w: 'w-4', h: 'h-4' },
|
|
23
|
+
5: { w: 'w-5', h: 'h-5' },
|
|
24
|
+
6: { w: 'w-6', h: 'h-6' },
|
|
25
|
+
7: { w: 'w-7', h: 'h-7' },
|
|
26
|
+
8: { w: 'w-8', h: 'h-8' },
|
|
27
|
+
9: { w: 'w-9', h: 'h-9' },
|
|
28
|
+
10: { w: 'w-10', h: 'h-10' },
|
|
29
|
+
11: { w: 'w-11', h: 'h-11' },
|
|
30
|
+
12: { w: 'w-12', h: 'h-12' },
|
|
31
|
+
14: { w: 'w-14', h: 'h-14' },
|
|
32
|
+
16: { w: 'w-16', h: 'h-16' },
|
|
33
|
+
20: { w: 'w-20', h: 'h-20' },
|
|
34
|
+
24: { w: 'w-24', h: 'h-24' },
|
|
35
|
+
28: { w: 'w-28', h: 'h-28' },
|
|
36
|
+
32: { w: 'w-32', h: 'h-32' },
|
|
37
|
+
36: { w: 'w-36', h: 'h-36' },
|
|
38
|
+
40: { w: 'w-40', h: 'h-40' },
|
|
39
|
+
44: { w: 'w-44', h: 'h-44' },
|
|
40
|
+
48: { w: 'w-48', h: 'h-48' },
|
|
41
|
+
52: { w: 'w-52', h: 'h-52' },
|
|
42
|
+
56: { w: 'w-56', h: 'h-56' },
|
|
43
|
+
60: { w: 'w-60', h: 'h-60' },
|
|
44
|
+
64: { w: 'w-64', h: 'h-64' },
|
|
45
|
+
72: { w: 'w-72', h: 'h-72' },
|
|
46
|
+
80: { w: 'w-80', h: 'h-80' },
|
|
47
|
+
96: { w: 'w-96', h: 'h-96' },
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const SIZE_VALUES: Size[] = Object.keys(sizeMap).map((key) => (key === 'px' ? 'px' : (Number(key) as Size)));
|
|
51
|
+
|
|
52
|
+
export const getHeight = (size: Size) => sizeMap[size]?.h;
|
|
53
|
+
export const getWidth = (size: Size) => sizeMap[size]?.w;
|
|
54
|
+
export const getSize = (size: Size) => mx(getHeight(size), getWidth(size));
|
|
55
|
+
|
|
56
|
+
export const sizeValue = (size: Size): number => (size === 'px' ? 1 : size);
|
|
57
|
+
export const sizeToRem = (size: Size): string => (size === 'px' ? '1px' : `${(size as number) * 0.25}rem`);
|
|
58
|
+
|
|
59
|
+
export const iconSize = (size: Size | null): CSSProperties =>
|
|
60
|
+
({ '--icon-size': size ? sizeToRem(size) : 'initial' }) as CSSProperties;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Snaps an arbitrary numeric value to the nearest valid Tailwind size token.
|
|
64
|
+
*
|
|
65
|
+
* The function tries progressively coarser series in order until a match is found:
|
|
66
|
+
* 1. Exact match — returns the value as-is if it is already a valid `Size`.
|
|
67
|
+
* 2. Zero or negative — clamps to `0`.
|
|
68
|
+
* 3. Sub-half values (`< 0.5`) — maps to the `'px'` token (1 px).
|
|
69
|
+
* 4. Half-step series (0.5 increments, e.g. 1.5, 2.5 …).
|
|
70
|
+
* 5. Whole-number series (1, 2, 3 …).
|
|
71
|
+
* 6. Double series (even numbers: 2, 4, 6 …).
|
|
72
|
+
* 7. Quadruple series (multiples of 4: 4, 8, 12 …).
|
|
73
|
+
* 8. Falls back to `defaultSize` if no series matches.
|
|
74
|
+
*
|
|
75
|
+
* @param value - Numeric size to snap (in Tailwind spacing units, where 1 unit = 0.25 rem).
|
|
76
|
+
* @param defaultSize - Fallback `Size` token used when no series produces a valid match.
|
|
77
|
+
* @returns The nearest valid `Size` token.
|
|
78
|
+
*/
|
|
79
|
+
export const snapSize = (value: number, defaultSize: Size): Size => {
|
|
80
|
+
if (SIZE_VALUES.includes(value as Size)) {
|
|
81
|
+
return value as Size;
|
|
82
|
+
} else if (value <= 0) {
|
|
83
|
+
return 0;
|
|
84
|
+
} else if (value < 0.5) {
|
|
85
|
+
return 'px';
|
|
86
|
+
} else {
|
|
87
|
+
const wholeSeries = Math.floor(value);
|
|
88
|
+
const halfSeries = Math.floor(value * 2) / 2;
|
|
89
|
+
const doubleSeries = Math.floor(value / 2) * 2;
|
|
90
|
+
const quadrupleSeries = Math.floor(value / 4) * 4;
|
|
91
|
+
if (SIZE_VALUES.includes(halfSeries as Size)) {
|
|
92
|
+
return halfSeries as Size;
|
|
93
|
+
} else if (SIZE_VALUES.includes(wholeSeries as Size)) {
|
|
94
|
+
return wholeSeries as Size;
|
|
95
|
+
} else if (SIZE_VALUES.includes(doubleSeries as Size)) {
|
|
96
|
+
return doubleSeries as Size;
|
|
97
|
+
} else if (SIZE_VALUES.includes(quadrupleSeries as Size)) {
|
|
98
|
+
return quadrupleSeries as Size;
|
|
99
|
+
} else {
|
|
100
|
+
return defaultSize;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type MessageValence } from '@dxos/ui-types';
|
|
6
|
+
|
|
7
|
+
export const textValence = (valence?: MessageValence) => {
|
|
8
|
+
switch (valence) {
|
|
9
|
+
case 'success':
|
|
10
|
+
return 'font-medium text-success-text';
|
|
11
|
+
case 'info':
|
|
12
|
+
return 'font-medium text-info-text';
|
|
13
|
+
case 'warning':
|
|
14
|
+
return 'font-medium text-warning-text';
|
|
15
|
+
case 'error':
|
|
16
|
+
return 'font-medium text-error-text';
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const messageValence = (valence?: MessageValence) => {
|
|
21
|
+
switch (valence) {
|
|
22
|
+
case 'success':
|
|
23
|
+
return 'font-medium text-success-text border-success-text bg-success-surface';
|
|
24
|
+
case 'info':
|
|
25
|
+
return 'font-medium text-info-text border-info-text bg-info-surface';
|
|
26
|
+
case 'warning':
|
|
27
|
+
return 'font-medium text-warning-text border-warning-text bg-warning-surface';
|
|
28
|
+
case 'error':
|
|
29
|
+
return 'font-medium text-error-text border-error-text bg-error-surface';
|
|
30
|
+
default:
|
|
31
|
+
return 'font-medium text-neutral-text border-neutral-text bg-neutral-surface';
|
|
32
|
+
}
|
|
33
|
+
};
|