-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(AlertDialog): create component (#26)
- Loading branch information
1 parent
06cd63d
commit 71371ac
Showing
6 changed files
with
133 additions
and
4 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
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 |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<template> | ||
<Modal v-model="isOpen" class="w-full"> | ||
<div class="sm:flex sm:items-start"> | ||
<div v-if="icon" :class="iconWrapperClass" class="mx-auto flex-shrink-0 flex items-center justify-center rounded-full sm:mx-0"> | ||
<Icon :name="icon" :class="iconClass" /> | ||
</div> | ||
<div class="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left space-y-2"> | ||
<DialogTitle v-if="title" as="h3" :class="titleClass"> | ||
{{ title }} | ||
</DialogTitle> | ||
<DialogDescription v-if="description" as="p" :class="descriptionClass"> | ||
{{ description }} | ||
</DialogDescription> | ||
</div> | ||
</div> | ||
<div class="mt-5 space-y-3 sm:space-y-0 sm:mt-4 sm:flex sm:gap-3" :class="{ 'sm:flex-row-reverse': !leadingButtons }"> | ||
<Button variant="primary" :label="confirmLabel" block custom-class="sm:w-auto" @click="onConfirm" /> | ||
<Button variant="secondary" :label="cancelLabel" block custom-class="sm:w-auto" @click="onCancel" /> | ||
</div> | ||
</Modal> | ||
</template> | ||
|
||
<script setup> | ||
import { computed } from 'vue' | ||
import { DialogTitle, DialogDescription } from '@headlessui/vue' | ||
import Modal from '../overlays/Modal' | ||
import Button from '../elements/Button' | ||
import Icon from '../elements/Icon' | ||
import $ui from '#build/ui' | ||
const props = defineProps({ | ||
modelValue: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
icon: { | ||
type: String, | ||
default: '' | ||
}, | ||
iconClass: { | ||
type: String, | ||
default: () => $ui.alertDialog.icon.base | ||
}, | ||
iconWrapperClass: { | ||
type: String, | ||
default: () => $ui.alertDialog.icon.wrapper | ||
}, | ||
title: { | ||
type: String, | ||
default: '' | ||
}, | ||
titleClass: { | ||
type: String, | ||
default: () => $ui.alertDialog.icon.title | ||
}, | ||
description: { | ||
type: String, | ||
default: '' | ||
}, | ||
descriptionClass: { | ||
type: String, | ||
default: () => $ui.alertDialog.description | ||
}, | ||
confirmLabel: { | ||
type: String, | ||
default: 'Confirm' | ||
}, | ||
cancelLabel: { | ||
type: String, | ||
default: 'Cancel' | ||
}, | ||
leadingButtons: { | ||
type: Boolean, | ||
default: false | ||
} | ||
}) | ||
const emit = defineEmits(['update:modelValue', 'confirm', 'cancel']) | ||
const isOpen = computed({ | ||
get () { | ||
return props.modelValue | ||
}, | ||
set (value) { | ||
emit('update:modelValue', value) | ||
} | ||
}) | ||
function onConfirm () { | ||
emit('confirm') | ||
isOpen.value = false | ||
} | ||
function onCancel () { | ||
emit('cancel') | ||
isOpen.value = false | ||
} | ||
</script> |
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