Skip to content

Commit 592ef81

Browse files
committed
feat: Update LocaleSwitcher to use app's Select element
1 parent b5616eb commit 592ef81

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ You can also check the
3434
- Dataset tags can now wrap
3535
- Dataset browse side panel now sticks to the top of the page when scrolling
3636
- Search input in table charts has better affordance now
37+
- Locale switcher has new appearance, in line with other selects
3738
- Security
3839
- Added additional protection against data source URL injection
3940
- Removed feature flag for custom GraphQL endpoint

app/components/header.tsx

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { TopBar } from "@interactivethings/swiss-federal-ci/dist/components";
22
import { Header as SwissFederalCiHeader } from "@interactivethings/swiss-federal-ci/dist/components/pages-router";
3-
import { Box, NativeSelect } from "@mui/material";
43
import { useRouter } from "next/router";
54

65
import { DataSourceMenu } from "@/components/data-source-menu";
6+
import { Flex } from "@/components/flex";
7+
import { Select } from "@/components/form";
78
import { __HEADER_HEIGHT_CSS_VAR } from "@/components/header-constants";
89
import contentRoutes from "@/content-routes.json";
910
import { SOURCE_OPTIONS } from "@/domain/data-source/constants";
@@ -54,12 +55,14 @@ export const Header = ({
5455
}}
5556
>
5657
{SOURCE_OPTIONS.length > 1 && <DataSourceMenu />}
57-
<Box display="flex" alignItems="center" gap={3} marginLeft="auto">
58+
<Flex alignItems="center" gap={3} marginLeft="auto">
5859
<LoginMenu />
59-
<NativeSelect
60+
<Select
61+
id="localeSwitcherSelect"
62+
variant="standard"
6063
value={currentLocale}
6164
onChange={(e) => {
62-
const locale = e.currentTarget.value;
65+
const locale = e.target.value as string;
6366
const alternate = alternates?.[locale];
6467

6568
if (alternate) {
@@ -68,27 +71,27 @@ export const Header = ({
6871
push({ pathname, query }, undefined, { locale });
6972
}
7073
}}
74+
options={localeConfig.locales.map((locale) => ({
75+
label: locale.toUpperCase(),
76+
value: locale,
77+
}))}
78+
sortOptions={false}
7179
sx={{
72-
padding: 0,
73-
border: "none !important",
74-
backgroundColor: "transparent",
80+
width: "fit-content",
7581
color: "white !important",
7682

7783
"&:hover": {
78-
backgroundColor: "transparent",
79-
color: (t) => `${t.palette.cobalt[100]} !important`,
84+
color: "cobalt.100",
85+
},
86+
87+
"& .MuiSelect-select": {
88+
"&:hover, &[aria-expanded='true']": {
89+
backgroundColor: "transparent !important",
90+
},
8091
},
8192
}}
82-
>
83-
{localeConfig.locales.map((locale) => (
84-
// Color override is needed to make sure the text is visible on
85-
// Windows machines.
86-
<option key={locale} value={locale} style={{ color: "initial" }}>
87-
{locale.toUpperCase()}
88-
</option>
89-
))}
90-
</NativeSelect>
91-
</Box>
93+
/>
94+
</Flex>
9295
</TopBar>
9396
{hideLogo ? null : (
9497
<SwissFederalCiHeader

0 commit comments

Comments
 (0)