Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
feat(components): make the `<SlideDeck />` more flashy (#4678)
Elijah Potter605578e3e68e
diff --git a/packages/components/src/lib/SlideDeck.stories.svelte b/packages/components/src/lib/SlideDeck.stories.svelteindex 0594c4d94..2a2c2da8e 100644--- a/packages/components/src/lib/SlideDeck.stories.svelte+++ b/packages/components/src/lib/SlideDeck.stories.svelte@@ -13,12 +13,14 @@ const { Story } = defineMeta({title: 'Slide deck',lede: 'A simple slide deck example.',nextDisabled: false,+ showAside: false,},argTypes: {slideProgress: { control: false },onBack: { control: false },onNext: { control: false },nextDisabled: { control: 'boolean' },+ showAside: { control: 'boolean' },},});</script>@@ -39,3 +41,19 @@ let step = $state(0);</SlideDeck>{/snippet}</Story>++<Story name="With Aside" args={{ showAside: true }}>+ {#snippet template(args)}+ <SlideDeck+ {...args}+ slideProgress={step / 2}+ onBack={() => (step = Math.max(0, step - 1))}+ onNext={() => (step = Math.min(2, step + 1))}+ >+ <p class="mt-4">Slide {step + 1} of 3</p>+ <div slot="aside" class="grid size-48 place-items-center rounded-lg bg-primary-100 text-primary-900">+ Aside content+ </div>+ </SlideDeck>+ {/snippet}+</Story>diff --git a/packages/components/src/lib/SlideDeck.svelte b/packages/components/src/lib/SlideDeck.svelteindex e38727c1c..ad4ac56b6 100644--- a/packages/components/src/lib/SlideDeck.svelte+++ b/packages/components/src/lib/SlideDeck.svelte@@ -8,10 +8,13 @@ import Panel from './Panel.svelte';/*** Slide deck shell: `slideProgress` runs from 0 (first slide) to 1 (last slide)* and controls navigation visibility. The default slot holds slide-specific- * content; the `outside` slot renders below the clipped panel. `onBack` and- * `onNext` synchronously update the parent's active slide before focus moves.+ * content; the `outside` slot renders below the clipped panel. Set `showAside`+ * to place the `aside` slot to the right of the text on desktop or below it on+ * mobile. `onBack` and `onNext` synchronously update the parent's active slide+ * before focus moves.* `nextDisabled` blocks forward navigation through both the button and keyboard- * shortcuts without preventing users from going back.+ * shortcuts without preventing users from going back. Forward navigation plays a+ * diagonal flash across the slide content unless the user prefers reduced motion.*/export let title: string;export let lede: string;@@ -19,19 +22,37 @@ export let slideProgress: number;export let onBack: () => void;export let onNext: () => void;export let nextDisabled = false;+export let showAside = false;let heading: HTMLElement;+/**+ * Number of flashes played. Each increment recreates the flash overlay through+ * `{#key}`, which restarts its CSS animation. Pointer presses on Next increment it+ * on press down; keyboard navigation increments it when the step changes.+ */+let flashCount = 0;+onMount(() => {window.addEventListener('keydown', handleKeydown);return () => window.removeEventListener('keydown', handleKeydown);});-/** Move within the walkthrough bounds, then focus the new heading after rendering. */-async function changeStep(direction: -1 | 1) {- if (direction === -1 ? slideProgress <= 0 : slideProgress >= 1 || nextDisabled) return;+function canAdvance() {+ return slideProgress < 1 && !nextDisabled;+}++/**+ * Move within the walkthrough bounds, then focus the new heading after rendering.+ * `flash` is false for pointer clicks because their press down already played it.+ */+async function changeStep(direction: -1 | 1, flash = direction === 1) {+ if (direction === -1 ? slideProgress <= 0 : !canAdvance()) return;if (direction === -1) onBack();- else onNext();+ else {+ onNext();+ if (flash) flashCount += 1;+ }await tick();heading?.focus();}@@ -71,7 +92,7 @@ function handleKeydown(event: KeyboardEvent) {<main class="grid h-dvh grid-cols-1 place-items-center overflow-y-auto bg-[#f1ede5] px-6 py-6 text-[var(--marketing-ink)] scheme-light [scrollbar-gutter:stable_both-edges] sm:py-12"><!-- Viewport-based width keeps the panel unchanged when reserving scrollbar gutters. -->- <div class="relative w-[calc(100vw-3rem)] max-w-[46rem]">+ <div class="relative w-[calc(100vw-3rem)] max-w-[64rem]"><div class="overflow-hidden rounded-lg border border-black/15 bg-[#fbfaf7] shadow-sm"><divclass="h-1 bg-black/5"@@ -87,36 +108,54 @@ function handleKeydown(event: KeyboardEvent) {></div></div>- <div class="p-3 sm:p-6">+ <div class="relative overflow-hidden p-3 sm:p-6"><Panel class="border-black/10! shadow-sm">- <div class="min-h-76 p-4 {slideProgress === 1 ? 'sm:p-8' : 'sm:p-7'}">+ <div class="grid min-h-112 p-6 sm:p-10">{#key slideProgress}- <div>- <svelte:element- this={slideProgress === 0 ? 'h1' : 'h2'}- bind:this={heading}- tabindex="-1"- id="step-heading"- class="m-0! p-0! font-[family-name:Domine,serif] font-semibold! text-3xl! leading-tight! tracking-normal! text-pretty focus:outline-none sm:text-4xl!"- >- {title}- </svelte:element>- <p class="m-0! max-w-lg font-[family-name:Domine,serif] text-base font-medium leading-relaxed! text-pretty text-[var(--marketing-ink-2)] sm:text-lg {slideProgress === 1 ? 'mt-10!' : 'mt-5!'}">{lede}</p>- <slot />+ <div class={showAside ? 'grid items-center gap-10 md:grid-cols-[minmax(0,1fr)_minmax(0,16rem)]' : ''}>+ <div class="min-w-0 self-start">+ <svelte:element+ this={slideProgress === 0 ? 'h1' : 'h2'}+ bind:this={heading}+ tabindex="-1"+ id="step-heading"+ class="m-0! p-0! font-[family-name:Domine,serif] font-semibold! leading-tight! tracking-normal! text-pretty focus:outline-none text-4xl! sm:text-5xl!"+ >+ {title}+ </svelte:element>+ <p class="mx-0! mb-0! font-[family-name:Domine,serif] font-medium leading-relaxed! text-pretty text-[var(--marketing-ink-2)] max-w-2xl text-lg sm:text-xl mt-6!">{lede}</p>+ <slot />+ </div>+ {#if showAside}+ <div class="flex min-w-0 items-center justify-center self-stretch py-3 md:px-3">+ <slot name="aside" />+ </div>+ {/if}</div>{/key}</div></Panel>++ {#key flashCount}+ {#if flashCount > 0}+ <div class="slide-flash pointer-events-none absolute inset-0 z-10" aria-hidden="true"></div>+ {/if}+ {/key}</div><div class="flex items-center justify-end gap-2 border-t border-black/10 bg-[#fbfaf7] px-6 pt-3 pb-4">{#if slideProgress > 0}- <Button size="sm" color="white" class="bg-white! text-gray-900! hover:bg-gray-100! motion-reduce:transition-none" aria-label="Back" on:click={() => changeStep(-1)}>+ <Button size="md" color="white" class="bg-white! text-gray-900! hover:bg-gray-100! motion-reduce:transition-none" aria-label="Back" on:click={() => changeStep(-1)}><ChevronLeftIcon className="size-4" /></Button>{/if}{#if slideProgress < 1}- <Button size="sm" color="primary" class="bg-primary-600! text-white! hover:bg-primary-700! focus:ring-primary-300! motion-reduce:transition-none" disabled={nextDisabled} on:click={() => changeStep(1)}>+ <Button size="md" color="primary" class="bg-primary-600! text-white! hover:bg-primary-700! focus:ring-primary-300! motion-reduce:transition-none" disabled={nextDisabled}+ onpointerdown={(event: PointerEvent) => {+ if (event.button === 0 && canAdvance()) flashCount += 1;+ }}+ onclick={(event: MouseEvent) => changeStep(1, event.detail === 0)}+ ><span>Next</span><ChevronRightIcon className="size-5" /></Button>diff --git a/packages/components/src/lib/styles.css b/packages/components/src/lib/styles.cssindex 79429eb15..c2619a748 100644--- a/packages/components/src/lib/styles.css+++ b/packages/components/src/lib/styles.css@@ -71,6 +71,68 @@--color-white-950: #221502;}+@layer components {+ /*+ * The gradient image is three times the size of the content area, so the visible+ * area shows one third of the 135deg gradient line. The streak occupies 45%-53% of+ * that line, and moving the position from 82% to 15% carries it from just outside+ * the top-left corner to just outside the bottom-right corner for any aspect ratio.+ */+ .slide-flash {+ /*+ * A light tint of the progress bar amber; the fallback covers hosts without+ * marketing tokens. Mixing with white keeps the hue while lifting the tone.+ */+ --flash-color: color-mix(in srgb, var(--marketing-amber-soft, #d98b3a) 55%, white);+ background-image:+ linear-gradient(+ 135deg,+ transparent 45.2%,+ color-mix(in srgb, var(--flash-color) 70%, transparent) 45.4%,+ color-mix(in srgb, var(--flash-color) 70%, transparent) 45.8%,+ transparent 46%+ ),+ linear-gradient(+ 135deg,+ transparent 47.5%,+ color-mix(in srgb, var(--flash-color) 30%, transparent) 49%,+ color-mix(in srgb, var(--flash-color) 50%, transparent) 50%,+ color-mix(in srgb, var(--flash-color) 30%, transparent) 51%,+ transparent 52.5%+ );+ background-repeat: no-repeat;+ background-size: 300% 300%;+ background-position: 82% 82%;+ /* A soft amber glow gives the streak an anime-style bloom. */+ filter: drop-shadow(0 0 8px color-mix(in srgb, var(--flash-color) 35%, transparent));+ opacity: 0;+ animation: slide-flash 350ms ease-in-out forwards;+ }++ @keyframes slide-flash {+ 0% {+ background-position: 82% 82%;+ opacity: 0;+ }+ 10% {+ opacity: 1;+ }+ 85% {+ opacity: 1;+ }+ 100% {+ background-position: 15% 15%;+ opacity: 0;+ }+ }++ @media (prefers-reduced-motion: reduce) {+ .slide-flash {+ display: none;+ }+ }+}+body {@apply bg-white dark:bg-white-900 dark:text-white;}diff --git a/packages/web/src/routes/install-browser-extension/+page.svelte b/packages/web/src/routes/install-browser-extension/+page.svelteindex b68ad78f2..ebc91d9d5 100644--- a/packages/web/src/routes/install-browser-extension/+page.svelte+++ b/packages/web/src/routes/install-browser-extension/+page.svelte@@ -49,16 +49,21 @@ let demoText =title={steps[step].title}lede={steps[step].lede}slideProgress={step / (steps.length - 1)}+ showAside={step === 1}onBack={() => step--}onNext={() => step++}>- {#if step === 1}- <div class="mt-[1.9rem] flex flex-wrap gap-[0.55rem] [&>span]:bg-[#fff]!">- {#each ['gmail', 'notion', 'github', 'slack', 'wordpress', 'reddit'] as id}- <AppLogoTile {id} size={32} />- {/each}- </div>- {:else if step === 2 || step === 3}+ <svelte:fragment slot="aside">+ {#if step === 1}+ <div class="grid w-fit -rotate-6 grid-cols-3 gap-3 [&>span]:bg-[#fff]! [&>span]:size-14! sm:[&>span]:size-17!">+ {#each ['gmail', 'github', 'reddit', 'wordpress', 'slack', 'notion', 'linear', 'discord', 'whatsapp'] as id}+ <AppLogoTile {id} size={68} />+ {/each}+ </div>+ {/if}+ </svelte:fragment>++ {#if step === 2 || step === 3}<videoclass="mt-6 block w-full rounded-[6px] border-[0.5px] border-[rgba(28,26,22,0.14)]"autoplay