feat(ui): introduce Add clan button into sidebar

This commit is contained in:
Brian McGee
2025-08-20 15:04:37 +01:00
parent fb5645ae33
commit 9834f413cc
3 changed files with 35 additions and 5 deletions

View File

@@ -58,6 +58,7 @@ div.sidebar-header {
@apply px-1; @apply px-1;
.dropdown-group-label { .dropdown-group-label {
@apply flex items-baseline justify-between w-full;
} }
.dropdown-group-items { .dropdown-group-items {

View File

@@ -7,6 +7,7 @@ import { createSignal, For, Suspense } from "solid-js";
import { useClanListQuery } from "@/src/hooks/queries"; import { useClanListQuery } from "@/src/hooks/queries";
import { navigateToClan, useClanURI } from "@/src/hooks/clan"; import { navigateToClan, useClanURI } from "@/src/hooks/clan";
import { clanURIs } from "@/src/stores/clan"; import { clanURIs } from "@/src/stores/clan";
import { Button } from "../Button/Button";
export const SidebarHeader = () => { export const SidebarHeader = () => {
const navigate = useNavigate(); const navigate = useNavigate();
@@ -71,9 +72,19 @@ export const SidebarHeader = () => {
family="mono" family="mono"
size="xs" size="xs"
color="tertiary" color="tertiary"
transform="uppercase"
> >
YOUR CLANS Your Clans
</Typography> </Typography>
<Button
hierarchy="secondary"
ghost
size="xs"
startIcon="Plus"
onClick={() => navigate("/?addClan=true")}
>
Add
</Button>
</DropdownMenu.GroupLabel> </DropdownMenu.GroupLabel>
<div class="dropdown-group-items"> <div class="dropdown-group-items">
<For each={allClans}> <For each={allClans}>

View File

@@ -6,7 +6,11 @@ import {
Setter, Setter,
Switch, Switch,
} from "solid-js"; } from "solid-js";
import { RouteSectionProps, useNavigate } from "@solidjs/router"; import {
RouteSectionProps,
useNavigate,
useSearchParams,
} from "@solidjs/router";
import "./Onboarding.css"; import "./Onboarding.css";
import { Typography } from "@/src/components/Typography/Typography"; import { Typography } from "@/src/components/Typography/Typography";
import { Button } from "@/src/components/Button/Button"; import { Button } from "@/src/components/Button/Button";
@@ -139,15 +143,21 @@ const welcome = (props: {
export const Onboarding: Component<RouteSectionProps> = (props) => { export const Onboarding: Component<RouteSectionProps> = (props) => {
const navigate = useNavigate(); const navigate = useNavigate();
const [searchParams] = useSearchParams();
const activeURI = activeClanURI(); const activeURI = activeClanURI();
if (activeURI) {
console.log("onboarding params", searchParams.addClan);
if (!searchParams.addClan && activeURI) {
// the user has already selected a clan, so we should navigate to it // the user has already selected a clan, so we should navigate to it
console.log("active clan detected, navigating to it", activeURI); console.log("active clan detected, navigating to it", activeURI);
navigateToClan(navigate, activeURI); navigateToClan(navigate, activeURI);
} }
const [state, setState] = createSignal<State>("welcome"); const [state, setState] = createSignal<State>(
searchParams.addClan ? "setup" : "welcome",
);
// used to display an error in the welcome screen in the event of a failed // used to display an error in the welcome screen in the event of a failed
// clan creation // clan creation
@@ -270,7 +280,15 @@ export const Onboarding: Component<RouteSectionProps> = (props) => {
hierarchy="secondary" hierarchy="secondary"
ghost={true} ghost={true}
icon="ArrowLeft" icon="ArrowLeft"
onClick={() => setState("welcome")} onClick={() => {
// if we arrived here by way of adding a clan then we return to the active clan
if (searchParams.addClan && activeURI) {
navigateToClan(navigate, activeURI);
}
// otherwise we return to the initial welcome screen
setState("welcome");
}}
/> />
<Typography hierarchy="headline" size="default" weight="bold"> <Typography hierarchy="headline" size="default" weight="bold">
Setup Setup