mirror of
https://github.com/Ku6epXBOCTuK/easy-png-tools.git
synced 2026-11-13 17:08:20 +00:00
feat: add size presets for tools
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
spec: FieldSpec;
|
||||
toolId: string;
|
||||
fieldId: string;
|
||||
onchange?: (value: unknown, axis?: "width" | "height") => void;
|
||||
onchange?: (value: unknown, axis?: "width" | "height" | "both") => void;
|
||||
}
|
||||
|
||||
const FIELDS: Record<FieldSpecKind, Component<FieldControlProps>> = {
|
||||
@@ -54,7 +54,11 @@
|
||||
schema: ToolSchema<Record<string, unknown>>;
|
||||
values: Record<string, unknown>;
|
||||
toolId: string;
|
||||
onchange: (id: string, value: unknown, axis?: "width" | "height") => void;
|
||||
onchange: (
|
||||
id: string,
|
||||
value: unknown,
|
||||
axis?: "width" | "height" | "both",
|
||||
) => void;
|
||||
onreset: () => void;
|
||||
}
|
||||
let { schema, values, toolId, onchange, onreset }: Props = $props();
|
||||
|
||||
@@ -74,9 +74,13 @@
|
||||
values = defaultSchemaParams(schema);
|
||||
}
|
||||
|
||||
function setValue(id: string, value: unknown, axis?: "width" | "height") {
|
||||
function setValue(
|
||||
id: string,
|
||||
value: unknown,
|
||||
axis?: "width" | "height" | "both",
|
||||
) {
|
||||
touched.add(id);
|
||||
if (axis) lastAxis[id] = axis;
|
||||
if (axis) lastAxis[id] = axis === "both" ? "width" : axis;
|
||||
const next: Record<string, unknown> = { ...values, [id]: value };
|
||||
const spec = schema?.fields[id]?.spec;
|
||||
if (source && schema && spec) {
|
||||
@@ -84,6 +88,7 @@
|
||||
if (
|
||||
spec.kind === "dimension" &&
|
||||
spec.lockAspectWith &&
|
||||
axis !== "both" &&
|
||||
next[spec.lockAspectWith] === true
|
||||
) {
|
||||
next[id] = withAspectLock(
|
||||
|
||||
Reference in New Issue
Block a user