@dxos/ui-theme 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/LICENSE +8 -0
  2. package/README.md +25 -0
  3. package/package.json +80 -0
  4. package/src/Tokens.stories.tsx +88 -0
  5. package/src/config/index.ts +6 -0
  6. package/src/config/tailwind.ts +250 -0
  7. package/src/config/tokens/alias-colors.ts +39 -0
  8. package/src/config/tokens/index.ts +92 -0
  9. package/src/config/tokens/lengths.ts +97 -0
  10. package/src/config/tokens/physical-colors.ts +125 -0
  11. package/src/config/tokens/semantic-colors.ts +27 -0
  12. package/src/config/tokens/sememes-calls.ts +17 -0
  13. package/src/config/tokens/sememes-codemirror.ts +50 -0
  14. package/src/config/tokens/sememes-hue.ts +54 -0
  15. package/src/config/tokens/sememes-sheet.ts +62 -0
  16. package/src/config/tokens/sememes-system.ts +302 -0
  17. package/src/config/tokens/sizes.ts +7 -0
  18. package/src/config/tokens/types.ts +9 -0
  19. package/src/docs/theme.drawio.svg +635 -0
  20. package/src/index.ts +19 -0
  21. package/src/plugins/esbuild-plugin.ts +65 -0
  22. package/src/plugins/plugin.ts +130 -0
  23. package/src/plugins/resolveContent.ts +51 -0
  24. package/src/styles/components/README.md +6 -0
  25. package/src/styles/components/anchored-overflow.ts +20 -0
  26. package/src/styles/components/avatar.ts +96 -0
  27. package/src/styles/components/breadcrumb.ts +29 -0
  28. package/src/styles/components/button.ts +48 -0
  29. package/src/styles/components/dialog.ts +36 -0
  30. package/src/styles/components/icon-button.ts +20 -0
  31. package/src/styles/components/icon.ts +19 -0
  32. package/src/styles/components/index.ts +27 -0
  33. package/src/styles/components/input.ts +177 -0
  34. package/src/styles/components/link.ts +26 -0
  35. package/src/styles/components/list.ts +46 -0
  36. package/src/styles/components/main.ts +36 -0
  37. package/src/styles/components/menu.ts +60 -0
  38. package/src/styles/components/message.ts +36 -0
  39. package/src/styles/components/popover.ts +40 -0
  40. package/src/styles/components/scroll-area.ts +43 -0
  41. package/src/styles/components/select.ts +60 -0
  42. package/src/styles/components/separator.ts +24 -0
  43. package/src/styles/components/status.ts +32 -0
  44. package/src/styles/components/tag.ts +23 -0
  45. package/src/styles/components/toast.ts +55 -0
  46. package/src/styles/components/toolbar.ts +29 -0
  47. package/src/styles/components/tooltip.ts +29 -0
  48. package/src/styles/components/treegrid.ts +37 -0
  49. package/src/styles/fragments/density.ts +17 -0
  50. package/src/styles/fragments/dimension.ts +8 -0
  51. package/src/styles/fragments/disabled.ts +6 -0
  52. package/src/styles/fragments/elevation.ts +29 -0
  53. package/src/styles/fragments/focus.ts +16 -0
  54. package/src/styles/fragments/group.ts +12 -0
  55. package/src/styles/fragments/hover.ts +25 -0
  56. package/src/styles/fragments/index.ts +20 -0
  57. package/src/styles/fragments/layout.ts +7 -0
  58. package/src/styles/fragments/motion.ts +6 -0
  59. package/src/styles/fragments/ornament.ts +10 -0
  60. package/src/styles/fragments/selected.ts +45 -0
  61. package/src/styles/fragments/shimmer.ts +9 -0
  62. package/src/styles/fragments/size.ts +117 -0
  63. package/src/styles/fragments/surface.ts +29 -0
  64. package/src/styles/fragments/text.ts +12 -0
  65. package/src/styles/fragments/valence.ts +46 -0
  66. package/src/styles/index.ts +7 -0
  67. package/src/styles/layers/README.md +15 -0
  68. package/src/styles/layers/anchored-overflow.css +9 -0
  69. package/src/styles/layers/animation.css +17 -0
  70. package/src/styles/layers/attention.css +8 -0
  71. package/src/styles/layers/base.css +25 -0
  72. package/src/styles/layers/button.css +76 -0
  73. package/src/styles/layers/can-scroll.css +26 -0
  74. package/src/styles/layers/checkbox.css +50 -0
  75. package/src/styles/layers/dialog.css +42 -0
  76. package/src/styles/layers/drag-preview.css +18 -0
  77. package/src/styles/layers/focus-ring.css +224 -0
  78. package/src/styles/layers/hues.css +110 -0
  79. package/src/styles/layers/index.css +26 -0
  80. package/src/styles/layers/main.css +160 -0
  81. package/src/styles/layers/native.css +20 -0
  82. package/src/styles/layers/positioning.css +23 -0
  83. package/src/styles/layers/size.css +397 -0
  84. package/src/styles/layers/surfaces.css +31 -0
  85. package/src/styles/layers/tag.css +132 -0
  86. package/src/styles/layers/tldraw.css +91 -0
  87. package/src/styles/layers/tokens.css +45 -0
  88. package/src/styles/layers/typography.css +157 -0
  89. package/src/styles/theme.ts +69 -0
  90. package/src/tailwind.ts +5 -0
  91. package/src/theme.css +9 -0
  92. package/src/types.ts +7 -0
  93. package/src/typings.d.ts +8 -0
  94. package/src/util/hash-styles.ts +168 -0
  95. package/src/util/index.ts +6 -0
  96. package/src/util/mx.ts +51 -0
  97. package/src/util/withLogical.ts +114 -0
