separate trim from review and save
This commit is contained in:
+15
-124
@@ -1,131 +1,22 @@
|
||||
<script lang="ts">
|
||||
import type { GifBudgetMode, GifDither } from "./api"
|
||||
import Dropdown from "./ui/Dropdown.svelte"
|
||||
import Slider from "./ui/Slider.svelte"
|
||||
|
||||
let {
|
||||
budgetMode = $bindable(),
|
||||
dither = $bindable(),
|
||||
colors = $bindable(),
|
||||
onChange,
|
||||
}: {
|
||||
budgetMode: GifBudgetMode
|
||||
dither: GifDither
|
||||
colors: number
|
||||
onChange: () => void
|
||||
let { budgetMode = $bindable(), dither = $bindable(), colors = $bindable(), disabled = false }: {
|
||||
budgetMode: GifBudgetMode; dither: GifDither; colors: number; disabled?: boolean
|
||||
} = $props()
|
||||
const priorities = [
|
||||
{ value:"balanced", label:"Balanced" }, { value:"resolution", label:"Preserve resolution" }, { value:"framerate", label:"Preserve frame rate" },
|
||||
] as const
|
||||
const dithers = [{ value:"floyd_steinberg",label:"Floyd-Steinberg" }, { value:"bayer",label:"Bayer" }, { value:"none",label:"None" }] as const
|
||||
|
||||
</script>
|
||||
|
||||
<div class="control-group">
|
||||
<span class="section-title">Budget priority</span>
|
||||
<div class="fmt-bar">
|
||||
{#each (["resolution", "framerate", "balanced"] as const) as m}
|
||||
<button
|
||||
class="fmt-chip"
|
||||
class:active={budgetMode === m}
|
||||
onclick={() => { budgetMode = m; onChange() }}
|
||||
>{m === "resolution" ? "Resolution" : m === "framerate" ? "Framerate" : "Balanced"}</button>
|
||||
{/each}
|
||||
</div>
|
||||
<p class="estimate">
|
||||
{budgetMode === "resolution" ? "Keeps resolution high, may reduce FPS" :
|
||||
budgetMode === "framerate" ? "Keeps FPS high, may reduce resolution" :
|
||||
"Balances resolution and FPS"}
|
||||
</p>
|
||||
<h3>GIF compression</h3>
|
||||
<div class="form-field"><span>Budget priority</span><Dropdown label="GIF budget priority" bind:value={budgetMode} options={priorities} {disabled} /></div>
|
||||
<div>
|
||||
<div class="row between"><span>Palette colors</span><output class="mono">{colors}</output></div>
|
||||
<Slider label="GIF palette colors" bind:value={colors} min={2} max={256} {disabled} />
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<span class="section-title">Colors</span>
|
||||
<div class="control-head">
|
||||
<input
|
||||
type="range"
|
||||
class="styled-range"
|
||||
min={2}
|
||||
max={256}
|
||||
step={1}
|
||||
aria-label="colors"
|
||||
bind:value={colors}
|
||||
onchange={onChange}
|
||||
/>
|
||||
<span class="mono" style="min-width:32px;text-align:right">{colors}</span>
|
||||
</div>
|
||||
<p class="estimate">{colors <= 32 ? "Low - small file, posterized" : colors <= 128 ? "Medium - balanced" : "High - full color"}</p>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<span class="section-title">Dithering</span>
|
||||
<div class="fmt-bar">
|
||||
{#each (["floyd_steinberg", "bayer", "none"] as const) as d}
|
||||
<button
|
||||
class="fmt-chip"
|
||||
class:active={dither === d}
|
||||
onclick={() => { dither = d; onChange() }}
|
||||
>{d === "floyd_steinberg" ? "Floyd-Steinberg" : d === "bayer" ? "Bayer" : "None"}</button>
|
||||
{/each}
|
||||
</div>
|
||||
<p class="estimate">{dither === "floyd_steinberg" ? "Smooth gradients, slightly larger" : dither === "bayer" ? "Patterned, smaller file" : "No dithering, smallest file"}</p>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.control-group { display: flex; flex-direction: column; gap: 8px; }
|
||||
.control-head { display: flex; justify-content: space-between; align-items: center; }
|
||||
.section-title {
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.1em;
|
||||
color: var(--text-3);
|
||||
}
|
||||
.estimate {
|
||||
margin: 0;
|
||||
font-size: 11px;
|
||||
color: var(--text-3);
|
||||
font-family: var(--mono);
|
||||
}
|
||||
|
||||
.fmt-bar {
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
padding: 3px;
|
||||
background: var(--bg-2);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--r-sm);
|
||||
width: fit-content;
|
||||
}
|
||||
.fmt-chip {
|
||||
padding: 5px 14px;
|
||||
background: transparent;
|
||||
border: 1px solid transparent;
|
||||
color: var(--text-3);
|
||||
border-radius: var(--r-sm);
|
||||
font-family: var(--mono);
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.04em;
|
||||
cursor: pointer;
|
||||
transition: all 80ms;
|
||||
}
|
||||
.fmt-chip:hover { color: var(--text-2); }
|
||||
.fmt-chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
|
||||
|
||||
.styled-range {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
width: 100%;
|
||||
height: 3px;
|
||||
background: var(--bg-3);
|
||||
border-radius: 2px;
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
.styled-range::-webkit-slider-thumb {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
width: 14px; height: 14px;
|
||||
border-radius: 50%;
|
||||
background: var(--accent);
|
||||
border: 2px solid var(--bg);
|
||||
cursor: pointer;
|
||||
transition: transform 80ms;
|
||||
}
|
||||
.styled-range::-webkit-slider-thumb:hover { transform: scale(1.2); }
|
||||
.mono { font-family: var(--mono); }
|
||||
</style>
|
||||
<div class="form-field"><span>Dithering</span><Dropdown label="GIF dithering" bind:value={dither} options={dithers} {disabled} /></div>
|
||||
|
||||
Reference in New Issue
Block a user