Skip to content

Commit d5d0418

Browse files
committed
removed image bg
1 parent e4244d7 commit d5d0418

9 files changed

Lines changed: 26 additions & 73 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Short notes for changes on branch **`v2`** relative to **`main`** (no dedicated
2424
### Changed
2525

2626
- **Home & SEO** — copy aligned with current UX (multi-line, adjacent links, terminology); Aligner (Bitext Align) branding; `SeoIntro`, `SeoSections`, `JsonLd`, `metadata.ts`.
27-
- **Preview**`AlignmentPreview`, token markup (`TokenView`, `TokenRow`), link layer (`AlignmentSvg`) with pairs and line order; line reorder and line actions; **in-preview controls follow preview light/dark (or image) background**, not only the page theme.
27+
- **Preview**`AlignmentPreview`, token markup (`TokenView`, `TokenRow`), link layer (`AlignmentSvg`) with pairs and line order; line reorder and line actions; **in-preview controls follow preview light/dark background**, not only the page theme.
2828
- **SVG export** — respects `pairControls`, background, line weight/opacity, optional embedded fonts, etc. (`svg.ts`, `ExportMenu`).
2929
- **Settings** — Style / Colors / Tokens / Fonts tabs; icons (gear for editor tokenization settings, split-cells for Tokens); **Flowbite `Tabs`**: `classes.content` instead of deprecated `contentClass`.
3030
- **Link palette** — when colors run out, the palette **cycles** (`palettes`).
@@ -38,6 +38,7 @@ Short notes for changes on branch **`v2`** relative to **`main`** (no dedicated
3838
### Removed / replaced
3939

4040
- Older narrow editor/preview pieces for a single-sentence model (`GlossInputRow`, `SentenceField`, `GlossRow`) — replaced by **multi-line cards** and token rows in preview.
41+
- **Preview background image** — removed from Style settings (legacy shares / compact `bg:2` decode as light).
4142

4243
### Dependencies (`bitext`)
4344

bitext/src/app.css

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,20 +101,6 @@ html {
101101
border-color: rgb(55 65 81);
102102
}
103103

104-
.preview-frame__image-overlay {
105-
position: absolute;
106-
inset: 0;
107-
backdrop-filter: blur(1px);
108-
}
109-
110-
.preview-frame--light .preview-frame__image-overlay {
111-
background: color-mix(in srgb, #ffffff 82%, transparent);
112-
}
113-
114-
.preview-frame--dark .preview-frame__image-overlay {
115-
background: color-mix(in srgb, #1e1e1e 82%, transparent);
116-
}
117-
118104
/* Floating link hint — no panel chrome; halo keeps text readable on busy previews */
119105
.preview-frame__link-hint {
120106
margin: 0;

bitext/src/lib/components/preview/AlignmentPreview.svelte

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,9 @@
3838
<div
3939
bind:this={rootEl}
4040
class="preview-frame"
41-
class:preview-frame--light={bg === 'light' || bg === 'image'}
41+
class:preview-frame--light={bg === 'light'}
4242
class:preview-frame--dark={bg === 'dark'}
43-
style:background-image={bg === 'image' && settingsStore.settings.backgroundImageDataUrl
44-
? `url(${settingsStore.settings.backgroundImageDataUrl})`
45-
: undefined}
46-
style:background-size="cover"
47-
style:background-position="center"
4843
>
49-
{#if bg === 'image' && settingsStore.settings.backgroundImageDataUrl}
50-
<div class="preview-frame__image-overlay"></div>
51-
{/if}
5244
{#if selectionStore.showLinkHint()}
5345
<p
5446
class="preview-frame__link-hint pointer-events-none absolute left-3 top-3 z-30 max-w-[min(calc(100%-1.5rem),15rem)] px-2 py-1 text-xs leading-snug"

bitext/src/lib/components/settings/AppearanceTab.svelte

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
const sel =
88
'block w-full rounded-none border border-gray-300 bg-gray-50 p-2.5 text-sm text-gray-900 focus:border-primary-500 focus:ring-primary-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:focus:border-primary-500 dark:focus:ring-primary-500';
99
10-
const fileInputClass =
11-
'block w-full cursor-pointer rounded-none border border-gray-300 bg-gray-50 text-sm text-gray-900 focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-400';
1210
</script>
1311

1412
<div class="grid grid-cols-12 gap-4">
@@ -52,12 +50,11 @@
5250
value={s.background}
5351
onchange={(e) =>
5452
settingsStore.patch({
55-
background: (e.currentTarget as HTMLSelectElement).value as 'light' | 'dark' | 'image'
53+
background: (e.currentTarget as HTMLSelectElement).value as 'light' | 'dark'
5654
})}
5755
>
5856
<option value="light">Light</option>
5957
<option value="dark">Dark</option>
60-
<option value="image">Image</option>
6158
</select>
6259
</div>
6360
<div class="col-span-12 md:col-span-6">
@@ -75,26 +72,4 @@
7572
<option value="curved">Curved</option>
7673
</select>
7774
</div>
78-
{#if s.background === 'image'}
79-
<div class="col-span-12">
80-
<Label for="settings-bg-file" class="mb-2">Background image</Label>
81-
<input
82-
id="settings-bg-file"
83-
type="file"
84-
accept="image/*"
85-
class={fileInputClass}
86-
onchange={async (e) => {
87-
const f = (e.currentTarget as HTMLInputElement).files?.[0];
88-
if (!f) return;
89-
const dataUrl = await new Promise<string>((res, rej) => {
90-
const r = new FileReader();
91-
r.onload = () => res(String(r.result));
92-
r.onerror = () => rej(new Error('read'));
93-
r.readAsDataURL(f);
94-
});
95-
settingsStore.patch({ backgroundImageDataUrl: dataUrl });
96-
}}
97-
/>
98-
</div>
99-
{/if}
10075
</div>

bitext/src/lib/serialization/compact-v2.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ function settingsToCompact(rounded: VisualSettingsV1): CompactSettings | undefin
234234
if (rounded.tokenSplitChars !== def.tokenSplitChars) o.sp = rounded.tokenSplitChars;
235235

236236
if (rounded.background !== def.background) {
237-
o.bg = rounded.background === 'light' ? 0 : rounded.background === 'dark' ? 1 : 2;
237+
o.bg = rounded.background === 'dark' ? 1 : 0;
238238
}
239239

240240
return Object.keys(o).length ? sortKeys(o) : undefined;
@@ -270,7 +270,8 @@ function compactToVisualSettings(s: CompactSettings | undefined): VisualSettings
270270
if (s.sp !== undefined) raw.tokenSplitChars = String(s.sp);
271271
if (s.bg !== undefined) {
272272
const n = Number(s.bg);
273-
raw.background = n === 1 ? 'dark' : n === 2 ? 'image' : 'light';
273+
/* Legacy 2 = image → light */
274+
raw.background = n === 1 ? 'dark' : 'light';
274275
}
275276
return normalizeVisualSettings(raw);
276277
}
@@ -355,7 +356,6 @@ function compactToProject(
355356

356357
export function toCompactJSON(state: AppStateV1): string {
357358
const slimSettings = { ...state.settings };
358-
delete slimSettings.backgroundImageDataUrl;
359359

360360
const rounded = roundVisualSettings(slimSettings);
361361
const sCompact = settingsToCompact(rounded);

bitext/src/lib/serialization/compact-v3.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function settingsToCompact(rounded: VisualSettingsV2): CompactSettings3 | undefi
6565
}
6666
if (rounded.tokenPunctuationChars) o.px = rounded.tokenPunctuationChars;
6767
if (rounded.background !== def.background) {
68-
o.bg = rounded.background === 'light' ? 0 : rounded.background === 'dark' ? 1 : 2;
68+
o.bg = rounded.background === 'dark' ? 1 : 0;
6969
}
7070
const keysBeforeFinalize = Object.keys(o).length;
7171
if (keysBeforeFinalize > 0) {
@@ -90,7 +90,8 @@ function compactToVisualSettings(s: CompactSettings3 | undefined): VisualSetting
9090
if (s.pp !== undefined) raw.tokenSplitPunctuation = Number(s.pp) === 1;
9191
if (s.bg !== undefined) {
9292
const n = Number(s.bg);
93-
raw.background = n === 1 ? 'dark' : n === 2 ? 'image' : 'light';
93+
/* Legacy 2 = image → light */
94+
raw.background = n === 1 ? 'dark' : 'light';
9495
}
9596
return normalizeVisualSettingsV2(raw);
9697
}
@@ -295,7 +296,6 @@ function pruneConnections(
295296

296297
export function toCompactJSON(state: AppStateV2): string {
297298
const slimSettings = { ...state.settings };
298-
delete slimSettings.backgroundImageDataUrl;
299299
const rounded = roundVisualSettings(slimSettings);
300300
const sCompact = settingsToCompact(rounded);
301301
const pCompact = projectToCompact(state.project);

bitext/src/lib/serialization/schema.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ export const MAX_LINES = 8;
1616
export const NEW_LINE_HINT_TEXT = 'Type your text here';
1717

1818
export type LineStyle = 'straight' | 'curved';
19-
export type BackgroundMode = 'light' | 'dark' | 'image';
19+
export type BackgroundMode = 'light' | 'dark';
20+
21+
/** Map legacy / invalid values to the preview background enum (image mode removed). */
22+
export function normalizePreviewBackground(mode: unknown): BackgroundMode {
23+
if (mode === 'dark') return 'dark';
24+
return 'light';
25+
}
2026
/** How link colors apply to tokens when “match token color to links” is on. */
2127
export type TokenLinkColorMode = 'text' | 'background';
2228
export type UiTheme = 'light' | 'dark';
@@ -150,7 +156,6 @@ export interface VisualSettingsV2 {
150156
/** Hide preview chrome (line controls, gap sliders, toolbar) and show export-style attribution in-frame. */
151157
previewHideChrome: boolean;
152158
background: BackgroundMode;
153-
backgroundImageDataUrl?: string;
154159
}
155160

156161
export interface AppStateV2 {
@@ -186,7 +191,6 @@ export interface VisualSettingsV1 {
186191
colorTokensByLink: boolean;
187192
tokenSplitChars: string;
188193
background: BackgroundMode;
189-
backgroundImageDataUrl?: string;
190194
}
191195

192196
/** @deprecated v1 */
@@ -302,8 +306,7 @@ export function visualSettingsV1ToV2(v1: VisualSettingsV1): VisualSettingsV2 {
302306
tokenSplitPunctuation: false,
303307
tokenPunctuationChars: '',
304308
previewHideChrome: false,
305-
background: v1.background,
306-
backgroundImageDataUrl: v1.backgroundImageDataUrl
309+
background: normalizePreviewBackground(v1.background)
307310
};
308311
}
309312

@@ -539,7 +542,7 @@ export function normalizeVisualSettings(
539542
)
540543
);
541544

542-
return {
545+
const out = {
543546
...d,
544547
...rawRest,
545548
sourceTextSizePx,
@@ -590,8 +593,11 @@ export function normalizeVisualSettings(
590593
glossLineGapPx:
591594
typeof rawRest.glossLineGapPx === 'number'
592595
? Math.max(0, Math.min(80, rawRest.glossLineGapPx))
593-
: d.glossLineGapPx
596+
: d.glossLineGapPx,
597+
background: normalizePreviewBackground(rawRest.background ?? d.background)
594598
} as VisualSettingsV1;
599+
delete (out as unknown as Record<string, unknown>).backgroundImageDataUrl;
600+
return out;
595601
}
596602

597603
export function appStateV2FromV1(state: AppStateV1): AppStateV2 {
@@ -769,13 +775,6 @@ export function normalizeVisualSettingsV2(
769775
tokenSplitChars: splitNorm,
770776
previewHideChrome:
771777
typeof raw.previewHideChrome === 'boolean' ? raw.previewHideChrome : d.previewHideChrome,
772-
background:
773-
raw.background === 'light' || raw.background === 'dark' || raw.background === 'image'
774-
? raw.background
775-
: d.background,
776-
backgroundImageDataUrl:
777-
typeof raw.backgroundImageDataUrl === 'string'
778-
? raw.backgroundImageDataUrl
779-
: d.backgroundImageDataUrl
778+
background: normalizePreviewBackground(raw.background ?? d.background)
780779
};
781780
}

bitext/src/lib/serialization/serialization-roundtrip.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ describe('compact v3 encode/decode (current share format)', () => {
250250
it('enum coverage: lineStyle, background', () => {
251251
const base = migrate({});
252252
const lineStyles: LineStyle[] = ['straight', 'curved'];
253-
const backgrounds: BackgroundMode[] = ['light', 'dark', 'image'];
253+
const backgrounds: BackgroundMode[] = ['light', 'dark'];
254254
for (const lineStyle of lineStyles) {
255255
for (const background of backgrounds) {
256256
const next: AppStateV2 = {

bitext/src/routes/about/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@
313313
<ul class="mt-3 list-disc space-y-2 pl-6 text-gray-700 dark:text-gray-300">
314314
<li>
315315
<strong class="text-gray-900 dark:text-white">Style</strong> — light or dark UI, background of the
316-
preview (including image background), whether connectors are curved or straight, how thick and faint
316+
preview background (light or dark), whether connectors are curved or straight, how thick and faint
317317
they are, default vertical space between lines, and optional per-pair spacing overrides. You can
318318
also hide preview controls for a clean screenshot and open fullscreen from the preview toolbar.
319319
</li>

0 commit comments

Comments
 (0)