Deep inspection and validation for theme development
Detailed inspection and debugging information for themes. Validate structure, check accessibility, and review generated CSS variables.
The ThemeInspector component is a powerful debugging tool that provides detailed insights into your theme's structure, validates configuration, checks for accessibility issues, and shows how your theme will be transformed into CSS variables.
1import { ThemeInspector } from '@shohojdhara/atomix/theme/devtools';
2import { createTheme } from '@shohojdhara/atomix/theme';
3
4const theme = createTheme({
5 name: 'My Theme',
6 palette: {
7 primary: { main: '#7AFFD7' },
8 secondary: { main: '#FF5733' },
9 },
10});
11
12function App() {
13 return (
14 <ThemeInspector
15 theme={theme}
16 showValidation={true}
17 showCSSVariables={true}
18 showStructure={true}
19 />
20 );
21}1<ThemeInspector
2 theme={theme}
3 showValidation={true}
4 className="my-inspector"
5 style={{ maxWidth: '800px', margin: '0 auto' }}
6/>| Prop | Type | Default | Description |
|---|---|---|---|
theme | Theme | Required | Theme object to inspect |
showValidation | boolean | false | Show validation results with errors and warnings |
showCSSVariables | boolean | false | Show generated CSS custom properties |
showStructure | boolean | false | Show theme structure tree visualization |
className | string | - | Custom CSS class name |
style | CSSProperties | - | Inline styles object |
Integrate inspector into a development dashboard:
1import { ThemeInspector } from '@shohojdhara/atomix/theme/devtools';
2import { useState } from 'react';
3
4function ThemeDevelopmentDashboard() {
5 const [theme, setTheme] = useState(myTheme);
6 const [activeTab, setActiveTab] = useState('validation');
7
8 return (
9 <div className="dashboard">
10 <div className="tabs">
11 <button onClick={() => setActiveTab('validation')}>
12 Validation
13 </button>
14 <button onClick={() => setActiveTab('css')}>
15 CSS Variables
16 </button>
17 <button onClick={() => setActiveTab('structure')}>
18 Structure
19 </button>
20 </div>
21
22 <ThemeInspector
23 theme={theme}
24 showValidation={activeTab === 'validation'}
25 showCSSVariables={activeTab === 'css'}
26 showStructure={activeTab === 'structure'}
27 />
28 </div>
29 );
30}Use inspector programmatically in tests:
1import { ThemeValidator } from '@shohojdhara/atomix/theme';
2
3describe('Theme Validation', () => {
4 it('should validate theme structure', () => {
5 const theme = createTheme({
6 palette: { primary: { main: '#7AFFD7' } },
7 });
8
9 const validator = new ThemeValidator();
10 const result = validator.validate(theme);
11
12 expect(result.valid).toBe(true);
13 expect(result.errors).toHaveLength(0);
14 });
15
16 it('should detect accessibility issues', () => {
17 const theme = createTheme({
18 palette: {
19 primary: { main: '#FFFF00' }, // Poor contrast
20 background: { default: '#FFFFFF' },
21 },
22 });
23
24 const validator = new ThemeValidator();
25 const result = validator.validate(theme);
26
27 expect(result.warnings).toContain(
28 expect.objectContaining({
29 type: 'accessibility',
30 message: expect.stringContaining('contrast'),
31 })
32 );
33 });
34});Create a Storybook addon for theme inspection:
1// .storybook/addons/ThemeInspectorAddon.tsx
2import { ThemeInspector } from '@shohojdhara/atomix/theme/devtools';
3import { useGlobals } from '@storybook/manager-api';
4
5export function ThemeInspectorAddon() {
6 const [{ theme }] = useGlobals();
7
8 return (
9 <div className="storybook-addon">
10 <ThemeInspector
11 theme={theme}
12 showValidation={true}
13 showCSSVariables={true}
14 />
15 </div>
16 );
17}Critical issues that will prevent the theme from working correctly. Must be fixed before using the theme in production.
Non-critical issues that may cause problems or accessibility concerns. Should be reviewed and addressed when possible.
Suggestions for improvements or best practices. Optional but recommended.
Combine ThemeInspector with other devtools for a complete development workflow: