From 7201ed256f6f034a2ba601409baa4765b0082e44 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 13 Nov 2026 16:38:07 +0000 Subject: [PATCH] Let the homepage compare sample photos with a drag handle. The landing before/after pairs now use the same split as the editor, in English and Spanish. The person-removal still stays on the tool pages and is left off the home showcase. Co-authored-by: Joan Comadran --- src/site/components/CompareSlider.astro | 140 +++++++++++++++++++ src/site/landing.ts | 4 + src/site/results.ts | 8 ++ src/site/styles/site.css | 177 ++++++++++++++++++++++++ src/site/views/LandingView.astro | 33 ++++- 5 files changed, 359 insertions(+), 3 deletions(-) create mode 100644 src/site/components/CompareSlider.astro diff --git a/src/site/components/CompareSlider.astro b/src/site/components/CompareSlider.astro new file mode 100644 index 0000000..6e90603 --- /dev/null +++ b/src/site/components/CompareSlider.astro @@ -0,0 +1,140 @@ +--- +/** + * Draggable before/after split. Same read as the editor preview: the original + * stays on the left of the line, the result on the right, and the handle tracks + * the pointer. No network and no extra packages — the stills are the ones already + * shipped in public/site/results/. + */ +import type { Still } from '../results' + +interface Props { + before: Still + after: Still + /** Accessible name for the handle, in the page language. */ + label: string +} + +const { before, after, label } = Astro.props +const ratio = `${before.width} / ${before.height}` +--- + +
+
+ + + {before.alt} + + + + {after.alt} + +
+
+ {before.label} + {after.label} + +
+
+ + diff --git a/src/site/landing.ts b/src/site/landing.ts index c098457..e009c18 100644 --- a/src/site/landing.ts +++ b/src/site/landing.ts @@ -18,6 +18,8 @@ export const landing = { results: { h2: 'Before and after, from the sample photos', lead: 'These are the sample photos shipped with the editor, processed with the same code. Nothing here is a mockup.', + hint: 'Drag the handle to compare. With the handle focused, the arrow keys move it too.', + compareLabel: 'Compare before and after', }, facts: ['Free and open source', 'Presets, XMP and LUTs', 'Nothing uploaded'], video: { @@ -79,6 +81,8 @@ export const landing = { results: { h2: 'Antes y después, con las fotos de ejemplo', lead: 'Son las fotos de ejemplo que trae el editor, procesadas con el mismo código. No hay maquetas.', + hint: 'Arrastra el control para comparar. Con el control enfocado, las flechas también lo mueven.', + compareLabel: 'Comparar antes y después', }, facts: ['Gratis y de código abierto', 'Presets, XMP y LUTs', 'Sin subir nada'], video: { diff --git a/src/site/results.ts b/src/site/results.ts index 1c99ca8..255d8a6 100644 --- a/src/site/results.ts +++ b/src/site/results.ts @@ -47,6 +47,11 @@ export interface ResultExample { title: string caption: string shots: Still[] + /** + * Home before/after showcase. Tool pages still pick the example up through + * `exampleForTool`, so `false` only hides it on `/` and `/es`. + */ + home?: boolean } const PATHS: Record> = { @@ -130,6 +135,9 @@ export function resultExamples(lang: Lang): ResultExample[] { { toolKey: 'remove-objects', href: href['remove-objects'], + // The heal still reads as a smudge at landing size, so the home showcase skips it. + // The remove-objects tool pages keep this pair, including the still files. + home: false, title: en ? 'Person healed out' : 'Persona eliminada con el parche', caption: en ? 'A crop of public/samples/pagoda.jpg. After is one Heal spot on the person standing on the gravel: brush radius about 53 px on the long edge, copying gravel from 110 px left and 70 px up, then blended by the editor’s Heal code. The brush also reaches the second person, who stands against the eaves, so that edge stays soft. An inpaint of these figures filled the hole with leaves, so this still is the Heal result.' diff --git a/src/site/styles/site.css b/src/site/styles/site.css index 7e94ba6..48b6cb8 100644 --- a/src/site/styles/site.css +++ b/src/site/styles/site.css @@ -586,10 +586,187 @@ a { margin-top: 48px; } +.ba-grid { + display: grid; + gap: 40px 24px; +} + +.ba-grid > .ba-block + .ba-block { + margin-top: 0; +} + +.ba-stack { + margin-top: 48px; +} + +@media (min-width: 860px) { + .ba-grid { + grid-template-columns: repeat(2, minmax(0, 1fr)); + align-items: start; + } + + .ba-block--lead { + grid-column: 1 / -1; + } +} + .ba-block h3 { margin-bottom: 12px; } +/* Landing compare handle. Mirrors the editor split divider (src/index.css .split-divider): + white line, round grip, before on the left of the line and after on the right. */ + +.compare { + --pos: 50%; + position: relative; + aspect-ratio: var(--ratio, 3 / 2); + overflow: hidden; + border-radius: 12px; + border: 1px solid var(--line-strong); + background: var(--bg-panel); + user-select: none; + -webkit-user-select: none; +} + +.compare__frame { + position: absolute; + inset: 0; + overflow: hidden; + border-radius: inherit; +} + +.compare--alpha .compare__frame { + background-color: #121816; + background-image: + linear-gradient(45deg, #243028 25%, transparent 25%), + linear-gradient(-45deg, #243028 25%, transparent 25%), + linear-gradient(45deg, transparent 75%, #243028 75%), + linear-gradient(-45deg, transparent 75%, #243028 75%); + background-size: 20px 20px; + background-position: + 0 0, + 0 10px, + 10px -10px, + -10px 0; +} + +.compare__layer { + position: absolute; + inset: 0; + margin: 0; + display: block; +} + +.compare__layer--before { + /* 1px under the after layer so a subpixel seam never shows the page background. */ + clip-path: inset(0 calc(100% - var(--pos) - 1px) 0 0); +} + +.compare__layer--after { + clip-path: inset(0 0 0 var(--pos)); +} + +.compare__layer img { + position: absolute; + inset: 0; + width: 100%; + height: 100%; + max-width: none; + object-fit: cover; + object-position: center; + border: 0; + border-radius: 0; + background: transparent; + pointer-events: none; + -webkit-user-drag: none; +} + +.compare__handle { + position: absolute; + z-index: 1; + top: 0; + bottom: 0; + left: var(--pos); + width: 44px; + margin: 0; + padding: 0; + transform: translateX(-50%); + border: 0; + background: transparent; + color: inherit; + cursor: ew-resize; + touch-action: none; +} + +.compare__handle::before { + content: ''; + position: absolute; + top: 0; + bottom: 0; + left: 50%; + width: 2px; + transform: translateX(-50%); + background: #fff; + box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35); +} + +.compare__handle:focus { + outline: none; +} + +.compare__handle:focus-visible .compare__grip { + outline: 2px solid var(--accent); + outline-offset: 3px; +} + +.compare__grip { + position: absolute; + top: 50%; + left: 50%; + width: 26px; + height: 26px; + transform: translate(-50%, -50%); + border-radius: 999px; + background: #fff; + box-shadow: 0 1px 6px rgba(0, 0, 0, 0.45); +} + +.compare__grip::before { + content: '‹ ›'; + position: absolute; + inset: 0; + display: grid; + place-items: center; + font-family: var(--font-ui); + font-size: 0.8rem; + font-weight: 700; + color: #222; + letter-spacing: 0.1em; +} + +.compare__label { + position: absolute; + top: 0.6rem; + padding: 0.15rem 0.45rem; + border-radius: 999px; + background: rgba(12, 16, 14, 0.7); + font-family: var(--font-ui); + font-size: 0.64rem; + letter-spacing: 0.06em; + text-transform: uppercase; + color: #fff; + white-space: nowrap; +} + +.compare__label--before { + right: calc(50% + 20px); +} + +.compare__label--after { + left: calc(50% + 20px); +} + .ba-block h3 a { color: inherit; text-underline-offset: 3px; diff --git a/src/site/views/LandingView.astro b/src/site/views/LandingView.astro index 168b374..7ac34e9 100644 --- a/src/site/views/LandingView.astro +++ b/src/site/views/LandingView.astro @@ -1,5 +1,6 @@ --- import BeforeAfter from '../components/BeforeAfter.astro' +import CompareSlider from '../components/CompareSlider.astro' import FaqList from '../components/FaqList.astro' import ToolList from '../components/ToolList.astro' import { SITE, absoluteUrl } from '../config' @@ -24,7 +25,11 @@ const allTools = await getTools(lang) const tools = allTools.filter((tool) => tool.data.featured) const faq = (await getFaq(lang)).slice(0, 6) const posts = (await getPosts(lang)).slice(0, 3) -const examples = resultExamples(lang) +// Person-removal stays on the tool page (`home: false`). Pairs become a slider; +// anything else (the carousel filmstrip) keeps the labeled stills. +const examples = resultExamples(lang).filter((example) => example.home !== false) +const compares = examples.filter((example) => example.shots.length === 2) +const galleries = examples.filter((example) => example.shots.length !== 2) ---

{c.results.h2}

{c.results.lead}

+

{c.results.hint}

+
+ { + compares.map((example, index) => { + const [before, after] = example.shots + if (!before || !after) return null + return ( + + ) + }) + } +
{ - examples.map((example) => ( -