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
89 changes: 89 additions & 0 deletions e2e/editor.smoke.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,95 @@ test('keeps valid images when another image in the same import batch is corrupt'
await expect(page.locator('.filmstrip__count')).toHaveText('1/1')
})

const FREE_PACK_LOOKS = [
'Coastal Mist',
'Golden Hour Glow',
'Ink Stone',
'Sage Garden',
'Rose Fade',
'Midnight City',
'Ember Portrait',
'Silver Rain',
]

async function openPresets(page: Page) {
const tab = page.getByRole('tab', { name: 'Presets', exact: true })
if (await tab.isVisible()) {
await tab.click()
return
}
await page.getByRole('button', { name: 'Editing tools' }).click()
await page.getByRole('button', { name: 'Presets', exact: true }).click()
}

test('loads one sample photo from an empty-state thumbnail', async ({ page }) => {
await page.goto('/editor')

await expect(page.getByRole('button', { name: 'Open photos' })).toBeVisible()
await expect(page.getByRole('button', { name: 'Try sample photos' })).toBeVisible()
await expect(page.getByRole('button', { name: 'Watch demo' })).toBeVisible()
await page.getByRole('button', { name: 'Open sample photo Pagoda' }).click()

await expect(page.locator('.toolbar__status')).toHaveText('Loaded 1 image')
await expect(page.locator('canvas[aria-label="pagoda.jpg"]')).toBeVisible()
})

test('spanish editor localizes the empty state', async ({ page }) => {
await page.goto('/es/editor')

const title = 'El editor de fotos open source que se queda en tu dispositivo'
await expect(page.getByRole('heading', { level: 1, name: title })).toBeVisible()
expect(await visibleH1Text(page)).toEqual([title])
await expect(page.getByRole('button', { name: 'Abrir fotos' })).toBeVisible()
await expect(page.getByRole('button', { name: 'Probar fotos de ejemplo' })).toBeVisible()
await expect(page.getByRole('button', { name: 'Ver la demo' })).toBeVisible()
await expect(page.getByRole('button', { name: 'Abrir la foto de ejemplo Pagoda' })).toBeVisible()
await expect(page.getByRole('button', { name: 'Sin subir archivos' })).toBeVisible()
await expect(page.getByRole('heading', { level: 1, name: 'The open-source photo editor that stays on your device' })).toHaveCount(0)
await expect(page.getByRole('tab', { name: 'Editar' })).toBeVisible()
await expect(page.getByRole('button', { name: 'Abrir', exact: true })).toBeVisible()
})

test('lists the eight free pack looks in the presets panel', async ({ page }) => {
await page.goto('/editor')
await page.getByRole('button', { name: 'Open sample photo Pagoda' }).click()
await expect(page.locator('.toolbar__status')).toHaveText('Loaded 1 image')

await openPresets(page)
const panel = page.getByRole('region', { name: 'Presets' })
for (const name of FREE_PACK_LOOKS) {
await expect(panel.getByRole('button', { name, exact: true })).toBeVisible()
}
await expect(panel.getByRole('link', { name: 'Download ZIP' })).toHaveAttribute(
'href',
'/downloads/lightframes-free-presets-luts.zip',
)
await expect(panel.getByRole('link', { name: 'About the pack' })).toHaveAttribute('href', '/free-presets-luts')
})

test('spanish presets panel names the free pack in Spanish', async ({ page }) => {
await page.goto('/es/editor')
await page.getByRole('button', { name: 'Abrir la foto de ejemplo Pagoda' }).click()
await expect(page.locator('.toolbar__status')).toHaveText('1 imagen cargada')

const tab = page.getByRole('tab', { name: 'Preajustes', exact: true })
if (await tab.isVisible()) {
await tab.click()
} else {
await page.getByRole('button', { name: 'Herramientas de edición' }).click()
await page.getByRole('button', { name: 'Preajustes', exact: true }).click()
}

const panel = page.getByRole('region', { name: 'Preajustes' })
await expect(panel.getByText('Pack gratis')).toBeVisible()
await expect(panel.getByRole('button', { name: 'Bruma costera', exact: true })).toBeVisible()
await expect(panel.getByRole('link', { name: 'Descargar ZIP' })).toHaveAttribute(
'href',
'/downloads/lightframes-free-presets-luts.zip',
)
await expect(panel.getByRole('link', { name: 'Sobre el pack' })).toHaveAttribute('href', '/es/presets-luts-gratis')
})

