diff --git a/src/app/tailwind.css b/src/app/tailwind.css index e94b0b9..219f298 100644 --- a/src/app/tailwind.css +++ b/src/app/tailwind.css @@ -819,6 +819,11 @@ body { width: 100%; } +.w-fit { + width: -moz-fit-content; + width: fit-content; +} + .min-w-\[8rem\] { min-width: 8rem; } @@ -827,10 +832,24 @@ body { min-width: var(--radix-select-trigger-width); } +.min-w-fit { + min-width: -moz-fit-content; + min-width: fit-content; +} + .max-w-sm { max-width: 24rem; } +.max-w-fit { + max-width: -moz-fit-content; + max-width: fit-content; +} + +.max-w-screen-sm { + max-width: 640px; +} + .shrink-0 { flex-shrink: 0; } diff --git a/src/app/ui/forms/genreCheckbox.tsx b/src/app/ui/forms/genreCheckbox.tsx new file mode 100644 index 0000000..b293f7a --- /dev/null +++ b/src/app/ui/forms/genreCheckbox.tsx @@ -0,0 +1,30 @@ +import { FormItem, FormControl, FormLabel } from "@/components/ui/form" +import { Checkbox } from "@/components/ui/checkbox" +export default function GenreCheckbox({ field, item }) { + return ( + + + { + return checked + ? field.onChange([...field.value, item.id]) + : field.onChange( + field.value?.filter( + (value) => value !== item.id + ) + ) + }} + /> + + + {item.name} + + + + + ) +} diff --git a/src/app/ui/forms/genresTrigger.tsx b/src/app/ui/forms/genresTrigger.tsx new file mode 100644 index 0000000..cd2d3d2 --- /dev/null +++ b/src/app/ui/forms/genresTrigger.tsx @@ -0,0 +1,27 @@ +import { FormField, FormItem, FormLabel, FormControl } from "@/components/ui/form" +import { Popover, PopoverContent, PopoverTrigger } from "@radix-ui/react-popover" +import { Checkbox } from "@radix-ui/react-checkbox" +import { Button } from "@/components/ui/button" +import { cn } from "@/lib/utils" +export default function GenresTrigger({ value, genres }) { + return ( + <> + + + + + ) +} diff --git a/src/app/ui/forms/story.tsx b/src/app/ui/forms/story.tsx index 2a76eb5..6357180 100644 --- a/src/app/ui/forms/story.tsx +++ b/src/app/ui/forms/story.tsx @@ -18,7 +18,6 @@ import { Input } from "@/components/ui/input" import { Checkbox } from "@/components/ui/checkbox" import { toast } from "@/components/ui/use-toast" - import { Popover, PopoverContent, @@ -26,6 +25,9 @@ import { } from "@/components/ui/popover" import { cn } from "@/lib/utils" import { Badge } from "lucide-react" +import GenresTrigger from "./genresTrigger" +import GenresPopoverContent from "./genresPopoverContent" +import GenreCheckbox from "./genreCheckbox" const formSchema = z.object({ title: z.string().min(2).max(50), @@ -110,22 +112,7 @@ export default function StoryForm({ genres }) { render={({ field }) => ( - - - + {genres.map((item) => ( { return ( - - - { - return checked - ? field.onChange([...field.value, item.id]) - : field.onChange( - field.value?.filter( - (value) => value !== item.id - ) - ) - }} - /> - - - {item.name} - - + ) }} /> ))} - )}