Skip to content

Commit 6149b1b

Browse files
committed
Migrate to spa-router
1 parent ebffff4 commit 6149b1b

13 files changed

+42
-123
lines changed

frontend/bun.lockb

729 Bytes
Binary file not shown.

frontend/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"mode-watcher": "^0.3.0",
3737
"openapi-fetch": "^0.9.3",
3838
"svelte-sonner": "^0.3.22",
39+
"svelte-spa-router": "^4.0.1",
3940
"tailwind-merge": "^2.2.2",
4041
"tailwind-variants": "^0.2.1",
4142
"vaul-svelte": "^0.3.0"

frontend/src/App.svelte

+27-28
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,42 @@
11
<script lang="ts">
22
import { ModeWatcher, toggleMode } from "mode-watcher";
33
import { Sun, Moon } from "lucide-svelte";
4-
import * as Tabs from "$lib/components/ui/tabs";
54
import { Button } from "$lib/components/ui/button";
6-
import Points from "./Points.svelte";
7-
import Setup from "./Setup.svelte";
8-
import Predictions from "./Predictions.svelte";
5+
import Points from "./routes/Points.svelte";
6+
import Setup from "./routes/Setup.svelte";
7+
import Predictions from "./routes/Predictions.svelte";
98
import { onMount } from "svelte";
109
import { get_streamers, streamers } from "./common";
11-
import Logs from "./Logs.svelte";
10+
import Logs from "./routes/Logs.svelte";
11+
import Router, { location } from "svelte-spa-router";
1212
1313
onMount(async () => {
1414
streamers.set(await get_streamers());
1515
});
16+
17+
const routes = {
18+
'/': Points,
19+
'/predictions': Predictions,
20+
'/setup': Setup,
21+
'/logs': Logs
22+
}
23+
24+
const tab_class = "data-[state=active]:bg-background data-[state=active]:text-foreground rounded-sm px-3 py-1.5 text-sm shadow-sm inline-flex items-center justify-center h-8";
1625
</script>
1726

1827
<main class="container min-w-full min-h-full pt-4 font-sans">
1928
<ModeWatcher />
20-
<Tabs.Root value="Points">
21-
<Tabs.List>
22-
<Tabs.Trigger value="Points">Points</Tabs.Trigger>
23-
<Tabs.Trigger value="Predictions">Predictions</Tabs.Trigger>
24-
<Tabs.Trigger value="Setup">Setup</Tabs.Trigger>
25-
<Tabs.Trigger value="Logs">Logs</Tabs.Trigger>
26-
</Tabs.List>
27-
<div class="flex justify-between items-center">
28-
<div></div>
29-
<h1 class="text-4xl mb-4 inline">Twitch points miner</h1>
29+
<div class="flex justify-center">
30+
<div class="flex justify-start w-full">
31+
<div class="bg-muted rounded-md p-1 h-10 inline-flex items-center text-muted-foreground">
32+
<Button variant="ghost" class={tab_class} data-state={$location === '/' ? 'active' : 'inactive'} href="#/">Points</Button>
33+
<Button variant="ghost" class={tab_class} data-state={$location === '/predictions' ? 'active' : 'inactive'} href="#/predictions">Predictions</Button>
34+
<Button variant="ghost" class={tab_class} data-state={$location === '/setup' ? 'active' : 'inactive'} href="#/setup">Setup</Button>
35+
<Button variant="ghost" class={tab_class} data-state={$location === '/logs' ? 'active' : 'inactive'} href="#/logs">Logs</Button>
36+
</div>
37+
</div>
38+
<h1 class="text-4xl mb-4 w-full text-center">Twitch points miner</h1>
39+
<div class="flex justify-end w-full">
3040
<Button
3141
on:click={toggleMode}
3242
variant="outline"
@@ -42,17 +52,6 @@
4252
<span class="sr-only">Toggle theme</span>
4353
</Button>
4454
</div>
45-
<Tabs.Content value="Points">
46-
<Points />
47-
</Tabs.Content>
48-
<Tabs.Content value="Predictions">
49-
<Predictions />
50-
</Tabs.Content>
51-
<Tabs.Content value="Setup">
52-
<Setup />
53-
</Tabs.Content>
54-
<Tabs.Content value="Logs">
55-
<Logs />
56-
</Tabs.Content>
57-
</Tabs.Root>
55+
</div>
56+
<Router {routes}/>
5857
</main>

frontend/src/Config.svelte renamed to frontend/src/lib/components/ui/Config.svelte

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
import { Button } from "$lib/components/ui/button";
66
import { Separator } from "$lib/components/ui/separator";
77
import { Plus, X } from "lucide-svelte";
8-
import DetailedStrategy from "./strategy/DetailedStrategy.svelte";
9-
import { type FilterType, type ValidateStrategy } from "./common";
10-
import type { components } from "./api";
8+
import DetailedStrategy from "../../../strategy/DetailedStrategy.svelte";
9+
import { type FilterType, type ValidateStrategy } from "../../../common";
10+
import type { components } from "../../../api";
1111
import {
1212
DETAILED_STRATEGY_ODDS_COMPARISON_TYPES,
1313
detailed_strategy_stringify,
14-
} from "./strategy/strategy";
14+
} from "../../../strategy/strategy";
1515
import type { Selected } from "bits-ui";
1616
1717
export let filters: FilterType[];

frontend/src/WatchPriority.svelte renamed to frontend/src/lib/components/ui/WatchPriority.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
set_watch_priority,
1010
streamers,
1111
type Streamer,
12-
} from "./common";
12+
} from "../../../common";
1313
import { Menu } from "lucide-svelte";
1414
import { Toaster, toast } from "svelte-sonner";
1515
import type { Selected } from "bits-ui";

frontend/src/lib/components/ui/tabs/index.ts

-18
This file was deleted.

frontend/src/lib/components/ui/tabs/tabs-content.svelte

-21
This file was deleted.

frontend/src/lib/components/ui/tabs/tabs-list.svelte

-19
This file was deleted.

frontend/src/lib/components/ui/tabs/tabs-trigger.svelte

-23
This file was deleted.

frontend/src/Logs.svelte renamed to frontend/src/routes/Logs.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
22
import * as Card from "$lib/components/ui/card";
33
import { onMount } from "svelte";
4-
import { get_logs } from "./common";
4+
import { get_logs } from "../common";
55
import { ScrollArea } from "$lib/components/ui/scroll-area";
66
import { Button } from "$lib/components/ui/button";
77
import { ChevronLeft, ChevronRight, RefreshCcw } from "lucide-svelte";

frontend/src/Points.svelte renamed to frontend/src/routes/Points.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import type { components } from "./api";
2+
import type { components } from "../api";
33
import { Button } from "$lib/components/ui/button";
44
import { Calendar } from "lucide-svelte";
55
import {
@@ -22,7 +22,7 @@
2222
import { writable } from "svelte/store";
2323
import * as Select from "$lib/components/ui/select";
2424
import type { Selected } from "bits-ui";
25-
import { get_timeline, streamers, type Streamer } from "./common";
25+
import { get_timeline, streamers, type Streamer } from "../common";
2626
let margin = {top: 50};
2727
2828
let streamers_name: Streamer[] = [];

frontend/src/Predictions.svelte renamed to frontend/src/routes/Predictions.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
get_live_streamers,
1313
get_last_prediction,
1414
place_bet_streamer,
15-
} from "./common";
15+
} from "../common";
1616
import { get } from "svelte/store";
17-
import type { components } from "./api";
17+
import type { components } from "../api";
1818
import type { Selected } from "bits-ui";
1919
import { RefreshCcw } from "lucide-svelte";
2020

frontend/src/Setup.svelte renamed to frontend/src/routes/Setup.svelte

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
add_or_update_preset,
3131
delete_preset,
3232
get_watching,
33-
} from "./common";
33+
} from "../common";
3434
import { ArrowUpDown, SlidersHorizontal, X } from "lucide-svelte";
35-
import Config from "./Config.svelte";
36-
import type { components } from "./api";
37-
import WatchPriority from "./WatchPriority.svelte";
35+
import Config from "../lib/components/ui/Config.svelte";
36+
import type { components } from "../api";
37+
import WatchPriority from "../lib/components/ui/WatchPriority.svelte";
3838
import { ScrollArea } from "$lib/components/ui/scroll-area";
3939
4040
let data = writable<Streamer[]>([]);

0 commit comments

Comments
 (0)