@principal-ade/industry-theme 0.1.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.
Files changed (46) hide show
  1. package/dist/cjs/ThemeProvider.d.ts +19 -0
  2. package/dist/cjs/ThemeProvider.d.ts.map +1 -0
  3. package/dist/cjs/ThemeShowcase.d.ts +24 -0
  4. package/dist/cjs/ThemeShowcase.d.ts.map +1 -0
  5. package/dist/cjs/defaultThemes.d.ts +8 -0
  6. package/dist/cjs/defaultThemes.d.ts.map +1 -0
  7. package/dist/cjs/glassmorphismTheme.d.ts +7 -0
  8. package/dist/cjs/glassmorphismTheme.d.ts.map +1 -0
  9. package/dist/cjs/index.d.ts +130 -0
  10. package/dist/cjs/index.d.ts.map +1 -0
  11. package/dist/cjs/index.js +1798 -0
  12. package/dist/cjs/package.json +1 -0
  13. package/dist/cjs/themeHelpers.d.ts +30 -0
  14. package/dist/cjs/themeHelpers.d.ts.map +1 -0
  15. package/dist/cjs/themes.d.ts +12 -0
  16. package/dist/cjs/themes.d.ts.map +1 -0
  17. package/dist/cjs/utils.d.ts +32 -0
  18. package/dist/cjs/utils.d.ts.map +1 -0
  19. package/dist/esm/ThemeProvider.d.ts +19 -0
  20. package/dist/esm/ThemeProvider.d.ts.map +1 -0
  21. package/dist/esm/ThemeShowcase.d.ts +24 -0
  22. package/dist/esm/ThemeShowcase.d.ts.map +1 -0
  23. package/dist/esm/defaultThemes.d.ts +8 -0
  24. package/dist/esm/defaultThemes.d.ts.map +1 -0
  25. package/dist/esm/glassmorphismTheme.d.ts +7 -0
  26. package/dist/esm/glassmorphismTheme.d.ts.map +1 -0
  27. package/dist/esm/index.d.ts +130 -0
  28. package/dist/esm/index.d.ts.map +1 -0
  29. package/dist/esm/index.js +1753 -0
  30. package/dist/esm/package.json +1 -0
  31. package/dist/esm/themeHelpers.d.ts +30 -0
  32. package/dist/esm/themeHelpers.d.ts.map +1 -0
  33. package/dist/esm/themes.d.ts +12 -0
  34. package/dist/esm/themes.d.ts.map +1 -0
  35. package/dist/esm/utils.d.ts +32 -0
  36. package/dist/esm/utils.d.ts.map +1 -0
  37. package/package.json +64 -0
  38. package/src/README.md +134 -0
  39. package/src/ThemeProvider.tsx +117 -0
  40. package/src/ThemeShowcase.tsx +442 -0
  41. package/src/defaultThemes.ts +369 -0
  42. package/src/glassmorphismTheme.ts +213 -0
  43. package/src/index.ts +230 -0
  44. package/src/themeHelpers.ts +106 -0
  45. package/src/themes.ts +746 -0
  46. package/src/utils.ts +135 -0
