Skip to content

Commit

Permalink
feat(NeSideDrawer): add prop closeOnClickOutside (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
andre8244 authored Feb 26, 2024
1 parent 3e5ef6e commit 3dd9ad7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/components/NeSideDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { faXmark } from '@fortawesome/free-solid-svg-icons'
const props = defineProps({
isShown: { type: Boolean, default: false },
title: { type: String, default: '' },
closeOnClickOutside: { type: Boolean, default: false },
closeAriaLabel: { type: String, default: 'Close side drawer' }
})

Expand All @@ -19,11 +20,17 @@ const emit = defineEmits(['close'])
function closeDrawer() {
emit('close')
}

function maybeCloseDrawer() {
if (props.closeOnClickOutside) {
closeDrawer()
}
}
</script>

<template>
<TransitionRoot :show="isShown" as="template">
<Dialog as="div" class="relative z-[100]" @close="closeDrawer">
<Dialog as="div" class="relative z-[100]" @close="maybeCloseDrawer">
<TransitionChild
as="template"
enter="transition-opacity ease-linear duration-300"
Expand Down
1 change: 1 addition & 0 deletions stories/NeSideDrawer.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
args: {
isShown: true,
title: 'Drawer title',
closeOnClickOutside: false,
closeAriaLabel: 'Close side drawer'
}
} satisfies Meta<typeof NeSideDrawer>
Expand Down

0 comments on commit 3dd9ad7

Please sign in to comment.