Skip to content

Commit f40fe56

Browse files
committed
Add new section with theme and locale pickers.
1 parent 911476f commit f40fe56

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

frontend/src/components/LocalePicker.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import { useTheme } from "src/hooks";
55
import { changeLocale, getFlagCodeForLocale, localeOptions, T } from "src/locale";
66
import styles from "./LocalePicker.module.css";
77

8-
function LocalePicker() {
8+
interface Props {
9+
menuAlign?: "start" | "end";
10+
}
11+
12+
function LocalePicker({ menuAlign = "start" }: Props) {
913
const { locale, setLocale } = useLocaleState();
1014
const { getTheme } = useTheme();
1115

@@ -23,7 +27,10 @@ function LocalePicker() {
2327
<button type="button" className={cns} data-bs-toggle="dropdown">
2428
<Flag countryCode={getFlagCodeForLocale(locale)} />
2529
</button>
26-
<div className="dropdown-menu">
30+
<div className={cn("dropdown-menu", {
31+
"dropdown-menu-end": menuAlign === "end",
32+
})}
33+
>
2734
{localeOptions.map((item) => {
2835
return (
2936
<a

frontend/src/components/SiteHeader.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,23 @@ export function SiteHeader() {
7070
</div>
7171
</a>
7272
<div className="dropdown-menu dropdown-menu-end dropdown-menu-arrow">
73+
<div className="d-md-none">
74+
<div className="p-2 pb-1 pe-1" onClick={(e) => e.stopPropagation()}>
75+
<div className="d-flex align-items-center">
76+
<div className="ps-2 pe-1 me-auto">
77+
<div>{currentUser?.nickname}</div>
78+
<div className="mt-1 small text-secondary">
79+
<T id={isAdmin ? "role.admin" : "role.standard-user"} />
80+
</div>
81+
</div>
82+
<div className="d-flex align-items-center">
83+
<ThemeSwitcher className="me-n1" />
84+
<LocalePicker menuAlign="end" />
85+
</div>
86+
</div>
87+
</div>
88+
<div className="dropdown-divider" />
89+
</div>
7390
<a
7491
href="?"
7592
className="dropdown-item"

0 commit comments

Comments
 (0)