feat(dialog-with-scroll-body): add demos with body scroll for Dialog component

This commit is contained in:
hrynevych.romann 2024-01-17 21:59:45 +02:00
parent 8e7bbe3a8d
commit dac89648d1
5 changed files with 107 additions and 1 deletions

View File

@ -380,6 +380,13 @@ export const Index = {
component: () => import('../src/lib/registry/default/example/DialogDemo.vue').then(m => m.default), component: () => import('../src/lib/registry/default/example/DialogDemo.vue').then(m => m.default),
files: ['../src/lib/registry/default/example/DialogDemo.vue'], files: ['../src/lib/registry/default/example/DialogDemo.vue'],
}, },
DialogScrollContentDemo: {
name: 'DialogScrollContentDemo',
type: 'components:example',
registryDependencies: ['button', 'dialog', 'input', 'label'],
component: () => import('../src/lib/registry/default/example/DialogScrollContentDemo.vue').then(m => m.default),
files: ['../src/lib/registry/default/example/DialogScrollContentDemo.vue'],
},
DropdownMenuDemo: { DropdownMenuDemo: {
name: 'DropdownMenuDemo', name: 'DropdownMenuDemo',
type: 'components:example', type: 'components:example',
@ -1264,6 +1271,13 @@ export const Index = {
component: () => import('../src/lib/registry/new-york/example/DialogDemo.vue').then(m => m.default), component: () => import('../src/lib/registry/new-york/example/DialogDemo.vue').then(m => m.default),
files: ['../src/lib/registry/new-york/example/DialogDemo.vue'], files: ['../src/lib/registry/new-york/example/DialogDemo.vue'],
}, },
DialogScrollContentDemo: {
name: 'DialogScrollContentDemo',
type: 'components:example',
registryDependencies: ['button', 'dialog', 'input', 'label'],
component: () => import('../src/lib/registry/new-york/example/DialogScrollContentDemo.vue').then(m => m.default),
files: ['../src/lib/registry/new-york/example/DialogScrollContentDemo.vue'],
},
DropdownMenuDemo: { DropdownMenuDemo: {
name: 'DropdownMenuDemo', name: 'DropdownMenuDemo',
type: 'components:example', type: 'components:example',

View File

@ -140,4 +140,4 @@ watch(CmdJ, (v) => {
### Combobox ### Combobox
You can use the `<Command />` component as a combobox. See the [Combobox](/docs/components/combobox) page for more information. You can use the `<Command />` component as a combobox. See the [Combobox](/docs/components/combobox) page for more information.

View File

@ -55,6 +55,10 @@ import {
<ComponentPreview name="DialogCustomCloseButton" /> <ComponentPreview name="DialogCustomCloseButton" />
### Dialog with Scroll Content
<ComponentPreview name="DialogScrollContentDemo" />
## Notes ## Notes
To activate the `Dialog` component from within a `Context Menu` or `Dropdown Menu`, you must encase the `Context Menu` or `Dropdown Menu` component in the `Dialog` component. For more information, refer to the linked issue [here](https://github.com/radix-ui/primitives/issues/1836). To activate the `Dialog` component from within a `Context Menu` or `Dropdown Menu`, you must encase the `Context Menu` or `Dropdown Menu` component in the `Dialog` component. For more information, refer to the linked issue [here](https://github.com/radix-ui/primitives/issues/1836).

View File

@ -0,0 +1,44 @@
<script setup lang="ts">
import { Button } from '@/lib/registry/default/ui/button'
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from '@/lib/registry/default/ui/dialog'
</script>
<template>
<Dialog>
<DialogTrigger as-child>
<Button variant="outline">
Edit Profile
</Button>
</DialogTrigger>
<DialogContent class="sm:max-w-[425px] grid-rows-[auto_minmax(0,1fr)_auto] p-0 max-h-[90dvh]">
<DialogHeader class="p-6 pb-0">
<DialogTitle>Edit profile</DialogTitle>
<DialogDescription>
Make changes to your profile here. Click save when you're done.
</DialogDescription>
</DialogHeader>
<div class="grid gap-4 py-4 overflow-y-auto px-6">
<div class="flex flex-col justify-between h-[300dvh]">
<p>
This is some placeholder content to show the scrolling behavior for modals. We use repeated line breaks to demonstrate how content can exceed minimum inner height, thereby showing inner scrolling. When content becomes longer than the predefined max-height of modal, content will be cropped and scrollable within the modal.
</p>
<p>This content should appear at the bottom after you scroll.</p>
</div>
</div>
<DialogFooter class="p-6 pt-0">
<Button type="submit">
Save changes
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</template>

View File

@ -0,0 +1,44 @@
<script setup lang="ts">
import { Button } from '@/lib/registry/new-york/ui/button'
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from '@/lib/registry/new-york/ui/dialog'
</script>
<template>
<Dialog>
<DialogTrigger as-child>
<Button variant="outline">
Edit Profile
</Button>
</DialogTrigger>
<DialogContent class="sm:max-w-[425px] grid-rows-[auto_minmax(0,1fr)_auto] p-0 max-h-[90dvh]">
<DialogHeader class="p-6 pb-0">
<DialogTitle>Edit profile</DialogTitle>
<DialogDescription>
Make changes to your profile here. Click save when you're done.
</DialogDescription>
</DialogHeader>
<div class="grid gap-4 py-4 overflow-y-auto px-6">
<div class="flex flex-col justify-between h-[300dvh]">
<p>
This is some placeholder content to show the scrolling behavior for modals. We use repeated line breaks to demonstrate how content can exceed minimum inner height, thereby showing inner scrolling. When content becomes longer than the predefined max-height of modal, content will be cropped and scrollable within the modal.
</p>
<p>This content should appear at the bottom after you scroll.</p>
</div>
</div>
<DialogFooter class="p-6 pt-0">
<Button type="submit">
Save changes
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</template>