Skip to content

Commit 365a6c0

Browse files
committed
fix: use themeSwitcher API for theme changes
1 parent d5a9c67 commit 365a6c0

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

apps/react-starter/src/main.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { themeSwitcher } from "@siemens/ix";
12
import { useIxTheme as getIxTheme } from "@siemens/ix-aggrid";
23
import { IxApplicationContext } from "@siemens/ix-react";
34
import "@siemens/ix/dist/siemens-ix/siemens-ix-core.css";
@@ -29,7 +30,7 @@ function optionalTheme() {
2930
script.type = "module";
3031
document.head.appendChild(script);
3132

32-
document.body.classList.add("theme-brand-dark");
33+
themeSwitcher.setTheme("brand");
3334
}
3435
}
3536

apps/react-starter/src/pages/user-settings/index.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
* LICENSE file in the root directory of this source tree.
88
*/
99

10+
import useShowDemoMessage from "@/hooks/demoMessage";
11+
import { themeSwitcher } from "@siemens/ix";
1012
import { IxRadio, IxRadioGroup, IxTypography } from "@siemens/ix-react";
11-
import brand from "./brand.png";
12-
import classic from "./classic.png";
13-
import styles from "./styles.module.css";
1413
import clsx from "clsx";
1514
import { useEffect, useState } from "react";
1615
import { useTranslation } from "react-i18next";
17-
import useShowDemoMessage from "@/hooks/demoMessage";
16+
import brand from "./brand.png";
17+
import classic from "./classic.png";
18+
import styles from "./styles.module.css";
1819

1920
function ThemeButton(props: {
2021
name: string;
@@ -65,7 +66,7 @@ export default function UserSettings() {
6566
);
6667

6768
useEffect(() => {
68-
document.documentElement.setAttribute("data-ix-theme", currentTheme);
69+
themeSwitcher.setTheme(currentTheme);
6970
}, [currentTheme]);
7071

7172
function changeTheme(theme: string) {

0 commit comments

Comments
 (0)