Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 19 additions & 26 deletions src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,14 @@ select optgroup {
/* The OS preference, unless Settings → Appearance has overridden it to "Full".
`data-motion` is absent when the setting is "System", so the media query is
the only thing deciding then. */
/* Labs, switching between open databases: the whole screen swaps at once, so
nothing fades or slides for that frame (StudioShell sets it for two frames).
Without it every tab pill, row highlight and chip ran its own 100ms
transition and the swap read as layers flickering in turn. */
html[data-swapping] :is(*, *::before, *::after) {
transition: none !important;
}

@media (prefers-reduced-motion: reduce) {
html:not([data-motion="full"]) :is(*, *::before, *::after) {
animation-duration: 0.01ms !important;
Expand Down Expand Up @@ -1530,36 +1538,21 @@ pre code,
linear-gradient(to bottom, transparent 45%, rgb(0 0 0 / 0.24));
}

/* ── Glossy chip ─────────────────────────────────────────────────────────────
A tinted pill in `--chip` (a colour): a lit top edge, a soft fill that darkens
toward the foot, a hairline ring and the same fine grain as the marks. Used
for plan badges (Pro, Trial). */
/* ── Plan tag ────────────────────────────────────────────────────────────────
A small flat tag in `--chip` (a colour): a faint tint and a hairline ring,
nothing more. It sits beside a name or a setting label, so it stays at the
text's own height and never reads as a button. Used for plan badges (Pro,
Trial, Free). */
.chip-gloss {
--chip: var(--success);
position: relative;
isolation: isolate;
overflow: hidden;
display: inline-flex;
align-items: center;
border-radius: 9999px;
color: color-mix(in oklch, var(--chip) 88%, var(--foreground));
background: linear-gradient(to bottom, color-mix(in oklch, var(--chip) 24%, transparent), color-mix(in oklch, var(--chip) 12%, transparent));
box-shadow:
inset 0 1px 0 color-mix(in oklch, white 22%, transparent),
inset 0 0 0 1px color-mix(in oklch, var(--chip) 40%, transparent),
0 1px 2px rgb(0 0 0 / 0.18);
}
.chip-gloss::after {
content: "";
position: absolute;
inset: 0;
z-index: -1;
pointer-events: none;
border-radius: inherit;
opacity: 0.22;
mix-blend-mode: overlay;
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0.6 0.6 0.6 0 -0.4 0.6 0.6 0.6 0 -0.4 0.6 0.6 0.6 0 -0.4 0 0 0 0 1'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
background-size: 120px 120px;
border-radius: 0.3125rem;
letter-spacing: 0.01em;
line-height: 1;
color: color-mix(in oklch, var(--chip) 85%, var(--foreground));
background: color-mix(in oklch, var(--chip) 12%, transparent);
box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--chip) 24%, transparent);
}
.chip-gloss.chip-warning { --chip: var(--warning); }
/* ── Glossy key ──────────────────────────────────────────────────────────────
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/AccountCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
{#snippet planPill()}
<span
class={cn(
'chip-gloss h-6 shrink-0 px-2.5 text-ui-2xs font-semibold',
'chip-gloss h-[1.125rem] shrink-0 px-1.5 text-ui-3xs font-medium',
plan.tone === 'trial' && 'chip-warning',
plan.tone === 'free' && 'chip-muted',
)}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/SettingsDialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@
<div class="min-w-0">
<p class="flex items-center gap-2 text-ui-sm font-medium text-foreground">
{label}
{#if badge}<span class="h-5 px-2 text-ui-2xs font-semibold {badge.class}">{badge.label}</span>{/if}
{#if badge}<span class="h-[1.125rem] px-1.5 text-ui-3xs font-medium {badge.class}">{badge.label}</span>{/if}
</p>
<p class="mt-0.5 text-ui-xs leading-relaxed text-muted-foreground">{desc}</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/SharesPage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
</span>
</span>
{:else}
<span class="chip-gloss h-5 px-2 text-ui-3xs font-semibold">Pro</span>
<span class="chip-gloss h-[1.125rem] px-1.5 text-ui-3xs font-medium">Pro</span>
{/if}
</div>
{/if}
Expand Down
28 changes: 11 additions & 17 deletions src/lib/components/StatusBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -725,30 +725,24 @@
</div>
{/if}

<!-- Labs, several databases open: every one of them, the one in front
marked. Clicking one brings it forward; its tabs are already in the
tab bar. While one opens, this says so and the page stays as it is. -->
<!-- Labs, several databases open: the database chip above is the one in
front; the others follow it, once each, as plain names. Clicking one
brings it forward (its tabs are already in the tab bar). While one
opens, its name shows with a spinner and the page stays as it is. -->
{#if switchingTo}
{@render sep()}
<span role="status" class="flex h-7 min-w-0 shrink-0 items-center gap-1.5 px-2 text-ui-xs text-muted-foreground">
<Icon name="loader-2" class="size-3.5 shrink-0 animate-spin" />
Opening <span class="max-w-[8rem] truncate text-foreground">{switchingTo}</span>
<span class="max-w-[8rem] truncate">{switchingTo}</span>
</span>
{:else if openDatabases.length}
{@render sep()}
<div role="group" aria-label="Open databases" class="flex min-w-0 items-center gap-0.5 @max-[48rem]/sb:hidden">
{#each openDatabases as db (db.key)}
{:else if openDatabases.length > 1}
<div role="group" aria-label="Other open databases" class="flex min-w-0 items-center @max-[48rem]/sb:hidden">
{#each openDatabases.filter((d) => !d.current) as db (db.key)}
<button
type="button"
class={cn(
'flex h-6 min-w-0 max-w-[9rem] items-center gap-1.5 rounded-md px-2 text-ui-2xs transition-colors duration-100',
db.current ? 'bg-sidebar-accent text-foreground' : 'text-muted-foreground hover:bg-sidebar-accent/60 hover:text-foreground',
)}
aria-current={db.current ? 'true' : undefined}
title={db.current ? `${db.label}: open now` : `Switch to ${db.label}`}
onclick={() => { if (!db.current) onopendatabase(db.key) }}
class="flex h-7 min-w-0 max-w-[9rem] items-center rounded-md px-2 text-ui-xs text-muted-foreground hover:bg-sidebar-accent/60 hover:text-foreground"
title={`Switch to ${db.label}`}
onclick={() => onopendatabase(db.key)}
>
<span aria-hidden="true" class={cn('size-1.5 shrink-0 rounded-full', db.current ? 'bg-success' : 'bg-muted-foreground/40')}></span>
<span class="truncate">{db.label}</span>
</button>
{/each}
Expand Down
32 changes: 23 additions & 9 deletions src/lib/components/StudioShell.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8627,8 +8627,12 @@ let rowSearch = $state('')
async function activateForeignTab(id) {
const hit = sessionOfTab(id)
if (!hit) return
await handleSwitchDatabase(hit.s.conn, { focusTab: id })
// The clicked tab lights up now, not when its database is in front.
pressedTab = id
try { await handleSwitchDatabase(hit.s.conn, { focusTab: id }) } finally { pressedTab = '' }
}
/** Labs: a tab of another database that was clicked and is being brought forward. */
let pressedTab = $state('')

