@puzzle-ui/theme 0.0.0-stage → 0.2.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 (87) hide show
  1. package/README.md +112 -2
  2. package/dist/LICENSE +21 -0
  3. package/dist/breakpoints.cjs +10 -0
  4. package/dist/breakpoints.cjs.map +1 -0
  5. package/dist/breakpoints.d.cts +7 -0
  6. package/dist/breakpoints.d.ts +7 -0
  7. package/dist/breakpoints.js +10 -0
  8. package/dist/breakpoints.js.map +1 -0
  9. package/dist/components-context.cjs +19 -0
  10. package/dist/components-context.cjs.map +1 -0
  11. package/dist/components-context.d.cts +8 -0
  12. package/dist/components-context.d.ts +8 -0
  13. package/dist/components-context.js +17 -0
  14. package/dist/components-context.js.map +1 -0
  15. package/dist/components.types.d.cts +46 -0
  16. package/dist/components.types.d.ts +46 -0
  17. package/dist/constants.cjs +567 -0
  18. package/dist/constants.cjs.map +1 -0
  19. package/dist/constants.d.cts +363 -0
  20. package/dist/constants.d.ts +363 -0
  21. package/dist/constants.js +565 -0
  22. package/dist/constants.js.map +1 -0
  23. package/dist/create-theme-css.cjs +7 -0
  24. package/dist/create-theme-css.cjs.map +1 -0
  25. package/dist/create-theme-css.js +7 -0
  26. package/dist/create-theme-css.js.map +1 -0
  27. package/dist/create-theme-variables.cjs +135 -0
  28. package/dist/create-theme-variables.cjs.map +1 -0
  29. package/dist/create-theme-variables.js +134 -0
  30. package/dist/create-theme-variables.js.map +1 -0
  31. package/dist/fonts/constants.cjs +9 -0
  32. package/dist/fonts/constants.cjs.map +1 -0
  33. package/dist/fonts/constants.js +9 -0
  34. package/dist/fonts/constants.js.map +1 -0
  35. package/dist/fonts/create-google-font-url.cjs +27 -0
  36. package/dist/fonts/create-google-font-url.cjs.map +1 -0
  37. package/dist/fonts/create-google-font-url.d.cts +2 -0
  38. package/dist/fonts/create-google-font-url.d.ts +2 -0
  39. package/dist/fonts/create-google-font-url.js +27 -0
  40. package/dist/fonts/create-google-font-url.js.map +1 -0
  41. package/dist/fonts/google-font-familiy.d.cts +1 -0
  42. package/dist/fonts/google-font-familiy.d.ts +1 -0
  43. package/dist/fonts/google-font.cjs +42 -0
  44. package/dist/fonts/google-font.cjs.map +1 -0
  45. package/dist/fonts/google-font.d.cts +4 -0
  46. package/dist/fonts/google-font.d.ts +4 -0
  47. package/dist/fonts/google-font.js +42 -0
  48. package/dist/fonts/google-font.js.map +1 -0
  49. package/dist/fonts/index.d.cts +4 -0
  50. package/dist/fonts/resolve-font-config.cjs +28 -0
  51. package/dist/fonts/resolve-font-config.cjs.map +1 -0
  52. package/dist/fonts/resolve-font-config.js +28 -0
  53. package/dist/fonts/resolve-font-config.js.map +1 -0
  54. package/dist/fonts/resolve-font-stylesheets.cjs +47 -0
  55. package/dist/fonts/resolve-font-stylesheets.cjs.map +1 -0
  56. package/dist/fonts/resolve-font-stylesheets.js +47 -0
  57. package/dist/fonts/resolve-font-stylesheets.js.map +1 -0
  58. package/dist/fonts/types.d.cts +28 -0
  59. package/dist/fonts/types.d.ts +28 -0
  60. package/dist/fonts/typography.cjs +172 -0
  61. package/dist/fonts/typography.cjs.map +1 -0
  62. package/dist/fonts/typography.d.cts +2 -0
  63. package/dist/fonts/typography.d.ts +2 -0
  64. package/dist/fonts/typography.js +170 -0
  65. package/dist/fonts/typography.js.map +1 -0
  66. package/dist/global.css +135 -0
  67. package/dist/index.cjs +9 -0
  68. package/dist/index.d.cts +10 -0
  69. package/dist/index.d.ts +9 -0
  70. package/dist/index.js +5 -0
  71. package/dist/scope-context.cjs +58 -0
  72. package/dist/scope-context.cjs.map +1 -0
  73. package/dist/scope-context.d.cts +14 -0
  74. package/dist/scope-context.d.ts +14 -0
  75. package/dist/scope-context.js +56 -0
  76. package/dist/scope-context.js.map +1 -0
  77. package/dist/theme-scopes.css +90 -0
  78. package/dist/theme.cjs +56 -0
  79. package/dist/theme.cjs.map +1 -0
  80. package/dist/theme.css +194 -0
  81. package/dist/theme.d.cts +18 -0
  82. package/dist/theme.d.ts +17 -0
  83. package/dist/theme.js +56 -0
  84. package/dist/theme.js.map +1 -0
  85. package/dist/types.d.cts +185 -0
  86. package/dist/types.d.ts +185 -0
  87. package/package.json +73 -4
package/README.md CHANGED
@@ -1,3 +1,113 @@
1
- # Temporary Holding Version
1
+ # @puzzle-ui/theme
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Puzzle's theme system: semantic design tokens, light/dark color schemes,
4
+ typography, Google Fonts, and configurable link and image components.
5
+
6
+ > Puzzle is under active development. APIs and framework compatibility may
7
+ > change; use it for experimentation and evaluation rather than production.
8
+
9
+ ## Installation
10
+
11
+ ```sh
12
+ npm install @puzzle-ui/theme
13
+ # or
14
+ bun add @puzzle-ui/theme
15
+ # or
16
+ pnpm add @puzzle-ui/theme
17
+ # or
18
+ yarn add @puzzle-ui/theme
19
+ ```
20
+
21
+ Requires React and React DOM 19 (`^19.0.0`) and a CSS-aware application
22
+ bundler. Styles are imported by the package; no separate stylesheet or
23
+ Tailwind setup is required.
24
+
25
+ ## Usage
26
+
27
+ ```tsx
28
+ import { Theme } from "@puzzle-ui/theme";
29
+
30
+ export const App = () => (
31
+ <Theme
32
+ theme="system"
33
+ tokens={{ radius: { md: "0.5rem" } }}
34
+ >
35
+ <main>Your application</main>
36
+ </Theme>
37
+ );
38
+ ```
39
+
40
+ Use one root theme for your application. By default it follows the system
41
+ color scheme, emits `--puzzle-*` CSS custom properties, and applies global
42
+ styles. Set `globalStyles={false}` to opt out of the global defaults.
43
+
44
+ ## Configuration
45
+
46
+ | Prop | Purpose |
47
+ | --- | --- |
48
+ | `theme` | `"light"`, `"dark"`, or `"system"`; defaults to `"system"`. |
49
+ | `scope` | `"root"` for document-wide styling or `"local"` for a subtree. |
50
+ | `tokens` | Deep-partial overrides of color, typography, spacing, radius, layout, motion, and other design tokens. |
51
+ | `colorTheme` | Select a built-in palette, such as `"cobalt-sky"`. |
52
+ | `fonts` | Configure Google Fonts for heading, body, and accent roles. |
53
+ | `components` | Override link and image rendering. |
54
+ | `nonce` | CSP nonce for injected style elements. |
55
+
56
+ Local themes do not apply global styles. Fonts configured through `fonts`
57
+ load external Google Fonts stylesheets; omit this prop to avoid those
58
+ requests.
59
+
60
+ ## Use tokens in your styles
61
+
62
+ ```css
63
+ .panel {
64
+ color: var(--puzzle-color-text);
65
+ background: var(--puzzle-color-surface);
66
+ padding: var(--puzzle-space-4);
67
+ border-radius: var(--puzzle-radius-md);
68
+ }
69
+ ```
70
+
71
+ ## Router integration
72
+
73
+ For routers whose links use `to`, configure the destination prop:
74
+
75
+ ```tsx
76
+ import { Link } from "@tanstack/react-router";
77
+
78
+ <Theme components={{ link: { component: Link, hrefProp: "to" } }}>
79
+ <AppContent />
80
+ </Theme>;
81
+ ```
82
+
83
+ Components using `href` can be passed directly. Use `link: null` or
84
+ `image: null` to restore native elements in a subtree.
85
+
86
+ ## Exports
87
+
88
+ The root exports `Theme`, `GoogleFont`, `createGoogleFontUrl`, `BREAKPOINTS`,
89
+ and their configuration types. Context helpers are available through
90
+ `@puzzle-ui/theme/components-context` and `@puzzle-ui/theme/scope-context`.
91
+
92
+ ESM and CommonJS builds with matching TypeScript declarations are included.
93
+ CSS imports require a bundler rather than a bare Node.js runtime.
94
+
95
+ See the repository's [theme documentation](../../apps/site/content/docs/theme)
96
+ for token references, fonts, colors, and component overrides.
97
+
98
+ ## Development
99
+
100
+ ```sh
101
+ # From the repository root
102
+ npm run build --workspace=@puzzle-ui/theme
103
+
104
+ # From this package directory
105
+ bun run vitest
106
+ ```
107
+
108
+ `prepack` rebuilds the package before packing or publishing. See the root
109
+ [publishing guide](../../README.md#publishing-packages).
110
+
111
+ ## License
112
+
113
+ MIT. See [LICENSE](../../LICENSE); the published license is at `dist/LICENSE`.
package/dist/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sjoerd van Den Berg
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,10 @@
1
+ // src/breakpoints.ts
2
+ const BREAKPOINTS = {
3
+ compact: 480,
4
+ tablet: 768,
5
+ desktop: 1024,
6
+ hd: 1440
7
+ };
8
+ exports.BREAKPOINTS = BREAKPOINTS;
9
+
10
+ //# sourceMappingURL=breakpoints.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"breakpoints.cjs","names":[],"sources":["../src/breakpoints.ts"],"sourcesContent":["export const BREAKPOINTS = {\n compact: 480,\n tablet: 768,\n desktop: 1024,\n hd: 1440,\n} as const;\n\nexport type Breakpoint = keyof typeof BREAKPOINTS;\n"],"mappings":";AAAA,MAAa,cAAc;CACzB,SAAS;CACT,QAAQ;CACR,SAAS;CACT,IAAI;AACN"}
@@ -0,0 +1,7 @@
1
+ export declare const BREAKPOINTS: {
2
+ readonly compact: 480;
3
+ readonly tablet: 768;
4
+ readonly desktop: 1024;
5
+ readonly hd: 1440;
6
+ };
7
+ export type Breakpoint = keyof typeof BREAKPOINTS;
@@ -0,0 +1,7 @@
1
+ export declare const BREAKPOINTS: {
2
+ readonly compact: 480;
3
+ readonly tablet: 768;
4
+ readonly desktop: 1024;
5
+ readonly hd: 1440;
6
+ };
7
+ export type Breakpoint = keyof typeof BREAKPOINTS;
@@ -0,0 +1,10 @@
1
+ // src/breakpoints.ts
2
+ const BREAKPOINTS = {
3
+ compact: 480,
4
+ tablet: 768,
5
+ desktop: 1024,
6
+ hd: 1440
7
+ };
8
+ export { BREAKPOINTS };
9
+
10
+ //# sourceMappingURL=breakpoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"breakpoints.js","names":[],"sources":["../src/breakpoints.ts"],"sourcesContent":["export const BREAKPOINTS = {\n compact: 480,\n tablet: 768,\n desktop: 1024,\n hd: 1440,\n} as const;\n\nexport type Breakpoint = keyof typeof BREAKPOINTS;\n"],"mappings":";AAAA,MAAa,cAAc;CACzB,SAAS;CACT,QAAQ;CACR,SAAS;CACT,IAAI;AACN"}
@@ -0,0 +1,19 @@
1
+ "use client";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ let react_jsx_runtime = require("react/jsx-runtime");
4
+ let react = require("react");
5
+ // src/components-context.tsx
6
+ const ThemeComponentsContext = (0, react.createContext)(void 0);
7
+ const ThemeComponentsProvider = ({ components, children }) => {
8
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThemeComponentsContext.Provider, {
9
+ value: components,
10
+ children
11
+ });
12
+ };
13
+ const useThemeComponents = () => {
14
+ return (0, react.useContext)(ThemeComponentsContext);
15
+ };
16
+ exports.ThemeComponentsProvider = ThemeComponentsProvider;
17
+ exports.useThemeComponents = useThemeComponents;
18
+
19
+ //# sourceMappingURL=components-context.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components-context.cjs","names":["createContext","useContext"],"sources":["../src/components-context.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext, type PropsWithChildren } from \"react\";\nimport type { ThemeComponents } from \"./components.types\";\n\nconst ThemeComponentsContext = createContext<ThemeComponents | undefined>(\n undefined,\n);\n\ntype ThemeComponentsProviderProps = PropsWithChildren<{\n components: ThemeComponents;\n}>;\n\nconst ThemeComponentsProvider = ({\n components,\n children,\n}: ThemeComponentsProviderProps) => {\n return (\n <ThemeComponentsContext.Provider value={components}>\n {children}\n </ThemeComponentsContext.Provider>\n );\n};\n\nconst useThemeComponents = () => {\n return useContext(ThemeComponentsContext);\n};\n\nexport { ThemeComponentsProvider, useThemeComponents };\n"],"mappings":";;;;;AAKA,MAAM,0BAAA,GAAyBA,MAAAA,cAAAA,CAC7B,KAAA,CACF;AAMA,MAAM,2BAA2B,EAC/B,YACA,eACkC;CAClC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,uBAAuB,UAAxB;EAAiC,OAAO;EACrC;CAC8B,CAAA;AAErC;AAEA,MAAM,2BAA2B;CAC/B,QAAA,GAAOC,MAAAA,WAAAA,CAAW,sBAAsB;AAC1C"}
@@ -0,0 +1,8 @@
1
+ import { ThemeComponents } from "./components.types.cjs";
2
+ import { PropsWithChildren } from "react";
3
+ type ThemeComponentsProviderProps = PropsWithChildren<{
4
+ components: ThemeComponents;
5
+ }>;
6
+ declare const ThemeComponentsProvider: ({ components, children }: ThemeComponentsProviderProps) => import("react").JSX.Element;
7
+ declare const useThemeComponents: () => ThemeComponents | undefined;
8
+ export { ThemeComponentsProvider, useThemeComponents };
@@ -0,0 +1,8 @@
1
+ import { ThemeComponents } from "./components.types.js";
2
+ import { PropsWithChildren } from "react";
3
+ type ThemeComponentsProviderProps = PropsWithChildren<{
4
+ components: ThemeComponents;
5
+ }>;
6
+ declare const ThemeComponentsProvider: ({ components, children }: ThemeComponentsProviderProps) => import("react").JSX.Element;
7
+ declare const useThemeComponents: () => ThemeComponents | undefined;
8
+ export { ThemeComponentsProvider, useThemeComponents };
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext } from "react";
4
+ // src/components-context.tsx
5
+ const ThemeComponentsContext = createContext(void 0);
6
+ const ThemeComponentsProvider = ({ components, children }) => {
7
+ return /* @__PURE__ */ jsx(ThemeComponentsContext.Provider, {
8
+ value: components,
9
+ children
10
+ });
11
+ };
12
+ const useThemeComponents = () => {
13
+ return useContext(ThemeComponentsContext);
14
+ };
15
+ export { ThemeComponentsProvider, useThemeComponents };
16
+
17
+ //# sourceMappingURL=components-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components-context.js","names":[],"sources":["../src/components-context.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext, type PropsWithChildren } from \"react\";\nimport type { ThemeComponents } from \"./components.types\";\n\nconst ThemeComponentsContext = createContext<ThemeComponents | undefined>(\n undefined,\n);\n\ntype ThemeComponentsProviderProps = PropsWithChildren<{\n components: ThemeComponents;\n}>;\n\nconst ThemeComponentsProvider = ({\n components,\n children,\n}: ThemeComponentsProviderProps) => {\n return (\n <ThemeComponentsContext.Provider value={components}>\n {children}\n </ThemeComponentsContext.Provider>\n );\n};\n\nconst useThemeComponents = () => {\n return useContext(ThemeComponentsContext);\n};\n\nexport { ThemeComponentsProvider, useThemeComponents };\n"],"mappings":";;;;AAKA,MAAM,yBAAyB,cAC7B,KAAA,CACF;AAMA,MAAM,2BAA2B,EAC/B,YACA,eACkC;CAClC,OACE,oBAAC,uBAAuB,UAAxB;EAAiC,OAAO;EACrC;CAC8B,CAAA;AAErC;AAEA,MAAM,2BAA2B;CAC/B,OAAO,WAAW,sBAAsB;AAC1C"}
@@ -0,0 +1,46 @@
1
+ import { ElementType } from "react";
2
+ /**
3
+ * Configuration for a custom Link component.
4
+ *
5
+ * Use this form when the component uses a different prop name
6
+ * for its destination, such as TanStack Router's `to`.
7
+ */
8
+ export type ThemeLinkComponentConfig = {
9
+ /** The component used to render links. */
10
+ component: ElementType;
11
+ /**
12
+ * The prop used by the component for its destination.
13
+ *
14
+ * Defaults to "href".
15
+ */
16
+ hrefProp?: "href" | "to";
17
+ };
18
+ /**
19
+ * Component used to render Puzzle links.
20
+ *
21
+ * A component can either follow the standard `href` contract
22
+ * or use an explicit configuration object.
23
+ *
24
+ * When passing components through a React Server Component boundary,
25
+ * use a component reference exported from a "use client" module.
26
+ */
27
+ export type ThemeLinkComponent = ElementType | ThemeLinkComponentConfig | null;
28
+ /**
29
+ * Component used to render Puzzle images.
30
+ *
31
+ * Defaults to the native HTML img element.
32
+ *
33
+ * This can be overridden with framework-specific image components,
34
+ * such as Next.js Image or a custom image CDN component.
35
+ *
36
+ * When passing components through a React Server Component boundary,
37
+ * use a component reference exported from a "use client" module.
38
+ */
39
+ export type ThemeImageComponent = ElementType | null;
40
+ /**
41
+ * Global component overrides provided by Theme.
42
+ */
43
+ export type ThemeComponents = {
44
+ link?: ThemeLinkComponent;
45
+ image?: ThemeImageComponent;
46
+ };
@@ -0,0 +1,46 @@
1
+ import { ElementType } from "react";
2
+ /**
3
+ * Configuration for a custom Link component.
4
+ *
5
+ * Use this form when the component uses a different prop name
6
+ * for its destination, such as TanStack Router's `to`.
7
+ */
8
+ export type ThemeLinkComponentConfig = {
9
+ /** The component used to render links. */
10
+ component: ElementType;
11
+ /**
12
+ * The prop used by the component for its destination.
13
+ *
14
+ * Defaults to "href".
15
+ */
16
+ hrefProp?: "href" | "to";
17
+ };
18
+ /**
19
+ * Component used to render Puzzle links.
20
+ *
21
+ * A component can either follow the standard `href` contract
22
+ * or use an explicit configuration object.
23
+ *
24
+ * When passing components through a React Server Component boundary,
25
+ * use a component reference exported from a "use client" module.
26
+ */
27
+ export type ThemeLinkComponent = ElementType | ThemeLinkComponentConfig | null;
28
+ /**
29
+ * Component used to render Puzzle images.
30
+ *
31
+ * Defaults to the native HTML img element.
32
+ *
33
+ * This can be overridden with framework-specific image components,
34
+ * such as Next.js Image or a custom image CDN component.
35
+ *
36
+ * When passing components through a React Server Component boundary,
37
+ * use a component reference exported from a "use client" module.
38
+ */
39
+ export type ThemeImageComponent = ElementType | null;
40
+ /**
41
+ * Global component overrides provided by Theme.
42
+ */
43
+ export type ThemeComponents = {
44
+ link?: ThemeLinkComponent;
45
+ image?: ThemeImageComponent;
46
+ };