@@ -0,0 +1,29 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ import { type ComponentFunction, type Theme } from '@dxos/ui-types';
6
+
7
+ import { mx } from '../../util';
8
+ import { textBlockWidth } from '../fragments';
9
+
10
+ export type ToolbarStyleProps = Partial<{ layoutManaged: boolean; disabled: boolean }>;
11
+
12
+ export const toolbarLayout =
13
+ 'is-full shrink-0 flex flex-nowrap items-center gap-1 p-1 overflow-x-auto scrollbar-none contain-layout';
14
+
15
+ // TODO(burdon): Detect: &:not([data-is-attention-source]_&)]:
16
+ export const toolbarInactive = '*:opacity-20';
17
+
18
+ export const toolbarRoot: ComponentFunction<ToolbarStyleProps> = ({ layoutManaged, disabled }, ...etc) => {
19
+ return mx('bg-toolbarSurface dx-toolbar', !layoutManaged && toolbarLayout, disabled && toolbarInactive, ...etc);
20
+ };
21
+
22
+ export const toolbarInner: ComponentFunction<ToolbarStyleProps> = ({ layoutManaged }, ...etc) => {
23
+ return mx(!layoutManaged && ['flex gap-1', textBlockWidth], ...etc);
24
+ };
25
+
26
+ export const toolbarTheme: Theme<ToolbarStyleProps> = {
27
+ root: toolbarRoot,
28
+ inner: toolbarInner,
29
+ };
@@ -0,0 +1,29 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type ComponentFunction, type Elevation, type Theme } from '@dxos/ui-types';
6
+
7
+ import { mx } from '../../util';
8
+ import { chromeText, popperMotion, surfaceShadow, surfaceZIndex } from '../fragments';
9
+
10
+ export type TooltipStyleProps = Partial<{
11
+ elevation: Elevation;
12
+ }>;
13
+
14
+ export const tooltipContent: ComponentFunction<TooltipStyleProps> = ({ elevation }, ...etc) =>
15
+ mx(
16
+ 'inline-flex items-center rounded-sm plb-1 pli-2 max-is-64 bg-inverseSurface text-inverseSurfaceText',
17
+ popperMotion,
18
+ surfaceShadow({ elevation: 'positioned' }),
19
+ surfaceZIndex({ elevation, level: 'tooltip' }),
20
+ chromeText,
21
+ ...etc,
22
+ );
23
+
24
+ export const tooltipArrow: ComponentFunction<TooltipStyleProps> = (_props, ...etc) => mx('fill-inverseSurface', ...etc);
25
+
26
+ export const tooltipTheme: Theme<TooltipStyleProps> = {
27
+ content: tooltipContent,
28
+ arrow: tooltipArrow,
29
+ };
@@ -0,0 +1,37 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import type { ComponentFunction, Theme } from '@dxos/ui-types';
6
+
7
+ import { mx } from '../../util';
8
+
9
+ export type TreegridStyleProps = Partial<{
10
+ level: number;
11
+ indent: boolean;
12
+ }>;
13
+
14
+ const levelStyles = new Map<number, string>([
15
+ [1, '[&>.indent:first-of-type]:pis-0 font-medium'],
16
+ [2, '[&>.indent:first-of-type]:pis-0'],
17
+ [3, '[&>.indent:first-of-type]:pis-1'],
18
+ [4, '[&>.indent:first-of-type]:pis-2'],
19
+ [5, '[&>.indent:first-of-type]:pis-3'],
20
+ [6, '[&>.indent:first-of-type]:pis-4'],
21
+ [7, '[&>.indent:first-of-type]:pis-5'],
22
+ [8, '[&>.indent:first-of-type]:pis-6'],
23
+ ]);
24
+
25
+ export const treegridRoot: ComponentFunction<TreegridStyleProps> = (_, ...etc) => mx('grid', ...etc);
26
+
27
+ export const treegridRow: ComponentFunction<TreegridStyleProps> = ({ level = 1 }, ...etc) =>
28
+ mx('contents', levelStyles.get(Math.min(Math.max(Math.round(level), 1), 8)), ...etc);
29
+
30
+ export const treegridCell: ComponentFunction<TreegridStyleProps> = ({ indent }, ...etc) =>
31
+ mx(indent && 'indent', ...etc);
32
+
33
+ export const treegridTheme: Theme<TreegridStyleProps> = {
34
+ root: treegridRoot,
35
+ row: treegridRow,
36
+ cell: treegridCell,
37
+ };
@@ -0,0 +1,17 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type Density } from '@dxos/ui-types';
6
+
7
+ export const coarseBlockSize = 'min-bs-[2.5rem]';
8
+ export const coarseTextPadding = 'pli-3';
9
+ export const coarseButtonPadding = 'pli-4';
10
+ export const coarseDimensions = `${coarseBlockSize} ${coarseTextPadding}`;
11
+ export const coarseButtonDimensions = `${coarseBlockSize} ${coarseButtonPadding}`;
12
+ export const fineBlockSize = 'min-bs-[2.5rem] pointer-fine:min-bs-[2rem]';
13
+ export const fineTextPadding = 'pli-2';
14
+ export const fineButtonPadding = 'pli-2.5';
15
+ export const fineDimensions = `${fineBlockSize} ${fineTextPadding}`;
16
+ export const fineButtonDimensions = `${fineBlockSize} ${fineButtonPadding}`;
17
+ export const densityBlockSize = (density: Density = 'coarse') => (density === 'fine' ? fineBlockSize : coarseBlockSize);
@@ -0,0 +1,8 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ /**
6
+ * Content areas that contain the text editor.
7
+ */
8
+ export const textBlockWidth = 'is-full mli-auto max-is-[--text-content]';
@@ -0,0 +1,6 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ export const staticDisabled = 'opacity-40 cursor-not-allowed shadow-none';
6
+ export const dataDisabled = 'data-[disabled]:opacity-40 data-[disabled]:cursor-not-allowed';
@@ -0,0 +1,29 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type ComponentFragment, type Elevation, type SurfaceLevel } from '@dxos/ui-types';
6
+
7
+ /**
8
+ * @deprecated
9
+ */
10
+ export const contentShadow: ComponentFragment<{ elevation?: Elevation }> = (_) => ['shadow-none'];
11
+
12
+ // TODO(thure): These should become tokens.
13
+ export const surfaceShadow: ComponentFragment<{ elevation?: Elevation }> = ({ elevation }) => [
14
+ elevation === 'positioned' ? 'shadow' : elevation === 'dialog' || elevation === 'toast' ? 'shadow-md' : 'shadow-none',
15
+ ];
16
+
17
+ export const surfaceZIndex: ComponentFragment<{ level?: SurfaceLevel; elevation?: Elevation }> = ({
18
+ level,
19
+ elevation,
20
+ }) => {
21
+ switch (level) {
22
+ case 'tooltip':
23
+ return elevation === 'dialog' ? ['z-[53]'] : elevation === 'toast' ? ['z-[43]'] : ['z-30'];
24
+ case 'menu':
25
+ return elevation === 'dialog' ? ['z-[52]'] : elevation === 'toast' ? ['z-[42]'] : ['z-20'];
26
+ default:
27
+ return elevation === 'dialog' ? ['z-[51]'] : elevation === 'toast' ? ['z-[41]'] : ['z-[1]'];
28
+ }
29
+ };
@@ -0,0 +1,16 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ export const focusRing = 'dx-focus-ring';
6
+
7
+ export const dropRing =
8
+ 'ring-1 ring-offset-0 ring-primary-350 ring-offset-white dark:ring-primary-450 dark:ring-offset-black';
9
+
10
+ export const dropRingInner =
11
+ 'before:z-[1] before:absolute before:inset-0 before:ring-1 before:ring-inset before:ring-primary-350 before:dark:ring-primary-450';
12
+
13
+ export const subduedFocus = 'focus:outline-none focus-visible:outline-none focus:ring-0 ring-0 focus:border-0 border-0';
14
+
15
+ export const staticFocusRing =
16
+ 'ring-2 ring-offset-0 ring-primary-350 ring-offset-white dark:ring-primary-450 dark:ring-offset-black';
@@ -0,0 +1,12 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type ComponentFragment, type Elevation } from '@dxos/ui-types';
6
+
7
+ import { surfaceShadow } from './elevation';
8
+
9
+ export const group: ComponentFragment<{ elevation?: Elevation }> = (props) => [
10
+ props.elevation === 'base' ? 'bg-transparent border border-separator' : 'bg-modalSurface',
11
+ surfaceShadow(props),
12
+ ];
@@ -0,0 +1,25 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ /**
6
+ * @deprecated
7
+ */
8
+ export const hoverColors = 'transition-colors duration-100 linear hover:bg-hoverSurface';
9
+
10
+ export const ghostHover = 'hover:bg-hoverSurface';
11
+ export const ghostFocusWithin = 'focus-within:bg-hoverSurface';
12
+ export const subtleHover = 'hover:bg-hoverOverlay';
13
+
14
+ export const hoverableControls =
15
+ '[--controls-opacity:1] hover-hover:[--controls-opacity:0] hover-hover:hover:[--controls-opacity:1]';
16
+
17
+ export const groupHoverControlItemWithTransition = 'transition-opacity duration-200 opacity-0 group-hover:opacity-100';
18
+
19
+ export const hoverableFocusedKeyboardControls = 'focus-visible:[--controls-opacity:1]';
20
+ export const hoverableFocusedWithinControls = 'focus-within:[--controls-opacity:1]';
21
+ export const hoverableFocusedControls = 'focus:[--controls-opacity:1]';
22
+ export const hoverableOpenControlItem = 'hover-hover:aria-[expanded=true]:[--controls-opacity:1]';
23
+ export const hoverableControlItem = 'opacity-[--controls-opacity]';
24
+ export const hoverableControlItemTransition = 'transition-opacity duration-200';
25
+ export const staticHoverableControls = 'hover-hover:[--controls-opacity:1]';
@@ -0,0 +1,20 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ export * from './density';
6
+ export * from './disabled';
7
+ export * from './dimension';
8
+ export * from './elevation';
9
+ export * from './focus';
10
+ export * from './group';
11
+ export * from './hover';
12
+ export * from './layout';
13
+ export * from './motion';
14
+ export * from './ornament';
15
+ export * from './selected';
16
+ export * from './shimmer';
17
+ export * from './surface';
18
+ export * from './size';
19
+ export * from './text';
20
+ export * from './valence';
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ export const bounceLayout = 'fixed inset-0 z-0 overflow-auto overscroll-auto';
6
+
7
+ export const fixedInsetFlexLayout = 'flex flex-col fixed inset-0 overflow-hidden overscroll-none';
@@ -0,0 +1,6 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ export const popperMotion =
6
+ 'will-change-[opacity,transform] data-[side=top]:animate-slideDownAndFade data-[side=right]:animate-slideLeftAndFade data-[side=bottom]:animate-slideUpAndFade data-[side=left]:animate-slideRightAndFade';
@@ -0,0 +1,10 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ // TODO(burdon): Remove?
6
+ export const separatorBorderColor = 'border-separator';
7
+ export const subduedSeparatorBorderColor = 'border-subduedSeparator';
8
+
9
+ export const inlineSeparator = 'self-stretch border-ie mli-1';
10
+ export const blockSeparator = 'self-stretch border-be mlb-1';
@@ -0,0 +1,45 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type ComponentFragment } from '@dxos/ui-types';
6
+
7
+ import { ghostHover } from './hover';
8
+
9
+ // TODO(burdon): Use semantic tokens (e.g., accentSurfaceHover, bg-gridSelectionOverlay)?
10
+
11
+ export const ghostSelectedCurrent = [
12
+ ghostHover,
13
+ 'aria-[current]:bg-inputSurface hover:aria-[current]:bg-hoverSurface',
14
+ 'aria-selected:bg-primary-100 dark:aria-selected:bg-primary-850 hover:aria-selected:bg-primary-150 hover:dark:aria-selected:bg-primary-800',
15
+ 'aria-[current]:aria-selected:bg-primary-200 dark:aria-[current]:aria-selected:bg-primary-750 hover:aria-[current]:aria-selected:bg-primary-200 hover:dark:aria-[current]:aria-selected:bg-primary-750',
16
+ ];
17
+
18
+ export const ghostHighlighted =
19
+ 'data-[highlighted]:bg-primary-100 dark:data-[highlighted]:bg-primary-600 hover:data-[highlighted]:bg-primary-150 hover:dark:data-[highlighted]:bg-primary-500';
20
+
21
+ export const ghostSelectedTrackingInterFromNormal = 'tracking-[0.0092em]';
22
+
23
+ export const ghostSelected =
24
+ 'aria-selected:bg-baseSurface aria-selected:text-accentText hover:aria-selected:text-accentTextHover aria-selected:font-semibold aria-selected:tracking-normal transition-[color,font-variation-settings,letter-spacing]';
25
+
26
+ export const ghostSelectedContainerMd =
27
+ '@md:aria-selected:bg-baseSurface @md:aria-selected:text-accentText @md:hover:aria-selected:text-accentTextHover @md:aria-selected:font-semibold @md:aria-selected:tracking-normal @md:transition-[color,font-variation-settings,letter-spacing]';
28
+
29
+ export type SelectedStyleProps = {
30
+ current?: boolean;
31
+ selected?: boolean;
32
+ };
33
+
34
+ export const staticGhostSelectedCurrent: ComponentFragment<SelectedStyleProps> = ({ current, selected }) => [
35
+ current && selected
36
+ ? 'bg-primary-200 dark:bg-primary-750 hover:bg-primary-200 hover:dark:bg-primary-750'
37
+ : current
38
+ ? 'bg-inputSurface hover:bg-hoverSurface'
39
+ : selected
40
+ ? 'bg-primary-100 dark:bg-primary-850 hover:bg-primary-150 hover:dark:bg-primary-800'
41
+ : ghostHover,
42
+ ];
43
+
44
+ export const staticGhostSelected: ComponentFragment<Pick<SelectedStyleProps, 'selected'>> = ({ selected }) =>
45
+ selected ? ['bg-primary-200 dark:bg-primary-750'] : [];
@@ -0,0 +1,9 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ export const shimmer =
6
+ 'relative before:absolute before:inset-0 before:-translate-x-full before:animate-shimmer before:bg-gradient-to-r before:from-transparent before:via-neutral-100/10 before:to-transparent isolate overflow-hidden';
7
+
8
+ export const strongShimmer =
9
+ 'relative before:absolute before:inset-0 before:-translate-x-full before:animate-shimmer before:bg-gradient-to-r before:from-transparent before:via-primary-100/80 before:to-transparent isolate overflow-hidden';
@@ -0,0 +1,117 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ import { type Size } from '@dxos/ui-types';
6
+
7
+ import { mx } from '../../util';
8
+
9
+ export const sizeWidthMap = new Map<Size, string>([
10
+ [0, 'is-0'],
11
+ ['px', 'is-px'],
12
+ [0.5, 'is-0.5'],
13
+ [1, 'is-1'],
14
+ [1.5, 'is-1.5'],
15
+ [2, 'is-2'],
16
+ [2.5, 'is-2.5'],
17
+ [3, 'is-3'],
18
+ [3.5, 'is-3.5'],
19
+ [4, 'is-4'],
20
+ [5, 'is-5'],
21
+ [6, 'is-6'],
22
+ [7, 'is-7'],
23
+ [8, 'is-8'],
24
+ [9, 'is-9'],
25
+ [10, 'is-10'],
26
+ [11, 'is-11'],
27
+ [12, 'is-12'],
28
+ [14, 'is-14'],
29
+ [16, 'is-16'],
30
+ [20, 'is-20'],
31
+ [24, 'is-24'],
32
+ [28, 'is-28'],
33
+ [32, 'is-32'],
34
+ [36, 'is-36'],
35
+ [40, 'is-40'],
36
+ [44, 'is-44'],
37
+ [48, 'is-48'],
38
+ [52, 'is-52'],
39
+ [56, 'is-56'],
40
+ [60, 'is-60'],
41
+ [64, 'is-64'],
42
+ [72, 'is-72'],
43
+ [80, 'is-80'],
44
+ [96, 'is-96'],
45
+ ]);
46
+
47
+ export const sizeHeightMap = new Map<Size, string>([
48
+ [0, 'bs-0'],
49
+ ['px', 'bs-px'],
50
+ [0.5, 'bs-0.5'],
51
+ [1, 'bs-1'],
52
+ [1.5, 'bs-1.5'],
53
+ [2, 'bs-2'],
54
+ [2.5, 'bs-2.5'],
55
+ [3, 'bs-3'],
56
+ [3.5, 'bs-3.5'],
57
+ [4, 'bs-4'],
58
+ [5, 'bs-5'],
59
+ [6, 'bs-6'],
60
+ [7, 'bs-7'],
61
+ [8, 'bs-8'],
62
+ [9, 'bs-9'],
63
+ [10, 'bs-10'],
64
+ [11, 'bs-11'],
65
+ [12, 'bs-12'],
66
+ [14, 'bs-14'],
67
+ [16, 'bs-16'],
68
+ [20, 'bs-20'],
69
+ [24, 'bs-24'],
70
+ [28, 'bs-28'],
71
+ [32, 'bs-32'],
72
+ [36, 'bs-36'],
73
+ [40, 'bs-40'],
74
+ [44, 'bs-44'],
75
+ [48, 'bs-48'],
76
+ [52, 'bs-52'],
77
+ [56, 'bs-56'],
78
+ [60, 'bs-60'],
79
+ [64, 'bs-64'],
80
+ [72, 'bs-72'],
81
+ [80, 'bs-80'],
82
+ [96, 'bs-96'],
83
+ ]);
84
+
85
+ const sizes = new Set(sizeWidthMap.keys());
86
+
87
+ export const getSizeHeight = sizeHeightMap.get.bind(sizeHeightMap);
88
+ export const getSizeWidth = sizeWidthMap.get.bind(sizeWidthMap);
89
+ export const getSize = (size: Size) => mx(getSizeHeight(size), getSizeWidth(size));
90
+
91
+ export const computeSize = (value: number, defaultSize: Size) => {
92
+ if (sizes.has(value as Size)) {
93
+ return value as Size;
94
+ } else if (value <= 0) {
95
+ return 0;
96
+ } else if (value === 1) {
97
+ return 'px';
98
+ } else {
99
+ const wholeSeries = Math.floor(value);
100
+ const halfSeries = Math.floor(value * 2) / 2;
101
+ const doubleSeries = Math.floor(value / 2) * 2;
102
+ const quadrupleSeries = Math.floor(value / 4) * 4;
103
+ if (sizes.has(halfSeries as Size)) {
104
+ return halfSeries as Size;
105
+ } else if (sizes.has(wholeSeries as Size)) {
106
+ return wholeSeries as Size;
107
+ } else if (sizes.has(doubleSeries as Size)) {
108
+ return doubleSeries as Size;
109
+ } else if (sizes.has(quadrupleSeries as Size)) {
110
+ return quadrupleSeries as Size;
111
+ } else {
112
+ return defaultSize;
113
+ }
114
+ }
115
+ };
116
+
117
+ export const sizeValue = (size: Size): number => (size === 'px' ? 1 : size);
@@ -0,0 +1,29 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ // NOTE: Please don’t make changes to these fragments without testing *all* the places where they’re used.
6
+
7
+ // If your scope of concern is narrower than exactly *the entire design system*, please define and apply your own
8
+ // fragment, either to the specific component or in an override to `ThemeProvider`’s `tx` value.
9
+
10
+ // Main background.
11
+ // NOTE: This should align with theme's root --surface-bg.
12
+ export const baseSurface = 'base-surface';
13
+
14
+ // Sidebars.
15
+ export const sidebarSurface = 'sidebar-surface backdrop-blur-md dark:backdrop-blur-lg';
16
+ export const sidebarBorder = 'border-separator';
17
+
18
+ // Generic grouping style.
19
+ export const activeSurface = 'base-surface';
20
+ export const groupBorder = 'border-separator';
21
+
22
+ // Tooltips, popovers, menus, dialogs, etc.
23
+ export const modalSurface = 'modal-surface backdrop-blur-md';
24
+
25
+ // Elements that actively have the user’s “attention”; prefer to select with CSS-native selectors like focus-within,
26
+ // but may be applied by app state. ⚠️ Do not apply statically.
27
+ export const attentionSurface = 'attention-surface';
28
+
29
+ export const accentSurface = 'bg-accentSurface text-accentSurfaceText';
@@ -0,0 +1,12 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ export const placeholderText = 'placeholder-neutral-300 dark:placeholder-neutral-500';
6
+ export const staticPlaceholderText = 'text-neutral-300 dark:text-neutral-500';
7
+
8
+ export const descriptionText = 'text-sm font-normal text-description';
9
+ export const descriptionTextPrimary = 'text-sm font-normal text-baseText';
10
+ export const descriptionMessage = [descriptionText, 'border border-dashed border-separator rounded p-4'];
11
+
12
+ export const chromeText = 'text-sm font-normal';
@@ -0,0 +1,46 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ import { type MessageValence } from '@dxos/ui-types';
6
+
7
+ export const successText = 'text-xs font-medium text-successText';
8
+ export const infoText = 'text-xs font-medium text-infoText';
9
+ export const warningText = 'text-xs font-medium text-warningText';
10
+ export const errorText = 'text-xs font-medium text-errorText';
11
+
12
+ export const valenceColorText = (valence?: MessageValence) => {
13
+ switch (valence) {
14
+ case 'success':
15
+ return successText;
16
+ case 'info':
17
+ return infoText;
18
+ case 'warning':
19
+ return warningText;
20
+ case 'error':
21
+ return errorText;
22
+ default:
23
+ return undefined;
24
+ }
25
+ };
26
+
27
+ export const neutralMessageColors = 'border border-dashed border-separator text-subdued';
28
+ export const successMessageColors = 'text-successSurfaceText bg-successSurface';
29
+ export const infoMessageColors = 'text-infoSurfaceText bg-infoSurface';
30
+ export const warningMessageColors = 'text-warningSurfaceText bg-warningSurface';
31
+ export const errorMessageColors = 'text-errorSurfaceText bg-errorSurface';
32
+
33
+ export const messageValence = (valence?: MessageValence) => {
34
+ switch (valence) {
35
+ case 'success':
36
+ return successMessageColors;
37
+ case 'info':
38
+ return infoMessageColors;
39
+ case 'warning':
40
+ return warningMessageColors;
41
+ case 'error':
42
+ return errorMessageColors;
43
+ default:
44
+ return neutralMessageColors;
45
+ }
46
+ };
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ export * from './fragments';
6
+ export * from './components';
7
+ export * from './theme';
@@ -0,0 +1,15 @@
1
+ # Layers
2
+
3
+ NOTE: The order of the layers is important and defined in the root `index.html`.
4
+
5
+ Example: `composer-app/index.html`
6
+
7
+ ```html
8
+ <style>
9
+ @layer dx-tokens, user-tokens, tw-base, dx-base, tw-components, dx-components, utilities;
10
+ </style>
11
+ ```
12
+
13
+ ## Resources
14
+
15
+ - https://cube.fyi
@@ -0,0 +1,9 @@
1
+ @layer utilities {
2
+ .overflow-anchored * {
3
+ overflow-anchor: none;
4
+ }
5
+
6
+ .overflow-anchor {
7
+ overflow-anchor: auto;
8
+ }
9
+ }
@@ -0,0 +1,17 @@
1
+ @layer utilities {
2
+ @keyframes blink {
3
+ 0%,
4
+ 50%,
5
+ 100% {
6
+ opacity: 1;
7
+ }
8
+ 25%,
9
+ 75% {
10
+ opacity: 0;
11
+ }
12
+ }
13
+
14
+ .animate-blink {
15
+ animation: blink 1s step-start infinite;
16
+ }
17
+ }
@@ -0,0 +1,8 @@
1
+ @layer utilities {
2
+ /* If an element should apply attention-related color tokens, it should use this class. */
3
+ .attention-surface {
4
+ --surface-separator: transparent;
5
+ background-color: var(--dx-baseSurface);
6
+ border-color: var(--dx-separator);
7
+ }
8
+ }
@@ -0,0 +1,25 @@
1
+ @layer dx-base {
2
+ :root {
3
+ touch-action: pan-x pan-y;
4
+ font-synthesis: none;
5
+ font-variation-settings: 'wght' 400,
6
+ 'slnt' 0;
7
+ scroll-padding-block-start: theme(spacing.14);
8
+ scroll-padding-block-end: theme(spacing.2);
9
+ @apply font-body;
10
+ }
11
+
12
+ button {
13
+ -webkit-tap-highlight-color: transparent;
14
+ }
15
+ }
16
+
17
+ @layer dx-tokens {
18
+ html, html.dark, html .dark {
19
+ background-color: var(--dx-baseSurface);
20
+ --surface-bg: var(--dx-baseSurface);
21
+ color: var(--dx-baseText);
22
+ --surface-text: var(--dx-baseText);
23
+ --description-text: var(--dx-description);
24
+ }
25
+ }