Skip to content

Commit 7de1cb8

Browse files
committed
fix: navbar state
1 parent a378e13 commit 7de1cb8

3 files changed

Lines changed: 12 additions & 18 deletions

File tree

TheGreenEpochWeb/src/App.tsx

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { onMount, createSignal, Show, type JSX } from "solid-js";
2-
import { Router, Route, A, useLocation } from "@solidjs/router";
2+
import { Router, Route, A } from "@solidjs/router";
33
import { AppProvider, useApp } from "./data/store";
44
import { ScenariosPage } from "./pages/ScenariosPage";
55
import { LiveSimPage } from "./pages/LiveSimPage";
66
import { ResultsPage } from "./pages/ResultsPage";
7-
import { RunAllPage } from "./pages/RunAllPage";
7+
import { RunsPage } from "./pages/RunsPage";
88

99
const THEME_KEY = "thegreenepoch-theme";
1010

@@ -21,10 +21,6 @@ function applyTheme(theme: "light" | "dark") {
2121
}
2222

2323
function Layout(props: { children?: JSX.Element }) {
24-
const location = useLocation();
25-
const isActive = (path: string, end?: boolean) =>
26-
end ? location.pathname === path : location.pathname.startsWith(path);
27-
2824
const [theme, setTheme] = createSignal(getInitialTheme());
2925

3026
onMount(() => {
@@ -55,19 +51,17 @@ function Layout(props: { children?: JSX.Element }) {
5551
<A
5652
href="/"
5753
end
58-
class={`px-3 py-1.5 rounded-lg no-underline transition-colors ${isActive("/", true)
59-
? "bg-accent-subtle text-accent font-medium"
60-
: "text-fg-subtle hover:text-fg-body hover:bg-white/5"
61-
}`}
54+
class="px-3 py-1.5 rounded-lg no-underline transition-colors"
55+
activeClass="bg-accent-subtle text-accent font-medium"
56+
inactiveClass="text-fg-subtle hover:text-fg-body hover:bg-white/5"
6257
>
6358
Scenarios
6459
</A>
6560
<A
66-
href="/run-all"
67-
class={`px-3 py-1.5 rounded-lg no-underline transition-colors ${isActive("/run-all")
68-
? "bg-accent-subtle text-accent font-medium"
69-
: "text-fg-subtle hover:text-fg-body hover:bg-white/5"
70-
}`}
61+
href="/runs"
62+
class="px-3 py-1.5 rounded-lg no-underline transition-colors"
63+
activeClass="bg-accent-subtle text-accent font-medium"
64+
inactiveClass="text-fg-subtle hover:text-fg-body hover:bg-white/5"
7165
>
7266
Runs
7367
</A>
@@ -126,7 +120,7 @@ export function App() {
126120
<Route path="/" component={ScenariosPage} />
127121
<Route path="/simulate/:id" component={LiveSimPage} />
128122
<Route path="/results/:id" component={ResultsPage} />
129-
<Route path="/run-all" component={RunAllPage} />
123+
<Route path="/runs" component={RunsPage} />
130124
</Router>
131125
</Show>
132126
);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function uniqVals(data: SimResult[], key: string, fmt: string, dec?: number) {
9494
.map(e => e[0]);
9595
}
9696

97-
export function RunAllPage() {
97+
export function RunsPage() {
9898
const app = useApp();
9999

100100
const [running, setRunning] = createSignal(false);

TheGreenEpochWeb/src/pages/ScenariosPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function ScenariosPage() {
5252
<span class="mr-1">+</span>Add scenario
5353
</button>
5454
<A
55-
href="/run-all"
55+
href="/runs"
5656
class="px-4 py-2 rounded-lg border border-accent/40 text-accent text-sm font-medium hover:bg-accent-subtle active:scale-[0.97] transition-all"
5757
>
5858
Run all

0 commit comments

Comments
 (0)