Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(space-nuxt-base-ui): add modal confirm #79

Merged
merged 3 commits into from
Aug 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions space-plugins/nuxt-base-ui/components/ModalConfirm.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<script setup lang="ts">
defineProps<{
title?: string;
message?: string;
}>();

const emit = defineEmits(['confirmed', 'canceled']);

const modalConfirmRef = ref<InstanceType<typeof BaseModal>>();

const show = () => modalConfirmRef.value?.show();
const close = () => modalConfirmRef.value?.close();

defineExpose({ show, close });

const onConfirmClicked = () => {
emit('confirmed');
close();
};

const onCancelClicked = () => {
emit('canceled');
close();
};
</script>

<template>
<BaseModal ref="modalConfirmRef" :title="title" :message="message">
<template #actions>
<menu class="modal-action px-8 py-6 m-0 bg-gray-100">
<button
class="btn btn-tertiary"
title="Close the modal and cancel the action"
@click.prevent="onCancelClicked"
>
Cancel
</button>
<button
class="btn btn-primary"
title="Confirm the action"
@click.prevent="onConfirmClicked"
>
Confirm
</button>
</menu>
</template>
</BaseModal>
</template>