Skip to content

Commit 376808c

Browse files
jonas89h3rmanj
authored andcommitted
chore: Upgrade to bifrost 4
1 parent 941cce6 commit 376808c

File tree

3 files changed

+54
-9
lines changed

3 files changed

+54
-9
lines changed

react/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
"dependencies": {
1616
"@azure/msal-browser": "^3.3.0",
1717
"@azure/msal-react": "^2.0.5",
18-
"@intility/bifrost-react": "^3.12.0",
18+
"@intility/bifrost-react": "^4.3.0",
1919
"@sentry/react": "^7.75.0",
2020
"@sentry/tracing": "^7.75.0",
2121
"react": "^18.2.0",
2222
"react-dom": "^18.2.0",
23-
"react-router-dom": "^6.17.0"
23+
"react-router-dom": "^6.17.0",
24+
"use-local-storage-state": "^19.2.0"
2425
},
2526
"devDependencies": {
2627
"@intility/helm-version": "^1.3.1",

react/src/components/Navigation.tsx

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
import { Nav } from "@intility/bifrost-react";
2-
import { NavLink, useNavigate } from "react-router-dom";
2+
import { NavLink } from "react-router-dom";
33
import {
44
faHome,
55
faInfoCircle,
66
faUser,
77
} from "@fortawesome/free-solid-svg-icons";
8+
import { ThemePicker } from "./ThemePicker";
9+
import reactLogo from "~/assets/react.svg";
810

911
export default function Navigation({ children }: React.PropsWithChildren) {
10-
const navigate = useNavigate();
1112
return (
1213
<Nav
13-
appName="App Name"
14-
logoOnClick={(e) => {
15-
e.preventDefault();
16-
navigate("/");
17-
}}
14+
logo={
15+
<NavLink to="/" className="bf-neutral-link">
16+
<Nav.Logo logo={reactLogo}>App Name</Nav.Logo>
17+
</NavLink>
18+
}
1819
top={
1920
<>
2021
<NavLink to="/profile">
2122
<Nav.Item icon={faUser}>Profile</Nav.Item>
2223
</NavLink>
24+
<ThemePicker />
2325
</>
2426
}
2527
side={

react/src/components/ThemePicker.tsx

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { Checkbox, Nav, Theme, useApplyTheme } from "@intility/bifrost-react";
2+
import { faCircleHalfStroke } from "@fortawesome/free-solid-svg-icons";
3+
import useLocalStorageState from "use-local-storage-state";
4+
5+
export function ThemePicker() {
6+
// persist theme state in local storage.
7+
// you might want to use a cookie or a database instead?
8+
const [theme, setTheme] = useLocalStorageState<Theme>("bfTheme", {
9+
defaultValue: "system",
10+
});
11+
// keep document theme in sync with state
12+
useApplyTheme(theme);
13+
14+
return (
15+
<Nav.Group icon={faCircleHalfStroke} aria-label="Theme picker">
16+
<section>
17+
<Nav.Header>Color theme</Nav.Header>
18+
<Checkbox
19+
type="radio"
20+
label="Dark"
21+
name="color-theme"
22+
checked={theme === "dark"}
23+
onChange={() => setTheme("dark")}
24+
/>
25+
<Checkbox
26+
type="radio"
27+
label="Light"
28+
name="color-theme"
29+
checked={theme === "light"}
30+
onChange={() => setTheme("light")}
31+
/>
32+
<Checkbox
33+
type="radio"
34+
label="System"
35+
name="color-theme"
36+
checked={theme === "system"}
37+
onChange={() => setTheme("system")}
38+
/>
39+
</section>
40+
</Nav.Group>
41+
);
42+
}

0 commit comments

Comments
 (0)