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 { .media-item {
cursor: pointer; cursor: pointer;
max-width: 15dvw; max-width: 15dvw;
border-radius: var(--embed-radius);
} }
</style> </style>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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