-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9595a69
commit 3c52d15
Showing
10 changed files
with
197 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
|
||
.DeviceRange { | ||
height: 21rem; | ||
min-width: 24rem; | ||
} | ||
|
||
.echarts { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Siemens AG | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import { IxTypography } from "@siemens/ix-react"; | ||
import brand from "./brand.png"; | ||
import classic from "./classic.png"; | ||
import styles from "./styles.module.css"; | ||
import clsx from "clsx"; | ||
import { useEffect, useState } from "react"; | ||
import { themeSwitcher } from "@siemens/ix"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
function ThemeButton(props: { | ||
name: string; | ||
theme: string; | ||
active?: boolean; | ||
image: string; | ||
onClick?: () => void; | ||
}) { | ||
return ( | ||
<div className={styles.ThemeButton}> | ||
<div | ||
className={clsx(styles.ThemeImagePreview, { | ||
[styles.Active]: props.active, | ||
})} | ||
onClick={props.onClick} | ||
> | ||
<img draggable={false} src={props.image} alt="Siemens brand theme" /> | ||
</div> | ||
<div> | ||
<input | ||
type="radio" | ||
checked={props.active} | ||
id={props.name} | ||
onChange={() => props.onClick?.()} | ||
/> | ||
<label htmlFor={props.name}>{props.name}</label> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default function UserSettings() { | ||
const { t, i18n } = useTranslation(); | ||
const [currentTheme, setCurrentTheme] = useState<string>("brand"); | ||
|
||
useEffect(() => { | ||
const currentVariant = themeSwitcher.getCurrentTheme(); | ||
const isDark = currentVariant.endsWith(themeSwitcher.suffixDark); | ||
themeSwitcher.setTheme(`theme-${currentTheme}-${isDark ? "dark" : "light"}`); | ||
}, [currentTheme]); | ||
|
||
return ( | ||
<div> | ||
<IxTypography className={styles.HeadlineMargin} format="h4"> | ||
Theme | ||
</IxTypography> | ||
<section className={styles.ThemeSelection}> | ||
<ThemeButton | ||
name="Siemens Brand" | ||
image={brand} | ||
active={currentTheme === "brand"} | ||
theme="brand" | ||
onClick={() => setCurrentTheme("brand")} | ||
/> | ||
<ThemeButton | ||
name="Classic" | ||
image={classic} | ||
active={currentTheme === "classic"} | ||
theme="classic" | ||
onClick={() => setCurrentTheme("classic")} | ||
/> | ||
</section> | ||
<IxTypography className={styles.HeadlineMargin} format="h4"> | ||
{t("language.title")} | ||
</IxTypography> | ||
<section className={styles.LanguageSelection}> | ||
<div> | ||
<input | ||
id="l_en" | ||
type="radio" | ||
checked={i18n.language === "en"} | ||
onChange={() => i18n.changeLanguage("en")} | ||
/> | ||
<label htmlFor="l_en">{t("language.en")}</label> | ||
</div> | ||
<div> | ||
<input | ||
id="l_de" | ||
type="radio" | ||
checked={i18n.language === "de"} | ||
onChange={() => i18n.changeLanguage("de")} | ||
/> | ||
<label htmlFor="l_de">{t("language.de")}</label> | ||
</div> | ||
</section> | ||
</div> | ||
); | ||
} |
55 changes: 55 additions & 0 deletions
55
apps/react-starter/src/pages/user-settings/styles.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Siemens AG | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
.ThemeSelection { | ||
display: flex; | ||
flex-wrap: wrap; | ||
position: relative; | ||
|
||
gap: 1rem; | ||
} | ||
|
||
.ThemeButton { | ||
display: inline-flex; | ||
flex-direction: column; | ||
position: relative; | ||
|
||
align-items: center; | ||
gap: 1rem; | ||
} | ||
|
||
.ThemeImagePreview { | ||
display: inline-flex; | ||
position: relative; | ||
border-radius: 0.125rem; | ||
border: 1px solid var(--theme-color-6); | ||
padding: 0.5rem; | ||
gap: 1rem; | ||
cursor: pointer; | ||
} | ||
|
||
.ThemeImagePreview img { | ||
user-select: none; | ||
} | ||
|
||
.ThemeImagePreview.Active { | ||
border-color: var(--theme-color-dynamic); | ||
} | ||
|
||
.LanguageSelection { | ||
display: flex; | ||
position: relative; | ||
flex-direction: column; | ||
|
||
gap: 0.5rem; | ||
} | ||
|
||
.HeadlineMargin { | ||
margin-bottom: 1rem; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.