@stackwright/themes 0.2.2 → 0.3.1-alpha.2

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.
@@ -0,0 +1,222 @@
1
+ # @stackwright/themes - Theme System
2
+
3
+ ## Overview
4
+
5
+ The `@stackwright/themes` package provides a YAML-configurable theme system for Stackwright applications. It enables developers and content creators to define custom visual themes declaratively, supporting everything from color palettes to typography scales and component styling variants.
6
+
7
+ ## Key Features
8
+
9
+ ### YAML-Driven Theme Configuration
10
+ Themes are defined in YAML format, making them accessible to non-developers:
11
+
12
+ ```yaml
13
+ id: "custom-brand-theme"
14
+ name: "Custom Brand Theme"
15
+ description: "A theme for our brand identity"
16
+ colors:
17
+ primary: "#1976d2"
18
+ secondary: "#dc004e"
19
+ accent: "#9c27b0"
20
+ background: "#ffffff"
21
+ text: "#212121"
22
+ typography:
23
+ fontFamily:
24
+ primary: "Inter"
25
+ secondary: "Cinzel"
26
+ spacing:
27
+ xs: "0.5rem"
28
+ sm: "0.75rem"
29
+ md: "1rem"
30
+ lg: "1.5rem"
31
+ xl: "2rem"
32
+ ```
33
+
34
+ ### Dynamic Color Resolution
35
+ The theme system provides intelligent color resolution that supports:
36
+ - **Hex codes**: Direct color values like `#1976d2`
37
+ - **Theme references**: Named colors from the theme palette
38
+ - **Fallback handling**: Graceful degradation for invalid colors
39
+
40
+ ```typescript
41
+ // Color resolution example from core package
42
+ function resolveColor(colorValue: string, themeColors: Record<string, string>): string {
43
+ if (colorValue.startsWith('#')) {
44
+ return colorValue; // Already a hex code
45
+ }
46
+ return themeColors[colorValue] || colorValue;
47
+ }
48
+ ```
49
+
50
+ ### Component Integration
51
+ Themes seamlessly integrate with React components through the `useSafeTheme()` hook:
52
+
53
+ ```typescript
54
+ // Example from ThemedButton component
55
+ const theme = useSafeTheme();
56
+ const buttonColor = button.buttonBackground
57
+ ? resolveColor(button.buttonBackground)
58
+ : background
59
+ ? resolveColor(background)
60
+ : theme.colors.primary;
61
+ ```
62
+
63
+ ### Background Image Support
64
+ Themes support background images with automatic transparency handling:
65
+
66
+ ```typescript
67
+ // From PageLayout component
68
+ const hasBackgroundImage = siteConfig?.customTheme?.backgroundImage?.url;
69
+ const backgroundColor = hasBackgroundImage ? 'transparent' : theme.colors.background;
70
+ ```
71
+
72
+ ## Architecture
73
+
74
+ ### Dependencies
75
+ - **React**: Core React hooks and components
76
+ - **js-yaml**: YAML parsing and serialization
77
+ - **TypeScript**: Type safety and development experience
78
+
79
+ ### Build Configuration
80
+ The package uses `tsup` for building with dual format support:
81
+
82
+ ```typescript
83
+ // tsup.config.ts
84
+ export default defineConfig({
85
+ entry: ['src/index.ts'],
86
+ format: ['cjs', 'esm'],
87
+ dts: true,
88
+ target: 'es2022',
89
+ splitting: false,
90
+ sourcemap: true,
91
+ clean: true,
92
+ outExtension({ format }) {
93
+ return {
94
+ js: format === 'cjs' ? '.js' : '.mjs',
95
+ }
96
+ }
97
+ });
98
+ ```
99
+
100
+ ## Development Workflow
101
+
102
+ ### Theme Creation Process
103
+ 1. **Define theme YAML** with colors, typography, and spacing
104
+ 2. **Add theme exports** in the themes package index
105
+ 3. **Test integration** with example applications
106
+ 4. **Validate** theme structure and color accessibility
107
+
108
+ ### Custom Theme Generation
109
+ The CLI package can generate custom themes from brand specifications:
110
+
111
+ ```javascript
112
+ // From CLI custom theme generation
113
+ function generateCustomTheme(brand) {
114
+ const colors = mapBrandColorsToTheme(brand.colors);
115
+
116
+ return {
117
+ id: `${brand.name.toLowerCase().replace(/\s+/g, '-')}-custom`,
118
+ name: `${brand.name} Custom`,
119
+ description: `Custom theme for ${brand.name}`,
120
+ colors,
121
+ typography: {
122
+ fontFamily: {
123
+ primary: brand.fonts.find(f => f.usage === 'body')?.name || 'Inter',
124
+ secondary: brand.fonts.find(f => f.usage === 'titles')?.name || 'Cinzel'
125
+ }
126
+ }
127
+ };
128
+ }
129
+ ```
130
+
131
+ ## Integration Points
132
+
133
+ ### With Core Framework
134
+ - **Color resolution**: Used throughout component system
135
+ - **Theme hooks**: Provides `useSafeTheme()` for components
136
+ - **Layout integration**: Background and styling support
137
+
138
+ ### With CLI Tools
139
+ - **Theme generation**: AI-powered custom theme creation
140
+ - **Validation**: Schema validation for theme structure
141
+ - **Documentation**: Auto-generated theme reference
142
+
143
+ ### With Next.js Adapter
144
+ - **SSR support**: Server-side theme resolution
145
+ - **Static generation**: Build-time theme optimization
146
+ - **Route integration**: Theme switching capabilities
147
+
148
+ ## Theme Structure
149
+
150
+ ### Core Properties
151
+ - **`id`**: Unique theme identifier
152
+ - **`name`**: Human-readable theme name
153
+ - **`description`**: Theme description and usage notes
154
+ - **`colors`**: Color palette definition
155
+ - **`typography`**: Font family and text styling
156
+ - **`spacing`**: Consistent spacing scale
157
+
158
+ ### Color Palette
159
+ Standard color keys supported:
160
+ - `primary`: Main brand color
161
+ - `secondary`: Secondary brand color
162
+ - `accent`: Accent/highlight color
163
+ - `background`: Page background color
164
+ - `text`: Primary text color
165
+
166
+ ### Typography System
167
+ Font family configuration:
168
+ - `primary`: Body text font
169
+ - `secondary`: Heading/title font
170
+
171
+ ### Spacing Scale
172
+ Consistent spacing tokens:
173
+ - `xs`, `sm`, `md`, `lg`, `xl`, `2xl`: Progressive spacing scale
174
+
175
+ ## Testing and Validation
176
+
177
+ ### Development Testing
178
+ ```bash
179
+ # Build the themes package
180
+ pnpm build:themes
181
+
182
+ # Test with example application
183
+ pnpm dev:example
184
+ ```
185
+
186
+ ### Theme Validation
187
+ - **YAML parsing**: Ensures valid YAML structure
188
+ - **Type checking**: TypeScript validation of theme properties
189
+ - **Color validation**: Hex code and named color validation
190
+ - **Integration testing**: Cross-package theme usage validation
191
+
192
+ ## Future Enhancements
193
+
194
+ ### Planned Features
195
+ - **Theme variants**: Light/dark mode support
196
+ - **Component theming**: Per-component style overrides
197
+ - **Theme inheritance**: Base theme extension capabilities
198
+ - **Advanced typography**: Font weight and size scales
199
+ - **Animation themes**: Motion and transition definitions
200
+
201
+ ### Performance Optimizations
202
+ - **Theme caching**: Runtime theme resolution caching
203
+ - **Build-time optimization**: Static theme extraction
204
+ - **Selective loading**: Dynamic theme loading
205
+
206
+ ## Contributing
207
+
208
+ ### Adding New Themes
209
+ 1. Create theme YAML definition
210
+ 2. Add to package exports
211
+ 3. Update documentation
212
+ 4. Test across components
213
+
214
+ ### Extending Theme Properties
215
+ 1. Update TypeScript types
216
+ 2. Modify parsing logic
217
+ 3. Update component integration
218
+ 4. Add CLI generation support
219
+
220
+ ---
221
+
222
+ **Note**: The themes package is currently in active development (version 0.3.1-alpha.1). Theme structure and APIs may evolve as the framework matures.
package/CHANGELOG.md CHANGED
@@ -1,10 +1,25 @@
1
1
  # @stackwright/themes
