|
| 1 | +<script setup lang="ts"> |
| 2 | +import { useMediaQuery } from '@vueuse/core' |
| 3 | +import { Button } from '@/registry/new-york-v4/ui/button' |
| 4 | +import { |
| 5 | + Dialog, |
| 6 | + DialogClose, |
| 7 | + DialogContent, |
| 8 | + DialogDescription, |
| 9 | + DialogFooter, |
| 10 | + DialogHeader, |
| 11 | + DialogTitle, |
| 12 | + DialogTrigger, |
| 13 | +} from '@/registry/new-york-v4/ui/dialog' |
| 14 | +import { |
| 15 | + Drawer, |
| 16 | + DrawerClose, |
| 17 | + DrawerContent, |
| 18 | + DrawerDescription, |
| 19 | + DrawerFooter, |
| 20 | + DrawerHeader, |
| 21 | + DrawerTitle, |
| 22 | + DrawerTrigger, |
| 23 | +} from '@/registry/new-york-v4/ui/drawer' |
| 24 | +import { Input } from '@/registry/new-york-v4/ui/input' |
| 25 | +import { Label } from '@/registry/new-york-v4/ui/label' |
| 26 | +
|
| 27 | +const isDesktop = useMediaQuery('(min-width: 640px)') |
| 28 | +
|
| 29 | +const Modal = computed(() => ({ |
| 30 | + Root: isDesktop.value ? Dialog : Drawer, |
| 31 | + Trigger: isDesktop.value ? DialogTrigger : DrawerTrigger, |
| 32 | + Content: isDesktop.value ? DialogContent : DrawerContent, |
| 33 | + Header: isDesktop.value ? DialogHeader : DrawerHeader, |
| 34 | + Title: isDesktop.value ? DialogTitle : DrawerTitle, |
| 35 | + Description: isDesktop.value ? DialogDescription : DrawerDescription, |
| 36 | + Footer: isDesktop.value ? DialogFooter : DrawerFooter, |
| 37 | + Close: isDesktop.value ? DialogClose : DrawerClose, |
| 38 | +})) |
| 39 | +</script> |
| 40 | + |
| 41 | +<template> |
| 42 | + <component :is="Modal.Root"> |
| 43 | + <component :is="Modal.Trigger" as-child> |
| 44 | + <Button variant="outline"> |
| 45 | + Open Dialog |
| 46 | + </Button> |
| 47 | + </component> |
| 48 | + <component |
| 49 | + :is="Modal.Content" |
| 50 | + class="sm:max-w-md" :class="[ |
| 51 | + { 'px-2 pb-8 *:px-4': !isDesktop }, |
| 52 | + ]" |
| 53 | + > |
| 54 | + <component :is="Modal.Header"> |
| 55 | + <component :is="Modal.Title"> |
| 56 | + Share Link |
| 57 | + </component> |
| 58 | + <component :is="Modal.Description"> |
| 59 | + Anyone who has this link will be able to view this. |
| 60 | + </component> |
| 61 | + </component> |
| 62 | + |
| 63 | + <div class="flex items-center gap-2"> |
| 64 | + <div class="grid flex-1 gap-2"> |
| 65 | + <Label for="link" class="sr-only"> |
| 66 | + Link |
| 67 | + </Label> |
| 68 | + <Input |
| 69 | + id="link" |
| 70 | + default-value="https://www.shadcn-vue.com/docs/installation" |
| 71 | + read-only |
| 72 | + /> |
| 73 | + </div> |
| 74 | + </div> |
| 75 | + |
| 76 | + <component :is="Modal.Footer" class="pt-4"> |
| 77 | + <component :is="Modal.Close" as-child> |
| 78 | + <Button variant="outline"> |
| 79 | + Close |
| 80 | + </Button> |
| 81 | + </component> |
| 82 | + </component> |
| 83 | + </component> |
| 84 | + </component> |
| 85 | +</template> |
0 commit comments