package/src/index.ts ADDED
@@ -0,0 +1,230 @@
1
+ /**
2
+ * Theme UI spec-compliant theme system for PrincipleMD
3
+ * Based on https://theme-ui.com/theme-spec
4
+ */
5
+
6
+ import { terminalTheme } from './themes';
7
+
8
+ // Component style variant types
9
+ type ButtonVariant = {
10
+ color?: string;
11
+ backgroundColor?: string;
12
+ bg?: string; // Theme UI shorthand for backgroundColor
13
+ borderColor?: string;
14
+ borderWidth?: number;
15
+ borderStyle?: string;
16
+ padding?: string | number;
17
+ fontSize?: number | string;
18
+ fontWeight?: number;
19
+ cursor?: string;
20
+ '&:hover'?: Partial<ButtonVariant>;
21
+ '&:active'?: Partial<ButtonVariant>;
22
+ '&:disabled'?: Partial<ButtonVariant>;
23
+ };
24
+
25
+ type TextVariant = {
26
+ fontSize?: number | string;
27
+ fontWeight?: number | string;
28
+ lineHeight?: number | string;
29
+ color?: string;
30
+ fontFamily?: string;
31
+ };
32
+
33
+ type CardVariant = {
34
+ padding?: string | number;
35
+ backgroundColor?: string;
36
+ bg?: string; // Theme UI shorthand for backgroundColor
37
+ borderRadius?: number;
38
+ boxShadow?: string;
39
+ border?: string;
40
+ borderColor?: string;
41
+ };
42
+
43
+ export interface Theme {
44
+ // Color modes (optional)
45
+ modes?: {
46
+ [modeName: string]: Partial<Theme['colors']>;
47
+ };
48
+
49
+ // Scale values for consistent spacing
50
+ space: number[];
51
+
52
+ // Typography
53
+ fonts: {
54
+ body: string;
55
+ heading: string;
56
+ monospace: string;
57
+ };
58
+
59
+ fontSizes: number[];
60
+
61
+ // Font scaling factor (1.0 = normal, 1.2 = 20% larger, 0.8 = 20% smaller)
62
+ fontScale?: number;
63
+
64
+ fontWeights: {
65
+ body: number;
66
+ heading: number;
67
+ bold: number;
68
+ light: number;
69
+ medium: number;
70
+ semibold: number;
71
+ };
72
+
73
+ lineHeights: {
74
+ body: number;
75
+ heading: number;
76
+ tight: number;
77
+ relaxed: number;
78
+ };
79
+
80
+ // Layout
81
+ breakpoints: string[];
82
+ sizes: number[];
83
+ radii: number[];
84
+ shadows: string[];
85
+ zIndices: number[];
86
+
87
+ // Colors - Theme UI spec structure
88
+ colors: {
89
+ // Base colors
90
+ text: string;
91
+ background: string;
92
+ primary: string;
93
+ secondary: string;
94
+ accent: string;
95
+ highlight: string;
96
+ muted: string;
97
+
98
+ // Status colors
99
+ success: string;
100
+ warning: string;
101
+ error: string;
102
+ info: string;
103
+
104
+ // Additional semantic colors for our use case
105
+ border: string;
106
+ backgroundSecondary: string;
107
+ backgroundTertiary: string;
108
+ backgroundLight: string;
109
+ backgroundHover: string;
110
+ surface: string;
111
+ textSecondary: string;
112
+ textTertiary: string;
113
+ textMuted: string;
114
+
115
+ // Search highlight colors
116
+ highlightBg?: string;
117
+ highlightBorder?: string;
118
+ };
119
+
120
+ // Component variants (optional but useful)
121
+ buttons: {
122
+ primary: ButtonVariant;
123
+ secondary: ButtonVariant;
124
+ ghost: ButtonVariant;
125
+ };
126
+
127
+ text: {
128
+ heading: TextVariant;
129
+ body: TextVariant;
130
+ caption: TextVariant;
131
+ };
132
+
133
+ cards: {
134
+ primary: CardVariant;
135
+ secondary: CardVariant;
136
+ };
137
+ }
138
+
139
+
140
+ // Default theme - Terminal theme for developers
141
+ export const theme: Theme = terminalTheme;
142
+
143
+ // Export all themes for direct access
144
+ export {
145
+ terminalTheme,
146
+ regalTheme,
147
+ glassmorphismTheme,
148
+ matrixTheme,
149
+ matrixMinimalTheme,
150
+ slateTheme,
151
+ defaultMarkdownTheme,
152
+ defaultEditorTheme,
153
+ defaultTerminalTheme,
154
+ } from './themes';
155
+
156
+ /**
157
+ * Scale font sizes in a theme by a given factor
158
+ */
159
+ export function scaleThemeFonts(theme: Theme, scale: number): Theme {
160
+ const currentScale = theme.fontScale || 1.0;
161
+
162
+ // Calculate effective scale (remove current scale and apply new scale)
163
+ const effectiveScale = scale / currentScale;
164
+
165
+ return {
166
+ ...theme,
167
+ fontSizes: theme.fontSizes.map(size => Math.round(size * effectiveScale)),
168
+ fontScale: scale,
169
+ };
170
+ }
171
+
172
+ /**
173
+ * Increase font scale by 10%
174
+ */
175
+ export function increaseFontScale(theme: Theme): Theme {
176
+ const currentScale = theme.fontScale || 1.0;
177
+ const newScale = Math.min(currentScale * 1.1, 2.0); // Cap at 200%
178
+ return scaleThemeFonts(theme, newScale);
179
+ }
180
+
181
+ /**
182
+ * Decrease font scale by 10%
183
+ */
184
+ export function decreaseFontScale(theme: Theme): Theme {
185
+ const currentScale = theme.fontScale || 1.0;
186
+ const newScale = Math.max(currentScale * 0.9, 0.5); // Floor at 50%
187
+ return scaleThemeFonts(theme, newScale);
188
+ }
189
+
190
+ /**
191
+ * Reset font scale to 100%
192
+ */
193
+ export function resetFontScale(theme: Theme): Theme {
194
+ return scaleThemeFonts(theme, 1.0);
195
+ }
196
+
197
+ // Export ThemeProvider and related utilities
198
+ export {
199
+ ThemeProvider,
200
+ useTheme,
201
+ withTheme,
202
+ } from './ThemeProvider';
203
+
204
+ // Export theme utilities
205
+ export {
206
+ getColor,
207
+ getSpace,
208
+ getFontSize,
209
+ getRadius,
210
+ getShadow,
211
+ getZIndex,
212
+ responsive,
213
+ sx,
214
+ createStyle,
215
+ mergeThemes,
216
+ } from './utils';
217
+
218
+ // Export theme helper functions
219
+ export {
220
+ overrideColors,
221
+ makeTheme,
222
+ addMode,
223
+ getMode
224
+ } from './themeHelpers';
225
+
226
+ // Export ThemeShowcase component
227
+ export { ThemeShowcase } from './ThemeShowcase';
228
+ export type { ThemeShowcaseProps } from './ThemeShowcase';
229
+
230
+ export default theme;
@@ -0,0 +1,106 @@
1
+ import { Theme } from './index';
2
+
3
+ /**
4
+ * Override colors in a theme with type checking
5
+ */
6
+ export function overrideColors<T extends Theme>(
7
+ theme: T,
8
+ colors: Partial<T['colors']>
9
+ ): T {
10
+ return {
11
+ ...theme,
12
+ colors: {
13
+ ...theme.colors,
14
+ ...colors,
15
+ },
16
+ };
17
+ }
18
+
19
+ /**
20
+ * Create a new theme by extending a base theme
21
+ */
22
+ export function makeTheme<T extends Theme>(
23
+ baseTheme: T,
24
+ overrides: Partial<{
25
+ colors: Partial<T['colors']>;
26
+ fonts: Partial<T['fonts']>;
27
+ fontSizes: T['fontSizes'];
28
+ space: T['space'];
29
+ radii: T['radii'];
30
+ }>
31
+ ): T {
32
+ return {
33
+ ...baseTheme,
34
+ ...overrides,
35
+ colors: {
36
+ ...baseTheme.colors,
37
+ ...overrides.colors,
38
+ },
39
+ fonts: {
40
+ ...baseTheme.fonts,
41
+ ...overrides.fonts,
42
+ },
43
+ } as T;
44
+ }
45
+
46
+ /**
47
+ * Add a new mode to a theme
48
+ * @param theme - The theme to add the mode to
49
+ * @param modeName - The name of the new mode (e.g., 'dark', 'light', 'high-contrast')
50
+ * @param colors - Partial colors to override for this mode
51
+ * @param baseMode - Optional existing mode to extend from (defaults to base colors)
52
+ */
53
+ export function addMode<T extends Theme>(
54
+ theme: T,
55
+ modeName: string,
56
+ colors: Partial<T['colors']>,
57
+ baseMode?: string
58
+ ): T {
59
+ // Get the base colors to merge with
60
+ let baseColors: T['colors'];
61
+
62
+ if (baseMode && theme.modes && theme.modes[baseMode]) {
63
+ // Merge with an existing mode
64
+ baseColors = {
65
+ ...theme.colors,
66
+ ...theme.modes[baseMode],
67
+ } as T['colors'];
68
+ } else {
69
+ // Use the default theme colors
70
+ baseColors = theme.colors;
71
+ }
72
+
73
+ // Create the new mode by merging base with new colors
74
+ const newMode = {
75
+ ...baseColors,
76
+ ...colors,
77
+ };
78
+
79
+ // Return theme with the new mode added
80
+ return {
81
+ ...theme,
82
+ modes: {
83
+ ...theme.modes,
84
+ [modeName]: newMode,
85
+ },
86
+ };
87
+ }
88
+
89
+ /**
90
+ * Get colors for a specific mode
91
+ * @param theme - The theme to get colors from
92
+ * @param mode - The mode name (returns base colors if mode doesn't exist)
93
+ */
94
+ export function getMode<T extends Theme>(
95
+ theme: T,
96
+ mode?: string
97
+ ): T['colors'] {
98
+ if (!mode || !theme.modes || !theme.modes[mode]) {
99
+ return theme.colors;
100
+ }
101
+
102
+ return {
103
+ ...theme.colors,
104
+ ...theme.modes[mode],
105
+ } as T['colors'];
106
+ }