/** Close a tab of another open database without switching to it. @param {string} id */
function closeForeignTab(id) {
Expand All @@ -8642,9 +8646,9 @@ let rowSearch = $state('')

/**
* Labs: one tab bar for every open database. This database's tabs and the
* kept ones, grouped in the order the databases were opened. A group after
* the first starts with a divider; which database a tab belongs to is in its
* tooltip and in the status bar (openDatabases), not on the tab.
* kept ones, in the order the databases were opened, so no tab moves on a
* switch. They look like any other tab: which database one belongs to is in
* its tooltip and in the status bar (openDatabases).
*/
const barTabs = $derived.by(() => {
void sessionsTick
Expand All @@ -8660,8 +8664,7 @@ let rowSearch = $state('')
for (const k of order) {
const group = k === here
? own.map((t) => ({ ...t, connLabel: label }))
: (_sessions.get(k)?.tabs ?? []).filter((t) => t.kind !== 'welcome' && t.kind !== 'ai').map((t) => ({ ...t, connLabel: _sessions.get(k)?.label, foreign: true }))
if (group.length && out.length) group[0] = { ...group[0], groupStart: true }
: (_sessions.get(k)?.tabs ?? []).filter((t) => t.kind !== 'welcome' && ($appAiInTab || t.kind !== 'ai')).map((t) => ({ ...t, connLabel: _sessions.get(k)?.label, foreign: true }))
out.push(...group)
}
return out
Expand Down Expand Up @@ -8805,11 +8808,22 @@ let rowSearch = $state('')
_sessions.delete(key)
noteSession(key)
sessionsTick++
holdTransitions()
await resumeSession(session.conn, session, focusTab)
sidebarShowTables()
return true
}

/** Swap the screen without transitions until two frames after the change (app.css, data-swapping). */
function holdTransitions() {
const root = document.documentElement
root.setAttribute('data-swapping', '')
clearTimeout(_swapTimer)
_swapTimer = setTimeout(() => requestAnimationFrame(() => requestAnimationFrame(() => root.removeAttribute('data-swapping'))), 0)
}
/** @type {ReturnType<typeof setTimeout> | undefined} */
let _swapTimer

/**
* Connect, and when a provider's credentials were revoked or rotated in its
* console, mint fresh ones once: the same recovery the connect dialog does.
Expand Down Expand Up @@ -9976,7 +9990,7 @@ let rowSearch = $state('')
{#if tabsInTitle}
<TabBar
tabs={barTabs}
{activeTabId}
activeTabId={pressedTab || activeTabId}
onselect={(id) => (tabs.some((t) => t.id === id) ? activateTab(id) : activateForeignTab(id))}
onclose={(id) => (tabs.some((t) => t.id === id) ? closeTab(id) : closeForeignTab(id))}
oncloseothers={(id) => { if (tabs.some((t) => t.id === id)) closeOtherTabs(id) }}
Expand Down Expand Up @@ -10337,7 +10351,7 @@ let rowSearch = $state('')
{#if tabBarVisible && !tabsInTitle}
<TabBar
tabs={barTabs}
{activeTabId}
activeTabId={pressedTab || activeTabId}
onselect={(id) => (tabs.some((t) => t.id === id) ? activateTab(id) : activateForeignTab(id))}
onclose={(id) => (tabs.some((t) => t.id === id) ? closeTab(id) : closeForeignTab(id))}
oncloseothers={(id) => { if (tabs.some((t) => t.id === id)) closeOtherTabs(id) }}
Expand All @@ -10360,7 +10374,7 @@ let rowSearch = $state('')
databases show their tabs here too. Split, each pane lists its own. -->
<TabBar
tabs={paneCount <= 1 && barTabs.some((t) => t.foreign) ? barTabs : group.tabIds.map((id) => tabsById.get(id)).filter(Boolean)}
activeTabId={group.activeTabId}
activeTabId={pressedTab || group.activeTabId}
onselect={(id) => (tabs.some((t) => t.id === id) ? void focusTabInGroup(group.id, id) : void activateForeignTab(id))}
onclose={(id) => (tabs.some((t) => t.id === id) ? void closeTabInGroup(group.id, id) : closeForeignTab(id))}
oncloseothers={(id) => { if (tabs.some((t) => t.id === id)) closeOtherTabs(id) }}
Expand Down
8 changes: 2 additions & 6 deletions src/lib/components/TabBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,6 @@
{@const tabIconName = tabIcon(tab)}
{@const active = tab.id === activeTabId}

<!-- Labs, several databases open: each database's tabs are a group. -->
{#if tab.groupStart}
<span aria-hidden="true" class="mx-1 h-4 w-px shrink-0 self-center bg-border"></span>
{/if}
<ContextMenu.Root>
<ContextMenu.Trigger>
{#snippet child({ props: ctxProps })}
Expand Down Expand Up @@ -220,8 +216,8 @@
)}
onclick={() => { if (_suppressTabClick) { _suppressTabClick = false; return } onselect(tab.id) }}
>
<Icon name={tabIconName} class={cn('size-3.5 shrink-0', active ? 'text-foreground' : 'text-muted-foreground', tab.foreign && 'opacity-60')} />
<span class={cn('truncate', tab.foreign && 'opacity-70')}>{tabDisplayTitle(tab)}</span>
<Icon name={tabIconName} class={cn('size-3.5 shrink-0', active ? 'text-foreground' : 'text-muted-foreground')} />
<span class="truncate">{tabDisplayTitle(tab)}</span>
</button>

{#if tab.pinned}
Expand Down
Loading