diff --git a/src/components/Form/FormControllers/ApplicationQuestionsFormController/ApplicationQuestionsFormController.tsx b/src/components/Form/FormControllers/ApplicationQuestionsFormController/ApplicationQuestionsFormController.tsx index 3d35a283..a4481d6d 100644 --- a/src/components/Form/FormControllers/ApplicationQuestionsFormController/ApplicationQuestionsFormController.tsx +++ b/src/components/Form/FormControllers/ApplicationQuestionsFormController/ApplicationQuestionsFormController.tsx @@ -8,11 +8,11 @@ import { PlusIcon } from "@heroicons/react/outline"; import { X } from "lucide-react"; import { Button } from "@/primitives/Button"; -import { Checkbox } from "@/ui-shadcn/checkbox"; +import { Checkbox } from "@/primitives/Checkbox"; +import { Switch } from "@/primitives/Switch"; import { Input } from "@/ui-shadcn/input"; import { Label } from "@/ui-shadcn/label"; import { Select, SelectTrigger, SelectContent, SelectItem } from "@/ui-shadcn/select"; -import { Switch } from "@/ui-shadcn/switch"; import { inputTypes } from "./utils"; diff --git a/src/components/Form/FormControllers/RoundDatesFormController/RoundDatesFormController.tsx b/src/components/Form/FormControllers/RoundDatesFormController/RoundDatesFormController.tsx index 3dea57b4..489a921c 100644 --- a/src/components/Form/FormControllers/RoundDatesFormController/RoundDatesFormController.tsx +++ b/src/components/Form/FormControllers/RoundDatesFormController/RoundDatesFormController.tsx @@ -5,7 +5,7 @@ import { useFormContext, Controller } from "react-hook-form"; import moment from "moment-timezone"; -import { Checkbox } from "@/ui-shadcn/checkbox"; +import { Checkbox } from "@/primitives/Checkbox"; import { Label } from "@/ui-shadcn/label"; import { Select, SelectTrigger, SelectContent, SelectItem } from "@/ui-shadcn/select"; diff --git a/src/primitives/Checkbox/Checkbox.stories.tsx b/src/primitives/Checkbox/Checkbox.stories.tsx new file mode 100644 index 00000000..e873e0ab --- /dev/null +++ b/src/primitives/Checkbox/Checkbox.stories.tsx @@ -0,0 +1,94 @@ +import type { Meta, StoryObj } from "@storybook/react"; + +import { Checkbox } from "./Checkbox"; + +const meta: Meta = { + title: "Primitives/Checkbox", + component: Checkbox, + tags: ["autodocs"], +}; + +export default meta; +type Story = StoryObj; + +// Small Checkboxes Story +export const SmallCheckboxes: Story = { + render: () => ( +
+ + + + +
+ ), +}; + +// Medium Checkboxes Story +export const MediumCheckboxes: Story = { + render: () => ( +
+ + + + +
+ ), +}; + +// Large Checkboxes Story +export const LargeCheckboxes: Story = { + render: () => ( +
+ + + + +
+ ), +}; + +// Interactive Checkbox Story with Controls +export const Interactive: Story = { + args: { + size: "md", + color: "moss", + defaultChecked: true, + }, + argTypes: { + size: { + control: "select", + options: ["sm", "md", "lg"], + }, + color: { + control: "select", + options: ["moss", "black", "white", "purple"], + }, + defaultChecked: { + control: "boolean", + }, + }, +}; + +// States Story +export const States: Story = { + render: () => ( +
+
+ + Unchecked +
+
+ + Checked +
+
+ + Disabled Unchecked +
+
+ + Disabled Checked +
+
+ ), +}; diff --git a/src/primitives/Checkbox/Checkbox.tsx b/src/primitives/Checkbox/Checkbox.tsx new file mode 100644 index 00000000..a5a7f4bb --- /dev/null +++ b/src/primitives/Checkbox/Checkbox.tsx @@ -0,0 +1,68 @@ +"use client"; + +import * as React from "react"; + +import { CheckIcon } from "@heroicons/react/solid"; +import * as CheckboxPrimitive from "@radix-ui/react-checkbox"; +import { tv, VariantProps } from "tailwind-variants"; + +import { cn } from "@/lib/utils"; + +const checkboxVariants = tv({ + slots: { + base: "peer size-4 rounded-sm border border-moss-300 text-center ring-offset-white hover:border-moss-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-moss-500 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-moss-500 data-[state=checked]:text-grey-50", + }, + variants: { + size: { + sm: { + base: "size-4", + }, + md: { + base: "size-5", + }, + lg: { + base: "size-6", + }, + }, + color: { + moss: { + base: "border-moss-700 hover:border-moss-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-moss-900 focus-visible:ring-offset-2 data-[state=checked]:bg-moss-700 data-[state=unchecked]:bg-transparent data-[state=checked]:text-white data-[state=unchecked]:text-white", + }, + black: { + base: "border-grey-300 hover:border-grey-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-grey-500 focus-visible:ring-offset-2 data-[state=checked]:bg-black data-[state=unchecked]:bg-transparent data-[state=checked]:text-grey-50 data-[state=unchecked]:text-grey-50", + }, + white: { + base: "border-black hover:border-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-black focus-visible:ring-offset-2 data-[state=checked]:bg-white data-[state=unchecked]:bg-transparent data-[state=checked]:text-black data-[state=unchecked]:text-black dark:border-grey-50 dark:hover:border-grey-200 dark:focus-visible:ring-grey-200 dark:data-[state=checked]:bg-grey-50 dark:data-[state=checked]:text-black dark:data-[state=unchecked]:text-grey-50", + }, + purple: { + base: "border-purple-700 hover:border-purple-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-purple-900 focus-visible:ring-offset-2 data-[state=checked]:bg-purple-700 data-[state=unchecked]:bg-transparent data-[state=checked]:text-grey-50 data-[state=unchecked]:text-white", + }, + }, + }, + defaultVariants: { + size: "sm", + color: "moss", + }, +}); + +export type CheckboxVariants = VariantProps; + +const Checkbox = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef & CheckboxVariants +>(({ className, ...props }, ref) => { + const { size, color, ...rest } = props; + const { base } = checkboxVariants({ size, color }); + + return ( + + + + + + ); +}); + +Checkbox.displayName = CheckboxPrimitive.Root.displayName; + +export { Checkbox }; diff --git a/src/primitives/Checkbox/index.ts b/src/primitives/Checkbox/index.ts new file mode 100644 index 00000000..4c1774ae --- /dev/null +++ b/src/primitives/Checkbox/index.ts @@ -0,0 +1 @@ +export { Checkbox } from "./Checkbox"; diff --git a/src/primitives/Switch/Switch.stories.tsx b/src/primitives/Switch/Switch.stories.tsx new file mode 100644 index 00000000..fcdf0bcf --- /dev/null +++ b/src/primitives/Switch/Switch.stories.tsx @@ -0,0 +1,107 @@ +import type { Meta, StoryObj } from "@storybook/react"; + +import { Switch } from "./Switch"; + +const meta: Meta = { + title: "Primitives/Switch", + component: Switch, + tags: ["autodocs"], +}; + +export default meta; +type Story = StoryObj; + +// Color Variants Story +export const ColorVariants: Story = { + render: () => ( +
+
+ + Moss +
+
+ + Black +
+
+ + Purple +
+
+ + White +
+
+ ), +}; + +// States Story +export const States: Story = { + render: () => ( +
+
+ + Unchecked +
+
+ + Checked +
+
+ + Disabled Unchecked +
+
+ + Disabled Checked +
+
+ ), +}; + +// Interactive Story with Controls +export const Interactive: Story = { + args: { + color: "moss", + defaultChecked: true, + disabled: false, + }, + argTypes: { + color: { + control: "select", + options: ["moss", "black", "purple", "white"], + }, + defaultChecked: { + control: "boolean", + }, + disabled: { + control: "boolean", + }, + }, +}; + +// Group Story +export const Group: Story = { + render: () => ( +
+
+ + +
+
+ + +
+
+ + +
+
+ ), +}; diff --git a/src/primitives/Switch/Switch.tsx b/src/primitives/Switch/Switch.tsx new file mode 100644 index 00000000..ce67cc2e --- /dev/null +++ b/src/primitives/Switch/Switch.tsx @@ -0,0 +1,59 @@ +"use client"; + +import * as React from "react"; + +import * as SwitchPrimitives from "@radix-ui/react-switch"; +import { tv, VariantProps } from "tailwind-variants"; + +import { cn } from "@/lib/utils"; + +const switchVariants = tv({ + slots: { + base: "peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-black focus-visible:ring-offset-2 focus-visible:ring-offset-white disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-moss-700 data-[state=unchecked]:bg-grey-100", + thumb: + "pointer-events-none block h-5 w-5 rounded-full bg-white shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0", + }, + variants: { + color: { + moss: { + base: "data-[state=checked]:bg-moss-700 data-[state=unchecked]:bg-grey-100", + thumb: "bg-white", + }, + black: { + base: "data-[state=checked]:bg-black data-[state=unchecked]:bg-grey-100", + thumb: "bg-white", + }, + purple: { + base: "data-[state=checked]:bg-purple-700 data-[state=unchecked]:bg-grey-100", + thumb: "bg-white", + }, + white: { + base: "data-[state=checked]:bg-white data-[state=unchecked]:bg-grey-100", + thumb: "bg-black", + }, + }, + }, + defaultVariants: { + color: "moss", + }, +}); + +type SwitchVariants = VariantProps; + +const Switch = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef & SwitchVariants +>(({ className, ...props }, ref) => { + const { color, ...rest } = props; + const { base, thumb } = switchVariants({ color }); + + return ( + + + + ); +}); + +Switch.displayName = SwitchPrimitives.Root.displayName; + +export { Switch }; diff --git a/src/primitives/Switch/index.ts b/src/primitives/Switch/index.ts new file mode 100644 index 00000000..c899e291 --- /dev/null +++ b/src/primitives/Switch/index.ts @@ -0,0 +1 @@ +export { Switch } from "./Switch"; diff --git a/src/ui-shadcn/checkbox.tsx b/src/ui-shadcn/checkbox.tsx deleted file mode 100644 index fc844d0d..00000000 --- a/src/ui-shadcn/checkbox.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import * as React from "react"; - -import * as CheckboxPrimitive from "@radix-ui/react-checkbox"; -import { Check } from "lucide-react"; - -import { cn } from "@/lib/utils"; - -const Checkbox = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - - - - - -)); -Checkbox.displayName = CheckboxPrimitive.Root.displayName; - -export { Checkbox }; diff --git a/src/ui-shadcn/switch.tsx b/src/ui-shadcn/switch.tsx deleted file mode 100644 index e4c0fd62..00000000 --- a/src/ui-shadcn/switch.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import * as React from "react"; - -import * as SwitchPrimitives from "@radix-ui/react-switch"; - -import { cn } from "@/lib/utils"; - -const Switch = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - - - -)); -Switch.displayName = SwitchPrimitives.Root.displayName; - -export { Switch };