+
@@ -29,44 +36,59 @@ import {useStore} from "@/store";
import {MutationTypes} from "@/store/mutation-types";
import {LiveAtlasUIModal} from "@/index";
import {computed, ref} from "vue";
+import SvgIcon from "@/components/SvgIcon.vue";
export default defineComponent({
+ components: {SvgIcon},
props: {
id: {
required: true,
type: String,
+ },
+ closeable: {
+ default: true,
+ type: Boolean,
+ },
+ backdrop: {
+ default: true,
+ type: Boolean,
}
},
setup(props) {
const store = useStore(),
modal = ref
(null),
+ messageClose = computed(() => store.state.messages.closeTitle),
visible = computed(() => store.state.ui.visibleModal === props.id);
const onKeydown = (e: KeyboardEvent) => {
- if(visible.value && e.key === 'Escape') {
- store.commit(MutationTypes.HIDE_UI_MODAL, props.id as LiveAtlasUIModal);
+ if(props.closeable && visible.value && e.key === 'Escape') {
+ close();
e.preventDefault();
e.stopImmediatePropagation();
}
};
- const onClick = (e: MouseEvent) => {
- if(e.target === modal.value) {
- store.commit(MutationTypes.HIDE_UI_MODAL, props.id as LiveAtlasUIModal);
+ const onBackdropClick = (e: MouseEvent) => {
+ if(props.closeable && e.target === modal.value) {
+ close();
}
};
+ const close = () => props.closeable && store.commit(MutationTypes.HIDE_UI_MODAL, props.id as LiveAtlasUIModal);
+
onMounted(() => {
window.addEventListener('keydown', onKeydown);
});
onUnmounted(() => {
- window.addEventListener('keydown', onKeydown);
+ window.removeEventListener('keydown', onKeydown);
});
return {
visible,
modal,
- onClick,
+ onBackdropClick,
+ close,
+ messageClose
}
}
});
@@ -83,20 +105,61 @@ export default defineComponent({
bottom: 0;
left: 0;
display: none;
- align-items: flex-start;
- justify-content: center;
+ align-items: center;
+ flex-direction: column;
+ justify-content: flex-start;
padding: 10vh 1rem;
- background-color: rgba(0, 0, 0, 0.8);
overflow: auto;
+ pointer-events: none;
+ cursor: default;
+
+ &.modal--backdrop {
+ pointer-events: auto;
+ background-color: rgba(0, 0, 0, 0.8);
+ }
&.modal--visible {
display: flex;
}
+ .modal__header,
.modal__content {
@extend %panel;
max-width: 80rem;
+ box-sizing: border-box;
width: 100%;
+ padding: 2rem;
+ pointer-events: auto;
+ }
+
+ .modal__header {
+ border-bottom-left-radius: 0;
+ border-bottom-right-radius: 0;
+ position: relative;
+ padding: 2rem 3rem 0;
+ text-align: center;
+ }
+
+ .modal__close {
+ position: absolute;
+ top: 0;
+ right: 0;
+ padding: 1rem;
+ width: 3.5rem;
+ height: 3.5rem;
+ display: block;
+ border-top-left-radius: 0;
+ border-bottom-right-radius: 0;
+
+ .svg-icon {
+ width: 1.5rem !important;
+ height: 1.5rem !important;
+ }
+ }
+
+ .modal__content {
+ border-top-left-radius: 0;
+ border-top-right-radius: 0;
}
}
diff --git a/src/components/login/LoginModal.vue b/src/components/login/LoginModal.vue
index 31e7dba..14c9142 100644
--- a/src/components/login/LoginModal.vue
+++ b/src/components/login/LoginModal.vue
@@ -15,9 +15,10 @@
-->
-
- {{ heading }}
-
+
+
+ {{ heading }}
+
@@ -33,6 +34,12 @@ import Modal from "@/components/Modal.vue";
export default defineComponent({
components: {Modal, RegisterForm, LoginForm},
+ props: {
+ required: {
+ default: false,
+ type: Boolean,
+ }
+ },
setup() {
const store = useStore(),
heading = computed(() => store.state.messages.loginTitle);
@@ -54,7 +61,6 @@ export default defineComponent({
justify-content: space-between;
}
- #login__heading,
#login__error {
width: 100%;
text-align: center;
@@ -62,8 +68,7 @@ export default defineComponent({
}
.form {
- width: 50%;
- padding: 1rem;
+ width: calc(50% - 1.5rem);
box-sizing: border-box;
}
}
diff --git a/src/index.d.ts b/src/index.d.ts
index b49a325..bbb3f67 100644
--- a/src/index.d.ts
+++ b/src/index.d.ts
@@ -121,6 +121,7 @@ interface LiveAtlasGlobalMessageConfig {
logoutTitle: string;
logoutErrorUnknown: string;
logoutSuccess: string;
+ closeTitle: string;
}
// Messages defined by dynmap configuration responses and can vary per server
diff --git a/src/store/mutations.ts b/src/store/mutations.ts
index 41f5bf5..7948b65 100644
--- a/src/store/mutations.ts
+++ b/src/store/mutations.ts
@@ -158,6 +158,7 @@ export const mutations: MutationTree & Mutations = {
logoutTitle: messageConfig.logoutTitle || '',
logoutErrorUnknown: messageConfig.logoutErrorUnknown || '',
logoutSuccess: messageConfig.logoutSuccess || '',
+ closeTitle: messageConfig.closeTitle || '',
}
state.messages = Object.assign(state.messages, messages);
diff --git a/src/store/state.ts b/src/store/state.ts
index b8616c5..8772324 100644
--- a/src/store/state.ts
+++ b/src/store/state.ts
@@ -166,6 +166,7 @@ export const state: State = {
logoutTitle: '',
logoutErrorUnknown: '',
logoutSuccess: '',
+ closeTitle: '',
},
loggedIn: false,