Side-by-side theme comparison with difference highlighting
Compare two themes to identify differences, track changes, and ensure consistency across theme versions.
The ThemeComparator component analyzes two themes and displays their differences in an easy-to-understand format. It's essential for version control, A/B testing, and ensuring theme consistency.
1import { ThemeComparator } from '@shohojdhara/atomix/theme/devtools';
2import { createTheme } from '@shohojdhara/atomix/theme';
3
4const lightTheme = createTheme({
5 name: 'Light Theme',
6 palette: {
7 primary: { main: '#2196f3' },
8 background: { default: '#ffffff' },
9 },
10});
11
12const darkTheme = createTheme({
13 name: 'Dark Theme',
14 palette: {
15 primary: { main: '#90caf9' },
16 background: { default: '#121212' },
17 },
18});
19
20function App() {
21 return (
22 <ThemeComparator
23 themeA={lightTheme}
24 themeB={darkTheme}
25 showOnlyDifferences={false}
26 />
27 );
28}1<ThemeComparator
2 themeA={currentVersion}
3 themeB={newVersion}
4 showOnlyDifferences={true}
5/>| Prop | Type | Default | Description |
|---|---|---|---|
themeA | Theme | Required | First theme to compare |
themeB | Theme | Required | Second theme to compare |
showOnlyDifferences | boolean | false | Show only properties that differ |
className | string | - | Custom CSS class name |
style | CSSProperties | - | Inline styles object |
The comparator displays summary statistics:
Compare theme versions before releasing updates:
1import { ThemeComparator } from '@shohojdhara/atomix/theme/devtools';
2import { useState } from 'react';
3
4function VersionComparison() {
5 const [showOnlyDiffs, setShowOnlyDiffs] = useState(true);
6
7 return (
8 <div>
9 <div className="controls">
10 <h2>Theme v1.0 vs v2.0</h2>
11 <label>
12 <input
13 type="checkbox"
14 checked={showOnlyDiffs}
15 onChange={(e) => setShowOnlyDiffs(e.target.checked)}
16 />
17 Show only differences
18 </label>
19 </div>
20
21 <ThemeComparator
22 themeA={themeV1}
23 themeB={themeV2}
24 showOnlyDifferences={showOnlyDiffs}
25 />
26
27 <div className="release-notes">
28 <h3>Breaking Changes</h3>
29 <p>Review removed or significantly changed properties</p>
30 </div>
31 </div>
32 );
33}Compare theme variants for A/B testing:
1function ABTestingDashboard() {
2 const variantA = createTheme({
3 name: 'Variant A',
4 palette: { primary: { main: '#2196f3' } },
5 });
6
7 const variantB = createTheme({
8 name: 'Variant B',
9 palette: { primary: { main: '#f44336' } },
10 });
11
12 return (
13 <div className="ab-testing">
14 <h2>A/B Test: Primary Color Impact</h2>
15
16 <ThemeComparator
17 themeA={variantA}
18 themeB={variantB}
19 showOnlyDifferences={true}
20 />
21
22 <div className="test-results">
23 <h3>Test Metrics</h3>
24 <p>Track conversion rates for each variant</p>
25 </div>
26 </div>
27 );
28}Compare old and new theme structures during migration:
1function MigrationHelper() {
2 return (
3 <div className="migration-tool">
4 <h2>Migration from v1 to v2</h2>
5
6 <ThemeComparator
7 themeA={legacyTheme}
8 themeB={modernTheme}
9 showOnlyDifferences={true}
10 />
11
12 <div className="migration-guide">
13 <h3>Migration Steps</h3>
14 <ol>
15 <li>Review removed properties (marked in red)</li>
16 <li>Update changed property values</li>
17 <li>Add new required properties (marked in green)</li>
18 </ol>
19 </div>
20 </div>
21 );
22}Track theme changes across versions:
Compare different theme variants:
Ensure theme consistency:
Combine ThemeComparator with other devtools: