Files
radicle-desktop/src/components/HomeSidebar.svelte
T
Thomas Scholtes 0936d7f9ff Use anchors on home view for better accesibility
Convert clickable elements for filtering repos to anchors so that they
can be focused and activated with the keyboard.
2025-07-21 17:02:03 +02:00

118 lines
3.0 KiB
Svelte

<script lang="ts">
import type { HomeReposTab } from "@app/views/home/router";
import type { RepoCount } from "@bindings/repo/RepoCount";
import * as router from "@app/lib/router";
import Border from "@app/components/Border.svelte";
import Icon from "@app/components/Icon.svelte";
import Settings from "@app/components/Settings.svelte";
interface Props {
activeTab: HomeReposTab;
repoCount: RepoCount;
}
const { activeTab, repoCount }: Props = $props();
</script>
<style>
.container {
display: flex;
flex-direction: column;
height: 100%;
justify-content: space-between;
}
.tab {
align-items: center;
gap: 0.5rem;
background-color: var(--color-background-float);
display: flex;
font-size: var(--font-size-small);
justify-content: space-between;
padding: 0.5rem 0.25rem 0.5rem 0.5rem;
width: 100%;
}
.tab:not(.active) {
color: var(--color-foreground-dim);
}
.tab:not(.active):hover {
background-color: var(--color-fill-float-hover);
}
.active {
background-color: var(--color-background-default);
font-weight: var(--font-weight-semibold);
}
</style>
<div class="container">
<div>
<Border
styleCursor="pointer"
variant="ghost"
styleFlexDirection="column"
styleGap="2px"
styleBackgroundColor="var(--color-background-float)">
<a
tabindex="0"
class="tab txt-small"
class:active={activeTab === "all"}
href={router.routeToPath({
resource: "home",
activeTab: "all",
})}>
<div class="global-flex"><Icon name="repo" />Repositories</div>
<div class="global-counter">
{repoCount.total}
</div>
</a>
<a
class="tab"
class:active={activeTab === "delegate"}
href={router.routeToPath({
resource: "home",
activeTab: "delegate",
})}>
<div class="global-flex">
<Icon name="delegate" />
<div>Delegate</div>
</div>
<div class="global-counter">{repoCount.delegate}</div>
</a>
<a
class="tab"
class:active={activeTab === "contributor"}
href={router.routeToPath({
resource: "home",
activeTab: "contributor",
})}>
<div class="global-flex">
<Icon name="user" />
<div>Contributor</div>
</div>
<div class="global-counter">{repoCount.contributor}</div>
</a>
<a
class="tab"
class:active={activeTab === "private"}
href={router.routeToPath({
resource: "home",
activeTab: "private",
})}>
<div class="global-flex">
<Icon name="lock" />
<div>Private</div>
</div>
<div class="global-counter">{repoCount.private}</div>
</a>
</Border>
</div>
<Settings
compact={false}
popoverProps={{
popoverPositionBottom: "3rem",
popoverPositionLeft: "0",
}} />
</div>