@dxos/ui-theme 0.0.0 → 0.8.4-main.16b68245aa

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 (257) hide show
  1. package/dist/lib/browser/index.mjs +1372 -0
  2. package/dist/lib/browser/index.mjs.map +7 -0
  3. package/dist/lib/browser/meta.json +1 -0
  4. package/dist/lib/node-esm/index.mjs +1374 -0
  5. package/dist/lib/node-esm/index.mjs.map +7 -0
  6. package/dist/lib/node-esm/meta.json +1 -0
  7. package/dist/plugin/node-cjs/main.css +1564 -0
  8. package/dist/plugin/node-cjs/main.css.map +7 -0
  9. package/dist/plugin/node-cjs/meta.json +1 -0
  10. package/dist/plugin/node-cjs/plugins/ThemePlugin.cjs +137 -0
  11. package/dist/plugin/node-cjs/plugins/ThemePlugin.cjs.map +7 -0
  12. package/dist/plugin/node-esm/main.css +1564 -0
  13. package/dist/plugin/node-esm/main.css.map +7 -0
  14. package/dist/plugin/node-esm/meta.json +1 -0
  15. package/dist/plugin/node-esm/plugins/ThemePlugin.mjs +105 -0
  16. package/dist/plugin/node-esm/plugins/ThemePlugin.mjs.map +7 -0
  17. package/dist/types/src/Theme.stories.d.ts +27 -0
  18. package/dist/types/src/Theme.stories.d.ts.map +1 -0
  19. package/dist/types/src/defs.d.ts +21 -0
  20. package/dist/types/src/defs.d.ts.map +1 -0
  21. package/dist/types/src/fragments/density.d.ts +4 -0
  22. package/dist/types/src/fragments/density.d.ts.map +1 -0
  23. package/dist/types/src/fragments/disabled.d.ts +3 -0
  24. package/dist/types/src/fragments/disabled.d.ts.map +1 -0
  25. package/dist/types/src/fragments/hover.d.ts +10 -0
  26. package/dist/types/src/fragments/hover.d.ts.map +1 -0
  27. package/dist/types/src/fragments/index.d.ts +5 -0
  28. package/dist/types/src/fragments/index.d.ts.map +1 -0
  29. package/dist/types/src/fragments/text.d.ts +2 -0
  30. package/dist/types/src/fragments/text.d.ts.map +1 -0
  31. package/dist/types/src/index.d.ts +5 -0
  32. package/dist/types/src/index.d.ts.map +1 -0
  33. package/dist/types/src/plugins/ThemePlugin.d.ts +16 -0
  34. package/dist/types/src/plugins/ThemePlugin.d.ts.map +1 -0
  35. package/dist/types/src/plugins/dark-mode.d.ts +1 -0
  36. package/dist/types/src/plugins/dark-mode.d.ts.map +1 -0
  37. package/dist/types/src/theme/components/avatar.d.ts +21 -0
  38. package/dist/types/src/theme/components/avatar.d.ts.map +1 -0
  39. package/dist/types/src/theme/components/breadcrumb.d.ts +9 -0
  40. package/dist/types/src/theme/components/breadcrumb.d.ts.map +1 -0
  41. package/dist/types/src/theme/components/button.d.ts +15 -0
  42. package/dist/types/src/theme/components/button.d.ts.map +1 -0
  43. package/dist/types/src/theme/components/card.d.ts +12 -0
  44. package/dist/types/src/theme/components/card.d.ts.map +1 -0
  45. package/dist/types/src/theme/components/dialog.d.ts +17 -0
  46. package/dist/types/src/theme/components/dialog.d.ts.map +1 -0
  47. package/dist/types/src/theme/components/focus.d.ts +6 -0
  48. package/dist/types/src/theme/components/focus.d.ts.map +1 -0
  49. package/dist/types/src/theme/components/icon-button.d.ts +9 -0
  50. package/dist/types/src/theme/components/icon-button.d.ts.map +1 -0
  51. package/dist/types/src/theme/components/icon.d.ts +10 -0
  52. package/dist/types/src/theme/components/icon.d.ts.map +1 -0
  53. package/dist/types/src/theme/components/index.d.ts +27 -0
  54. package/dist/types/src/theme/components/index.d.ts.map +1 -0
  55. package/dist/types/src/theme/components/input.d.ts +115 -0
  56. package/dist/types/src/theme/components/input.d.ts.map +1 -0
  57. package/dist/types/src/theme/components/link.d.ts +7 -0
  58. package/dist/types/src/theme/components/link.d.ts.map +1 -0
  59. package/dist/types/src/theme/components/list.d.ts +14 -0
  60. package/dist/types/src/theme/components/list.d.ts.map +1 -0
  61. package/dist/types/src/theme/components/main.d.ts +28 -0
  62. package/dist/types/src/theme/components/main.d.ts.map +1 -0
  63. package/dist/types/src/theme/components/menu.d.ts +13 -0
  64. package/dist/types/src/theme/components/menu.d.ts.map +1 -0
  65. package/dist/types/src/theme/components/message.d.ts +12 -0
  66. package/dist/types/src/theme/components/message.d.ts.map +1 -0
  67. package/dist/types/src/theme/components/popover.d.ts +11 -0
  68. package/dist/types/src/theme/components/popover.d.ts.map +1 -0
  69. package/dist/types/src/theme/components/scroll-area.d.ts +32 -0
  70. package/dist/types/src/theme/components/scroll-area.d.ts.map +1 -0
  71. package/dist/types/src/theme/components/select.d.ts +13 -0
  72. package/dist/types/src/theme/components/select.d.ts.map +1 -0
  73. package/dist/types/src/theme/components/separator.d.ts +8 -0
  74. package/dist/types/src/theme/components/separator.d.ts.map +1 -0
  75. package/dist/types/src/theme/components/skeleton.d.ts +7 -0
  76. package/dist/types/src/theme/components/skeleton.d.ts.map +1 -0
  77. package/dist/types/src/theme/components/splitter.d.ts +4 -0
  78. package/dist/types/src/theme/components/splitter.d.ts.map +1 -0
  79. package/dist/types/src/theme/components/status.d.ts +9 -0
  80. package/dist/types/src/theme/components/status.d.ts.map +1 -0
  81. package/dist/types/src/theme/components/tag.d.ts +7 -0
  82. package/dist/types/src/theme/components/tag.d.ts.map +1 -0
  83. package/dist/types/src/theme/components/toast.d.ts +12 -0
  84. package/dist/types/src/theme/components/toast.d.ts.map +1 -0
  85. package/dist/types/src/theme/components/toolbar.d.ts +11 -0
  86. package/dist/types/src/theme/components/toolbar.d.ts.map +1 -0
  87. package/dist/types/src/theme/components/tooltip.d.ts +8 -0
  88. package/dist/types/src/theme/components/tooltip.d.ts.map +1 -0
  89. package/dist/types/src/theme/components/treegrid.d.ts +10 -0
  90. package/dist/types/src/theme/components/treegrid.d.ts.map +1 -0
  91. package/dist/types/src/theme/index.d.ts +4 -0
  92. package/dist/types/src/theme/index.d.ts.map +1 -0
  93. package/dist/types/src/theme/primitives/column.d.ts +29 -0
  94. package/dist/types/src/theme/primitives/column.d.ts.map +1 -0
  95. package/dist/types/src/theme/primitives/index.d.ts +3 -0
  96. package/dist/types/src/theme/primitives/index.d.ts.map +1 -0
  97. package/dist/types/src/theme/primitives/panel.d.ts +13 -0
  98. package/dist/types/src/theme/primitives/panel.d.ts.map +1 -0
  99. package/dist/types/src/theme/theme.d.ts +5 -0
  100. package/dist/types/src/theme/theme.d.ts.map +1 -0
  101. package/dist/types/src/util/elevation.d.ts +9 -0
  102. package/dist/types/src/util/elevation.d.ts.map +1 -0
  103. package/dist/types/src/util/hash-styles.d.ts +18 -0
  104. package/dist/types/src/util/hash-styles.d.ts.map +1 -0
  105. package/dist/types/src/util/index.d.ts +6 -0
  106. package/dist/types/src/util/index.d.ts.map +1 -0
  107. package/dist/types/src/util/mx.d.ts +58 -0
  108. package/dist/types/src/util/mx.d.ts.map +1 -0
  109. package/dist/types/src/util/size.d.ts +27 -0
  110. package/dist/types/src/util/size.d.ts.map +1 -0
  111. package/dist/types/src/util/valence.d.ts +4 -0
  112. package/dist/types/src/util/valence.d.ts.map +1 -0
  113. package/dist/types/tsconfig.tsbuildinfo +1 -0
  114. package/package.json +30 -36
  115. package/src/Theme.stories.tsx +224 -0
  116. package/src/css/base/base.css +43 -0
  117. package/src/{styles/layers → css/base}/typography.css +21 -3
  118. package/src/{styles/layers → css/components}/button.css +23 -14
  119. package/src/{styles/layers → css/components}/checkbox.css +12 -8
  120. package/src/css/components/dialog.css +78 -0
  121. package/src/{styles/layers/focus-ring.css → css/components/focus.css} +60 -41
  122. package/src/css/components/icon.css +9 -0
  123. package/src/css/components/link.css +9 -0
  124. package/src/css/components/panel.css +117 -0
  125. package/src/css/components/scrollbar.css +24 -0
  126. package/src/css/components/selected.css +35 -0
  127. package/src/css/components/selected.md +101 -0
  128. package/src/css/components/surface.css +34 -0
  129. package/src/css/components/tag.css +132 -0
  130. package/src/css/components/text.css +124 -0
  131. package/src/css/integrations/codemirror.css +34 -0
  132. package/src/css/integrations/tldraw.css +14 -0
  133. package/src/css/layout/main.css +205 -0
  134. package/src/{styles/layers → css/layout}/native.css +6 -4
  135. package/src/css/layout/positioning.css +19 -0
  136. package/src/{styles/layers → css/layout}/size.css +130 -102
  137. package/src/css/theme/animation.css +260 -0
  138. package/src/css/theme/border.css +23 -0
  139. package/src/css/theme/palette.css +36 -0
  140. package/src/css/theme/semantic.css +116 -0
  141. package/src/css/theme/spacing.css +147 -0
  142. package/src/css/theme/styles.css +145 -0
  143. package/src/css/theme/text.css +37 -0
  144. package/src/css/utilities.css +118 -0
  145. package/src/defs.ts +48 -0
  146. package/src/fragments/AUDIT.md +57 -0
  147. package/src/fragments/density.ts +16 -0
  148. package/src/fragments/hover.ts +18 -0
  149. package/src/fragments/index.ts +10 -0
  150. package/src/fragments/text.ts +6 -0
  151. package/src/index.ts +3 -14
  152. package/src/main.css +121 -0
  153. package/src/plugins/ThemePlugin.ts +125 -0
  154. package/src/plugins/dark-mode.ts +22 -0
  155. package/src/plugins/main.css +45 -0
  156. package/src/{styles → theme}/components/avatar.ts +12 -13
  157. package/src/theme/components/button.ts +48 -0
  158. package/src/theme/components/card.ts +102 -0
  159. package/src/theme/components/dialog.ts +61 -0
  160. package/src/theme/components/focus.ts +33 -0
  161. package/src/{styles → theme}/components/icon-button.ts +6 -5
  162. package/src/theme/components/icon.ts +28 -0
  163. package/src/{styles → theme}/components/index.ts +4 -1
  164. package/src/theme/components/input.ts +171 -0
  165. package/src/{styles → theme}/components/link.ts +3 -4
  166. package/src/{styles → theme}/components/list.ts +5 -5
  167. package/src/{styles → theme}/components/main.ts +9 -11
  168. package/src/{styles → theme}/components/menu.ts +11 -21
  169. package/src/{styles → theme}/components/message.ts +11 -7
  170. package/src/{styles → theme}/components/popover.ts +13 -12
  171. package/src/theme/components/scroll-area.ts +115 -0
  172. package/src/{styles → theme}/components/select.ts +8 -16
  173. package/src/{styles → theme}/components/separator.ts +3 -3
  174. package/src/theme/components/skeleton.ts +23 -0
  175. package/src/theme/components/splitter.ts +20 -0
  176. package/src/{styles → theme}/components/status.ts +7 -7
  177. package/src/{styles → theme}/components/tag.ts +1 -1
  178. package/src/{styles → theme}/components/toast.ts +6 -8
  179. package/src/theme/components/toolbar.ts +35 -0
  180. package/src/{styles → theme}/components/tooltip.ts +4 -6
  181. package/src/{styles → theme}/components/treegrid.ts +9 -9
  182. package/src/{styles → theme}/index.ts +2 -2
  183. package/src/theme/primitives/column.ts +71 -0
  184. package/src/theme/primitives/index.ts +6 -0
  185. package/src/theme/primitives/panel.ts +43 -0
  186. package/src/{styles → theme}/theme.ts +27 -9
  187. package/src/typings.d.ts +3 -1
  188. package/src/{styles/fragments → util}/elevation.ts +6 -8
  189. package/src/util/hash-styles.ts +118 -98
  190. package/src/util/index.ts +3 -0
  191. package/src/util/mx.ts +165 -43
  192. package/src/util/size.ts +103 -0
  193. package/src/util/valence.ts +33 -0
  194. package/src/Tokens.stories.tsx +0 -88
  195. package/src/config/index.ts +0 -6
  196. package/src/config/tailwind.ts +0 -250
  197. package/src/config/tokens/alias-colors.ts +0 -39
  198. package/src/config/tokens/index.ts +0 -92
  199. package/src/config/tokens/lengths.ts +0 -97
  200. package/src/config/tokens/physical-colors.ts +0 -125
  201. package/src/config/tokens/semantic-colors.ts +0 -27
  202. package/src/config/tokens/sememes-calls.ts +0 -17
  203. package/src/config/tokens/sememes-codemirror.ts +0 -50
  204. package/src/config/tokens/sememes-hue.ts +0 -54
  205. package/src/config/tokens/sememes-sheet.ts +0 -62
  206. package/src/config/tokens/sememes-system.ts +0 -302
  207. package/src/config/tokens/sizes.ts +0 -7
  208. package/src/config/tokens/types.ts +0 -9
  209. package/src/docs/theme.drawio.svg +0 -635
  210. package/src/plugins/esbuild-plugin.ts +0 -65
  211. package/src/plugins/plugin.ts +0 -130
  212. package/src/plugins/resolveContent.ts +0 -51
  213. package/src/styles/components/README.md +0 -6
  214. package/src/styles/components/anchored-overflow.ts +0 -20
  215. package/src/styles/components/button.ts +0 -48
  216. package/src/styles/components/dialog.ts +0 -36
  217. package/src/styles/components/icon.ts +0 -19
  218. package/src/styles/components/input.ts +0 -177
  219. package/src/styles/components/scroll-area.ts +0 -43
  220. package/src/styles/components/toolbar.ts +0 -29
  221. package/src/styles/fragments/density.ts +0 -17
  222. package/src/styles/fragments/dimension.ts +0 -8
  223. package/src/styles/fragments/focus.ts +0 -16
  224. package/src/styles/fragments/group.ts +0 -12
  225. package/src/styles/fragments/hover.ts +0 -25
  226. package/src/styles/fragments/index.ts +0 -20
  227. package/src/styles/fragments/layout.ts +0 -7
  228. package/src/styles/fragments/motion.ts +0 -6
  229. package/src/styles/fragments/ornament.ts +0 -10
  230. package/src/styles/fragments/selected.ts +0 -45
  231. package/src/styles/fragments/shimmer.ts +0 -9
  232. package/src/styles/fragments/size.ts +0 -117
  233. package/src/styles/fragments/surface.ts +0 -29
  234. package/src/styles/fragments/text.ts +0 -12
  235. package/src/styles/fragments/valence.ts +0 -46
  236. package/src/styles/layers/README.md +0 -15
  237. package/src/styles/layers/anchored-overflow.css +0 -9
  238. package/src/styles/layers/animation.css +0 -17
  239. package/src/styles/layers/attention.css +0 -8
  240. package/src/styles/layers/base.css +0 -25
  241. package/src/styles/layers/can-scroll.css +0 -26
  242. package/src/styles/layers/dialog.css +0 -42
  243. package/src/styles/layers/drag-preview.css +0 -18
  244. package/src/styles/layers/hues.css +0 -110
  245. package/src/styles/layers/index.css +0 -26
  246. package/src/styles/layers/main.css +0 -160
  247. package/src/styles/layers/positioning.css +0 -23
  248. package/src/styles/layers/surfaces.css +0 -31
  249. package/src/styles/layers/tag.css +0 -132
  250. package/src/styles/layers/tldraw.css +0 -91
  251. package/src/styles/layers/tokens.css +0 -45
  252. package/src/tailwind.ts +0 -5
  253. package/src/theme.css +0 -9
  254. package/src/types.ts +0 -7
  255. package/src/util/withLogical.ts +0 -114
  256. /package/src/{styles/fragments → fragments}/disabled.ts +0 -0
  257. /package/src/{styles → theme}/components/breadcrumb.ts +0 -0
