Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: add slider to dynamic parameters #17453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions site/src/components/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const Checkbox = React.forwardRef<
<CheckboxPrimitive.Root
ref={ref}
className={cn(
`peer h-6 w-6 shrink-0 rounded-sm border border-border border-solid
`peer h-5 w-5 shrink-0 rounded-sm border border-border border-solid
focus-visible:outline-none focus-visible:ring-2
focus-visible:ring-content-link focus-visible:ring-offset-4 focus-visible:ring-offset-surface-primary
disabled:cursor-not-allowed disabled:bg-surface-primary disabled:data-[state=checked]:bg-surface-tertiary
Expand All @@ -34,10 +34,10 @@ export const Checkbox = React.forwardRef<
>
<div className="flex">
{(props.checked === true || props.defaultChecked === true) && (
<Check className="w-5 h-5" strokeWidth={2.5} />
<Check className="w-4 h-4" strokeWidth={2.5} />
)}
{props.checked === "indeterminate" && (
<Minus className="w-5 h-5" strokeWidth={2.5} />
<Minus className="w-4 h-4" strokeWidth={2.5} />
)}
</div>
</CheckboxPrimitive.Indicator>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
SelectTrigger,
SelectValue,
} from "components/Select/Select";
import { Slider } from "components/Slider/Slider";
import { Switch } from "components/Switch/Switch";
import {
Tooltip,
Expand Down Expand Up @@ -91,7 +92,7 @@ const ParameterLabel: FC<ParameterLabelProps> = ({ parameter, isPreset }) => {
</span>
)}

<div className="flex flex-col gap-1.5">
<div className="flex flex-col w-full">
<Label className="flex gap-2 flex-wrap text-sm font-medium">
{displayName}

Expand Down Expand Up @@ -130,6 +131,11 @@ const ParameterLabel: FC<ParameterLabelProps> = ({ parameter, isPreset }) => {
</Tooltip>
</TooltipProvider>
)}
{parameter.form_type === "slider" && (
<output className="ml-auto font-semibold">
{parameter.value.value}
</output>
)}
</Label>

{hasDescription && (
Expand Down Expand Up @@ -278,6 +284,23 @@ const ParameterField: FC<ParameterFieldProps> = ({
</Label>
</div>
);

case "slider":
return (
<Slider
className="mt-2"
defaultValue={[
Number(
parameter.default_value.valid ? parameter.default_value.value : 0,
),
]}
onValueChange={([value]) => onChange(value.toString())}
min={parameter.validations[0]?.validation_min ?? 0}
max={parameter.validations[0]?.validation_max ?? 100}
disabled={disabled}
/>
);

case "input": {
const inputType = parameter.type === "number" ? "number" : "text";
const inputProps: Record<string, unknown> = {};
Expand Down
Loading