2
2
 
3
- ## 0.2.2
3
+ ## 0.3.1-alpha.2
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - 63338d5: testing 122
7
+ - 46df7ac: Documentation updates
8
+
9
+ ## 0.3.1-alpha.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 51dbbc9: Refactor types out of core into own package.
14
+
15
+ ## 0.3.1-alpha.0
16
+
17
+ ### Patch Changes
18
+
19
+ - bd7cd6e: Internal packagename refactor.
20
+ - ca71410: Core testing implemented
21
+ - f195337: Adding test dependencies to all packages.
22
+ - 5ff20a6: Fixing mixed compilation tooling (tsup/tsc) to only tsup
8
23
 
9
24
  ## 0.2.1
10
25
 
@@ -1,4 +1,6 @@
1
- export interface ThemeConfig {
1
+ import React, { ReactNode } from 'react';
2
+
3
+ interface ThemeConfig {
2
4
  id: string;
3
5
  name: string;
4
6
  description: string;
@@ -51,7 +53,7 @@ export interface ThemeConfig {
51
53
  footer: ComponentStyle;
52
54
  };
53
55
  }
54
- export interface ComponentStyle {
56
+ interface ComponentStyle {
55
57
  base?: string;
56
58
  primary?: string;
57
59
  secondary?: string;
@@ -61,6 +63,29 @@ export interface ComponentStyle {
61
63
  text?: string;
62
64
  [key: string]: string | undefined;
63
65
  }
64
- export interface Theme extends ThemeConfig {
66
+ interface Theme extends ThemeConfig {
65
67
  }
66
- //# sourceMappingURL=types.d.ts.map
68
+
69
+ interface ThemeContextType {
70
+ theme: Theme;
71
+ setTheme?: (theme: Theme) => void;
72
+ }
73
+ interface ThemeProviderProps {
74
+ theme: Theme;
75
+ children: ReactNode;
76
+ }
77
+ declare const ThemeProvider: React.FC<ThemeProviderProps>;
78
+ declare const useTheme: () => ThemeContextType;
79
+
80
+ declare class ThemeLoader {
81
+ private static themes;
82
+ static loadThemeFromYaml(yamlContent: string): Theme;
83
+ static loadThemeFromFile(themeName: string): Theme;
84
+ static getTheme(name: string): Theme | undefined;
85
+ static getAllThemes(): Theme[];
86
+ static registerCustomTheme(theme: Theme): void;
87
+ static loadCustomTheme(theme: Theme): Theme;
88
+ private static getEmbeddedTheme;
89
+ }
90
+
91
+ export { type ComponentStyle, type Theme, type ThemeConfig, ThemeLoader, ThemeProvider, useTheme };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,91 @@
1
- export * from './types';
2
- export * from './ThemeProvider';
3
- export * from './themeLoader';
4
- export type { ThemeConfig, Theme, ComponentStyle } from './types';
5
- //# sourceMappingURL=index.d.ts.map
1
+ import React, { ReactNode } from 'react';
2
+
3
+ interface ThemeConfig {
4
+ id: string;
5
+ name: string;
6
+ description: string;
7
+ colors: {
8
+ primary: string;
9
+ secondary: string;
10
+ accent: string;
11
+ background: string;
12
+ surface: string;
13
+ text: string;
14
+ textSecondary: string;
15
+ };
16
+ backgroundImage?: {
17
+ url: string;
18
+ repeat?: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';
19
+ size?: 'auto' | 'cover' | 'contain' | string;
20
+ position?: string;
21
+ attachment?: 'scroll' | 'fixed' | 'local';
22
+ scale?: number;
23
+ animation?: 'drift' | 'float' | 'shimmer' | 'shimmer-float' | 'none';
24
+ customAnimation?: string;
25
+ };
26
+ typography: {
27
+ fontFamily: {
28
+ primary: string;
29
+ secondary: string;
30
+ };
31
+ scale: {
32
+ xs: string;
33
+ sm: string;
34
+ base: string;
35
+ lg: string;
36
+ xl: string;
37
+ '2xl': string;
38
+ '3xl': string;
39
+ };
40
+ };
41
+ spacing: {
42
+ xs: string;
43
+ sm: string;
44
+ md: string;
45
+ lg: string;
46
+ xl: string;
47
+ '2xl': string;
48
+ };
49
+ components: {
50
+ button: ComponentStyle;
51
+ card: ComponentStyle;
52
+ header: ComponentStyle;
53
+ footer: ComponentStyle;
54
+ };
55
+ }
56
+ interface ComponentStyle {
57
+ base?: string;
58
+ primary?: string;
59
+ secondary?: string;
60
+ outline?: string;
61
+ shadow?: string;
62
+ nav?: string;
63
+ text?: string;
64
+ [key: string]: string | undefined;
65
+ }
66
+ interface Theme extends ThemeConfig {
67
+ }
68
+
69
+ interface ThemeContextType {
70
+ theme: Theme;
71
+ setTheme?: (theme: Theme) => void;
72
+ }
73
+ interface ThemeProviderProps {
74
+ theme: Theme;
75
+ children: ReactNode;
76
+ }
77
+ declare const ThemeProvider: React.FC<ThemeProviderProps>;
78
+ declare const useTheme: () => ThemeContextType;
79
+
80
+ declare class ThemeLoader {
81
+ private static themes;
82
+ static loadThemeFromYaml(yamlContent: string): Theme;
83
+ static loadThemeFromFile(themeName: string): Theme;
84
+ static getTheme(name: string): Theme | undefined;
85
+ static getAllThemes(): Theme[];
86
+ static registerCustomTheme(theme: Theme): void;
87
+ static loadCustomTheme(theme: Theme): Theme;
88
+ private static getEmbeddedTheme;
89
+ }
90
+
91
+ export { type ComponentStyle, type Theme, type ThemeConfig, ThemeLoader, ThemeProvider, useTheme };
package/dist/index.js CHANGED
@@ -1,19 +1,176 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ ThemeLoader: () => ThemeLoader,
34
+ ThemeProvider: () => ThemeProvider,
35
+ useTheme: () => useTheme
36
+ });
37
+ module.exports = __toCommonJS(index_exports);
38
+
39
+ // src/ThemeProvider.tsx
40
+ var import_react = require("react");
41
+ var import_jsx_runtime = require("react/jsx-runtime");
42
+ var ThemeContext = (0, import_react.createContext)(void 0);
43
+ var ThemeProvider = ({ theme, children }) => {
44
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeContext.Provider, { value: { theme }, children });
45
+ };
46
+ var useTheme = () => {
47
+ const context = (0, import_react.useContext)(ThemeContext);
48
+ if (!context) {
49
+ throw new Error("useTheme must be used within a ThemeProvider");
50
+ }
51
+ return context;
52
+ };
53
+
54
+ // src/themeLoader.ts
55
+ var yaml = __toESM(require("js-yaml"));
56
+ var ThemeLoader = class {
57
+ static themes = /* @__PURE__ */ new Map();
58
+ static loadThemeFromYaml(yamlContent) {
59
+ try {
60
+ const theme = yaml.load(yamlContent);
61
+ this.themes.set(theme.name, theme);
62
+ return theme;
63
+ } catch (error) {
64
+ throw new Error(`Failed to parse theme YAML: ${error}`);
65
+ }
66
+ }
67
+ static loadThemeFromFile(themeName) {
68
+ const themeData = this.getEmbeddedTheme(themeName);
69
+ return this.loadThemeFromYaml(themeData);
70
+ }
71
+ static getTheme(name) {
72
+ return this.themes.get(name);
73
+ }
74
+ static getAllThemes() {
75
+ return Array.from(this.themes.values());
76
+ }
77
+ static registerCustomTheme(theme) {
78
+ this.themes.set(theme.name, theme);
79
+ console.log(`\u{1F3A8} Registered custom theme: ${theme.name}`);
80
+ }
81
+ static loadCustomTheme(theme) {
82
+ this.registerCustomTheme(theme);
83
+ return theme;
84
+ }
85
+ static getEmbeddedTheme(name) {
86
+ const themes = {
87
+ corporate: `
88
+ name: "Corporate"
89
+ colors:
90
+ primary:
91
+ 50: "#fef7ee"
92
+ 100: "#fdedd3"
93
+ 500: "#f59e0b"
94
+ 600: "#d97706"
95
+ 700: "#b45309"
96
+ neutral:
97
+ 50: "#f8fafc"
98
+ 100: "#f1f5f9"
99
+ 700: "#334155"
100
+ 800: "#1e293b"
101
+ 900: "#0f172a"
102
+ text:
103
+ primary: "#1f2937"
104
+ secondary: "#6b7280"
105
+ inverse: "#ffffff"
106
+
107
+ spacing:
108
+ section: "py-20"
109
+ container: "max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"
110
+
111
+ typography:
112
+ hero: "text-4xl md:text-6xl font-bold"
113
+ subtitle: "text-xl md:text-2xl"
114
+
115
+ components:
116
+ button:
117
+ primary: "bg-amber-600 text-white hover:bg-amber-700 px-8 py-3 rounded-lg font-semibold"
118
+ secondary: "text-amber-600 border border-amber-600 hover:bg-amber-50 px-8 py-3 rounded-lg font-semibold"
119
+ header:
120
+ background: "bg-white shadow-sm"
121
+ border: "border-b border-gray-200"
122
+ hero:
123
+ background: "bg-gradient-to-br from-slate-900 to-slate-800"
124
+ `,
125
+ soft: `
126
+ name: "Soft"
127
+ colors:
128
+ primary:
129
+ 50: "#fdf2f8"
130
+ 100: "#fce7f3"
131
+ 500: "#ec4899"
132
+ 600: "#db2777"
133
+ 700: "#be185d"
134
+ neutral:
135
+ 50: "#fefefe"
136
+ 100: "#f9fafb"
137
+ 700: "#6b7280"
138
+ 800: "#4b5563"
139
+ 900: "#374151"
140
+ text:
141
+ primary: "#374151"
142
+ secondary: "#9ca3af"
143
+ inverse: "#ffffff"
144
+
145
+ spacing:
146
+ section: "py-16"
147
+ container: "max-w-6xl mx-auto px-6 sm:px-8 lg:px-10"
148
+
149
+ typography:
150
+ hero: "text-3xl md:text-5xl font-semibold"
151
+ subtitle: "text-lg md:text-xl"
152
+
153
+ components:
154
+ button:
155
+ primary: "bg-pink-600 text-white hover:bg-pink-700 px-6 py-2 rounded-full font-medium"
156
+ secondary: "text-pink-600 border border-pink-600 hover:bg-pink-50 px-6 py-2 rounded-full font-medium"
157
+ header:
158
+ background: "bg-neutral-50 shadow-none"
159
+ border: "border-b border-neutral-200"
160
+ hero:
161
+ background: "bg-gradient-to-br from-neutral-100 to-neutral-200"
162
+ `
163
+ };
164
+ if (!themes[name]) {
165
+ throw new Error(`Theme '${name}' not found`);
7
166
  }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
167
+ return themes[name];
168
+ }
15
169
  };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./types"), exports);
18
- __exportStar(require("./ThemeProvider"), exports);
19
- __exportStar(require("./themeLoader"), exports);
170
+ // Annotate the CommonJS export names for ESM import in node:
171
+ 0 && (module.exports = {
172
+ ThemeLoader,
173
+ ThemeProvider,
174
+ useTheme
175
+ });
176
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/ThemeProvider.tsx","../src/themeLoader.ts"],"sourcesContent":["export * from './types';\nexport * from './ThemeProvider';\nexport * from './themeLoader';\nexport type { ThemeConfig, Theme, ComponentStyle } from './types';","import React, { createContext, useContext, ReactNode } from 'react';\nimport { Theme } from './types';\n\ninterface ThemeContextType {\n theme: Theme;\n setTheme?: (theme: Theme) => void;\n}\n\nconst ThemeContext = createContext<ThemeContextType | undefined>(undefined);\n\ninterface ThemeProviderProps {\n theme: Theme;\n children: ReactNode;\n}\n\nexport const ThemeProvider: React.FC<ThemeProviderProps> = ({ theme, children }) => {\n return (\n <ThemeContext.Provider value={{ theme }}>\n {children}\n </ThemeContext.Provider>\n );\n};\n\nexport const useTheme = (): ThemeContextType => {\n const context = useContext(ThemeContext);\n if (!context) {\n throw new Error('useTheme must be used within a ThemeProvider');\n }\n return context;\n};","import * as yaml from 'js-yaml';\nimport { Theme } from './types';\n\nexport class ThemeLoader {\n private static themes: Map<string, Theme> = new Map();\n\n static loadThemeFromYaml(yamlContent: string): Theme {\n try {\n const theme = yaml.load(yamlContent) as Theme;\n this.themes.set(theme.name, theme);\n return theme;\n } catch (error) {\n throw new Error(`Failed to parse theme YAML: ${error}`);\n }\n }\n\n static loadThemeFromFile(themeName: string): Theme {\n // In a real implementation, this would load from the file system\n // For now, we'll embed the themes\n const themeData = this.getEmbeddedTheme(themeName);\n return this.loadThemeFromYaml(themeData);\n }\n\n static getTheme(name: string): Theme | undefined {\n return this.themes.get(name);\n }\n\n static getAllThemes(): Theme[] {\n return Array.from(this.themes.values());\n }\n\n static registerCustomTheme(theme: Theme): void {\n this.themes.set(theme.name, theme);\n console.log(`🎨 Registered custom theme: ${theme.name}`);\n }\n\n static loadCustomTheme(theme: Theme): Theme {\n this.registerCustomTheme(theme);\n return theme;\n }\n\n private static getEmbeddedTheme(name: string): string {\n const themes: Record<string, string> = {\n corporate: `\nname: \"Corporate\"\ncolors:\n primary:\n 50: \"#fef7ee\"\n 100: \"#fdedd3\"\n 500: \"#f59e0b\"\n 600: \"#d97706\"\n 700: \"#b45309\"\n neutral:\n 50: \"#f8fafc\"\n 100: \"#f1f5f9\"\n 700: \"#334155\"\n 800: \"#1e293b\"\n 900: \"#0f172a\"\n text:\n primary: \"#1f2937\"\n secondary: \"#6b7280\"\n inverse: \"#ffffff\"\n\nspacing:\n section: \"py-20\"\n container: \"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8\"\n\ntypography:\n hero: \"text-4xl md:text-6xl font-bold\"\n subtitle: \"text-xl md:text-2xl\"\n\ncomponents:\n button:\n primary: \"bg-amber-600 text-white hover:bg-amber-700 px-8 py-3 rounded-lg font-semibold\"\n secondary: \"text-amber-600 border border-amber-600 hover:bg-amber-50 px-8 py-3 rounded-lg font-semibold\"\n header:\n background: \"bg-white shadow-sm\"\n border: \"border-b border-gray-200\"\n hero:\n background: \"bg-gradient-to-br from-slate-900 to-slate-800\"\n`,\n soft: `\nname: \"Soft\"\ncolors:\n primary:\n 50: \"#fdf2f8\"\n 100: \"#fce7f3\"\n 500: \"#ec4899\"\n 600: \"#db2777\"\n 700: \"#be185d\"\n neutral:\n 50: \"#fefefe\"\n 100: \"#f9fafb\"\n 700: \"#6b7280\"\n 800: \"#4b5563\"\n 900: \"#374151\"\n text:\n primary: \"#374151\"\n secondary: \"#9ca3af\"\n inverse: \"#ffffff\"\n\nspacing:\n section: \"py-16\"\n container: \"max-w-6xl mx-auto px-6 sm:px-8 lg:px-10\"\n\ntypography:\n hero: \"text-3xl md:text-5xl font-semibold\"\n subtitle: \"text-lg md:text-xl\"\n\ncomponents:\n button:\n primary: \"bg-pink-600 text-white hover:bg-pink-700 px-6 py-2 rounded-full font-medium\"\n secondary: \"text-pink-600 border border-pink-600 hover:bg-pink-50 px-6 py-2 rounded-full font-medium\"\n header:\n background: \"bg-neutral-50 shadow-none\"\n border: \"border-b border-neutral-200\"\n hero:\n background: \"bg-gradient-to-br from-neutral-100 to-neutral-200\"\n`\n };\n\n if (!themes[name]) {\n throw new Error(`Theme '${name}' not found`);\n }\n\n return themes[name];\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA4D;AAiBxD;AATJ,IAAM,mBAAe,4BAA4C,MAAS;AAOnE,IAAM,gBAA8C,CAAC,EAAE,OAAO,SAAS,MAAM;AAClF,SACE,4CAAC,aAAa,UAAb,EAAsB,OAAO,EAAE,MAAM,GACnC,UACH;AAEJ;AAEO,IAAM,WAAW,MAAwB;AAC9C,QAAM,cAAU,yBAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,8CAA8C;AAAA,EAChE;AACA,SAAO;AACT;;;AC7BA,WAAsB;AAGf,IAAM,cAAN,MAAkB;AAAA,EACvB,OAAe,SAA6B,oBAAI,IAAI;AAAA,EAEpD,OAAO,kBAAkB,aAA4B;AACnD,QAAI;AACF,YAAM,QAAa,UAAK,WAAW;AACnC,WAAK,OAAO,IAAI,MAAM,MAAM,KAAK;AACjC,aAAO;AAAA,IACT,SAAS,OAAO;AACd,YAAM,IAAI,MAAM,+BAA+B,KAAK,EAAE;AAAA,IACxD;AAAA,EACF;AAAA,EAEA,OAAO,kBAAkB,WAA0B;AAGjD,UAAM,YAAY,KAAK,iBAAiB,SAAS;AACjD,WAAO,KAAK,kBAAkB,SAAS;AAAA,EACzC;AAAA,EAEA,OAAO,SAAS,MAAiC;AAC/C,WAAO,KAAK,OAAO,IAAI,IAAI;AAAA,EAC7B;AAAA,EAEA,OAAO,eAAwB;AAC7B,WAAO,MAAM,KAAK,KAAK,OAAO,OAAO,CAAC;AAAA,EACxC;AAAA,EAEA,OAAO,oBAAoB,OAAoB;AAC7C,SAAK,OAAO,IAAI,MAAM,MAAM,KAAK;AACjC,YAAQ,IAAI,sCAA+B,MAAM,IAAI,EAAE;AAAA,EACzD;AAAA,EAEA,OAAO,gBAAgB,OAAqB;AAC1C,SAAK,oBAAoB,KAAK;AAC9B,WAAO;AAAA,EACT;AAAA,EAEA,OAAe,iBAAiB,MAAsB;AACpD,UAAM,SAAiC;AAAA,MACrC,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAsCX,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAsCR;AAEA,QAAI,CAAC,OAAO,IAAI,GAAG;AACjB,YAAM,IAAI,MAAM,UAAU,IAAI,aAAa;AAAA,IAC7C;AAEA,WAAO,OAAO,IAAI;AAAA,EACpB;AACF;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1,137 @@
1
+ // src/ThemeProvider.tsx
2
+ import { createContext, useContext } from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ var ThemeContext = createContext(void 0);
5
+ var ThemeProvider = ({ theme, children }) => {
6
+ return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: { theme }, children });
7
+ };
8
+ var useTheme = () => {
9
+ const context = useContext(ThemeContext);
10
+ if (!context) {
11
+ throw new Error("useTheme must be used within a ThemeProvider");
12
+ }
13
+ return context;
14
+ };
15
+
16
+ // src/themeLoader.ts
17
+ import * as yaml from "js-yaml";
18
+ var ThemeLoader = class {
19
+ static themes = /* @__PURE__ */ new Map();
20
+ static loadThemeFromYaml(yamlContent) {
21
+ try {
22
+ const theme = yaml.load(yamlContent);
23
+ this.themes.set(theme.name, theme);
24
+ return theme;
25
+ } catch (error) {
26
+ throw new Error(`Failed to parse theme YAML: ${error}`);
27
+ }
28
+ }
29
+ static loadThemeFromFile(themeName) {
30
+ const themeData = this.getEmbeddedTheme(themeName);
31
+ return this.loadThemeFromYaml(themeData);
32
+ }
33
+ static getTheme(name) {
34
+ return this.themes.get(name);
35
+ }
36
+ static getAllThemes() {
37
+ return Array.from(this.themes.values());
38
+ }
39
+ static registerCustomTheme(theme) {
40
+ this.themes.set(theme.name, theme);
41
+ console.log(`\u{1F3A8} Registered custom theme: ${theme.name}`);
42
+ }
43
+ static loadCustomTheme(theme) {
44
+ this.registerCustomTheme(theme);
45
+ return theme;
46
+ }
47
+ static getEmbeddedTheme(name) {
48
+ const themes = {
49
+ corporate: `
50
+ name: "Corporate"
51
+ colors:
52
+ primary:
53
+ 50: "#fef7ee"
54
+ 100: "#fdedd3"
55
+ 500: "#f59e0b"
56
+ 600: "#d97706"
57
+ 700: "#b45309"
58
+ neutral:
59
+ 50: "#f8fafc"
60
+ 100: "#f1f5f9"
61
+ 700: "#334155"
62
+ 800: "#1e293b"
63
+ 900: "#0f172a"
64
+ text:
65
+ primary: "#1f2937"
66
+ secondary: "#6b7280"
67
+ inverse: "#ffffff"
68
+
69
+ spacing:
70
+ section: "py-20"
71
+ container: "max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"
72
+
73
+ typography:
74
+ hero: "text-4xl md:text-6xl font-bold"
75
+ subtitle: "text-xl md:text-2xl"
76
+
77
+ components:
78
+ button:
79
+ primary: "bg-amber-600 text-white hover:bg-amber-700 px-8 py-3 rounded-lg font-semibold"
80
+ secondary: "text-amber-600 border border-amber-600 hover:bg-amber-50 px-8 py-3 rounded-lg font-semibold"
81
+ header:
82
+ background: "bg-white shadow-sm"
83
+ border: "border-b border-gray-200"
84
+ hero:
85
+ background: "bg-gradient-to-br from-slate-900 to-slate-800"
86
+ `,
87
+ soft: `
88
+ name: "Soft"
89
+ colors:
90
+ primary:
91
+ 50: "#fdf2f8"
92
+ 100: "#fce7f3"
93
+ 500: "#ec4899"
94
+ 600: "#db2777"
95
+ 700: "#be185d"
96
+ neutral:
97
+ 50: "#fefefe"
98
+ 100: "#f9fafb"
99
+ 700: "#6b7280"
100
+ 800: "#4b5563"
101
+ 900: "#374151"
102
+ text:
103
+ primary: "#374151"
104
+ secondary: "#9ca3af"
105
+ inverse: "#ffffff"
106
+
107
+ spacing:
108
+ section: "py-16"
109
+ container: "max-w-6xl mx-auto px-6 sm:px-8 lg:px-10"
110
+
111
+ typography:
112
+ hero: "text-3xl md:text-5xl font-semibold"
113
+ subtitle: "text-lg md:text-xl"
114
+
115
+ components:
116
+ button:
117
+ primary: "bg-pink-600 text-white hover:bg-pink-700 px-6 py-2 rounded-full font-medium"
118
+ secondary: "text-pink-600 border border-pink-600 hover:bg-pink-50 px-6 py-2 rounded-full font-medium"
119
+ header:
120
+ background: "bg-neutral-50 shadow-none"
121
+ border: "border-b border-neutral-200"
122
+ hero:
123
+ background: "bg-gradient-to-br from-neutral-100 to-neutral-200"
124
+ `
125
+ };
126
+ if (!themes[name]) {
127
+ throw new Error(`Theme '${name}' not found`);
128
+ }
129
+ return themes[name];
130
+ }
131
+ };
132
+ export {
133
+ ThemeLoader,
134
+ ThemeProvider,
135
+ useTheme
136
+ };
137
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ThemeProvider.tsx","../src/themeLoader.ts"],"sourcesContent":["import React, { createContext, useContext, ReactNode } from 'react';\nimport { Theme } from './types';\n\ninterface ThemeContextType {\n theme: Theme;\n setTheme?: (theme: Theme) => void;\n}\n\nconst ThemeContext = createContext<ThemeContextType | undefined>(undefined);\n\ninterface ThemeProviderProps {\n theme: Theme;\n children: ReactNode;\n}\n\nexport const ThemeProvider: React.FC<ThemeProviderProps> = ({ theme, children }) => {\n return (\n <ThemeContext.Provider value={{ theme }}>\n {children}\n </ThemeContext.Provider>\n );\n};\n\nexport const useTheme = (): ThemeContextType => {\n const context = useContext(ThemeContext);\n if (!context) {\n throw new Error('useTheme must be used within a ThemeProvider');\n }\n return context;\n};","import * as yaml from 'js-yaml';\nimport { Theme } from './types';\n\nexport class ThemeLoader {\n private static themes: Map<string, Theme> = new Map();\n\n static loadThemeFromYaml(yamlContent: string): Theme {\n try {\n const theme = yaml.load(yamlContent) as Theme;\n this.themes.set(theme.name, theme);\n return theme;\n } catch (error) {\n throw new Error(`Failed to parse theme YAML: ${error}`);\n }\n }\n\n static loadThemeFromFile(themeName: string): Theme {\n // In a real implementation, this would load from the file system\n // For now, we'll embed the themes\n const themeData = this.getEmbeddedTheme(themeName);\n return this.loadThemeFromYaml(themeData);\n }\n\n static getTheme(name: string): Theme | undefined {\n return this.themes.get(name);\n }\n\n static getAllThemes(): Theme[] {\n return Array.from(this.themes.values());\n }\n\n static registerCustomTheme(theme: Theme): void {\n this.themes.set(theme.name, theme);\n console.log(`🎨 Registered custom theme: ${theme.name}`);\n }\n\n static loadCustomTheme(theme: Theme): Theme {\n this.registerCustomTheme(theme);\n return theme;\n }\n\n private static getEmbeddedTheme(name: string): string {\n const themes: Record<string, string> = {\n corporate: `\nname: \"Corporate\"\ncolors:\n primary:\n 50: \"#fef7ee\"\n 100: \"#fdedd3\"\n 500: \"#f59e0b\"\n 600: \"#d97706\"\n 700: \"#b45309\"\n neutral:\n 50: \"#f8fafc\"\n 100: \"#f1f5f9\"\n 700: \"#334155\"\n 800: \"#1e293b\"\n 900: \"#0f172a\"\n text:\n primary: \"#1f2937\"\n secondary: \"#6b7280\"\n inverse: \"#ffffff\"\n\nspacing:\n section: \"py-20\"\n container: \"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8\"\n\ntypography:\n hero: \"text-4xl md:text-6xl font-bold\"\n subtitle: \"text-xl md:text-2xl\"\n\ncomponents:\n button:\n primary: \"bg-amber-600 text-white hover:bg-amber-700 px-8 py-3 rounded-lg font-semibold\"\n secondary: \"text-amber-600 border border-amber-600 hover:bg-amber-50 px-8 py-3 rounded-lg font-semibold\"\n header:\n background: \"bg-white shadow-sm\"\n border: \"border-b border-gray-200\"\n hero:\n background: \"bg-gradient-to-br from-slate-900 to-slate-800\"\n`,\n soft: `\nname: \"Soft\"\ncolors:\n primary:\n 50: \"#fdf2f8\"\n 100: \"#fce7f3\"\n 500: \"#ec4899\"\n 600: \"#db2777\"\n 700: \"#be185d\"\n neutral:\n 50: \"#fefefe\"\n 100: \"#f9fafb\"\n 700: \"#6b7280\"\n 800: \"#4b5563\"\n 900: \"#374151\"\n text:\n primary: \"#374151\"\n secondary: \"#9ca3af\"\n inverse: \"#ffffff\"\n\nspacing:\n section: \"py-16\"\n container: \"max-w-6xl mx-auto px-6 sm:px-8 lg:px-10\"\n\ntypography:\n hero: \"text-3xl md:text-5xl font-semibold\"\n subtitle: \"text-lg md:text-xl\"\n\ncomponents:\n button:\n primary: \"bg-pink-600 text-white hover:bg-pink-700 px-6 py-2 rounded-full font-medium\"\n secondary: \"text-pink-600 border border-pink-600 hover:bg-pink-50 px-6 py-2 rounded-full font-medium\"\n header:\n background: \"bg-neutral-50 shadow-none\"\n border: \"border-b border-neutral-200\"\n hero:\n background: \"bg-gradient-to-br from-neutral-100 to-neutral-200\"\n`\n };\n\n if (!themes[name]) {\n throw new Error(`Theme '${name}' not found`);\n }\n\n return themes[name];\n }\n}"],"mappings":";AAAA,SAAgB,eAAe,kBAA6B;AAiBxD;AATJ,IAAM,eAAe,cAA4C,MAAS;AAOnE,IAAM,gBAA8C,CAAC,EAAE,OAAO,SAAS,MAAM;AAClF,SACE,oBAAC,aAAa,UAAb,EAAsB,OAAO,EAAE,MAAM,GACnC,UACH;AAEJ;AAEO,IAAM,WAAW,MAAwB;AAC9C,QAAM,UAAU,WAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,8CAA8C;AAAA,EAChE;AACA,SAAO;AACT;;;AC7BA,YAAY,UAAU;AAGf,IAAM,cAAN,MAAkB;AAAA,EACvB,OAAe,SAA6B,oBAAI,IAAI;AAAA,EAEpD,OAAO,kBAAkB,aAA4B;AACnD,QAAI;AACF,YAAM,QAAa,UAAK,WAAW;AACnC,WAAK,OAAO,IAAI,MAAM,MAAM,KAAK;AACjC,aAAO;AAAA,IACT,SAAS,OAAO;AACd,YAAM,IAAI,MAAM,+BAA+B,KAAK,EAAE;AAAA,IACxD;AAAA,EACF;AAAA,EAEA,OAAO,kBAAkB,WAA0B;AAGjD,UAAM,YAAY,KAAK,iBAAiB,SAAS;AACjD,WAAO,KAAK,kBAAkB,SAAS;AAAA,EACzC;AAAA,EAEA,OAAO,SAAS,MAAiC;AAC/C,WAAO,KAAK,OAAO,IAAI,IAAI;AAAA,EAC7B;AAAA,EAEA,OAAO,eAAwB;AAC7B,WAAO,MAAM,KAAK,KAAK,OAAO,OAAO,CAAC;AAAA,EACxC;AAAA,EAEA,OAAO,oBAAoB,OAAoB;AAC7C,SAAK,OAAO,IAAI,MAAM,MAAM,KAAK;AACjC,YAAQ,IAAI,sCAA+B,MAAM,IAAI,EAAE;AAAA,EACzD;AAAA,EAEA,OAAO,gBAAgB,OAAqB;AAC1C,SAAK,oBAAoB,KAAK;AAC9B,WAAO;AAAA,EACT;AAAA,EAEA,OAAe,iBAAiB,MAAsB;AACpD,UAAM,SAAiC;AAAA,MACrC,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAsCX,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAsCR;AAEA,QAAI,CAAC,OAAO,IAAI,GAAG;AACjB,YAAM,IAAI,MAAM,UAAU,IAAI,aAAa;AAAA,IAC7C;AAEA,WAAO,OAAO,IAAI;AAAA,EACpB;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackwright/themes",
3
- "version": "0.2.2",
3
+ "version": "0.3.1-alpha.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "dependencies": {
@@ -10,10 +10,12 @@
10
10
  "devDependencies": {
11
11
  "@types/react": "^18.0.0",
12
12
  "@types/js-yaml": "^4.0.0",
13
- "typescript": "^5.0.0"
13
+ "typescript": "^5.0.0",
14
+ "tsup": "^8.0.0",
15
+ "vitest": "^3.2.4"
14
16
  },
15
17
  "scripts": {
16
- "build": "tsc",
17
- "dev": "tsc --watch"
18
+ "build": "tsup",
19
+ "dev": "tsup --watch"
18
20
  }
19
21
  }
package/tsconfig.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "es5",
3
+ "target": "es2022",
4
4
  "lib": ["dom", "dom.iterable", "es6"],
5
5
  "allowJs": true,
6
6
  "skipLibCheck": true,
package/tsup.config.ts CHANGED
@@ -3,8 +3,14 @@ import { defineConfig } from 'tsup';
3
3
  export default defineConfig({
4
4
  entry: ['src/index.ts'],
5
5
  format: ['cjs', 'esm'],
6
- dts: false, // Disable type generation temporarily
6
+ dts: true,
7
+ target: 'es2022',
7
8
  splitting: false,
8
9
  sourcemap: true,
9
10
  clean: true,
11
+ outExtension({ format }) {
12
+ return {
13
+ js: format === 'cjs' ? '.js' : '.mjs',
14
+ }
15
+ }
10
16
  });
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from 'vitest/config'
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ globals: true,
6
+ environment: 'jsdom',
7
+ setupFiles: ['./test/setup.ts'],
8
+ },
9
+ css: {
10
+ postcss: {},
11
+ },
12
+ })
@@ -1,14 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import { Theme } from './types';
3
- interface ThemeContextType {
4
- theme: Theme;
5
- setTheme?: (theme: Theme) => void;
6
- }
7
- interface ThemeProviderProps {
8
- theme: Theme;
9
- children: ReactNode;
10
- }
11
- export declare const ThemeProvider: React.FC<ThemeProviderProps>;
12
- export declare const useTheme: () => ThemeContextType;
13
- export {};
14
- //# sourceMappingURL=ThemeProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../src/ThemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAA6B,SAAS,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,UAAU,gBAAgB;IACxB,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACnC;AAID,UAAU,kBAAkB;IAC1B,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAMtD,CAAC;AAEF,eAAO,MAAM,QAAQ,QAAO,gBAM3B,CAAC"}
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useTheme = exports.ThemeProvider = void 0;
4
- var jsx_runtime_1 = require("react/jsx-runtime");
5
- var react_1 = require("react");
6
- var ThemeContext = (0, react_1.createContext)(undefined);
7
- var ThemeProvider = function (_a) {
8
- var theme = _a.theme, children = _a.children;
9
- return ((0, jsx_runtime_1.jsx)(ThemeContext.Provider, { value: { theme: theme }, children: children }));
10
- };
11
- exports.ThemeProvider = ThemeProvider;
12
- var useTheme = function () {
13
- var context = (0, react_1.useContext)(ThemeContext);
14
- if (!context) {
15
- throw new Error('useTheme must be used within a ThemeProvider');
16
- }
17
- return context;
18
- };
19
- exports.useTheme = useTheme;
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,YAAY,EAAE,WAAW,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC"}
@@ -1,12 +0,0 @@
1
- import { Theme } from './types';
2
- export declare class ThemeLoader {
3
- private static themes;
4
- static loadThemeFromYaml(yamlContent: string): Theme;
5
- static loadThemeFromFile(themeName: string): Theme;
6
- static getTheme(name: string): Theme | undefined;
7
- static getAllThemes(): Theme[];
8
- static registerCustomTheme(theme: Theme): void;
9
- static loadCustomTheme(theme: Theme): Theme;
10
- private static getEmbeddedTheme;
11
- }
12
- //# sourceMappingURL=themeLoader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"themeLoader.d.ts","sourceRoot":"","sources":["../src/themeLoader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,MAAM,CAAiC;IAEtD,MAAM,CAAC,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,KAAK;IAUpD,MAAM,CAAC,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK;IAOlD,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS;IAIhD,MAAM,CAAC,YAAY,IAAI,KAAK,EAAE;IAI9B,MAAM,CAAC,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAK9C,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK;IAK3C,OAAO,CAAC,MAAM,CAAC,gBAAgB;CAsFhC"}
@@ -1,84 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ThemeLoader = void 0;
37
- var yaml = __importStar(require("js-yaml"));
38
- var ThemeLoader = /** @class */ (function () {
39
- function ThemeLoader() {
40
- }
41
- ThemeLoader.loadThemeFromYaml = function (yamlContent) {
42
- try {
43
- var theme = yaml.load(yamlContent);
44
- this.themes.set(theme.name, theme);
45
- return theme;
46
- }
47
- catch (error) {
48
- throw new Error("Failed to parse theme YAML: ".concat(error));
49
- }
50
- };
51
- ThemeLoader.loadThemeFromFile = function (themeName) {
52
- // In a real implementation, this would load from the file system
53
- // For now, we'll embed the themes
54
- var themeData = this.getEmbeddedTheme(themeName);
55
- return this.loadThemeFromYaml(themeData);
56
- };
57
- ThemeLoader.getTheme = function (name) {
58
- return this.themes.get(name);
59
- };
60
- ThemeLoader.getAllThemes = function () {
61
- return Array.from(this.themes.values());
62
- };
63
- ThemeLoader.registerCustomTheme = function (theme) {
64
- this.themes.set(theme.name, theme);
65
- console.log("\uD83C\uDFA8 Registered custom theme: ".concat(theme.name));
66
- };
67
- ThemeLoader.loadCustomTheme = function (theme) {
68
- this.registerCustomTheme(theme);
69
- return theme;
70
- };
71
- ThemeLoader.getEmbeddedTheme = function (name) {
72
- var themes = {
73
- corporate: "\nname: \"Corporate\"\ncolors:\n primary:\n 50: \"#fef7ee\"\n 100: \"#fdedd3\"\n 500: \"#f59e0b\"\n 600: \"#d97706\"\n 700: \"#b45309\"\n neutral:\n 50: \"#f8fafc\"\n 100: \"#f1f5f9\"\n 700: \"#334155\"\n 800: \"#1e293b\"\n 900: \"#0f172a\"\n text:\n primary: \"#1f2937\"\n secondary: \"#6b7280\"\n inverse: \"#ffffff\"\n\nspacing:\n section: \"py-20\"\n container: \"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8\"\n\ntypography:\n hero: \"text-4xl md:text-6xl font-bold\"\n subtitle: \"text-xl md:text-2xl\"\n\ncomponents:\n button:\n primary: \"bg-amber-600 text-white hover:bg-amber-700 px-8 py-3 rounded-lg font-semibold\"\n secondary: \"text-amber-600 border border-amber-600 hover:bg-amber-50 px-8 py-3 rounded-lg font-semibold\"\n header:\n background: \"bg-white shadow-sm\"\n border: \"border-b border-gray-200\"\n hero:\n background: \"bg-gradient-to-br from-slate-900 to-slate-800\"\n",
74
- soft: "\nname: \"Soft\"\ncolors:\n primary:\n 50: \"#fdf2f8\"\n 100: \"#fce7f3\"\n 500: \"#ec4899\"\n 600: \"#db2777\"\n 700: \"#be185d\"\n neutral:\n 50: \"#fefefe\"\n 100: \"#f9fafb\"\n 700: \"#6b7280\"\n 800: \"#4b5563\"\n 900: \"#374151\"\n text:\n primary: \"#374151\"\n secondary: \"#9ca3af\"\n inverse: \"#ffffff\"\n\nspacing:\n section: \"py-16\"\n container: \"max-w-6xl mx-auto px-6 sm:px-8 lg:px-10\"\n\ntypography:\n hero: \"text-3xl md:text-5xl font-semibold\"\n subtitle: \"text-lg md:text-xl\"\n\ncomponents:\n button:\n primary: \"bg-pink-600 text-white hover:bg-pink-700 px-6 py-2 rounded-full font-medium\"\n secondary: \"text-pink-600 border border-pink-600 hover:bg-pink-50 px-6 py-2 rounded-full font-medium\"\n header:\n background: \"bg-neutral-50 shadow-none\"\n border: \"border-b border-neutral-200\"\n hero:\n background: \"bg-gradient-to-br from-neutral-100 to-neutral-200\"\n"
75
- };
76
- if (!themes[name]) {
77
- throw new Error("Theme '".concat(name, "' not found"));
78
- }
79
- return themes[name];
80
- };
81
- ThemeLoader.themes = new Map();
82
- return ThemeLoader;
83
- }());
84
- exports.ThemeLoader = ThemeLoader;
@@ -1,32 +0,0 @@
1
- export declare const corporateTheme: {
2
- colors: {
3
- primary: {
4
- 50: string;
5
- 100: string;
6
- 500: string;
7
- 600: string;
8
- 700: string;
9
- };
10
- neutral: {
11
- 50: string;
12
- 100: string;
13
- 700: string;
14
- 800: string;
15
- 900: string;
16
- };
17
- text: {
18
- primary: string;
19
- secondary: string;
20
- inverse: string;
21
- };
22
- };
23
- spacing: {
24
- section: string;
25
- container: string;
26
- };
27
- typography: {
28
- hero: string;
29
- subtitle: string;
30
- };
31
- };
32
- //# sourceMappingURL=corporate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"corporate.d.ts","sourceRoot":"","sources":["../../src/themes/corporate.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8B1B,CAAC"}
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.corporateTheme = void 0;
4
- exports.corporateTheme = {
5
- colors: {
6
- primary: {
7
- 50: '#fef7ee',
8
- 100: '#fdedd3',
9
- 500: '#f59e0b', // amber-500
10
- 600: '#d97706', // amber-600
11
- 700: '#b45309', // amber-700
12
- },
13
- neutral: {
14
- 50: '#f8fafc',
15
- 100: '#f1f5f9',
16
- 700: '#334155',
17
- 800: '#1e293b',
18
- 900: '#0f172a',
19
- },
20
- text: {
21
- primary: '#1f2937',
22
- secondary: '#6b7280',
23
- inverse: '#ffffff',
24
- }
25
- },
26
- spacing: {
27
- section: 'py-20',
28
- container: 'max-w-7xl mx-auto px-4 sm:px-6 lg:px-8',
29
- },
30
- typography: {
31
- hero: 'text-4xl md:text-6xl font-bold',
32
- subtitle: 'text-xl md:text-2xl',
33
- }
34
- };
@@ -1,32 +0,0 @@
1
- export declare const softTheme: {
2
- colors: {
3
- primary: {
4
- 50: string;
5
- 100: string;
6
- 500: string;
7
- 600: string;
8
- 700: string;
9
- };
10
- neutral: {
11
- 50: string;
12
- 100: string;
13
- 700: string;
14
- 800: string;
15
- 900: string;
16
- };
17
- text: {
18
- primary: string;
19
- secondary: string;
20
- inverse: string;
21
- };
22
- };
23
- spacing: {
24
- section: string;
25
- container: string;
26
- };
27
- typography: {
28
- hero: string;
29
- subtitle: string;
30
- };
31
- };
32
- //# sourceMappingURL=soft.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"soft.d.ts","sourceRoot":"","sources":["../../src/themes/soft.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BrB,CAAC"}
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.softTheme = void 0;
4
- exports.softTheme = {
5
- colors: {
6
- primary: {
7
- 50: '#fdf2f8',
8
- 100: '#fce7f3',
9
- 500: '#ec4899', // pink-500
10
- 600: '#db2777', // pink-600
11
- 700: '#be185d', // pink-700
12
- },
13
- neutral: {
14
- 50: '#fefefe',
15
- 100: '#f9fafb',
16
- 700: '#6b7280',
17
- 800: '#4b5563',
18
- 900: '#374151',
19
- },
20
- text: {
21
- primary: '#374151',
22
- secondary: '#9ca3af',
23
- inverse: '#ffffff',
24
- }
25
- },
26
- spacing: {
27
- section: 'py-16',
28
- container: 'max-w-6xl mx-auto px-6 sm:px-8 lg:px-10',
29
- },
30
- typography: {
31
- hero: 'text-3xl md:text-5xl font-semibold',
32
- subtitle: 'text-lg md:text-xl',
33
- }
34
- };
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,eAAe,CAAC,EAAE;QAChB,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,CAAC;QAC1D,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;QAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;QAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,eAAe,GAAG,MAAM,CAAC;QACrE,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,UAAU,EAAE;QACV,UAAU,EAAE;YACV,OAAO,EAAE,MAAM,CAAC;YAChB,SAAS,EAAE,MAAM,CAAC;SACnB,CAAC;QACF,KAAK,EAAE;YACL,EAAE,EAAE,MAAM,CAAC;YACX,EAAE,EAAE,MAAM,CAAC;YACX,IAAI,EAAE,MAAM,CAAC;YACb,EAAE,EAAE,MAAM,CAAC;YACX,EAAE,EAAE,MAAM,CAAC;YACX,KAAK,EAAE,MAAM,CAAC;YACd,KAAK,EAAE,MAAM,CAAC;SACf,CAAC;KACH,CAAC;IACF,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,CAAC;QACX,EAAE,EAAE,MAAM,CAAC;QACX,EAAE,EAAE,MAAM,CAAC;QACX,EAAE,EAAE,MAAM,CAAC;QACX,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,UAAU,EAAE;QACV,MAAM,EAAE,cAAc,CAAC;QACvB,IAAI,EAAE,cAAc,CAAC;QACrB,MAAM,EAAE,cAAc,CAAC;QACvB,MAAM,EAAE,cAAc,CAAC;KACxB,CAAC;CACH;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC;AAED,MAAM,WAAW,KAAM,SAAQ,WAAW;CAAG"}
package/dist/types.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });