@pie-element/shared-theming 0.1.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.
@@ -0,0 +1,39 @@
1
+ import { type Theme } from '@mui/material/styles';
2
+ import type { PieThemeExtended, MuiThemeOptions } from './types';
3
+ /**
4
+ * Create MUI theme from PIE theme
5
+ * Uses CSS variables in component overrides for compatibility
6
+ *
7
+ * This function creates a Material-UI theme that works alongside PIE's CSS variable system.
8
+ * By default, it preserves MUI's existing styles and optionally injects CSS variables.
9
+ *
10
+ * @param pieTheme - PIE theme with color values
11
+ * @param options - MUI theme configuration options
12
+ * @returns MUI Theme object
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const pieTheme = { primary: '#3F51B5', 'base-content': '#000' };
17
+ * const muiTheme = createPieMuiTheme(pieTheme, {
18
+ * useThemePalette: true,
19
+ * injectCssVariables: true,
20
+ * preserveMuiDefaults: false
21
+ * });
22
+ * ```
23
+ */
24
+ export declare function createPieMuiTheme(pieTheme: Partial<PieThemeExtended>, options?: MuiThemeOptions): Theme;
25
+ /**
26
+ * Update existing MUI theme with PIE colors
27
+ * Useful for dynamically updating a theme without recreating it
28
+ *
29
+ * @param existingTheme - Existing MUI theme
30
+ * @param pieTheme - New PIE theme colors
31
+ * @returns Updated MUI theme
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const updated = updateMuiThemeFromPie(currentTheme, newPieTheme);
36
+ * ```
37
+ */
38
+ export declare function updateMuiThemeFromPie(existingTheme: Theme, pieTheme: Partial<PieThemeExtended>): Theme;
39
+ //# sourceMappingURL=mui-integration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mui-integration.d.ts","sourceRoot":"","sources":["../src/mui-integration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,OAAO,CAAC,gBAAgB,CAAC,EACnC,OAAO,GAAE,eAAoB,GAC5B,KAAK,CA0GP;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,KAAK,EACpB,QAAQ,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAClC,KAAK,CA4BP"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * PIE Default Themes
3
+ *
4
+ * Provides default light and dark themes with PIE branding.
5
+ * PIE brand color: Orange (#FF6F00 / orange[800])
6
+ *
7
+ * These themes provide good defaults while remaining fully customizable.
8
+ */
9
+ import type { PieThemeExtended } from './types';
10
+ /**
11
+ * PIE Orange - Primary brand color
12
+ */
13
+ export declare const PIE_ORANGE: "#ef6c00";
14
+ /**
15
+ * PIE Light Theme
16
+ *
17
+ * A clean, professional light theme with PIE orange branding.
18
+ * Designed for optimal readability and accessibility (WCAG AA compliant).
19
+ */
20
+ export declare const PIE_LIGHT_THEME: Partial<PieThemeExtended>;
21
+ /**
22
+ * PIE Dark Theme
23
+ *
24
+ * A modern dark theme with PIE orange branding.
25
+ * Designed for reduced eye strain and WCAG AA compliance in dark environments.
26
+ */
27
+ export declare const PIE_DARK_THEME: Partial<PieThemeExtended>;
28
+ /**
29
+ * Get theme by name
30
+ */
31
+ export declare function getPieTheme(theme: 'light' | 'dark'): Partial<PieThemeExtended>;
32
+ /**
33
+ * PIE theme names
34
+ */
35
+ export declare const PIE_THEME_NAMES: readonly ["light", "dark"];
36
+ export type PieThemeName = (typeof PIE_THEME_NAMES)[number];
37
+ //# sourceMappingURL=pie-themes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pie-themes.d.ts","sourceRoot":"","sources":["../src/pie-themes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,UAAU,WAAc,CAAC;AAEtC;;;;;GAKG;AACH,eAAO,MAAM,eAAe,EAAE,OAAO,CAAC,gBAAgB,CAkFrD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,OAAO,CAAC,gBAAgB,CAkFpD,CAAC;AAEF;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAE9E;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,4BAA6B,CAAC;AAC1D,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC"}
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import type { ThemeContextValue, PieThemeProviderProps } from './types';
3
+ /**
4
+ * PIE Theme Context
5
+ * Provides theme state and update functions to child components
6
+ */
7
+ export declare const PieThemeContext: React.Context<ThemeContextValue | undefined>;
8
+ /**
9
+ * PIE Theme Provider
10
+ * Manages theme state and generates CSS variables + MUI theme
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * function App() {
15
+ * const config: ThemeConfig = {
16
+ * theme: { primary: '#3F51B5', 'base-content': '#000' },
17
+ * injectGlobally: true,
18
+ * muiOptions: { preserveMuiDefaults: true }
19
+ * };
20
+ *
21
+ * return (
22
+ * <PieThemeProvider config={config}>
23
+ * <YourApp />
24
+ * </PieThemeProvider>
25
+ * );
26
+ * }
27
+ * ```
28
+ */
29
+ export declare function PieThemeProvider({ children, config }: PieThemeProviderProps): JSX.Element;
30
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAGlE,OAAO,KAAK,EAAoB,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAI1F;;;GAGG;AACH,eAAO,MAAM,eAAe,8CAA0D,CAAC;AAEvF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,qBAAqB,GAAG,GAAG,CAAC,OAAO,CAsCzF"}
@@ -0,0 +1,113 @@
1
+ import type { PieTheme } from '@pie-element/shared-types';
2
+ import type { Theme } from '@mui/material/styles';
3
+ /**
4
+ * Extended PIE theme with all 45+ color properties
5
+ * Extends base PieTheme from shared-types
6
+ */
7
+ export interface PieThemeExtended extends PieTheme {
8
+ primary?: string;
9
+ secondary?: string;
10
+ accent?: string;
11
+ success?: string;
12
+ error?: string;
13
+ warning?: string;
14
+ info?: string;
15
+ neutral?: string;
16
+ 'base-content'?: string;
17
+ 'base-100'?: string;
18
+ 'base-200'?: string;
19
+ 'base-300'?: string;
20
+ disabled?: string;
21
+ 'disabled-secondary'?: string;
22
+ 'correct-secondary'?: string;
23
+ 'correct-tertiary'?: string;
24
+ 'correct-icon'?: string;
25
+ incorrect?: string;
26
+ 'incorrect-secondary'?: string;
27
+ 'incorrect-icon'?: string;
28
+ missing?: string;
29
+ 'missing-icon'?: string;
30
+ 'primary-light'?: string;
31
+ 'primary-dark'?: string;
32
+ 'secondary-light'?: string;
33
+ 'secondary-dark'?: string;
34
+ tertiary?: string;
35
+ 'tertiary-light'?: string;
36
+ 'background-dark'?: string;
37
+ 'dropdown-background'?: string;
38
+ 'secondary-background'?: string;
39
+ border?: string;
40
+ 'border-light'?: string;
41
+ 'border-dark'?: string;
42
+ 'border-gray'?: string;
43
+ 'faded-primary'?: string;
44
+ 'focus-checked'?: string;
45
+ 'focus-checked-border'?: string;
46
+ 'focus-unchecked'?: string;
47
+ 'focus-unchecked-border'?: string;
48
+ 'blue-grey-100'?: string;
49
+ 'blue-grey-300'?: string;
50
+ 'blue-grey-600'?: string;
51
+ 'blue-grey-900'?: string;
52
+ black?: string;
53
+ white?: string;
54
+ 'choice-input-color'?: string;
55
+ 'choice-input-selected-color'?: string;
56
+ 'choice-input-disabled-color'?: string;
57
+ 'feedback-correct-bg'?: string;
58
+ 'feedback-incorrect-bg'?: string;
59
+ 'annotation-pointer-right'?: string;
60
+ 'annotation-pointer-top'?: string;
61
+ 'annotation-pointer-border-width'?: string;
62
+ 'annotation-pointer-border-color'?: string;
63
+ 'arrow-color'?: string;
64
+ 'tick-color'?: string;
65
+ 'line-stroke'?: string;
66
+ 'point-fill'?: string;
67
+ 'point-stroke'?: string;
68
+ 'correct-answer-toggle-label-color'?: string;
69
+ 'primary-text'?: string;
70
+ }
71
+ /**
72
+ * CSS variable mapping configuration
73
+ */
74
+ export interface CssVariableMapping {
75
+ variableName: string;
76
+ themeKey: keyof PieThemeExtended;
77
+ fallback: string;
78
+ }
79
+ /**
80
+ * MUI theme integration options
81
+ */
82
+ export interface MuiThemeOptions {
83
+ useThemePalette?: boolean;
84
+ injectCssVariables?: boolean;
85
+ preserveMuiDefaults?: boolean;
86
+ }
87
+ /**
88
+ * Theme configuration for PieThemeProvider
89
+ */
90
+ export interface ThemeConfig {
91
+ theme: Partial<PieThemeExtended>;
92
+ muiOptions?: MuiThemeOptions;
93
+ injectGlobally?: boolean;
94
+ prefix?: string;
95
+ mappings?: CssVariableMapping[];
96
+ }
97
+ /**
98
+ * Theme context value
99
+ */
100
+ export interface ThemeContextValue {
101
+ theme: Partial<PieThemeExtended>;
102
+ cssVariables: Record<string, string>;
103
+ muiTheme: Theme;
104
+ setTheme: (theme: Partial<PieThemeExtended>) => void;
105
+ }
106
+ /**
107
+ * PieThemeProvider props
108
+ */
109
+ export interface PieThemeProviderProps {
110
+ children: React.ReactNode;
111
+ config: ThemeConfig;
112
+ }
113
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;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BAAkB;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,gBAAgB,CAAC;IACjC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACjC,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,kBAAkB,EAAE,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACjC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,QAAQ,EAAE,KAAK,CAAC;IAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;CACtD;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,MAAM,EAAE,WAAW,CAAC;CACrB"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@pie-element/shared-theming",
3
+ "version": "0.1.0",
4
+ "description": "Base theming system for PIE elements with MUI integration",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "rm -rf dist tsconfig.tsbuildinfo && vite build && tsc --emitDeclarationOnly",
19
+ "dev": "vite build --watch",
20
+ "test": "vitest",
21
+ "clean": "rm -rf dist"
22
+ },
23
+ "dependencies": {
24
+ "@pie-element/shared-types": "workspace:*",
25
+ "@mui/material": "^7.3.4",
26
+ "@emotion/react": "^11.14.0",
27
+ "@emotion/styled": "^11.14.1",
28
+ "react": "^18.3.0"
29
+ },
30
+ "devDependencies": {
31
+ "@types/react": "^18.3.0",
32
+ "typescript": "^5.9.3",
33
+ "vite": "^7.2.2",
34
+ "vitest": "^4.0.17"
35
+ },
36
+ "peerDependencies": {
37
+ "react": "^18.0.0"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
42
+ "license": "MIT"
43
+ }