From 869d4fbc789a5fb3456158b30a497ae2ec3ee82a Mon Sep 17 00:00:00 2001
From: Ayoub Chaaoui
Date: Tue, 19 Nov 2024 22:24:21 +0100
Subject: [PATCH 1/7] feat(vue3/modal): added new slot for custom footers
---
packages/vue3/src/_dev/App.vue | 37 +++++++++++++++++---
packages/vue3/src/components/Modal/Modal.vue | 35 ++++++++++++------
2 files changed, 57 insertions(+), 15 deletions(-)
diff --git a/packages/vue3/src/_dev/App.vue b/packages/vue3/src/_dev/App.vue
index 127dae2d..55a77fab 100644
--- a/packages/vue3/src/_dev/App.vue
+++ b/packages/vue3/src/_dev/App.vue
@@ -1,15 +1,40 @@
-
+
+
+ The quick brown fox jumps over the lazy dog.
+
+
+
+
+
+
+ Open Modal
+
@@ -23,4 +48,8 @@ const date = ref();
height: 100vh;
gap: 40px;
}
+.footer {
+ display: flex;
+ justify-content: end;
+}
diff --git a/packages/vue3/src/components/Modal/Modal.vue b/packages/vue3/src/components/Modal/Modal.vue
index d2c8bded..8740341f 100644
--- a/packages/vue3/src/components/Modal/Modal.vue
+++ b/packages/vue3/src/components/Modal/Modal.vue
@@ -1,8 +1,9 @@
@@ -45,15 +53,20 @@ onUnmounted(() => {
@@ -84,7 +97,7 @@ onUnmounted(() => {
}
.modal .header,
-.modal .footer {
+.modal .footer-content {
display: flex;
flex-direction: row-reverse;
align-items: center;
From 8d14eff0eb945c2ce510c9a37442009e8587e744 Mon Sep 17 00:00:00 2001
From: Ayoub Chaaoui
Date: Tue, 19 Nov 2024 22:28:27 +0100
Subject: [PATCH 2/7] chore(vue3/modal): lint files
---
packages/vue3/src/_dev/App.vue | 15 +++++++++------
packages/vue3/src/components/Modal/Modal.vue | 6 ++----
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/packages/vue3/src/_dev/App.vue b/packages/vue3/src/_dev/App.vue
index 55a77fab..eaae299c 100644
--- a/packages/vue3/src/_dev/App.vue
+++ b/packages/vue3/src/_dev/App.vue
@@ -6,17 +6,17 @@ import Modal from '~/components/Modal/Modal.vue';
import PrimaryButton from '~/components/Button/PrimaryButton.vue';
const state = reactive({
- showModal : false,
- isLoading : false,
+ showModal: false,
+ isLoading: false,
});
const clicked = async () => {
state.isLoading = true;
state.showModal = true;
- (await new Promise(r => setTimeout(r, 1000)))
- state.isLoading = false
- state.showModal = false
+ (await new Promise(resolve => setTimeout(resolve, 1000)));
+ state.isLoading = false;
+ state.showModal = false;
};
@@ -28,7 +28,9 @@ const clicked = async () => {
@@ -48,6 +50,7 @@ const clicked = async () => {
height: 100vh;
gap: 40px;
}
+
.footer {
display: flex;
justify-content: end;
diff --git a/packages/vue3/src/components/Modal/Modal.vue b/packages/vue3/src/components/Modal/Modal.vue
index 8740341f..21d2917f 100644
--- a/packages/vue3/src/components/Modal/Modal.vue
+++ b/packages/vue3/src/components/Modal/Modal.vue
@@ -1,9 +1,8 @@
From 34866f0ef58f8f5bb3488b243c2b38e55966d24f Mon Sep 17 00:00:00 2001
From: Ayoub Chaaoui
Date: Tue, 19 Nov 2024 22:46:03 +0100
Subject: [PATCH 3/7] refactor(vue3/modal): start using defineSlots mcaro
---
packages/vue3/src/components/Modal/Modal.vue | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/packages/vue3/src/components/Modal/Modal.vue b/packages/vue3/src/components/Modal/Modal.vue
index 21d2917f..fd6562a7 100644
--- a/packages/vue3/src/components/Modal/Modal.vue
+++ b/packages/vue3/src/components/Modal/Modal.vue
@@ -10,13 +10,20 @@ const props = withDefaults(defineProps(), {
cancelLabel: 'Cancel',
});
+const slots = defineSlots<{
+ default(): any
+ footer?(): any
+}>()
+
const emit = defineEmits(['update:visible', 'onConfirm']);
+
const confirmLabel = ref(props.confirmLabel);
const cancelLabel = ref(props.cancelLabel);
const close = () => {
emit('update:visible', false);
};
+
const handleKeypress = (event: KeyboardEvent) => {
if (props.visible && event.key === 'Escape') {
close();
@@ -30,9 +37,6 @@ onMounted(() => {
onUnmounted(() => {
window.removeEventListener('keydown', handleKeypress);
});
-
-const slots = useSlots();
-const showCustomFooter = !!slots.footer;
@@ -51,7 +55,7 @@ const showCustomFooter = !!slots.footer;