-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
262 additions
and
74 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,53 @@ | ||
<template> | ||
<div | ||
style="position: relative; overflow: hidden; min-height: 150px" | ||
class="sidebar-example-layout" | ||
> | ||
<!-- #region example --> | ||
<ipl-dialog | ||
v-model:is-open="dialogOpen" | ||
style="width: 500px" | ||
> | ||
<div class="width-capped-content"> | ||
<ipl-space | ||
color="light" | ||
class="vertical-layout" | ||
> | ||
<div>Hello!</div> | ||
<ipl-button | ||
label="Button!" | ||
/> | ||
<ipl-button | ||
label="Close dialog" | ||
color="red" | ||
@click="dialogOpen = false" | ||
/> | ||
</ipl-space> | ||
</div> | ||
</ipl-dialog> | ||
<ipl-button | ||
label="Open dialog" | ||
@click="dialogOpen = true" | ||
/> | ||
<!-- #endregion example --> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { IplButton, IplSpace, IplDialog } from '../../src'; | ||
import { ref } from 'vue'; | ||
const dialogOpen = ref(false); | ||
</script> | ||
|
||
<style lang="scss"> | ||
.sidebar-example-layout { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
> .ipl-button { | ||
width: auto; | ||
} | ||
} | ||
</style> |
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,104 @@ | ||
<template> | ||
<dialog | ||
ref="dialog" | ||
@close="onClose" | ||
@cancel.prevent="onCancel" | ||
@click.self="onClick" | ||
> | ||
<div class="content"> | ||
<slot /> | ||
</div> | ||
</dialog> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent, onMounted, ref, watch } from 'vue'; | ||
import { dialogAnimationComplete } from '../helpers/dialogHelper'; | ||
export default defineComponent({ | ||
name: 'IplDialog', | ||
props: { | ||
isOpen: { | ||
type: Boolean, | ||
required: true | ||
} | ||
}, | ||
emits: ['update:isOpen'], | ||
setup(props, { emit }) { | ||
const dialog = ref<HTMLDialogElement | null>(null); | ||
async function onClose() { | ||
if (!dialog.value) return; | ||
dialog.value.setAttribute('inert', ''); | ||
await dialogAnimationComplete(dialog.value); | ||
dialog.value.close('dismiss'); | ||
} | ||
onMounted(() => { | ||
if (!props.isOpen) { | ||
dialog.value?.setAttribute('inert', ''); | ||
} else { | ||
dialog.value?.showModal(); | ||
} | ||
watch(() => props.isOpen, newValue => { | ||
if (newValue) { | ||
dialog.value?.removeAttribute('inert'); | ||
dialog.value?.showModal(); | ||
} else { | ||
onClose(); | ||
} | ||
}); | ||
}); | ||
return { | ||
dialog, | ||
onClose() { | ||
emit('update:isOpen', false); | ||
}, | ||
onCancel() { | ||
onClose(); | ||
}, | ||
onClick() { | ||
onClose(); | ||
} | ||
}; | ||
} | ||
}); | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
@use 'src/styles/constants'; | ||
@use 'src/styles/dialogs'; | ||
dialog { | ||
@include dialogs.dialog-common(constants.$transition-duration-low, constants.$transition-duration-med, constants.$transition-duration-low, linear, linear); | ||
opacity: 0; | ||
left: 50%; | ||
top: 50%; | ||
transform: translate(-50%, -50%); | ||
border-radius: constants.$border-radius-outer; | ||
} | ||
@include dialogs.dialog-common-animation; | ||
@keyframes dialog-enter { | ||
to { | ||
opacity: 1; | ||
} | ||
} | ||
@keyframes dialog-exit { | ||
0% { | ||
opacity: 1; | ||
} | ||
100% { | ||
opacity: 0; | ||
} | ||
} | ||
</style> |
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,3 @@ | ||
export async function dialogAnimationComplete(element: HTMLElement): Promise<unknown> { | ||
return Promise.allSettled(element.getAnimations({ subtree: true }).filter(anim => anim.effect instanceof KeyframeEffect && anim.effect.target === element && (anim.effect.pseudoElement == null || anim.effect.pseudoElement === '::backdrop')).map(animation => animation.finished)); | ||
} |
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
Oops, something went wrong.