Skip to content

Commit a75df5a

Browse files
committed
feat: add slider to dynamic parameters
1 parent 5e4050e commit a75df5a

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

site/src/components/Checkbox/Checkbox.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const Checkbox = React.forwardRef<
1818
<CheckboxPrimitive.Root
1919
ref={ref}
2020
className={cn(
21-
`peer h-6 w-6 shrink-0 rounded-sm border border-border border-solid
21+
`peer h-5 w-5 shrink-0 rounded-sm border border-border border-solid
2222
focus-visible:outline-none focus-visible:ring-2
2323
focus-visible:ring-content-link focus-visible:ring-offset-4 focus-visible:ring-offset-surface-primary
2424
disabled:cursor-not-allowed disabled:bg-surface-primary disabled:data-[state=checked]:bg-surface-tertiary
@@ -34,10 +34,10 @@ export const Checkbox = React.forwardRef<
3434
>
3535
<div className="flex">
3636
{(props.checked === true || props.defaultChecked === true) && (
37-
<Check className="w-5 h-5" strokeWidth={2.5} />
37+
<Check className="w-4 h-4" strokeWidth={2.5} />
3838
)}
3939
{props.checked === "indeterminate" && (
40-
<Minus className="w-5 h-5" strokeWidth={2.5} />
40+
<Minus className="w-4 h-4" strokeWidth={2.5} />
4141
)}
4242
</div>
4343
</CheckboxPrimitive.Indicator>

site/src/modules/workspaces/DynamicParameter/DynamicParameter.tsx

+24-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
SelectTrigger,
2323
SelectValue,
2424
} from "components/Select/Select";
25+
import { Slider } from "components/Slider/Slider";
2526
import { Switch } from "components/Switch/Switch";
2627
import {
2728
Tooltip,
@@ -91,7 +92,7 @@ const ParameterLabel: FC<ParameterLabelProps> = ({ parameter, isPreset }) => {
9192
</span>
9293
)}
9394

94-
<div className="flex flex-col gap-1.5">
95+
<div className="flex flex-col w-full">
9596
<Label className="flex gap-2 flex-wrap text-sm font-medium">
9697
{displayName}
9798

@@ -130,6 +131,11 @@ const ParameterLabel: FC<ParameterLabelProps> = ({ parameter, isPreset }) => {
130131
</Tooltip>
131132
</TooltipProvider>
132133
)}
134+
{parameter.form_type === "slider" && (
135+
<output className="ml-auto font-semibold">
136+
{parameter.value.value}
137+
</output>
138+
)}
133139
</Label>
134140

135141
{hasDescription && (
@@ -278,6 +284,23 @@ const ParameterField: FC<ParameterFieldProps> = ({
278284
</Label>
279285
</div>
280286
);
287+
288+
case "slider":
289+
return (
290+
<Slider
291+
className="mt-2"
292+
defaultValue={[
293+
Number(
294+
parameter.default_value.valid ? parameter.default_value.value : 0,
295+
),
296+
]}
297+
onValueChange={([value]) => onChange(value.toString())}
298+
min={parameter.validations[0]?.validation_min ?? 0}
299+
max={parameter.validations[0]?.validation_max ?? 100}
300+
disabled={disabled}
301+
/>
302+
);
303+
281304
case "input": {
282305
const inputType = parameter.type === "number" ? "number" : "text";
283306
const inputProps: Record<string, unknown> = {};

0 commit comments

Comments
 (0)