@@ -1,27 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import type { HelicalArcValue, SemanticLayer } from '@ch-ui/tokens';
6
-
7
- import { callsSememes } from './sememes-calls';
8
- import { codemirrorSememes } from './sememes-codemirror';
9
- import { hueSememes } from './sememes-hue';
10
- import { sheetSememes } from './sememes-sheet';
11
- import { systemSememes } from './sememes-system';
12
-
13
- export const semanticColors = {
14
- conditions: {
15
- light: [':root'],
16
- dark: ['.dark'],
17
- },
18
- sememes: {
19
- // Define each set of sememes in its own file.
20
- ...callsSememes,
21
- ...codemirrorSememes,
22
- ...hueSememes,
23
- ...sheetSememes,
24
- ...systemSememes,
25
- },
26
- namespace: 'dx-',
27
- } satisfies SemanticLayer<string, string, HelicalArcValue>;
@@ -1,17 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { type ColorSememes } from './types';
6
-
7
- // TODO(burdon): This should be broader than just calls.
8
- export const callsSememes: ColorSememes = {
9
- callActive: {
10
- light: ['green', '500'],
11
- dark: ['green', '500'],
12
- },
13
- callAlert: {
14
- light: ['rose', '500'],
15
- dark: ['rose', '500'],
16
- },
17
- };
@@ -1,50 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { type ColorSememes } from './types';
6
-
7
- export const codemirrorSememes = {
8
- // NOTE: background styles for the main content area must have transparency otherwise they will mask the selection.
9
- cmCodeblock: {
10
- light: ['neutral', '500/.1'],
11
- dark: ['neutral', '500/.1'],
12
- },
13
- cmActiveLine: {
14
- light: ['neutral', '200/.5'],
15
- dark: ['neutral', '800/.5'],
16
- },
17
- cmSeparator: {
18
- light: ['primary', 500],
19
- dark: ['primary', 500],
20
- },
21
- cmCursor: {
22
- light: ['neutral', 900],
23
- dark: ['neutral', 100],
24
- },
25
- cmSelection: {
26
- light: ['primary', '400/.5'],
27
- dark: ['primary', '600/.5'],
28
- },
29
- cmFocusedSelection: {
30
- light: ['primary', 400],
31
- dark: ['primary', 600],
32
- },
33
- cmHighlight: {
34
- light: ['neutral', 950],
35
- dark: ['neutral', 50],
36
- },
37
- cmHighlightSurface: {
38
- light: ['sky', 200],
39
- dark: ['cyan', 600],
40
- },
41
- // TODO(burdon): Factor out defs in common with sheet.
42
- cmCommentText: {
43
- light: ['neutral', 50],
44
- dark: ['neutral', 950],
45
- },
46
- cmCommentSurface: {
47
- light: ['amber', 700],
48
- dark: ['amber', 200],
49
- },
50
- } satisfies ColorSememes;
@@ -1,54 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { huePalettes } from './physical-colors';
6
- import { type ColorAliases, type ColorSememes } from './types';
7
-
8
- export const hueSememes: ColorSememes = [...Object.keys(huePalettes), 'neutral', 'primary'].reduce(
9
- (acc: ColorSememes, palette) => {
10
- acc[`${palette}Cursor`] = {
11
- light: [palette, 400],
12
- dark: [palette, 300],
13
- };
14
- acc[`${palette}Text`] = {
15
- light: [palette, 550],
16
- dark: [palette, 300],
17
- };
18
- acc[`${palette}Fill`] = {
19
- light: [palette, 500],
20
- dark: [palette, 500],
21
- };
22
- acc[`${palette}Surface`] = {
23
- light: [palette, 200],
24
- dark: [palette, 700],
25
- };
26
- acc[`${palette}SurfaceText`] = {
27
- light: [palette, 700],
28
- dark: [palette, 200],
29
- };
30
- acc[`${palette}Screen`] = {
31
- light: [palette, 100],
32
- dark: [palette, 800],
33
- };
34
- return acc;
35
- },
36
- {},
37
- );
38
-
39
- const valenceAliasSememeStems = ['Text', 'Surface', 'SurfaceText', 'Fill', 'Cursor'];
40
- const valenceMapping = {
41
- emerald: ['success'],
42
- cyan: ['info'],
43
- amber: ['warning'],
44
- rose: ['error'],
45
- primary: ['current'],
46
- fuchsia: ['internal'],
47
- };
48
-
49
- export const valenceAliases: ColorAliases = valenceAliasSememeStems.reduce((acc: ColorAliases, stem) => {
50
- return Object.entries(valenceMapping).reduce((acc: ColorAliases, [hue, valences]) => {
51
- acc[`${hue}${stem}`] = { root: valences.map((valence) => `${valence}${stem}`) };
52
- return acc;
53
- }, acc);
54
- }, {});
@@ -1,62 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import type { ColorAliases, ColorSememes } from './types';
6
-
7
- export const sheetSememes = {
8
- // NOTE: background styles for the main content area must have transparency otherwise they will mask the selection.
9
- axisSurface: {
10
- light: ['neutral', 50],
11
- dark: ['neutral', 800],
12
- },
13
- axisText: {
14
- light: ['neutral', 800],
15
- dark: ['neutral', 200],
16
- },
17
- axisSelectedSurface: {
18
- light: ['neutral', 100],
19
- dark: ['neutral', 900],
20
- },
21
- axisSelectedText: {
22
- light: ['neutral', 100],
23
- dark: ['neutral', 900],
24
- },
25
- gridCell: {
26
- // TODO(thure): Why override only dark?
27
- light: ['neutral', '50/0'],
28
- dark: ['neutral', 850],
29
- },
30
- gridCellSelected: {
31
- // TODO(thure): Can this not just use `attention`?
32
- light: ['neutral', 50],
33
- dark: ['neutral', 800],
34
- },
35
- gridOverlay: {
36
- light: ['primary', '500/.5'],
37
- dark: ['primary', '500/.5'],
38
- },
39
- gridSelectionOverlay: {
40
- light: ['primary', '500/.2'],
41
- dark: ['primary', '500/.2'],
42
- },
43
- gridHighlight: {
44
- light: ['emerald', '500/.5'],
45
- dark: ['emerald', '500/.5'],
46
- },
47
- // TODO(burdon): Factor out def (in common with editor).
48
- gridCommented: {
49
- light: ['green', 200],
50
- dark: ['green', 600],
51
- },
52
- gridCommentedActive: {
53
- light: ['green', '200/.5'],
54
- dark: ['green', '600/.5'],
55
- },
56
- } satisfies ColorSememes;
57
-
58
- export const sheetAliases = {
59
- activeSurface: { root: ['gridLine'] },
60
- accentFocusIndicator: { root: ['gridFocusIndicatorColor'] },
61
- neutralFocusIndicator: { gridFocusStack: ['gridFocusIndicatorColor'] },
62
- } satisfies ColorAliases;
@@ -1,302 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- // TODO(thure): TS2742
6
- /* eslint-disable unused-imports/no-unused-imports */
7
- import * as _colors from '@ch-ui/colors';
8
-
9
- import { type ColorAliases, type ColorSememes } from './types';
10
-
11
- // TODO(burdon): Move to util.
12
- const getMapValue = <T>(map: Record<string, T>, key: string, defaultValue: () => T): T => {
13
- let value = map[key];
14
- if (!value) {
15
- value = defaultValue();
16
- map[key] = value;
17
- }
18
- return value;
19
- };
20
-
21
- type Sememe = ColorSememes[string];
22
-
23
- const applyAlpha = (sememe: Sememe, alpha: number): Sememe => {
24
- if (alpha >= 1) {
25
- return sememe;
26
- } else {
27
- return {
28
- light: [sememe.light![0], `${sememe.light![1]}/${alpha}`],
29
- dark: [sememe.dark![0], `${sememe.dark![1]}/${alpha}`],
30
- };
31
- }
32
- };
33
-
34
- // Luminosity extrema and key points.
35
-
36
- // Both elevation cadences go from darker to lighter from “elevation” 0 to `ELEVATION_SCALE`,
37
- // whereas both contrast cadences go from highest contrast at 0 to lowest contrast at `CONTRAST_SCALE`.
38
-
39
- const DARK_ELEVATION_MIN = 855;
40
- const DARK_ELEVATION_MAX = 731;
41
-
42
- const DARK_CONTRAST_MIN = 750;
43
- const DARK_CONTRAST_MAX = 665;
44
-
45
- const LIGHT_ELEVATION_MIN = 0;
46
- const LIGHT_ELEVATION_MAX = 0;
47
-
48
- const LIGHT_CONTRAST_MIN = 82;
49
- const LIGHT_CONTRAST_MAX = 24;
50
-
51
- const ELEVATION_SCALE = 2;
52
- const CONTRAST_SCALE = 3;
53
-
54
- const darkElevationCadence = (depth: number) =>
55
- Math.round(
56
- DARK_ELEVATION_MAX + (DARK_ELEVATION_MIN - DARK_ELEVATION_MAX) * ((ELEVATION_SCALE - depth) / ELEVATION_SCALE),
57
- );
58
- const darkContrastCadence = (depth: number) =>
59
- Math.round(
60
- DARK_CONTRAST_MAX + (DARK_CONTRAST_MIN - DARK_CONTRAST_MAX) * ((ELEVATION_SCALE - depth) / ELEVATION_SCALE),
61
- );
62
-
63
- const lightElevationCadence = (depth: number) =>
64
- Math.round(
65
- LIGHT_ELEVATION_MIN + (LIGHT_ELEVATION_MAX - LIGHT_ELEVATION_MIN) * ((CONTRAST_SCALE - depth) / CONTRAST_SCALE),
66
- );
67
- const lightContrastCadence = (depth: number) =>
68
- Math.round(LIGHT_CONTRAST_MAX + (LIGHT_CONTRAST_MIN - LIGHT_CONTRAST_MAX) * (depth / CONTRAST_SCALE));
69
-
70
- const elevationCadence = (lightDepth: number, darkDepth: number = lightDepth, alpha: number = 1): Sememe =>
71
- applyAlpha(
72
- {
73
- light: ['neutral', lightElevationCadence(lightDepth)],
74
- dark: ['neutral', darkElevationCadence(darkDepth)],
75
- },
76
- alpha,
77
- );
78
-
79
- const contrastCadence = (lightDepth: number, darkDepth: number = lightDepth, alpha: number = 1): Sememe =>
80
- applyAlpha(
81
- {
82
- light: ['neutral', lightContrastCadence(lightDepth)],
83
- dark: ['neutral', darkContrastCadence(darkDepth)],
84
- },
85
- alpha,
86
- );
87
-
88
- export const systemSememes = {
89
- //
90
- // Elevation cadence tokens
91
- //
92
-
93
- baseSurface: elevationCadence(0),
94
- groupSurface: elevationCadence(1),
95
- modalSurface: elevationCadence(2, 1.7),
96
-
97
- //
98
- // Contrast cadence tokens
99
- //
100
-
101
- textInputSurfaceBase: contrastCadence(0, 0),
102
- textInputSurfaceGroup: contrastCadence(0, 0.5),
103
- textInputSurfaceModal: contrastCadence(0, 1),
104
-
105
- inputSurfaceBase: contrastCadence(0.8, 0.33),
106
- inputSurfaceGroup: contrastCadence(0.8, 0.66),
107
- inputSurfaceModal: contrastCadence(0.8, 1),
108
-
109
- hoverSurfaceBase: contrastCadence(2, 1.5),
110
- hoverSurfaceGroup: contrastCadence(2, 2),
111
- hoverSurfaceModal: contrastCadence(2, 2.5),
112
-
113
- separatorBase: contrastCadence(3, 2),
114
- separatorGroup: contrastCadence(3, 2.5),
115
- separatorModal: contrastCadence(3, 3),
116
-
117
- subduedSeparator: contrastCadence(3, 1),
118
-
119
- unAccent: {
120
- light: ['neutral', 400],
121
- dark: ['neutral', 400],
122
- },
123
- unAccentHover: {
124
- light: ['neutral', 450],
125
- dark: ['neutral', 450],
126
- },
127
- hoverOverlay: {
128
- light: ['neutral', '450/.1'],
129
- dark: ['neutral', '450/.1'],
130
- },
131
-
132
- //
133
- // Special surfaces.
134
- //
135
-
136
- // Screen overlay for modal dialogs.
137
- scrimSurface: applyAlpha(
138
- {
139
- light: ['neutral', LIGHT_CONTRAST_MAX],
140
- dark: ['neutral', DARK_ELEVATION_MIN],
141
- },
142
- 0.65,
143
- ),
144
-
145
- // High contrast for focused interactive elements. (Technically this is part of the surface cadence, but the contrast cadence is on the opposite side of the elevation cadence as this point.)
146
- focusSurface: {
147
- light: ['neutral', 0],
148
- dark: ['neutral', 1000],
149
- },
150
-
151
- deckSurface: {
152
- light: ['neutral', 50],
153
- dark: ['neutral', 950],
154
- },
155
-
156
- // For tooltips only; the highest elevation from the opposite theme
157
- inverseSurface: {
158
- light: ['neutral', DARK_ELEVATION_MIN],
159
- dark: ['neutral', LIGHT_ELEVATION_MIN],
160
- },
161
-
162
- //
163
- // Accent surfaces
164
- //
165
-
166
- accentSurfaceRelated: {
167
- light: ['primary', '300/.1'],
168
- dark: ['primary', '400/.1'],
169
- },
170
- accentSurfaceHover: {
171
- light: ['primary', 600],
172
- dark: ['primary', 475],
173
- },
174
- accentSurface: {
175
- light: ['primary', 500],
176
- dark: ['primary', 500],
177
- },
178
-
179
- //
180
- // Text (text-) and other foregrounds
181
- // TODO(thure): Establish contrast-order cadence for text.
182
- //
183
-
184
- baseText: {
185
- light: ['neutral', 1000],
186
- dark: ['neutral', 50],
187
- },
188
- inverseSurfaceText: {
189
- light: ['neutral', 50],
190
- dark: ['neutral', 1000],
191
- },
192
- description: {
193
- light: ['neutral', 550],
194
- dark: ['neutral', 350],
195
- },
196
- subdued: {
197
- light: ['neutral', 700],
198
- dark: ['neutral', 300],
199
- },
200
- placeholder: {
201
- light: ['neutral', 500],
202
- dark: ['neutral', 500],
203
- },
204
- accentText: {
205
- light: ['primary', 550],
206
- dark: ['primary', 400],
207
- },
208
- accentSurfaceText: {
209
- light: ['neutral', 0],
210
- dark: ['neutral', 0],
211
- },
212
- accentTextHover: {
213
- light: ['primary', 500],
214
- dark: ['primary', 350],
215
- },
216
- accentFocusIndicator: {
217
- light: ['primary', 300],
218
- dark: ['primary', 450],
219
- },
220
- neutralFocusIndicator: {
221
- light: ['neutral', 300],
222
- dark: ['neutral', 550],
223
- },
224
- } satisfies ColorSememes;
225
-
226
- type SememeName = keyof typeof systemSememes;
227
- type SememeKey = 'root' | 'group' | 'modal';
228
-
229
- /**
230
- * Alias map.
231
- */
232
- const aliasDefs: Record<string, Partial<Record<SememeKey, SememeName>>> = {
233
- // Selected items, current items, other surfaces needing special contrast against baseSurface.
234
- activeSurface: {
235
- root: 'inputSurfaceBase',
236
- },
237
-
238
- // Main sidebar panel.
239
- sidebarSurface: {
240
- root: 'groupSurface',
241
- },
242
-
243
- // Plank header.
244
- headerSurface: {
245
- root: 'groupSurface',
246
- },
247
-
248
- // Toolbars, table/sheet headers, etc.
249
- toolbarSurface: {
250
- root: 'groupSurface',
251
- },
252
-
253
- // Forms, cards, etc.
254
- cardSurface: {
255
- root: 'groupSurface',
256
- },
257
-
258
- // Secondary aliases.
259
- textInputSurface: {
260
- root: 'textInputSurfaceBase',
261
- group: 'textInputSurfaceGroup',
262
- modal: 'textInputSurfaceModal',
263
- },
264
- inputSurface: {
265
- root: 'inputSurfaceBase',
266
- group: 'inputSurfaceGroup',
267
- modal: 'inputSurfaceModal',
268
- },
269
- hoverSurface: {
270
- root: 'hoverSurfaceBase',
271
- group: 'hoverSurfaceGroup',
272
- modal: 'hoverSurfaceModal',
273
- },
274
-
275
- // TODO(thure): Rename uses of this token to `focusSurface` and remove this alias.
276
- attention: {
277
- root: 'focusSurface',
278
- },
279
-
280
- // In “master-detail” patterns, the background of the item in the list which is enumerated in the adjacent view.
281
- // TODO(burdon): Review tokens.
282
- currentRelated: {
283
- root: 'modalSurface',
284
- },
285
-
286
- // Borders and dividers.
287
- separator: {
288
- root: 'separatorBase',
289
- group: 'separatorGroup',
290
- modal: 'separatorModal',
291
- },
292
- };
293
-
294
- export const systemAliases: ColorAliases = Object.entries(aliasDefs).reduce((aliases, [alias, values]) => {
295
- Object.entries(values).forEach(([key, sememe]) => {
296
- const record = getMapValue(aliases, sememe, () => ({}));
297
- const list = getMapValue<string[]>(record, key, () => []);
298
- list.push(alias);
299
- });
300
-
301
- return aliases;
302
- }, {} as ColorAliases);
@@ -1,7 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- export const cardMinInlineSize = 18;
6
- export const cardDefaultInlineSize = 20;
7
- export const cardMaxInlineSize = 25;
@@ -1,9 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import type { AliasLayer, HelicalArcValue, ResolvedHelicalArcSeries, SemanticLayer } from '@ch-ui/tokens';
6
-
7
- export type PhysicalPalette = Omit<ResolvedHelicalArcSeries, 'extends' | 'physicalValueRelation'>;
8
- export type ColorSememes = SemanticLayer<string, string, HelicalArcValue>['sememes'];
9
- export type ColorAliases = AliasLayer<string>['aliases'];