diff --git a/apps/web/src/components/SliderInput.tsx b/apps/web/src/components/SliderInput.tsx index 541b1b0..b3604f3 100644 --- a/apps/web/src/components/SliderInput.tsx +++ b/apps/web/src/components/SliderInput.tsx @@ -10,6 +10,7 @@ interface SliderInputProps { min: number max: number className?: string + controlRef: { setValue?: (weight: number) => void } } export function SliderInput(props: SliderInputProps) { @@ -45,6 +46,7 @@ export function SliderInput(props: SliderInputProps) { props.onChange(value) data.currentValue = value } + props.controlRef.setValue = setValue const labelElem = ( diff --git a/apps/web/src/main.ts b/apps/web/src/main.ts index 0545f41..b77146d 100644 --- a/apps/web/src/main.ts +++ b/apps/web/src/main.ts @@ -170,10 +170,14 @@ function makeToolbar( } toolSelect.append(option) }) + + let setWeightRef: { setValue?: (weight: number | string) => void } = {} toolSelect.addEventListener("change", () => { options.onSetTool(toolSelect.value as T) - // todo: set current line weight when switching tools - options.getLineWeight() + const weight = options.getLineWeight() + if (weight) { + setWeightRef.setValue?.(weight) + } }) inputTray.append(toolSelect) @@ -244,6 +248,7 @@ function makeToolbar( labelAppend: "%", min: 0, max: 100, + controlRef: setWeightRef, getDisplayValue: (value) => value.toFixed(0), onChange(value) { options.onSetOpacity(value) @@ -264,6 +269,7 @@ function makeToolbar( })(), min: 1, max: 256, + controlRef: setWeightRef, getDisplayValue: (value) => value.toString(), onChange(value) { options.onSetLineWeight(value)