Polish the modals #80

Open
twig wants to merge 4 commits from modal-polish into main
9 changed files with 38 additions and 67 deletions

View file

@ -42,6 +42,7 @@ function createModal(link: string) {
.media-item {
cursor: pointer;
max-width: 15dvw;
border-radius: var(--embed-radius);
}
</style>

View file

@ -1,18 +1,11 @@
<template>
<dialog ref="dialog" class="modal" :class="props.obscure ? 'modal-obscure' : 'modal-regular'">
<span class="modal-exit-button-container" style="position: absolute; right: 2em; top: .2em; width: .5em; height: .5em;">
<Button text="✕" variant="stealth" :callback="onCloseButton" />
</span>
<div class="modal-content">
<h1 class="modal-title">{{ title }}</h1>
<slot />
</div>
<slot />
</dialog>
</template>
<script lang="ts" setup>
import type { ModalProps } from '~/types/interfaces';
import Button from '~/components/UserInterface/Button.vue';
const props = defineProps<ModalProps>();
const dialog = ref<HTMLDialogElement>();
@ -20,75 +13,47 @@ const dialog = ref<HTMLDialogElement>();
onMounted(() => {
if (dialog.value) {
dialog.value.showModal();
if (props.onClose) {
dialog.value.addEventListener("close", props.onClose);
}
if (props.onCancel) {
dialog.value.addEventListener("cancel", props.onCancel);
}
// close the modal if you click outside of it
dialog.value.addEventListener('click', (event) => {
if (event.target === dialog.value) {
dialog.value.close();
}
});
if (props.onClose) dialog.value.addEventListener("close", props.onClose);
if (props.onCancel) dialog.value.addEventListener("cancel", props.onCancel);
}
});
function onCloseButton () {
if (dialog.value) {
if (props.onCloseButton) {
props.onCloseButton()
}
dialog.value.remove
}
}
</script>
<style>
<style scoped>
.modal {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
gap: 1em;
opacity: 100%;
left: 0;
top: 0;
right: 0;
bottom: 0;
padding: var(--standard-radius);
border-radius: var(--standard-radius);
background-color: var(--chat-highlighted-background-color);
color: var(--text-color);
/* preferably set these to 70dvh and 70dvw in your components, this is a failsafe if you forget */
max-height: 90dvh;
max-width: 90dvw;
overflow: hidden;
background-color: var(--modal-background-color);
border-radius: var(--standard-radius);
border-width: 0;
padding: 0;
/* completely transparent colour, fixes weird border radius stuff */
background-color: #b00b1e00;
}
.modal-regular::backdrop {
background-color: var(--chat-background-color);
opacity: 0%;
opacity: 10%;
}
.modal-obscure::backdrop {
background-color: var(--chat-background-color);
opacity: 80%;
}
.modal-top-container {
position: fixed;
display: flex;
justify-content: center;
align-items: center;
height: 100%;
width: 100%;
}
.modal-title {
font-size: 1.5rem;
padding: 0;
}
.modal-content {
display: flex;
flex-direction: column;
align-items: center;
gap: 1em;
margin: 1em;
width: 100%;
}
</style>

View file

@ -114,16 +114,16 @@ function buttonEditProfile() {
text-align: left;
position: relative;
max-height: 60dvh;
max-width: 60dvw;
max-height: 70dvh;
max-width: 70dvw;
height: 30em;
width: 40em;
display: flex;
flex-direction: column;
background-color: var(--chat-background-color);
border-radius: var(--standard-radius);
color: var(--text-color);
background-color: var(--modal-background-color);
overflow-y: scroll;
}
@ -142,7 +142,6 @@ function buttonEditProfile() {
z-index: 0;
background-color: var(--primary-color);
border-radius: var(--standard-radius) var(--standard-radius) 0 0; /* top left and top right */
}
#avatar {

View file

@ -10,6 +10,7 @@ complementaryColor = white
--sidebar-margin: .5em;
--standard-radius: .5em;
--embed-radius: .3em;
--button-radius: .6em;
--guild-icon-radius: 15%;
--pfp-radius: 50%;

View file

@ -17,6 +17,7 @@ complementaryColor = white
--chat-featured-message-color: #4f3f2f60;
--popup-background-color: #2f2828;
--popup-highlighted-background-color: #382f2f;
--modal-background-color: #3a352f;
--sidebar-background-color: #3e3a37;
--sidebar-highlighted-background-color: #46423b;

View file

@ -17,6 +17,7 @@ complementaryColor = white
--chat-featured-message-color: #4f2f1f58;
--popup-background-color: #2f1f1f;
--popup-highlighted-background-color: #3f2f2f;
--modal-background-color: #28241f;
--sidebar-background-color: #2e2a27;
--sidebar-highlighted-background-color: #36322b;

View file

@ -18,6 +18,7 @@ complementaryColor = black
--chat-featured-message-color: #4f2f1f58;
--popup-background-color: #2f1f1f;
--popup-highlighted-background-color: #3f2f2f;
--modal-background-color: #181f1f;
--sidebar-background-color: #80808000;
--sidebar-highlighted-background-color: #ffffff20;

View file

@ -17,6 +17,7 @@ complementaryColor = black
--chat-featured-message-color: #e8ac841f;
--popup-background-color: #e8e4e0;
--popup-highlighted-background-color: #dfdbd6;
--modal-background-color: #e8e4e0;
--sidebar-background-color: #dbd8d4;
--sidebar-highlighted-background-color: #d4d0ca;

View file

@ -17,6 +17,7 @@ complementaryColor = white
--chat-featured-message-color: #4f8f4f80;
--popup-background-color: #80808080;
--popup-highlighted-background-color: #9f9f9f9f;
--modal-background-color: #7fa87fff;
--sidebar-background-color: #80808000;
--sidebar-highlighted-background-color: #ffffff20;