Skip to content

Commit 861e43c

Browse files
committed
allow customizing ModalDialog close button
1 parent 5641139 commit 861e43c

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/components/Autocomplete.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</svg>
2424
</button>
2525

26-
<ul v-if="expanded" class="absolute z-10 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white dark:bg-black py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm"
26+
<ul v-if="expanded" class="absolute z-20 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white dark:bg-black py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm"
2727
@keydown="keyDown" :id="`${id}-options`" role="listbox">
2828
<li v-for="option in filteredValues"
2929
:class="[option === active ? 'active bg-indigo-600 text-white' : 'text-gray-900 dark:text-gray-100', 'relative cursor-default select-none py-2 pl-3 pr-9']"

src/components/ModalDialog.vue

+10-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66

77
<div class="fixed inset-0 z-10 overflow-y-auto">
88
<div class="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0">
9-
<div :class="[modalClass, sizeClass, transition2]"
10-
@mousedown.stop="">
9+
<div :class="[modalClass, sizeClass, transition2]" @mousedown.stop="">
1110
<div>
12-
<div class="hidden sm:block absolute top-0 right-0 pt-4 pr-4 z-10">
13-
<button type="button" @click="close"
14-
class="bg-white dark:bg-black rounded-md text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 dark:ring-offset-black">
11+
<slot v-if="slots.closebutton" name="createform"></slot>
12+
<div v-else class="hidden sm:block absolute top-0 right-0 pt-4 pr-4 z-10">
13+
<button type="button" @click="close":class="closeButtonClass">
1514
<span class="sr-only">Close</span>
1615
<!-- Heroicon name: outline/x -->
1716
<svg class="h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
@@ -24,6 +23,7 @@
2423
<slot></slot>
2524
</div>
2625
</div>
26+
<slot name="bottom"></slot>
2727
</div>
2828
</div>
2929

@@ -33,18 +33,22 @@
3333

3434
<script setup lang="ts">
3535
import type { ModalProvider } from "@/types"
36-
import { onMounted, onUnmounted, watch, ref, provide } from "vue"
36+
import { onMounted, onUnmounted, watch, ref, provide, useSlots } from "vue"
3737
import { transition } from '@/use/utils'
3838
import * as css from "./css"
3939
40+
const slots = useSlots()
41+
4042
const props = withDefaults(defineProps<{
4143
id?: string
4244
modalClass?: string
4345
sizeClass?: string
46+
closeButtonClass?: string
4447
}>(), {
4548
id: 'ModalDialog',
4649
modalClass: css.modal.modalClass,
4750
sizeClass: css.modal.sizeClass,
51+
closeButtonClass: "bg-white dark:bg-black rounded-md text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 dark:ring-offset-black",
4852
})
4953
5054
const emit = defineEmits<{

0 commit comments

Comments
 (0)