@ohos-ports/dxos-react-ui-theme 0.8.3-beta.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 (260) hide show
  1. package/LICENSE +8 -0
  2. package/README.md +25 -0
  3. package/README.yml +1 -0
  4. package/dist/lib/browser/index.mjs +3199 -0
  5. package/dist/lib/browser/index.mjs.map +7 -0
  6. package/dist/lib/browser/meta.json +1 -0
  7. package/dist/plugin/node/chunk-3IKFINB6.cjs +1500 -0
  8. package/dist/plugin/node/chunk-3IKFINB6.cjs.map +7 -0
  9. package/dist/plugin/node/chunk-QA5KMUXP.cjs +70 -0
  10. package/dist/plugin/node/chunk-QA5KMUXP.cjs.map +7 -0
  11. package/dist/plugin/node/config/tailwind.cjs +29 -0
  12. package/dist/plugin/node/config/tailwind.cjs.map +7 -0
  13. package/dist/plugin/node/meta.json +1 -0
  14. package/dist/plugin/node/plugins/esbuild-plugin.cjs +90 -0
  15. package/dist/plugin/node/plugins/esbuild-plugin.cjs.map +7 -0
  16. package/dist/plugin/node/plugins/plugin.cjs +123 -0
  17. package/dist/plugin/node/plugins/plugin.cjs.map +7 -0
  18. package/dist/plugin/node/theme.css +1223 -0
  19. package/dist/plugin/node/theme.css.map +7 -0
  20. package/dist/plugin/node-esm/chunk-LNTZCFPD.mjs +1493 -0
  21. package/dist/plugin/node-esm/chunk-LNTZCFPD.mjs.map +7 -0
  22. package/dist/plugin/node-esm/chunk-TFKSVC5U.mjs +50 -0
  23. package/dist/plugin/node-esm/chunk-TFKSVC5U.mjs.map +7 -0
  24. package/dist/plugin/node-esm/config/tailwind.mjs +8 -0
  25. package/dist/plugin/node-esm/config/tailwind.mjs.map +7 -0
  26. package/dist/plugin/node-esm/meta.json +1 -0
  27. package/dist/plugin/node-esm/plugins/esbuild-plugin.mjs +63 -0
  28. package/dist/plugin/node-esm/plugins/esbuild-plugin.mjs.map +7 -0
  29. package/dist/plugin/node-esm/plugins/plugin.mjs +97 -0
  30. package/dist/plugin/node-esm/plugins/plugin.mjs.map +7 -0
  31. package/dist/plugin/node-esm/theme.css +1223 -0
  32. package/dist/plugin/node-esm/theme.css.map +7 -0
  33. package/dist/types/src/config/index.d.ts +3 -0
  34. package/dist/types/src/config/index.d.ts.map +1 -0
  35. package/dist/types/src/config/tailwind.d.ts +9 -0
  36. package/dist/types/src/config/tailwind.d.ts.map +1 -0
  37. package/dist/types/src/config/tokens/Tokens.stories.d.ts +7 -0
  38. package/dist/types/src/config/tokens/Tokens.stories.d.ts.map +1 -0
  39. package/dist/types/src/config/tokens/alias-colors.d.ts +14 -0
  40. package/dist/types/src/config/tokens/alias-colors.d.ts.map +1 -0
  41. package/dist/types/src/config/tokens/index.d.ts +438 -0
  42. package/dist/types/src/config/tokens/index.d.ts.map +1 -0
  43. package/dist/types/src/config/tokens/lengths.d.ts +116 -0
  44. package/dist/types/src/config/tokens/lengths.d.ts.map +1 -0
  45. package/dist/types/src/config/tokens/physical-colors.d.ts +23 -0
  46. package/dist/types/src/config/tokens/physical-colors.d.ts.map +1 -0
  47. package/dist/types/src/config/tokens/semantic-colors.d.ts +179 -0
  48. package/dist/types/src/config/tokens/semantic-colors.d.ts.map +1 -0
  49. package/dist/types/src/config/tokens/sememes-calls.d.ts +3 -0
  50. package/dist/types/src/config/tokens/sememes-calls.d.ts.map +1 -0
  51. package/dist/types/src/config/tokens/sememes-codemirror.d.ts +43 -0
  52. package/dist/types/src/config/tokens/sememes-codemirror.d.ts.map +1 -0
  53. package/dist/types/src/config/tokens/sememes-hue.d.ts +4 -0
  54. package/dist/types/src/config/tokens/sememes-hue.d.ts.map +1 -0
  55. package/dist/types/src/config/tokens/sememes-sheet.d.ts +52 -0
  56. package/dist/types/src/config/tokens/sememes-sheet.d.ts.map +1 -0
  57. package/dist/types/src/config/tokens/sememes-system.d.ts +91 -0
  58. package/dist/types/src/config/tokens/sememes-system.d.ts.map +1 -0
  59. package/dist/types/src/config/tokens/types.d.ts +5 -0
  60. package/dist/types/src/config/tokens/types.d.ts.map +1 -0
  61. package/dist/types/src/index.d.ts +8 -0
  62. package/dist/types/src/index.d.ts.map +1 -0
  63. package/dist/types/src/plugins/esbuild-plugin.d.ts +9 -0
  64. package/dist/types/src/plugins/esbuild-plugin.d.ts.map +1 -0
  65. package/dist/types/src/plugins/plugin.d.ts +17 -0
  66. package/dist/types/src/plugins/plugin.d.ts.map +1 -0
  67. package/dist/types/src/plugins/resolveContent.d.ts +2 -0
  68. package/dist/types/src/plugins/resolveContent.d.ts.map +1 -0
  69. package/dist/types/src/styles/components/anchored-overflow.d.ts +6 -0
  70. package/dist/types/src/styles/components/anchored-overflow.d.ts.map +1 -0
  71. package/dist/types/src/styles/components/avatar.d.ts +21 -0
  72. package/dist/types/src/styles/components/avatar.d.ts.map +1 -0
  73. package/dist/types/src/styles/components/breadcrumb.d.ts +9 -0
  74. package/dist/types/src/styles/components/breadcrumb.d.ts.map +1 -0
  75. package/dist/types/src/styles/components/button.d.ts +19 -0
  76. package/dist/types/src/styles/components/button.d.ts.map +1 -0
  77. package/dist/types/src/styles/components/dialog.d.ts +12 -0
  78. package/dist/types/src/styles/components/dialog.d.ts.map +1 -0
  79. package/dist/types/src/styles/components/icon-button.d.ts +5 -0
  80. package/dist/types/src/styles/components/icon-button.d.ts.map +1 -0
  81. package/dist/types/src/styles/components/icon.d.ts +7 -0
  82. package/dist/types/src/styles/components/icon.d.ts.map +1 -0
  83. package/dist/types/src/styles/components/index.d.ts +24 -0
  84. package/dist/types/src/styles/components/index.d.ts.map +1 -0
  85. package/dist/types/src/styles/components/input.d.ts +111 -0
  86. package/dist/types/src/styles/components/input.d.ts.map +1 -0
  87. package/dist/types/src/styles/components/link.d.ts +7 -0
  88. package/dist/types/src/styles/components/link.d.ts.map +1 -0
  89. package/dist/types/src/styles/components/list.d.ts +14 -0
  90. package/dist/types/src/styles/components/list.d.ts.map +1 -0
  91. package/dist/types/src/styles/components/main.d.ts +28 -0
  92. package/dist/types/src/styles/components/main.d.ts.map +1 -0
  93. package/dist/types/src/styles/components/menu.d.ts +13 -0
  94. package/dist/types/src/styles/components/menu.d.ts.map +1 -0
  95. package/dist/types/src/styles/components/message.d.ts +11 -0
  96. package/dist/types/src/styles/components/message.d.ts.map +1 -0
  97. package/dist/types/src/styles/components/popover.d.ts +11 -0
  98. package/dist/types/src/styles/components/popover.d.ts.map +1 -0
  99. package/dist/types/src/styles/components/scroll-area.d.ts +9 -0
  100. package/dist/types/src/styles/components/scroll-area.d.ts.map +1 -0
  101. package/dist/types/src/styles/components/select.d.ts +14 -0
  102. package/dist/types/src/styles/components/select.d.ts.map +1 -0
  103. package/dist/types/src/styles/components/separator.d.ts +8 -0
  104. package/dist/types/src/styles/components/separator.d.ts.map +1 -0
  105. package/dist/types/src/styles/components/status.d.ts +9 -0
  106. package/dist/types/src/styles/components/status.d.ts.map +1 -0
  107. package/dist/types/src/styles/components/tag.d.ts +7 -0
  108. package/dist/types/src/styles/components/tag.d.ts.map +1 -0
  109. package/dist/types/src/styles/components/toast.d.ts +12 -0
  110. package/dist/types/src/styles/components/toast.d.ts.map +1 -0
  111. package/dist/types/src/styles/components/toolbar.d.ts +8 -0
  112. package/dist/types/src/styles/components/toolbar.d.ts.map +1 -0
  113. package/dist/types/src/styles/components/tooltip.d.ts +8 -0
  114. package/dist/types/src/styles/components/tooltip.d.ts.map +1 -0
  115. package/dist/types/src/styles/components/treegrid.d.ts +10 -0
  116. package/dist/types/src/styles/components/treegrid.d.ts.map +1 -0
  117. package/dist/types/src/styles/fragments/density.d.ts +13 -0
  118. package/dist/types/src/styles/fragments/density.d.ts.map +1 -0
  119. package/dist/types/src/styles/fragments/dimension.d.ts +5 -0
  120. package/dist/types/src/styles/fragments/dimension.d.ts.map +1 -0
  121. package/dist/types/src/styles/fragments/disabled.d.ts +3 -0
  122. package/dist/types/src/styles/fragments/disabled.d.ts.map +1 -0
  123. package/dist/types/src/styles/fragments/elevation.d.ts +15 -0
  124. package/dist/types/src/styles/fragments/elevation.d.ts.map +1 -0
  125. package/dist/types/src/styles/fragments/focus.d.ts +6 -0
  126. package/dist/types/src/styles/fragments/focus.d.ts.map +1 -0
  127. package/dist/types/src/styles/fragments/group.d.ts +5 -0
  128. package/dist/types/src/styles/fragments/group.d.ts.map +1 -0
  129. package/dist/types/src/styles/fragments/hover.d.ts +16 -0
  130. package/dist/types/src/styles/fragments/hover.d.ts.map +1 -0
  131. package/dist/types/src/styles/fragments/index.d.ts +17 -0
  132. package/dist/types/src/styles/fragments/index.d.ts.map +1 -0
  133. package/dist/types/src/styles/fragments/layout.d.ts +3 -0
  134. package/dist/types/src/styles/fragments/layout.d.ts.map +1 -0
  135. package/dist/types/src/styles/fragments/motion.d.ts +2 -0
  136. package/dist/types/src/styles/fragments/motion.d.ts.map +1 -0
  137. package/dist/types/src/styles/fragments/ornament.d.ts +5 -0
  138. package/dist/types/src/styles/fragments/ornament.d.ts.map +1 -0
  139. package/dist/types/src/styles/fragments/selected.d.ts +13 -0
  140. package/dist/types/src/styles/fragments/selected.d.ts.map +1 -0
  141. package/dist/types/src/styles/fragments/shimmer.d.ts +3 -0
  142. package/dist/types/src/styles/fragments/shimmer.d.ts.map +1 -0
  143. package/dist/types/src/styles/fragments/size.d.ts +9 -0
  144. package/dist/types/src/styles/fragments/size.d.ts.map +1 -0
  145. package/dist/types/src/styles/fragments/surface.d.ts +9 -0
  146. package/dist/types/src/styles/fragments/surface.d.ts.map +1 -0
  147. package/dist/types/src/styles/fragments/text.d.ts +7 -0
  148. package/dist/types/src/styles/fragments/text.d.ts.map +1 -0
  149. package/dist/types/src/styles/fragments/valence.d.ts +13 -0
  150. package/dist/types/src/styles/fragments/valence.d.ts.map +1 -0
  151. package/dist/types/src/styles/index.d.ts +4 -0
  152. package/dist/types/src/styles/index.d.ts.map +1 -0
  153. package/dist/types/src/styles/theme.d.ts +5 -0
  154. package/dist/types/src/styles/theme.d.ts.map +1 -0
  155. package/dist/types/src/tailwind.d.ts +1 -0
  156. package/dist/types/src/tailwind.d.ts.map +1 -0
  157. package/dist/types/src/types.d.ts +3 -0
  158. package/dist/types/src/types.d.ts.map +1 -0
  159. package/dist/types/src/util/hash.d.ts +8 -0
  160. package/dist/types/src/util/hash.d.ts.map +1 -0
  161. package/dist/types/src/util/index.d.ts +3 -0
  162. package/dist/types/src/util/index.d.ts.map +1 -0
  163. package/dist/types/src/util/mx.d.ts +2 -0
  164. package/dist/types/src/util/mx.d.ts.map +1 -0
  165. package/dist/types/src/util/withLogical.d.ts +164 -0
  166. package/dist/types/src/util/withLogical.d.ts.map +1 -0
  167. package/dist/types/tsconfig.tsbuildinfo +1 -0
  168. package/package.json +58 -0
  169. package/plugin.d.ts +7 -0
  170. package/plugin.js +10 -0
  171. package/src/config/index.ts +6 -0
  172. package/src/config/tailwind.ts +236 -0
  173. package/src/config/tokens/Tokens.stories.tsx +94 -0
  174. package/src/config/tokens/alias-colors.ts +38 -0
  175. package/src/config/tokens/index.ts +90 -0
  176. package/src/config/tokens/lengths.ts +87 -0
  177. package/src/config/tokens/physical-colors.ts +125 -0
  178. package/src/config/tokens/semantic-colors.ts +27 -0
  179. package/src/config/tokens/sememes-calls.ts +17 -0
  180. package/src/config/tokens/sememes-codemirror.ts +50 -0
  181. package/src/config/tokens/sememes-hue.ts +54 -0
  182. package/src/config/tokens/sememes-sheet.ts +60 -0
  183. package/src/config/tokens/sememes-system.ts +255 -0
  184. package/src/config/tokens/types.ts +9 -0
  185. package/src/index.ts +15 -0
  186. package/src/plugins/esbuild-plugin.ts +60 -0
  187. package/src/plugins/plugin.ts +127 -0
  188. package/src/plugins/resolveContent.ts +55 -0
  189. package/src/styles/components/README.md +6 -0
  190. package/src/styles/components/anchored-overflow.ts +20 -0
  191. package/src/styles/components/avatar.ts +96 -0
  192. package/src/styles/components/breadcrumb.ts +29 -0
  193. package/src/styles/components/button.ts +48 -0
  194. package/src/styles/components/dialog.ts +36 -0
  195. package/src/styles/components/icon-button.ts +17 -0
  196. package/src/styles/components/icon.ts +19 -0
  197. package/src/styles/components/index.ts +27 -0
  198. package/src/styles/components/input.ts +176 -0
  199. package/src/styles/components/link.ts +26 -0
  200. package/src/styles/components/list.ts +46 -0
  201. package/src/styles/components/main.ts +36 -0
  202. package/src/styles/components/menu.ts +60 -0
  203. package/src/styles/components/message.ts +36 -0
  204. package/src/styles/components/popover.ts +40 -0
  205. package/src/styles/components/scroll-area.ts +42 -0
  206. package/src/styles/components/select.ts +64 -0
  207. package/src/styles/components/separator.ts +24 -0
  208. package/src/styles/components/status.ts +32 -0
  209. package/src/styles/components/tag.ts +23 -0
  210. package/src/styles/components/toast.ts +55 -0
  211. package/src/styles/components/toolbar.ts +20 -0
  212. package/src/styles/components/tooltip.ts +29 -0
  213. package/src/styles/components/treegrid.ts +37 -0
  214. package/src/styles/fragments/density.ts +17 -0
  215. package/src/styles/fragments/dimension.ts +8 -0
  216. package/src/styles/fragments/disabled.ts +6 -0
  217. package/src/styles/fragments/elevation.ts +29 -0
  218. package/src/styles/fragments/focus.ts +16 -0
  219. package/src/styles/fragments/group.ts +12 -0
  220. package/src/styles/fragments/hover.ts +24 -0
  221. package/src/styles/fragments/index.ts +20 -0
  222. package/src/styles/fragments/layout.ts +7 -0
  223. package/src/styles/fragments/motion.ts +6 -0
  224. package/src/styles/fragments/ornament.ts +10 -0
  225. package/src/styles/fragments/selected.ts +45 -0
  226. package/src/styles/fragments/shimmer.ts +9 -0
  227. package/src/styles/fragments/size.ts +117 -0
  228. package/src/styles/fragments/surface.ts +29 -0
  229. package/src/styles/fragments/text.ts +13 -0
  230. package/src/styles/fragments/valence.ts +48 -0
  231. package/src/styles/index.ts +7 -0
  232. package/src/styles/layers/anchored-overflow.css +9 -0
  233. package/src/styles/layers/attention.css +8 -0
  234. package/src/styles/layers/base.css +25 -0
  235. package/src/styles/layers/button.css +76 -0
  236. package/src/styles/layers/can-scroll.css +26 -0
  237. package/src/styles/layers/checkbox.css +50 -0
  238. package/src/styles/layers/dialog.css +42 -0
  239. package/src/styles/layers/drag-preview.css +18 -0
  240. package/src/styles/layers/focus-ring.css +129 -0
  241. package/src/styles/layers/hues.css +110 -0
  242. package/src/styles/layers/index.css +21 -0
  243. package/src/styles/layers/main.css +162 -0
  244. package/src/styles/layers/native.css +14 -0
  245. package/src/styles/layers/positioning.css +23 -0
  246. package/src/styles/layers/size.css +299 -0
  247. package/src/styles/layers/surfaces.css +31 -0
  248. package/src/styles/layers/tag.css +123 -0
  249. package/src/styles/layers/tldraw.css +91 -0
  250. package/src/styles/layers/tokens.css +44 -0
  251. package/src/styles/layers/typography.css +152 -0
  252. package/src/styles/theme.ts +69 -0
  253. package/src/tailwind.ts +5 -0
  254. package/src/theme.css +5 -0
  255. package/src/types.ts +7 -0
  256. package/src/typings.d.ts +8 -0
  257. package/src/util/hash.ts +39 -0
  258. package/src/util/index.ts +6 -0
  259. package/src/util/mx.ts +34 -0
  260. package/src/util/withLogical.ts +114 -0
@@ -0,0 +1,55 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { glob as globCb } from 'glob';
6
+ import { promisify } from 'node:util';
7
+
8
+ const glob = promisify(globCb);
9
+
10
+ /**
11
+ *
12
+ */
13
+ // TODO(burdon): Comment.
14
+ const knownIndirectPeers = [
15
+ '@dxos/gem-*',
16
+ '@dxos/react-*',
17
+ '@dxos/react-ui-*',
18
+ '@dxos/devtools',
19
+ '@dxos/shell',
20
+ // TODO(thure): glob v7 runs out of memory if we do a `**` search, and this is (hopefully) the only L3 content package; find a better solution.
21
+ '@dxos/react-ui-table/node_modules/@dxos/react-ui-searchlist',
22
+ ];
23
+
24
+ const knownDirectPeers = ['@dxos/plugin-*', ...knownIndirectPeers];
25
+
26
+ const packageNamePattern = /.*node_modules\/(.+?)$/;
27
+ const packageName = (path: string) => path.match(packageNamePattern)?.[1];
28
+
29
+ const flatten = (acc: string[], group: string[]) => [...acc, ...group];
30
+ const dedupe = (acc: Record<string, string>, path: string) => {
31
+ const name = packageName(path);
32
+ if (name && !acc[name]) {
33
+ acc[name] = path;
34
+ }
35
+ return acc;
36
+ };
37
+
38
+ export const resolveKnownPeers = async (content: string[], cwd: string): Promise<string[]> => {
39
+ const globOptions = { cwd, absolute: true };
40
+
41
+ const directPeers = await Promise.all(knownDirectPeers.map((peer) => glob(`./node_modules/${peer}`, globOptions)));
42
+
43
+ // NOTE(thure): With glob v7, JS runs out of memory if `**` is used, so this limits the search to @dxos/plugin-*/node_modules
44
+ const indirectPeers = await Promise.all(
45
+ knownIndirectPeers.map((peer) => glob(`./node_modules/@dxos/plugin-*/node_modules/${peer}`, globOptions)),
46
+ );
47
+
48
+ const knownPeerContent = Object.values(
49
+ indirectPeers.reduce(flatten, []).reduce(dedupe, directPeers.reduce(flatten, []).reduce(dedupe, {})),
50
+ ).map((value) => `${value}/dist/lib/**/*.mjs`);
51
+
52
+ // console.log('[found known peer content paths]', knownPeerContent);
53
+
54
+ return [...content, ...knownPeerContent];
55
+ };
@@ -0,0 +1,6 @@
1
+ # react-ui themes
2
+
3
+ References:
4
+ - https://tailwindcss-radix.vercel.app
5
+ - https://github.com/ecklf/tailwindcss-radix
6
+ - https://www.radix-ui.com/primitives/docs/components
@@ -0,0 +1,20 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type ComponentFunction, type Theme } from '@dxos/react-ui-types';
6
+
7
+ import { mx } from '../../util';
8
+
9
+ export type AnchoredOverflowStyleProps = {};
10
+
11
+ export const anchoredOverflowRoot: ComponentFunction<AnchoredOverflowStyleProps> = (_props, ...etc) =>
12
+ mx('overflow-anchored overflow-auto', ...etc);
13
+
14
+ export const anchoredOverflowAnchor: ComponentFunction<AnchoredOverflowStyleProps> = (_props, ...etc) =>
15
+ mx('overflow-anchor is-px bs-px', ...etc);
16
+
17
+ export const anchoredOverflowTheme: Theme<AnchoredOverflowStyleProps> = {
18
+ root: anchoredOverflowRoot,
19
+ anchor: anchoredOverflowAnchor,
20
+ };
@@ -0,0 +1,96 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type ComponentFunction, type Size, type Theme } from '@dxos/react-ui-types';
6
+
7
+ import { mx } from '../../util';
8
+ import { descriptionText, getSize, getSizeHeight } from '../fragments';
9
+
10
+ export type AvatarStyleProps = Partial<{
11
+ size: Size;
12
+ srOnly: boolean;
13
+ status: 'active' | 'inactive' | 'current' | 'error' | 'warning' | 'internal';
14
+ animation: 'pulse' | 'none';
15
+ variant: 'circle' | 'square';
16
+ inGroup: boolean;
17
+ }>;
18
+
19
+ export const avatarRoot: ComponentFunction<AvatarStyleProps> = ({ size = 10, inGroup }, ...etc) =>
20
+ mx(
21
+ 'relative inline-flex shrink-0',
22
+ getSize(size),
23
+ inGroup && (size === 'px' || size <= 3 ? '-mie-1' : '-mie-2'),
24
+ ...etc,
25
+ );
26
+
27
+ export const avatarLabel: ComponentFunction<AvatarStyleProps> = ({ srOnly }, ...etc) => mx(srOnly && 'sr-only', ...etc);
28
+
29
+ export const avatarDescription: ComponentFunction<AvatarStyleProps> = ({ srOnly }, ...etc) =>
30
+ mx(descriptionText, srOnly && 'sr-only', ...etc);
31
+
32
+ export const avatarFrame: ComponentFunction<AvatarStyleProps> = ({ variant }, ...etc) =>
33
+ mx('is-full bs-full bg-[--surface-bg]', variant === 'circle' ? 'rounded-full' : 'rounded', ...etc);
34
+
35
+ export const avatarStatusIcon: ComponentFunction<AvatarStyleProps> = ({ status, size = 3 }, ...etc) =>
36
+ mx(
37
+ 'absolute block-end-0 inline-end-0',
38
+ getSize(size),
39
+ status === 'inactive'
40
+ ? 'text-amber-350 dark:text-amber-250'
41
+ : status === 'active'
42
+ ? 'text-emerald-350 dark:text-emerald-250'
43
+ : 'text-neutral-350 dark:text-neutral-250',
44
+ ...etc,
45
+ );
46
+
47
+ export const avatarRing: ComponentFunction<AvatarStyleProps> = ({ status, variant, animation }, ...etc) =>
48
+ mx(
49
+ 'absolute inset-0 border-2',
50
+ variant === 'circle' ? 'rounded-full' : 'rounded',
51
+ status === 'current'
52
+ ? 'border-primary-400 dark:border-primary-500'
53
+ : status === 'active'
54
+ ? 'border-emerald-400 dark:border-emerald-400'
55
+ : status === 'error'
56
+ ? 'border-rose-400 dark:border-rose-500'
57
+ : status === 'warning'
58
+ ? 'border-amber-400 dark:border-amber-500'
59
+ : status === 'inactive'
60
+ ? 'border-separator'
61
+ : status === 'internal'
62
+ ? 'border-fuchsia-600'
63
+ : 'border-[color:var(--surface-bg)]',
64
+ animation === 'pulse' ? 'animate-halo-pulse' : '',
65
+ ...etc,
66
+ );
67
+
68
+ export const avatarFallbackText: ComponentFunction<AvatarStyleProps> = (_props, ...etc) => mx('fill-white', ...etc);
69
+
70
+ export const avatarGroup: ComponentFunction<AvatarStyleProps> = (_props, ...etc) =>
71
+ mx('inline-flex items-center', ...etc);
72
+
73
+ export const avatarGroupLabel: ComponentFunction<AvatarStyleProps> = ({ size, srOnly }, ...etc) =>
74
+ mx(
75
+ srOnly
76
+ ? 'sr-only'
77
+ : 'rounded-full truncate text-sm leading-none plb-1 pli-2 relative z-[1] flex items-center justify-center',
78
+ size && getSizeHeight(size),
79
+ ...etc,
80
+ );
81
+
82
+ export const avatarGroupDescription: ComponentFunction<AvatarStyleProps> = ({ srOnly }, ...etc) =>
83
+ mx(srOnly ? 'sr-only' : descriptionText, ...etc);
84
+
85
+ export const avatarTheme: Theme<AvatarStyleProps> = {
86
+ root: avatarRoot,
87
+ label: avatarLabel,
88
+ description: avatarDescription,
89
+ statusIcon: avatarStatusIcon,
90
+ frame: avatarFrame,
91
+ ring: avatarRing,
92
+ fallbackText: avatarFallbackText,
93
+ group: avatarGroup,
94
+ groupLabel: avatarGroupLabel,
95
+ groupDescription: avatarGroupDescription,
96
+ };
@@ -0,0 +1,29 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type ComponentFunction, type Theme } from '@dxos/react-ui-types';
6
+
7
+ import { mx } from '../../util';
8
+
9
+ export type breadcrumbStyleProps = {};
10
+
11
+ export const breadcrumbRoot: ComponentFunction<breadcrumbStyleProps> = (_props, ...etc) =>
12
+ mx('shrink-0 flex items-center', ...etc);
13
+
14
+ export const breadcrumbList: ComponentFunction<breadcrumbStyleProps> = (_props, ...etc) => mx('contents', ...etc);
15
+
16
+ export const breadcrumbListItem: ComponentFunction<breadcrumbStyleProps> = (_props, ...etc) => mx('contents', ...etc);
17
+
18
+ export const breadcrumbCurrent: ComponentFunction<breadcrumbStyleProps> = (_props, ...etc) => mx(...etc);
19
+
20
+ export const breadcrumbSeparator: ComponentFunction<breadcrumbStyleProps> = (_props, ...etc) =>
21
+ mx('opacity-50', ...etc);
22
+
23
+ export const breadcrumbTheme: Theme<breadcrumbStyleProps> = {
24
+ root: breadcrumbRoot,
25
+ list: breadcrumbList,
26
+ listItem: breadcrumbListItem,
27
+ current: breadcrumbCurrent,
28
+ separator: breadcrumbSeparator,
29
+ };
@@ -0,0 +1,48 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ import type { Density, Elevation, ComponentFunction, Theme } from '@dxos/react-ui-types';
6
+
7
+ import { mx } from '../../util';
8
+ import { ghostHover } from '../fragments';
9
+
10
+ export const primaryButtonColors =
11
+ 'text-accentSurfaceText bg-accentSurface hover:bg-accentSurfaceHover aria-pressed:bg-primary-500 dark:aria-pressed:bg-primary-500 data-[state=open]:bg-primary-500 dark:data-[state=open]:bg-primary-500 aria-checked:bg-primary-500 dark:aria-checked:bg-primary-500 aria-checked:text-primary-100';
12
+
13
+ export const staticDefaultButtonColors = 'bg-inputSurface';
14
+
15
+ export const defaultButtonColors = mx(
16
+ staticDefaultButtonColors,
17
+ 'data-[state=open]:bg-inputSurface aria-pressed:text-accentText aria-pressed:bg-baseSurface aria-checked:text-accentText aria-checked:bg-baseSurface',
18
+ );
19
+
20
+ export const ghostButtonColors = mx(
21
+ ghostHover,
22
+ 'hover:text-inherit data-[state=open]:bg-inputSurface aria-pressed:text-accentText aria-pressed:bg-baseSurface aria-checked:text-accentText aria-checked:bg-baseSurface',
23
+ );
24
+
25
+ export type ButtonStyleProps = Partial<{
26
+ inGroup?: boolean;
27
+ textWrap?: boolean;
28
+ density: Density;
29
+ elevation: Elevation;
30
+ disabled: boolean;
31
+ variant: 'default' | 'primary' | 'ghost' | 'outline';
32
+ }>;
33
+
34
+ export const buttonRoot: ComponentFunction<ButtonStyleProps> = (_props, ...etc) => {
35
+ return mx('dx-button dx-focus-ring group', ...etc);
36
+ };
37
+
38
+ export const buttonGroup: ComponentFunction<{ elevation?: Elevation }> = (props, ...etc) => {
39
+ return mx(
40
+ 'inline-flex rounded-sm [&>:first-child]:rounded-is-sm [&>:last-child]:rounded-ie-sm [&>button]:relative',
41
+ ...etc,
42
+ );
43
+ };
44
+
45
+ export const buttonTheme: Theme<ButtonStyleProps> = {
46
+ root: buttonRoot,
47
+ group: buttonGroup,
48
+ };
@@ -0,0 +1,36 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type ComponentFunction, type Elevation, type Theme } from '@dxos/react-ui-types';
6
+
7
+ import { mx } from '../../util';
8
+ import { descriptionText } from '../fragments';
9
+
10
+ export type DialogStyleProps = {
11
+ srOnly?: boolean;
12
+ inOverlayLayout?: boolean;
13
+ elevation?: Elevation;
14
+ };
15
+
16
+ export const dialogOverlay: ComponentFunction<DialogStyleProps> = (_props, ...etc) => mx('dx-dialog__overlay', ...etc);
17
+
18
+ export const dialogContent: ComponentFunction<DialogStyleProps> = ({ inOverlayLayout }, ...etc) =>
19
+ mx(
20
+ 'dx-dialog__content modal-surface density-coarse @container dx-focus-ring',
21
+ !inOverlayLayout && 'fixed z-50 top-[50%] left-[50%] -translate-x-[50%] -translate-y-[50%]',
22
+ ...etc,
23
+ );
24
+
25
+ export const dialogTitle: ComponentFunction<DialogStyleProps> = ({ srOnly }, ...etc) =>
26
+ mx('dx-dialog__title', srOnly && 'sr-only', ...etc);
27
+
28
+ export const dialogDescription: ComponentFunction<DialogStyleProps> = ({ srOnly }, ...etc) =>
29
+ mx('dx-dialog__description', descriptionText, srOnly && 'sr-only', ...etc);
30
+
31
+ export const dialogTheme: Theme<DialogStyleProps> = {
32
+ overlay: dialogOverlay,
33
+ content: dialogContent,
34
+ title: dialogTitle,
35
+ description: dialogDescription,
36
+ };
@@ -0,0 +1,17 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ import type { ComponentFunction, Theme } from '@dxos/react-ui-types';
6
+
7
+ import { type ButtonStyleProps } from './button';
8
+ import { mx } from '../../util';
9
+
10
+ // TODO(burdon): Gap/font size should depend on density.
11
+ export const iconButtonRoot: ComponentFunction<ButtonStyleProps> = (_props, ...etc) => {
12
+ return mx('ch-icon-button dx-focus-ring gap-2', ...etc);
13
+ };
14
+
15
+ export const iconButtonTheme: Theme<ButtonStyleProps> = {
16
+ root: iconButtonRoot,
17
+ };
@@ -0,0 +1,19 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type ComponentFunction, type Size, type Theme } from '@dxos/react-ui-types';
6
+
7
+ import { mx } from '../../util';
8
+ import { getSize } from '../fragments';
9
+
10
+ export type IconStyleProps = {
11
+ size?: Size;
12
+ };
13
+
14
+ export const iconRoot: ComponentFunction<IconStyleProps> = ({ size }, etc) =>
15
+ mx('shrink-0 bs-[1em] is-[1em] text-[var(--icons-color,currentColor)]', size && getSize(size), etc);
16
+
17
+ export const iconTheme: Theme<IconStyleProps> = {
18
+ root: iconRoot,
19
+ };
@@ -0,0 +1,27 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ export * from './anchored-overflow';
6
+ export * from './avatar';
7
+ export * from './breadcrumb';
8
+ export * from './button';
9
+ export * from './dialog';
10
+ export * from './icon';
11
+ export * from './icon-button';
12
+ export * from './input';
13
+ export * from './link';
14
+ export * from './list';
15
+ export * from './main';
16
+ export * from './menu';
17
+ export * from './message';
18
+ export * from './popover';
19
+ export * from './scroll-area';
20
+ export * from './select';
21
+ export * from './separator';
22
+ export * from './status';
23
+ export * from './tag';
24
+ export * from './toast';
25
+ export * from './toolbar';
26
+ export * from './tooltip';
27
+ export * from './treegrid';
@@ -0,0 +1,176 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import {
6
+ type ComponentFragment,
7
+ type ComponentFunction,
8
+ type Density,
9
+ type Elevation,
10
+ type MessageValence,
11
+ type Size,
12
+ } from '@dxos/react-ui-types';
13
+
14
+ import { mx } from '../../util';
15
+ import {
16
+ coarseBlockSize,
17
+ coarseDimensions,
18
+ computeSize,
19
+ descriptionText,
20
+ fineBlockSize,
21
+ fineDimensions,
22
+ focusRing,
23
+ getSize,
24
+ getSizeHeight,
25
+ getSizeWidth,
26
+ placeholderText,
27
+ sizeValue,
28
+ staticFocusRing,
29
+ staticDisabled,
30
+ subduedFocus,
31
+ valenceColorText,
32
+ } from '../fragments';
33
+
34
+ export type InputStyleProps = Partial<{
35
+ variant: 'default' | 'subdued' | 'static';
36
+ density: Density;
37
+ disabled: boolean;
38
+ elevation: Elevation;
39
+ focused: boolean;
40
+ validationValence: MessageValence;
41
+ size: Size;
42
+ checked: boolean;
43
+ }>;
44
+
45
+ export type InputMetaStyleProps = Partial<{
46
+ srOnly: boolean;
47
+ validationValence: MessageValence;
48
+ }>;
49
+
50
+ export const neutralInputValence = '';
51
+ export const successInputValence = 'shadow-emerald-500/50 dark:shadow-emerald-600/50';
52
+ export const infoInputValence = 'shadow-cyan-500/50 dark:shadow-cyan-600/50';
53
+ export const warningInputValence = 'shadow-amber-500/50 dark:shadow-amber-600/50';
54
+ export const errorInputValence = 'shadow-rose-500/50 dark:shadow-rose-600/50';
55
+
56
+ const textInputSurfaceFocus =
57
+ 'transition-colors bg-textInputSurface focus:bg-focusSurface border border-separator focus:border-separator';
58
+
59
+ const textInputSurfaceHover = 'hover:bg-textInputSurface focus:hover:bg-focusSurface';
60
+
61
+ const booleanInputSurface =
62
+ 'shadow-inner transition-colors bg-unAccent aria-checked:bg-accentSurface aria-[checked=mixed]:bg-accentSurface';
63
+
64
+ const booleanInputSurfaceHover =
65
+ 'hover:bg-unAccentHover hover:aria-checked:bg-accentSurfaceHover hover:aria-[checked=mixed]:bg-accentSurfaceHover';
66
+
67
+ export const inputTextLabel = 'text-xs font-medium mbs-inputSpacingBlock mbe-labelSpacingBlock first:mbs-0';
68
+
69
+ export const inputValence = (valence?: MessageValence) => {
70
+ switch (valence) {
71
+ case 'success':
72
+ return successInputValence;
73
+ case 'info':
74
+ return infoInputValence;
75
+ case 'warning':
76
+ return warningInputValence;
77
+ case 'error':
78
+ return errorInputValence;
79
+ default:
80
+ return null;
81
+ }
82
+ };
83
+
84
+ // TODO(burdon): Factor out color defs?
85
+
86
+ const sharedSubduedInputStyles: ComponentFragment<InputStyleProps> = (props) => [
87
+ 'py-0 is-full bg-transparent text-current [[data-drag-autoscroll="active"]_&]:pointer-events-none',
88
+ props.density === 'fine' ? fineBlockSize : coarseBlockSize,
89
+ placeholderText,
90
+ subduedFocus,
91
+ props.disabled && staticDisabled,
92
+ ];
93
+
94
+ const sharedDefaultInputStyles: ComponentFragment<InputStyleProps> = (props) => [
95
+ 'py-0 is-full text-baseText rounded-sm text-[color:var(--surface-text)] [[data-drag-autoscroll="active"]_&]:pointer-events-none',
96
+ textInputSurfaceFocus,
97
+ placeholderText,
98
+ props.density === 'fine' ? fineDimensions : coarseDimensions,
99
+ props.disabled ? staticDisabled : textInputSurfaceHover,
100
+ ];
101
+
102
+ const sharedStaticInputStyles: ComponentFragment<InputStyleProps> = (props) => [
103
+ 'py-0 is-full text-baseText rounded-sm text-[color:var(--surface-text)] [[data-drag-autoscroll="active"]_&]:pointer-events-none',
104
+ textInputSurfaceFocus,
105
+ textInputSurfaceHover,
106
+ props.focused && 'bg-attention',
107
+ placeholderText,
108
+ inputValence(props.validationValence),
109
+ props.disabled && staticDisabled,
110
+ props.focused && staticFocusRing,
111
+ ];
112
+
113
+ export const inputInput: ComponentFunction<InputStyleProps> = (props, ...etc) =>
114
+ props.variant === 'subdued'
115
+ ? mx(...sharedSubduedInputStyles(props), ...etc)
116
+ : props.variant === 'static'
117
+ ? mx(...sharedStaticInputStyles(props), ...etc)
118
+ : mx(
119
+ ...sharedDefaultInputStyles(props),
120
+ !props.disabled && focusRing,
121
+ inputValence(props.validationValence) || neutralInputValence,
122
+ ...etc,
123
+ );
124
+
125
+ export const inputCheckbox: ComponentFunction<InputStyleProps> = ({ size = 5 }, ...etc) =>
126
+ mx('dx-checkbox dx-focus-ring', getSize(size), ...etc);
127
+
128
+ export const inputCheckboxIndicator: ComponentFunction<InputStyleProps> = ({ size = 5, checked }, ...etc) =>
129
+ mx(getSize(computeSize(sizeValue(size) * 0.65, 4)), !checked && 'invisible', ...etc);
130
+
131
+ export const inputSwitch: ComponentFunction<InputStyleProps> = ({ size = 5, disabled }, ...etc) =>
132
+ mx(
133
+ getSizeHeight(size),
134
+ getSizeWidth(computeSize(sizeValue(size) * 1.75, 9)),
135
+ booleanInputSurface,
136
+ !disabled && booleanInputSurfaceHover,
137
+ // TODO(burdon): Added m-1 margin to make 40px width to align with 40px icon button.
138
+ 'cursor-pointer shrink-0 rounded-full pli-1 mx-1 relative',
139
+ focusRing,
140
+ ...etc,
141
+ );
142
+
143
+ export const inputSwitchThumb: ComponentFunction<InputStyleProps> = ({ size = 5 }, ...etc) =>
144
+ mx(
145
+ getSize(size === 'px' ? 'px' : ((size - 2) as Size)),
146
+ 'block bg-white rounded-full transition-transform duration-100 will-change-transform data-[state=checked]:translate-x-[100%]',
147
+ ...etc,
148
+ );
149
+
150
+ export const inputWithSegmentsInput: ComponentFunction<InputStyleProps> = (props, ...etc) =>
151
+ mx('font-mono selection:bg-transparent mli-auto', props.disabled && 'cursor-not-allowed', ...etc);
152
+
153
+ export const inputLabel: ComponentFunction<InputMetaStyleProps> = (props, ...etc) =>
154
+ mx('block', inputTextLabel, props.srOnly && 'sr-only', ...etc);
155
+
156
+ export const inputDescription: ComponentFunction<InputMetaStyleProps> = (props, ...etc) =>
157
+ mx(descriptionText, props.srOnly && 'sr-only', ...etc);
158
+
159
+ export const inputDescriptionAndValidation: ComponentFunction<InputMetaStyleProps> = (props, ...etc) =>
160
+ mx('leading-none mlb-labelSpacingBlock', props.srOnly && 'sr-only', ...etc);
161
+
162
+ export const inputValidation: ComponentFunction<InputMetaStyleProps> = (props, ...etc) =>
163
+ mx(descriptionText, props.srOnly ? 'sr-only' : valenceColorText(props.validationValence), ...etc);
164
+
165
+ export const inputTheme = {
166
+ input: inputInput,
167
+ inputWithSegments: inputWithSegmentsInput,
168
+ checkbox: inputCheckbox,
169
+ checkboxIndicator: inputCheckboxIndicator,
170
+ label: inputLabel,
171
+ description: inputDescription,
172
+ validation: inputValidation,
173
+ switch: inputSwitch,
174
+ switchThumb: inputSwitchThumb,
175
+ descriptionAndValidation: inputDescriptionAndValidation,
176
+ };
@@ -0,0 +1,26 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type ComponentFunction, type Theme } from '@dxos/react-ui-types';
6
+
7
+ import { mx } from '../../util';
8
+ import { focusRing } from '../fragments';
9
+
10
+ export type LinkStyleProps = {
11
+ variant?: 'accent' | 'neutral';
12
+ };
13
+
14
+ export const linkRoot: ComponentFunction<LinkStyleProps> = ({ variant }, ...etc) =>
15
+ mx(
16
+ 'underline decoration-1 underline-offset-2 transition-color rounded-sm',
17
+ variant === 'neutral'
18
+ ? 'text-inherit hover:opacity-90 visited:text-inherit visited:hover:opacity-90'
19
+ : 'text-accentText hover:text-accentTextHover visited:text-accentText visited:hover:text-accentTextHover',
20
+ focusRing,
21
+ ...etc,
22
+ );
23
+
24
+ export const linkTheme: Theme<LinkStyleProps> = {
25
+ root: linkRoot,
26
+ };
@@ -0,0 +1,46 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type ComponentFunction, type Density, type Theme } from '@dxos/react-ui-types';
6
+
7
+ import { mx } from '../../util';
8
+ import { focusRing, densityBlockSize, getSize, ghostHover } from '../fragments';
9
+
10
+ export type ListStyleProps = Partial<{
11
+ density: Density;
12
+ collapsible: boolean;
13
+ }>;
14
+
15
+ export const listRoot: ComponentFunction<ListStyleProps> = (_, ...etc) => mx(...etc);
16
+
17
+ export const listItem: ComponentFunction<ListStyleProps> = ({ collapsible }, ...etc) =>
18
+ mx(!collapsible && 'flex', ...etc);
19
+
20
+ export const listItemEndcap: ComponentFunction<ListStyleProps> = ({ density }, ...etc) =>
21
+ mx(density === 'fine' ? getSize(8) : getSize(10), 'shrink-0 flex items-start justify-center', ...etc);
22
+
23
+ export const listItemHeading: ComponentFunction<ListStyleProps> = ({ density }, ...etc) =>
24
+ mx(densityBlockSize(density), ...etc);
25
+
26
+ export const listItemDragHandleIcon: ComponentFunction<ListStyleProps> = (_props, ...etc) =>
27
+ mx(getSize(5), 'mbs-2.5', ...etc);
28
+
29
+ export const listItemOpenTrigger: ComponentFunction<ListStyleProps> = ({ density }, ...etc) =>
30
+ mx('is-5 rounded flex justify-center items-center', densityBlockSize(density), ghostHover, focusRing, ...etc);
31
+
32
+ export const listItemOpenTriggerIcon: ComponentFunction<ListStyleProps> = (_props, ...etc) => {
33
+ return mx(getSize(5), ...etc);
34
+ };
35
+
36
+ export const listTheme: Theme<ListStyleProps> = {
37
+ root: listRoot,
38
+ item: {
39
+ root: listItem,
40
+ endcap: listItemEndcap,
41
+ heading: listItemHeading,
42
+ dragHandleIcon: listItemDragHandleIcon,
43
+ openTrigger: listItemOpenTrigger,
44
+ openTriggerIcon: listItemOpenTriggerIcon,
45
+ },
46
+ };
@@ -0,0 +1,36 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type ComponentFunction } from '@dxos/react-ui-types';
6
+
7
+ import { mx } from '../../util';
8
+
9
+ // Padding to apply to in-flow elements which need to clear the fixed topbar / bottombar.
10
+ export const topbarBlockPaddingStart = 'pbs-[--topbar-size] sticky-top-from-topbar-bottom';
11
+ export const bottombarBlockPaddingEnd = 'pbe-[--statusbar-size] sticky-bottom-from-statusbar-bottom';
12
+
13
+ export type MainStyleProps = Partial<{
14
+ bounce: boolean;
15
+ handlesFocus: boolean;
16
+ }>;
17
+
18
+ export const mainSidebar: ComponentFunction<MainStyleProps> = (_, ...etc) =>
19
+ mx('dx-main-sidebar', 'dx-focus-ring-inset-over-all', ...etc);
20
+
21
+ export const mainPadding = 'dx-main-content-padding';
22
+
23
+ export const mainPaddingTransitions = 'dx-main-content-padding-transitions';
24
+
25
+ export const mainContent: ComponentFunction<MainStyleProps> = ({ bounce }, ...etc) =>
26
+ mx(mainPadding, mainPaddingTransitions, bounce && 'dx-main-bounce-layout', 'dx-focus-ring-main', ...etc);
27
+
28
+ export const mainIntrinsicSize = 'dx-main-intrinsic-size';
29
+
30
+ export const mainOverlay: ComponentFunction<MainStyleProps> = (_, ...etc) => mx('dx-main-overlay', ...etc);
31
+
32
+ export const mainTheme = {
33
+ content: mainContent,
34
+ sidebar: mainSidebar,
35
+ overlay: mainOverlay,
36
+ };