-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Overlays): Improve the Dialog and Slideover triggers and transit…
…ions (#6)
- Loading branch information
Showing
7 changed files
with
204 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,67 @@ | ||
<script setup lang="ts"> | ||
import { UiContainer, UiDialog } from '#components'; | ||
import { DialogClose, DialogTitle } from 'radix-vue'; | ||
import { ref } from 'vue'; | ||
const show = ref(false); | ||
</script> | ||
|
||
<template> | ||
<UiContainer class="py-8"> | ||
<h1 class="demo-page-title">Dialog</h1> | ||
<p class="demo-page-description">Modal that pops-up to call the attention of the user.</p> | ||
|
||
<UiDialog prevent-close> | ||
<template #trigger> | ||
<UiButton label="Open dialog" class="mt-4" /> | ||
</template> | ||
|
||
<template #content> | ||
<div class="px-6 py-8"> | ||
<DialogTitle class="text-xl font-medium text-gray-900">This is a dialog</DialogTitle> | ||
<p class="mt-3 text-gray-600"> | ||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Minus libero quo voluptatem perspiciatis | ||
similique, omnis explicabo quos consequatur, ab adipisci itaque excepturi, voluptatum voluptatibus | ||
a unde deserunt inventore veritatis quod delectus esse hic? | ||
</p> | ||
|
||
<DialogClose as-child> | ||
<UiButton label="Close dialog" class="mt-4" /> | ||
</DialogClose> | ||
</div> | ||
</template> | ||
</UiDialog> | ||
<div class="demo-category-container mt-4 items-start"> | ||
<span class="demo-category-title" | ||
>Controlled: | ||
<code class="demo-code-line">"{{ show }}"</code> | ||
</span> | ||
|
||
<UiButton label="Open dialog" class="mt-4" @click="show = true" /> | ||
|
||
<UiDialog v-model:open="show"> | ||
<template #content> | ||
<div class="px-6 py-8"> | ||
<DialogTitle class="text-xl font-medium text-gray-900">This is a controlled dialog</DialogTitle> | ||
<p class="mt-3 text-gray-600"> | ||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Minus libero quo voluptatem | ||
perspiciatis similique, omnis explicabo quos consequatur, ab adipisci itaque excepturi, | ||
voluptatum voluptatibus a unde deserunt inventore veritatis quod delectus esse hic? | ||
</p> | ||
|
||
<DialogClose as-child> | ||
<UiButton label="Close dialog" class="mt-4" /> | ||
</DialogClose> | ||
</div> | ||
</template> | ||
</UiDialog> | ||
</div> | ||
|
||
<div class="demo-category-container mt-4 items-start"> | ||
<span class="demo-category-title">Uncontrolled</span> | ||
|
||
<UiDialog> | ||
<template #trigger> | ||
<UiButton label="Open dialog" class="mt-4" /> | ||
</template> | ||
|
||
<template #content> | ||
<div class="px-6 py-8"> | ||
<DialogTitle class="text-xl font-medium text-gray-900" | ||
>This is an uncontrolled dialog</DialogTitle | ||
> | ||
<p class="mt-3 text-gray-600"> | ||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Minus libero quo voluptatem | ||
perspiciatis similique, omnis explicabo quos consequatur, ab adipisci itaque excepturi, | ||
voluptatum voluptatibus a unde deserunt inventore veritatis quod delectus esse hic? | ||
</p> | ||
|
||
<DialogClose as-child> | ||
<UiButton label="Close dialog" class="mt-4" /> | ||
</DialogClose> | ||
</div> | ||
</template> | ||
</UiDialog> | ||
</div> | ||
</UiContainer> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,23 @@ | ||
export default /*ui*/ { | ||
container: 'fixed left-1/2 top-1/2 z-50 -translate-x-1/2 -translate-y-1/2 rounded-lg bg-white shadow-xl', | ||
size: 'w-full max-w-lg', | ||
overlay: | ||
'fixed inset-0 z-40 bg-black/70 backdrop-blur-sm backdrop-filter duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0', | ||
transition: | ||
'duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]', | ||
overlay: { | ||
base: 'fixed inset-0 z-40 bg-black/70 backdrop-blur-sm backdrop-filter', | ||
transition: { | ||
enterActive: 'ease-out duration-200', | ||
enterFrom: 'opacity-0', | ||
enterTo: 'opacity-100', | ||
leaveActive: 'ease-in duration-200', | ||
leaveFrom: 'opacity-100', | ||
leaveTo: 'opacity-0', | ||
}, | ||
}, | ||
transition: { | ||
enterActive: 'transition-[opacity,transform] ease-out duration-300', | ||
enterFrom: 'opacity-0 -translate-y-[40%] scale-95', | ||
enterTo: 'opacity-100 scale-100', | ||
leaveActive: 'transition-[opacity,transform] ease-in duration-200', | ||
leaveFrom: 'opacity-100 scale-100', | ||
leaveTo: 'opacity-0 scale-95', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
export default /*ui*/ { | ||
container: 'fixed z-50 bg-white shadow-xl', | ||
size: '', | ||
overlay: | ||
'fixed inset-0 z-40 bg-black/70 backdrop-blur-sm backdrop-filter duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0', | ||
transition: | ||
'transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500', | ||
overlay: { | ||
base: 'fixed inset-0 z-40 bg-black/70 backdrop-blur-sm backdrop-filter', | ||
transition: { | ||
enterActive: 'ease-out duration-200', | ||
enterFrom: 'opacity-0', | ||
enterTo: 'opacity-100', | ||
leaveActive: 'ease-in duration-200', | ||
leaveFrom: 'opacity-100', | ||
leaveTo: 'opacity-0', | ||
}, | ||
}, | ||
transition: { | ||
enterActive: 'transition-transform ease-in-out duration-500', | ||
leaveActive: 'transition-transform ease-in-out duration-300', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { TransitionProps } from 'vue'; | ||
|
||
export type UiTransition = { | ||
enterActive?: string; | ||
enterFrom?: string; | ||
enterTo?: string; | ||
leaveActive?: string; | ||
leaveFrom?: string; | ||
leaveTo?: string; | ||
}; | ||
|
||
/** Converts our simplified transition props into <Transition> props */ | ||
export function uiToTransitionProps(transition: UiTransition): TransitionProps { | ||
return { | ||
enterActiveClass: transition.enterActive, | ||
enterFromClass: transition.enterFrom, | ||
enterToClass: transition.enterTo, | ||
leaveActiveClass: transition.leaveActive, | ||
leaveFromClass: transition.leaveFrom, | ||
leaveToClass: transition.leaveTo, | ||
}; | ||
} |