mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
- Create DynamicParameter component and test with locally run preview websocket. - Adapt CreateWorkspacePageExperimental to work with PreviewParameter instead of TemplateVersionParameter - Small changes to checkbox, multi-select combobox and radiogroup The websocket implementation is temporary for testing purpose with a locally run preview websocket
46 lines
1.7 KiB
TypeScript
46 lines
1.7 KiB
TypeScript
/**
|
|
* Copied from shadc/ui on 04/03/2025
|
|
* @see {@link https://ui.shadcn.com/docs/components/checkbox}
|
|
*/
|
|
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
import { Check, Minus } from "lucide-react";
|
|
import * as React from "react";
|
|
|
|
import { cn } from "utils/cn";
|
|
|
|
/**
|
|
* To allow for an indeterminate state the checkbox must be controlled, otherwise the checked prop would remain undefined
|
|
*/
|
|
export const Checkbox = React.forwardRef<
|
|
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
|
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
|
|
>(({ className, ...props }, ref) => (
|
|
<CheckboxPrimitive.Root
|
|
ref={ref}
|
|
className={cn(
|
|
`peer h-6 w-6 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
|
|
data-[state=unchecked]:bg-surface-primary
|
|
data-[state=checked]:bg-surface-invert-primary data-[state=checked]:text-content-invert
|
|
hover:border-border-hover hover:data-[state=checked]:bg-surface-invert-secondary`,
|
|
className,
|
|
)}
|
|
{...props}
|
|
>
|
|
<CheckboxPrimitive.Indicator
|
|
className={cn("flex items-center justify-center text-current relative")}
|
|
>
|
|
<div className="flex">
|
|
{(props.checked === true || props.defaultChecked === true) && (
|
|
<Check className="w-5 h-5" strokeWidth={2.5} />
|
|
)}
|
|
{props.checked === "indeterminate" && (
|
|
<Minus className="w-5 h-5" strokeWidth={2.5} />
|
|
)}
|
|
</div>
|
|
</CheckboxPrimitive.Indicator>
|
|
</CheckboxPrimitive.Root>
|
|
));
|