@@ -6,9 +6,10 @@ import { ORIENTATION, OrientationSwitch } from '../sandbox/actions/OrientationSw
66import styles from './themeGenerator.module.css' ;
77import { ThemeGeneratorTreeView } from './themeGeneratorTreeView/ThemeGeneratorTreeView' ;
88import { ThemeGeneratorPreview } from './themeGeneratorPreview/ThemeGeneratorPreview' ;
9- import { parseCssVariables } from './themeVariableUtils' ;
109import { ThemeGeneratorSwitchThemeModal } from './themeGeneratorSwitchThemeModal/ThemeGeneratorSwitchThemeModal' ;
1110import { ThemeGeneratorJSONModal } from './themeGeneratorJSONModal/ThemeGeneratorJSONModal' ;
11+ import defaultTokens from '@ovhcloud/ods-themes/default/tokens' ;
12+ import developerTokens from '@ovhcloud/ods-themes/developer/tokens' ;
1213
1314const ThemeGenerator = ( ) : JSX . Element => {
1415 const [ isFullscreen , setIsFullscreen ] = useState ( false ) ;
@@ -21,34 +22,14 @@ const ThemeGenerator = (): JSX.Element => {
2122 const [ isJsonOpen , setIsJsonOpen ] = useState ( false ) ;
2223
2324 useEffect ( ( ) => {
24- const loadTheme = async ( ) => {
25- if ( selectedTheme === 'custom' ) {
26- setIsCustomTheme ( true ) ;
27- return ;
28- }
29-
30- try {
31-
32- // Fetch the CSS file from the static directory
33- // Path: /themes/{themeName}/index.css (exposed via staticDirs in main.ts)
34- const response = await fetch ( `/themes/${ selectedTheme } /index.css` ) ;
35-
36- if ( ! response . ok ) {
37- throw new Error ( `Failed to fetch theme: ${ response . statusText } ` ) ;
38- }
39-
40- const cssContent = await response . text ( ) ;
41-
42- // Parse CSS variables
43- const variables = parseCssVariables ( cssContent ) ;
44- setEditedVariables ( variables ) ;
45- setIsCustomTheme ( false ) ;
46- } catch ( error ) {
47- console . error ( 'Failed to load theme:' , error ) ;
48- }
49- } ;
25+ if ( selectedTheme === 'custom' ) {
26+ setIsCustomTheme ( true ) ;
27+ return ;
28+ }
5029
51- loadTheme ( ) ;
30+ const themeTokens = selectedTheme === 'developer' ? developerTokens : defaultTokens ;
31+ setEditedVariables ( themeTokens . root ) ;
32+ setIsCustomTheme ( false ) ;
5233 } , [ selectedTheme ] ) ;
5334
5435
@@ -62,7 +43,6 @@ const ThemeGenerator = (): JSX.Element => {
6243 [ name ] : value ,
6344 } ) ) ;
6445
65- // Automatically switch to custom theme when user edits a variable
6646 if ( ! isCustomTheme ) {
6747 setSelectedTheme ( 'custom' ) ;
6848 setIsCustomTheme ( true ) ;
0 commit comments