@monimesl/dot-renderer-react 1.0.0-beta.7 → 1.0.0-beta.8

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 (43) hide show
  1. package/dist/components/amount-input.js +1 -1
  2. package/dist/components/avatar.js +1 -1
  3. package/dist/components/box.js +8 -2
  4. package/dist/components/button.js +64 -14
  5. package/dist/components/carousel.js +4 -4
  6. package/dist/components/chip.js +3 -3
  7. package/dist/components/code-input.js +1 -1
  8. package/dist/components/detail-row.js +5 -5
  9. package/dist/components/disclosure.js +4 -4
  10. package/dist/components/empty-state.js +7 -6
  11. package/dist/components/feedback.js +7 -7
  12. package/dist/components/field-box.js +1 -1
  13. package/dist/components/field.js +5 -4
  14. package/dist/components/footer.js +3 -3
  15. package/dist/components/grid.js +16 -13
  16. package/dist/components/icon-button.js +1 -1
  17. package/dist/components/icon.js +32 -5
  18. package/dist/components/input.js +1 -1
  19. package/dist/components/list.js +10 -8
  20. package/dist/components/option.js +3 -3
  21. package/dist/components/padding.js +9 -10
  22. package/dist/components/prose.js +23 -20
  23. package/dist/components/scroll.js +4 -3
  24. package/dist/components/select.js +1 -1
  25. package/dist/components/sheet.js +8 -7
  26. package/dist/components/skeleton.js +1 -1
  27. package/dist/components/slider.js +3 -3
  28. package/dist/components/spinner.js +1 -1
  29. package/dist/components/stepper.js +3 -3
  30. package/dist/components/steps.js +17 -14
  31. package/dist/components/tabs.js +7 -7
  32. package/dist/components/text.js +10 -14
  33. package/dist/components/toast.js +3 -3
  34. package/dist/components/toggles.js +13 -9
  35. package/dist/components/tokens.d.ts +16 -0
  36. package/dist/components/tokens.js +11 -1
  37. package/dist/components/view.js +16 -7
  38. package/dist/page-root.js +9 -3
  39. package/dist/pull-to-refresh.js +1 -1
  40. package/dist/root.js +3 -3
  41. package/dist/theme.d.ts +11 -1
  42. package/dist/theme.js +80 -14
  43. package/package.json +4 -4
package/dist/root.js CHANGED
@@ -1,4 +1,4 @@
1
- import { FONT_FAMILY, ThemeContext, resolveTheme, useTheme } from "./theme.js";
1
+ import { ThemeContext, resolveTheme, useTheme } from "./theme.js";
2
2
  import { HOME_INDICATOR } from "./components/padding.js";
3
3
  import { PortalContainerContext } from "./portal.js";
4
4
  import { PageRoot } from "./page-root.js";
@@ -51,7 +51,7 @@ function withPageColors(theme, scheme, pageColors) {
51
51
  };
52
52
  }
53
53
  function DefaultSurface({ children }) {
54
- const { colors } = useTheme();
54
+ const { colors, fontFamily } = useTheme();
55
55
  return /* @__PURE__ */ jsx("div", {
56
56
  className: "dot-surface",
57
57
  style: {
@@ -62,7 +62,7 @@ function DefaultSurface({ children }) {
62
62
  flexDirection: "column",
63
63
  background: colors.background,
64
64
  color: colors.text,
65
- fontFamily: FONT_FAMILY
65
+ fontFamily
66
66
  },
67
67
  children
68
68
  });
package/dist/theme.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { ColorScheme, PageColors, Theme, ThemeShape } from "@monimesl/dot-core";
1
+ import { FONT_SIZE, SPACE } from "./components/tokens.js";
2
+ import { ColorScheme, PageColors, Theme, ThemeComponents, ThemeElevation, ThemeShape, ThemeWeight } from "@monimesl/dot-core";
2
3
  //#region src/theme.d.ts
3
4
  export interface ResolvedColors {
4
5
  primary: string;
@@ -20,6 +21,15 @@ export interface ResolvedTheme {
20
21
  customColors: Readonly<Record<string, string>>;
21
22
  shape: ThemeShape;
22
23
  radius: number;
24
+ fontFamily: string;
25
+ headingFontFamily: string;
26
+ headingWeight: ThemeWeight | undefined;
27
+ fontSize: Readonly<Record<keyof typeof FONT_SIZE, number>>;
28
+ components: ThemeComponents;
29
+ icons: Readonly<Record<string, string>>;
30
+ gradients: Readonly<Record<string, string>>;
31
+ space: Readonly<Record<keyof typeof SPACE, number>>;
32
+ elevation: ThemeElevation;
23
33
  }
24
34
  export declare function resolveTheme(theme: Theme, systemScheme: ColorScheme, pageColors?: PageColors): ResolvedTheme;
25
35
  export declare function useTheme(): ResolvedTheme;
package/dist/theme.js CHANGED
@@ -1,8 +1,29 @@
1
+ import { FONT_SIZE, SPACE } from "./components/tokens.js";
1
2
  import { darken, mix } from "./color.js";
2
3
  import { DEFAULT_BACKGROUND, READABLE_CONTRAST, contrast, isDark, pageBackground, textOn, themeScheme } from "@monimesl/dot-core";
3
4
  import { createContext, useContext } from "react";
4
5
  //#region src/theme.ts
5
- const FONT_FAMILY = "system-ui, sans-serif";
6
+ const DENSITY_SCALE = {
7
+ compact: .75,
8
+ regular: 1,
9
+ comfortable: 1.25
10
+ };
11
+ const TEXT_SCALE = {
12
+ small: .9,
13
+ regular: 1,
14
+ large: 1.1
15
+ };
16
+ const GRADIENT_DIRECTIONS = {
17
+ down: "to bottom",
18
+ right: "to right",
19
+ diagonal: "to bottom right"
20
+ };
21
+ const FONT_FAMILIES = {
22
+ system: "system-ui, sans-serif",
23
+ rounded: "ui-rounded, \"SF Pro Rounded\", system-ui, sans-serif",
24
+ serif: "ui-serif, \"New York\", Georgia, serif",
25
+ mono: "ui-monospace, \"SF Mono\", Menlo, monospace"
26
+ };
6
27
  const SHAPE_RADIUS = {
7
28
  square: 0,
8
29
  subtle: 4,
@@ -52,21 +73,66 @@ function resolveTheme(theme, systemScheme, pageColors = {}) {
52
73
  let subtle = defaults.subtle;
53
74
  if (!onDashBackground) subtle = quieterText(text, background, surface);
54
75
  const primary = ownColor("primary") ?? defaults.primary;
76
+ const colors = {
77
+ ...defaults,
78
+ ...primaryAndOnPrimary(primary, surface, text, scheme),
79
+ background,
80
+ surface,
81
+ text,
82
+ muted: ownColor("muted") ?? surfaces.muted,
83
+ border: ownColor("border") ?? surfaces.border,
84
+ subtle: ownColor("subtle") ?? subtle,
85
+ info: ownColor("info") ?? defaults.info,
86
+ success: ownColor("success") ?? defaults.success,
87
+ warning: ownColor("warning") ?? defaults.warning,
88
+ danger: ownColor("danger") ?? defaults.danger
89
+ };
90
+ const customColors = resolveCustomColors(themeColors.custom ?? {}, scheme);
91
+ const fontFamily = FONT_FAMILIES[theme.font ?? "system"] ?? FONT_FAMILIES.system;
92
+ let headingFontFamily = fontFamily;
93
+ if (theme.headingFont) headingFontFamily = FONT_FAMILIES[theme.headingFont] ?? fontFamily;
55
94
  return {
56
95
  scheme,
57
- colors: {
58
- ...defaults,
59
- ...primaryAndOnPrimary(primary, surface, text, scheme),
60
- background,
61
- surface,
62
- text,
63
- muted: ownColor("muted") ?? surfaces.muted,
64
- border: ownColor("border") ?? surfaces.border,
65
- subtle: ownColor("subtle") ?? subtle
66
- },
67
- customColors: resolveCustomColors(themeColors.custom ?? {}, scheme),
96
+ colors,
97
+ customColors,
68
98
  shape,
69
- radius: SHAPE_RADIUS[shape]
99
+ radius: SHAPE_RADIUS[shape],
100
+ fontFamily,
101
+ headingFontFamily,
102
+ headingWeight: theme.headingWeight,
103
+ fontSize: scaledFontSize(TEXT_SCALE[theme.textSize ?? "regular"] ?? 1),
104
+ components: theme.components ?? {},
105
+ icons: theme.icons ?? {},
106
+ gradients: resolveGradients(theme.gradients ?? {}, colors, customColors),
107
+ space: scaledSpace(DENSITY_SCALE[theme.density ?? "regular"] ?? 1),
108
+ elevation: theme.elevation === "raised" ? "raised" : "flat"
109
+ };
110
+ }
111
+ function scaledFontSize(scale) {
112
+ const sizes = { ...FONT_SIZE };
113
+ for (const variant of Object.keys(sizes)) sizes[variant] = Math.round(FONT_SIZE[variant] * scale);
114
+ return sizes;
115
+ }
116
+ function resolveGradients(gradients, colors, customColors) {
117
+ const resolved = {};
118
+ for (const [name, gradient] of Object.entries(gradients)) {
119
+ const from = themeColor(gradient.from, colors, customColors);
120
+ const to = themeColor(gradient.to, colors, customColors);
121
+ const direction = GRADIENT_DIRECTIONS[gradient.direction ?? "down"] ?? GRADIENT_DIRECTIONS.down;
122
+ if (from && to) resolved[name] = `linear-gradient(${direction}, ${from}, ${to})`;
123
+ }
124
+ return resolved;
125
+ }
126
+ function themeColor(name, colors, customColors) {
127
+ if (Object.hasOwn(colors, name)) return colors[name];
128
+ if (Object.hasOwn(customColors, name)) return customColors[name];
129
+ }
130
+ function scaledSpace(scale) {
131
+ return {
132
+ none: SPACE.none,
133
+ small: Math.round(SPACE.small * scale),
134
+ medium: Math.round(SPACE.medium * scale),
135
+ large: Math.round(SPACE.large * scale)
70
136
  };
71
137
  }
72
138
  function surfacesOn(background) {
@@ -126,4 +192,4 @@ function useTheme() {
126
192
  return useContext(ThemeContext);
127
193
  }
128
194
  //#endregion
129
- export { FONT_FAMILY, ThemeContext, resolveTheme, useTheme };
195
+ export { ThemeContext, resolveTheme, useTheme };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monimesl/dot-renderer-react",
3
- "version": "1.0.0-beta.7",
3
+ "version": "1.0.0-beta.8",
4
4
  "description": "React renderer for Dot webviews",
5
5
  "type": "module",
6
6
  "repository": {
@@ -29,8 +29,8 @@
29
29
  "react": "19.3.0",
30
30
  "react-dom": "19.3.0",
31
31
  "uqr": "^0.1.3",
32
- "@monimesl/dot-core": "1.0.0-beta.7",
33
- "@monimesl/dot-webview": "1.0.0-beta.7"
32
+ "@monimesl/dot-core": "1.0.0-beta.8",
33
+ "@monimesl/dot-webview": "1.0.0-beta.8"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@base-ui/react": "1.8.0",
@@ -46,7 +46,7 @@
46
46
  "tsdown": "^0.23.0",
47
47
  "typescript": "^5.9.3",
48
48
  "vitest": "^5.0.1",
49
- "@monimesl/dot-service": "1.0.0-beta.7"
49
+ "@monimesl/dot-service": "1.0.0-beta.8"
50
50
  },
51
51
  "publishConfig": {
52
52
  "access": "public"