Skip to content

Commit e7d90ae

Browse files
committed
single-button-theme-toggle-and-responsive-logo
Signed-off-by: amanycodes <amanycodes@gmail.com>
1 parent 906f6a3 commit e7d90ae

File tree

2 files changed

+29
-50
lines changed

2 files changed

+29
-50
lines changed

web/ui/mantine-ui/src/App.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,14 +332,16 @@ function App() {
332332
justify="space-between"
333333
wrap="nowrap"
334334
>
335-
<Group gap={65} wrap="nowrap">
335+
<Group gap={40} wrap="nowrap">
336336
<Link
337337
to="/"
338338
style={{ textDecoration: "none", color: "white" }}
339339
>
340340
<Group gap={10} wrap="nowrap">
341341
<img src={PrometheusLogo} height={30} />
342-
<Text fz={20}>Prometheus{agentMode && " Agent"}</Text>
342+
<Text hiddenFrom="sm" fz={20}>Prometheus</Text>
343+
<Text visibleFrom="md" fz={20}>Prometheus</Text>
344+
<Text fz={20}>{agentMode && "Agent"}</Text>
343345
</Group>
344346
</Link>
345347
<Group gap={12} visibleFrom="sm" wrap="nowrap">
Lines changed: 25 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
import {
2-
useMantineColorScheme,
3-
SegmentedControl,
4-
rem,
5-
MantineColorScheme,
6-
Tooltip,
7-
} from "@mantine/core";
1+
import { useMantineColorScheme, rem, ActionIcon } from "@mantine/core";
82
import {
93
IconMoonFilled,
104
IconSunFilled,
11-
IconUserFilled,
5+
IconBrightnessFilled,
126
} from "@tabler/icons-react";
137
import { FC } from "react";
148

@@ -20,45 +14,28 @@ export const ThemeSelector: FC = () => {
2014
};
2115

2216
return (
23-
<SegmentedControl
24-
color="gray.7"
25-
size="xs"
26-
// styles={{ root: { backgroundColor: "var(--mantine-color-gray-7)" } }}
27-
styles={{
28-
root: {
29-
padding: 3,
30-
backgroundColor: "var(--mantine-color-gray-6)",
31-
},
32-
}}
33-
withItemsBorders={false}
34-
value={colorScheme}
35-
onChange={(v) => setColorScheme(v as MantineColorScheme)}
36-
data={[
37-
{
38-
value: "light",
39-
label: (
40-
<Tooltip label="Use light theme" offset={15}>
41-
<IconSunFilled {...iconProps} />
42-
</Tooltip>
43-
),
44-
},
45-
{
46-
value: "dark",
47-
label: (
48-
<Tooltip label="Use dark theme" offset={15}>
49-
<IconMoonFilled {...iconProps} />
50-
</Tooltip>
51-
),
52-
},
53-
{
54-
value: "auto",
55-
label: (
56-
<Tooltip label="Use browser-preferred theme" offset={15}>
57-
<IconUserFilled {...iconProps} />
58-
</Tooltip>
59-
),
60-
},
61-
]}
62-
/>
17+
<ActionIcon
18+
color="gray"
19+
title={`Switch to ${colorScheme === "light" ? "dark" : colorScheme === "dark" ? "browser-preferred" : "light"} theme`}
20+
aria-label={`Switch to ${colorScheme === "light" ? "dark" : colorScheme === "dark" ? "browser-preferred" : "light"} theme`}
21+
size={32}
22+
onClick={() =>
23+
setColorScheme(
24+
colorScheme === "light"
25+
? "dark"
26+
: colorScheme === "dark"
27+
? "auto"
28+
: "light"
29+
)
30+
}
31+
>
32+
{colorScheme === "light" ? (
33+
<IconSunFilled {...iconProps} />
34+
) : colorScheme === "dark" ? (
35+
<IconMoonFilled {...iconProps} />
36+
) : (
37+
<IconBrightnessFilled {...iconProps} />
38+
)}
39+
</ActionIcon>
6340
);
6441
};

0 commit comments

Comments
 (0)