Skip to content

Commit a4a635d

Browse files
committed
feat: SyncIndicator in navbar, cancel button, and responsive polish
Add SyncIndicator to navbar showing sync progress from any page. Add Cancel button to settings sync section with fire-and-forget sync. Improve mobile layout with responsive padding and grid breakpoints, add tabular-nums to prevent number-jitter in sync counters.
1 parent 79b1563 commit a4a635d

6 files changed

Lines changed: 15 additions & 10 deletions

File tree

src/lib/components/layout/NavBar.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { page } from '$app/stores';
33
import { resolve } from '$app/paths';
44
import { Button } from '$lib/components/ui/button';
5+
import SyncIndicator from './SyncIndicator.svelte';
56
67
const searchHref = resolve('/search');
78
const settingsHref = resolve('/settings');
@@ -15,6 +16,7 @@
1516
<nav class="bg-background border-b">
1617
<div class="mx-auto flex h-14 max-w-7xl items-center justify-between px-4">
1718
<a href={searchHref} class="text-lg font-semibold tracking-tight">Stargazer</a>
19+
<SyncIndicator />
1820
<div class="flex gap-1">
1921
{#each navItems as item (item.href)}
2022
<Button

src/lib/components/search/RepoDetail.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
<Separator />
6464

6565
<!-- Stats -->
66-
<div class="grid grid-cols-2 gap-3 text-sm sm:grid-cols-4">
66+
<div class="grid grid-cols-2 gap-3 text-sm sm:grid-cols-3 md:grid-cols-4">
6767
<div>
6868
<div class="text-muted-foreground">Stars</div>
6969
<div class="font-medium">{formatNumber(repo.stargazersCount)}</div>

src/lib/components/settings/SyncProgress.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<div class="flex items-center justify-between text-sm">
3737
<span class="font-medium">{phaseLabel}</span>
3838
{#if progress.total > 0}
39-
<span class="text-muted-foreground">{progress.current}/{progress.total}</span>
39+
<span class="text-muted-foreground tabular-nums">{progress.current}/{progress.total}</span>
4040
{/if}
4141
</div>
4242

@@ -49,6 +49,6 @@
4949
</div>
5050
{/if}
5151

52-
<p class="text-muted-foreground text-sm">{progress.message}</p>
52+
<p class="text-muted-foreground text-sm tabular-nums">{progress.message}</p>
5353
</div>
5454
{/if}

src/lib/components/ui/dialog/dialog-content.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
bind:ref
2828
data-slot="dialog-content"
2929
class={cn(
30-
'bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg',
30+
'bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-4 shadow-lg duration-200 sm:max-w-lg sm:p-6',
3131
className
3232
)}
3333
{...restProps}

src/lib/components/ui/sheet/sheet-content.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts" module>
22
import { tv, type VariantProps } from 'tailwind-variants';
33
export const sheetVariants = tv({
4-
base: 'bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500',
4+
base: 'bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 p-4 sm:p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500',
55
variants: {
66
side: {
77
top: 'data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b',

src/routes/settings/+page.svelte

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
2323
async function handleSync() {
2424
await settingsStore.save();
25-
await syncStore.startSync();
26-
await settingsStore.load();
25+
syncStore.startSync();
2726
}
2827
2928
async function handleClearData() {
@@ -35,7 +34,7 @@
3534
}
3635
</script>
3736

38-
<div class="mx-auto max-w-2xl space-y-8 p-6">
37+
<div class="mx-auto max-w-2xl space-y-8 p-3 sm:p-6">
3938
<div>
4039
<h1 class="text-2xl font-bold">Settings</h1>
4140
<p class="text-muted-foreground mt-1 text-sm">
@@ -66,13 +65,17 @@
6665
<section class="space-y-4">
6766
<h2 class="text-lg font-semibold">Sync</h2>
6867

69-
<div class="flex items-center gap-4">
68+
<div class="flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-4">
7069
<SyncButton
7170
isSyncing={syncStore.isSyncing}
7271
disabled={!settingsStore.isValid}
7372
onSync={handleSync}
7473
/>
7574

75+
{#if syncStore.isSyncing}
76+
<Button variant="outline" size="sm" onclick={() => syncStore.cancel()}>Cancel</Button>
77+
{/if}
78+
7679
{#if syncStore.error}
7780
<p class="text-destructive text-sm">{syncStore.error}</p>
7881
{/if}
@@ -83,7 +86,7 @@
8386
<!-- Stats -->
8487
{#if syncStore.lastSyncedAt || syncStore.repoCount > 0}
8588
<div class="rounded-lg border p-4">
86-
<div class="grid grid-cols-3 gap-4 text-center">
89+
<div class="grid grid-cols-1 gap-4 text-center sm:grid-cols-2 md:grid-cols-3">
8790
<div>
8891
<div class="text-2xl font-bold">{syncStore.repoCount}</div>
8992
<div class="text-muted-foreground text-sm">Repositories</div>

0 commit comments

Comments
 (0)