+
Put your content here!
()
-const props = defineProps<{
- open: boolean
- maxWidth?: MaxWidthValue
- fullscreen?: boolean
- hideCloser?: boolean
- showBackButton?: boolean
- /**
- * Prevent modal from closing when the user clicks outside of the modal or presses Esc
- */
- preventCloseOnClickOutside?: boolean
- title?: string
- buttons?: Array
- /**
- * Extra classes to apply to the button container.
- */
- buttonsWrapperClasses?: string
- /**
- * If set, the modal will be wrapped in a form element and the `onSubmit` callback will be invoked when the user submits the form
- */
- onSubmit?: (e: SubmitEvent) => void
-}>()
+const props = withDefaults(
+ defineProps<{
+ open: boolean
+ maxWidth?: MaxWidthValue
+ fullscreen?: FullscreenValues
+ hideCloser?: boolean
+ showBackButton?: boolean
+ /**
+ * Prevent modal from closing when the user clicks outside of the modal or presses Esc
+ */
+ preventCloseOnClickOutside?: boolean
+ title?: string
+ buttons?: Array
+ /**
+ * Extra classes to apply to the button container.
+ */
+ buttonsWrapperClasses?: string
+ /**
+ * If set, the modal will be wrapped in a form element and the `onSubmit` callback will be invoked when the user submits the form
+ */
+ onSubmit?: (e: SubmitEvent) => void
+ }>(),
+ {
+ fullscreen: 'mobile'
+ }
+)
const slots = useSlots()
@@ -197,7 +204,7 @@ const maxWidthWeight = computed(() => {
const widthClasses = computed(() => {
const classParts: string[] = ['w-full', 'sm:w-full']
- if (!props.fullscreen) {
+ if (!isFullscreenDesktop.value) {
classParts.push('md:max-w-2xl')
if (maxWidthWeight.value >= 2) {
@@ -214,6 +221,56 @@ const widthClasses = computed(() => {
return classParts.join(' ')
})
+const isFullscreenDesktop = computed(
+ () => props.fullscreen === 'desktop' || props.fullscreen === 'all'
+)
+
+const dialogPanelClasses = computed(() => {
+ const classParts: string[] = [
+ 'transform md:rounded-xl text-foreground overflow-hidden transition-all bg-foundation text-left shadow-xl flex flex-col md:h-auto'
+ ]
+
+ if (isFullscreenDesktop.value) {
+ classParts.push('md:h-full md:h-[98vh] md:!h-[98dvh]')
+ } else {
+ classParts.push('md:max-h-[90vh]')
+ }
+
+ if (props.fullscreen === 'mobile') {
+ classParts.push('max-md:h-[98vh] max-md:!h-[98dvh]')
+ }
+
+ if (props.fullscreen === 'all') {
+ classParts.push('h-[98vh] !h-[98dvh]')
+ }
+
+ if (props.fullscreen === 'none' || props.fullscreen === 'desktop') {
+ classParts.push('rounded-lg max-h-[90vh]')
+ } else {
+ classParts.push('rounded-t-lg')
+ }
+
+ classParts.push(widthClasses.value)
+ return classParts.join(' ')
+})
+
+const slotContainerClasses = computed(() => {
+ const classParts: string[] = [
+ 'flex-1 simple-scrollbar overflow-y-auto text-sm sm:text-base'
+ ]
+
+ if (hasTitle.value) {
+ classParts.push('px-6 pb-4')
+ if (isFullscreenDesktop.value) {
+ classParts.push('md:p-0')
+ }
+ } else if (!isFullscreenDesktop.value) {
+ classParts.push('p-6')
+ }
+
+ return classParts.join(' ')
+})
+
const onClose = () => {
if (props.preventCloseOnClickOutside) return
open.value = false
@@ -260,9 +317,4 @@ html.dialog-open {
html.dialog-open body {
overflow: hidden !important;
}
-/* Workaround because in Tailwind vh gets added after dvh */
-.dialog-panel {
- height: 98vh;
- height: 98dvh;
-}