test('reports a batch with no importable images without creating a photo', async ({ page }) => {
await prepareFilePicker(page, false)

Expand Down
63 changes: 63 additions & 0 deletions scripts/editor-copy.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { editorCopy, editorLangFromLocation } from '../src/lib/editorCopy.ts'
import pack from '../src/data/free-pack-looks.json' with { type: 'json' }
import { trackFreePackDownload, setAnalyticsTransportForTests } from '../src/lib/analytics.ts'

test('editor language follows the route when html lang is missing', () => {
assert.equal(editorLangFromLocation('/editor', ''), 'en')
assert.equal(editorLangFromLocation('/es/editor', ''), 'es')
assert.equal(editorLangFromLocation('/es/editor', 'en'), 'en')
assert.equal(editorLangFromLocation('/editor', 'es'), 'es')
})

test('empty-state copy keeps the tagline and never says 100% private', () => {
const en = editorCopy('en')
const es = editorCopy('es')
assert.equal(en.empty.title, 'The open-source photo editor that stays on your device')
assert.equal(es.empty.title, 'El editor de fotos open source que se queda en tu dispositivo')
assert.equal(en.empty.nothingUploaded, 'Nothing uploaded')
assert.equal(es.empty.nothingUploaded, 'Sin subir archivos')
assert.deepEqual(
en.empty.samples.map((sample) => sample.file),
['pagoda.jpg', 'twelve-apostles.jpg', 'opera-night.jpg'],
)
assert.deepEqual(
es.empty.samples.map((sample) => sample.file),
en.empty.samples.map((sample) => sample.file),
)
const blob = JSON.stringify({ en, es })
assert.equal(blob.toLowerCase().includes('100% private'), false)
assert.equal(blob.toLowerCase().includes('100 % privado'), false)
})

test('english status lines used by the editor stay exact', () => {
const status = editorCopy('en').status
assert.equal(status.loaded(1, 1, false), 'Loaded 1 image; 1 failed')
assert.equal(status.loaded(2, 0, false), 'Loaded 2 images')
assert.equal(status.loaded(1, 0, true), 'Added 1 image')
assert.equal(status.couldNotOpen(1), 'Could not open 1 image')
assert.equal(status.couldNotOpen(2), 'Could not open 2 images')
assert.equal(status.openToBegin, 'Open images to begin')
assert.equal(status.exportFailed, 'Export failed')
assert.equal(editorCopy('es').status.loaded(1, 0, false), '1 imagen cargada')
assert.equal(editorCopy('es').status.couldNotOpen(1), 'No se ha podido abrir 1 imagen')
})

test('the free pack is eight looks with Spanish names', () => {
assert.equal(pack.looks.length, 8)
assert.equal(pack.looks[0].name, 'Coastal Mist')
assert.equal(pack.looks[0].nameEs, 'Bruma costera')
assert.equal(editorCopy('es').presets.freePack, 'Pack gratis')
assert.equal(editorCopy('en').presets.freePack, 'Free Pack')
})

test('the pack zip download event stays free_pack_download', () => {
const events = []
setAnalyticsTransportForTests((name, props) => {
events.push({ name, props })
})
trackFreePackDownload('full-pack')
assert.deepEqual(events, [{ name: 'free_pack_download', props: { look: 'full-pack' } }])
setAnalyticsTransportForTests(null)
})
44 changes: 29 additions & 15 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { Toast } from './components/Toast'
import { ToneCurvePanel } from './components/ToneCurvePanel'
import { Toolbar } from './components/Toolbar'
import { PANELS, useEditorSession, type PanelId } from './hooks/useEditorSession'
import { useEditorLang } from './hooks/useEditorLang'
import { PHONE_QUERY, useMediaQuery } from './hooks/useMediaQuery'
import { useSheetSwipe } from './hooks/useSheetSwipe'
import type { StudioApi, StudioFormat } from './hooks/useStudio'
Expand All @@ -38,6 +39,7 @@ import { createCollageDoc, type CollageDoc } from './lib/collage'
import { trackToolUsed } from './lib/analytics'
import { aspectRatioFor, fitCropInImage, type FrameSize } from './lib/crop'
import type { ClippingStats, HistogramBins } from './lib/histogram'
import { isSamplePhoto } from './lib/files'
import { isRawFile } from './lib/rawDecode'
import { DEFAULT_EDITS, type HealSpot, type LiquifyStroke } from './types/edits'

Expand All @@ -54,6 +56,7 @@ function loadHistogramHidden(): boolean {
}

export default function App() {
const { copy } = useEditorLang()
const [mode, setMode] = useState<AppMode>('edit')
const modeRef = useRef(mode)
useEffect(() => {
Expand Down Expand Up @@ -427,6 +430,9 @@ export default function App() {
onFrameSize={setFrameSize}
onOpen={() => session.handleOpen()}
onOpenSamples={session.openSamples}
onOpenSample={(name) => {
if (isSamplePhoto(name)) void session.openSample(name)
}}
cropOverlay={
canEdit && session.panelFocus === 'crop' && session.cropMode
? {
Expand Down Expand Up @@ -517,15 +523,20 @@ export default function App() {
overlay={histogramHidden ? null : histogramPanel}
exit={
photoTool
? { label: `Close ${PANELS.find((p) => p.id === session.panelFocus)?.label ?? 'tool'}`, onExit: exitTool }
? {
label: copy.panels.closeTool(
copy.panels[session.panelFocus] ?? 'tool',
),
onExit: exitTool,
}
: null
}
action={{
kind: 'menu',
items: [
...PANELS.map(({ id, label }) => ({
...PANELS.map(({ id }) => ({
id,
label,
label: copy.panels[id],
icon: <PanelIcon id={id} size={18} />,
active: sheetOpen && id === session.panelFocus,
onSelect: () => selectPanel(id),
Expand All @@ -535,7 +546,7 @@ export default function App() {
? [
{
id: 'histogram',
label: 'Histogram',
label: copy.panels.histogram,
icon: <HistogramIcon />,
extra: true,
onSelect: () => changeHistogramHidden(false),
Expand All @@ -550,21 +561,25 @@ export default function App() {
{/* Phones show the tool sheet only once a tool is picked: until then the photo gets the whole screen. */}
{(!phone || (canEdit && sheetOpen)) && (
<aside
className={sheetSwipe.offset !== 0 ? 'sidebar sidebar--dragging' : 'sidebar'}
className={['sidebar', !canEdit && 'sidebar--idle', sheetSwipe.offset !== 0 && 'sidebar--dragging']
.filter(Boolean)
.join(' ')}
style={sheetSwipe.offset ? { transform: `translateY(${sheetSwipe.offset}px)` } : undefined}
aria-label="Editor panels"
aria-label={copy.panels.editorPanels}
>
{phone && (
<PhoneSheetHead
icon={<PanelIcon id={session.panelFocus} />}
title={PANELS.find((p) => p.id === session.panelFocus)?.label}
title={copy.panels[session.panelFocus]}
onClose={() => setSheetCollapsed(true)}
{...swipe}
/>
)}
{!phone && (
<div className="panel-tabs" role="tablist" aria-label="Panels" ref={tabsRef}>
{PANELS.map(({ id, label }, index) => (
<div className="panel-tabs" role="tablist" aria-label={copy.panels.tablist} ref={tabsRef}>
{PANELS.map(({ id }, index) => {
const label = copy.panels[id]
return (
<button
key={id}
type="button"
Expand All @@ -579,7 +594,7 @@ export default function App() {
<PanelIcon id={id} />
<span className="panel-tab__label">{label}</span>
</button>
))}
)})}
</div>
)}

Expand Down Expand Up @@ -782,8 +797,8 @@ export default function App() {

<ConfirmDialog
open={clearOpen}
title="Clear workspace?"
confirmLabel={`Remove ${session.photos.length} photo${session.photos.length === 1 ? '' : 's'}`}
title={copy.confirm.clearTitle}
confirmLabel={copy.confirm.remove(session.photos.length)}
onCancel={closeClear}
onConfirm={() => {
session.clearWorkspace()
Expand All @@ -793,10 +808,9 @@ export default function App() {
}}
>
<p>
This removes all {session.photos.length} open photo{session.photos.length === 1 ? '' : 's'}, their
edits and the undo history. It can't be undone.
{copy.confirm.body(session.photos.length)}
</p>
<p className="confirm__note">Your original files and your presets are not affected.</p>
<p className="confirm__note">{copy.confirm.note}</p>
</ConfirmDialog>

<Toast toast={session.toast} onDismiss={session.dismissToast} />
Expand Down
14 changes: 8 additions & 6 deletions src/components/AdjustmentsPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useEditorLang } from '../hooks/useEditorLang'
import { DEFAULT_EDITS, EDIT_SLIDERS, type BasicEditKey, type EditParams } from '../types/edits'
import { Slider } from './Slider'

Expand Down Expand Up @@ -75,12 +76,13 @@ export function AdjustmentsPanel({
onBegin,
onCommit,
}: AdjustmentsPanelProps) {
const { copy } = useEditorLang()
const sliderProps = { edits, disabled, onChange, onBegin, onCommit }
return (
<section className="panel" aria-label="Adjustments">
<section className="panel" aria-label={copy.panels.adjustments}>
<div className="adjust-group">
<div className="adjust-group__header">
<h3 className="adjust-group__title">Light</h3>
<h3 className="adjust-group__title">{copy.panels.light}</h3>
<div className="btn-group">
<button
type="button"
Expand All @@ -96,9 +98,9 @@ export function AdjustmentsPanel({
className="btn btn--ghost btn--sm"
onClick={onReset}
disabled={disabled}
title="Reset all adjustments"
title={copy.panels.resetAllTitle}
>
Reset all
{copy.panels.resetAll}
</button>
</div>
</div>
Expand All @@ -107,7 +109,7 @@ export function AdjustmentsPanel({

<div className="adjust-group">
<div className="adjust-group__header">
<h3 className="adjust-group__title">Color</h3>
<h3 className="adjust-group__title">{copy.panels.color}</h3>
<div className="btn-group">
<button
type="button"
Expand Down Expand Up @@ -145,7 +147,7 @@ export function AdjustmentsPanel({

<div className="adjust-group">
<div className="adjust-group__header">
<h3 className="adjust-group__title">Presence</h3>
<h3 className="adjust-group__title">{copy.panels.presence}</h3>
</div>
<SliderGroup keys={['texture', 'clarity', 'dehaze']} {...sliderProps} />
</div>
Expand Down
6 changes: 4 additions & 2 deletions src/components/BackgroundPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useSyncExternalStore } from 'react'
import { useEditorLang } from '../hooks/useEditorLang'
import { getAiStatus, preloadModel, subscribeAi } from '../lib/ai'
import type { BackgroundEdit, BackgroundMode } from '../types/edits'
import type { RefineTool } from './RefineOverlay'
Expand Down Expand Up @@ -35,6 +36,7 @@ export function BackgroundPanel({
refine,
onRefineChange,
}: BackgroundPanelProps) {
const { copy } = useEditorLang()
const status = useSyncExternalStore(subscribeAi, () => getAiStatus('segment'))
const active = background.mode !== 'original'

Expand All @@ -45,9 +47,9 @@ export function BackgroundPanel({
}

return (
<section className="panel" aria-label="Background">
<section className="panel" aria-label={copy.panels.background}>
<div className="adjust-group__header heal-header">
<h3 className="adjust-group__title">Background</h3>
<h3 className="adjust-group__title">{copy.panels.background}</h3>
</div>

<div className="segmented" role="group" aria-label="Background">
Expand Down
Loading
Loading