Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
69 lines
1.9 KiB
TypeScript
69 lines
1.9 KiB
TypeScript
"use client";
|
|
|
|
import * as React from "react";
|
|
import type { CoverStyle } from "@/lib/types";
|
|
import { Label } from "@/components/ui/label";
|
|
import { Select } from "@/components/ui/select";
|
|
|
|
export interface CoverStylePickerProps {
|
|
styles: readonly CoverStyle[];
|
|
/** Currently selected style id. */
|
|
value: string;
|
|
disabled?: boolean;
|
|
onChange: (styleId: string) => void;
|
|
}
|
|
|
|
/** Simple hex-colour validation for an optional swatch. */
|
|
function isHexColor(value: unknown): value is string {
|
|
return typeof value === "string" && /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(value);
|
|
}
|
|
|
|
/**
|
|
* Native-select picker for the cover render style. Selection is owned by the
|
|
* parent; this component only reports changes. Renders an accent swatch and the
|
|
* selected style's description as help text.
|
|
*/
|
|
export function CoverStylePicker({
|
|
styles,
|
|
value,
|
|
disabled = false,
|
|
onChange,
|
|
}: Readonly<CoverStylePickerProps>) {
|
|
const selectId = React.useId();
|
|
const selected = React.useMemo(
|
|
() => styles.find((s) => s.id === value),
|
|
[styles, value],
|
|
);
|
|
const accent = selected && isHexColor(selected.accent) ? selected.accent : undefined;
|
|
|
|
return (
|
|
<div className="space-y-1.5">
|
|
<Label htmlFor={selectId}>Style</Label>
|
|
<div className="flex items-center gap-2">
|
|
{accent && (
|
|
<span
|
|
aria-hidden
|
|
className="size-5 shrink-0 rounded-full border border-border"
|
|
style={{ backgroundColor: accent }}
|
|
/>
|
|
)}
|
|
<Select
|
|
id={selectId}
|
|
value={value}
|
|
disabled={disabled}
|
|
onChange={(e) => onChange(e.target.value)}
|
|
>
|
|
{styles.map((style) => (
|
|
<option key={style.id} value={style.id}>
|
|
{style.name}
|
|
</option>
|
|
))}
|
|
</Select>
|
|
</div>
|
|
{selected?.description && (
|
|
<p className="text-xs text-muted-foreground">{selected.description}</p>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|