traxxx/assets/components/dialog/dialog.vue

139 lines
2.0 KiB
Vue
Raw Normal View History

2021-01-03 21:53:51 +00:00
<template>
<teleport to="body">
<div
class="container"
@click="$emit('close')"
>
<div
class="dialog"
@click.stop="events.emit('blur')"
2021-01-03 21:53:51 +00:00
>
<div
v-if="title || $slots.header"
class="header"
>
<slot name="header">
<h2 class="header-title">{{ title }}</h2>
</slot>
<Icon
icon="cross2"
class="close"
@click="$emit('close')"
/>
</div>
<div class="body">
<slot />
</div>
</div>
</div>
</teleport>
</template>
<script>
function mounted() {
this.events.emit('blur');
}
2021-01-03 21:53:51 +00:00
export default {
props: {
title: {
type: String,
default: null,
},
},
emits: ['close'],
mounted,
2021-01-03 21:53:51 +00:00
};
</script>
<style lang="scss" scoped>
.container {
display: flex;
align-items: center;
justify-content: center;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
box-sizing: border-box;
padding: 1rem;
2021-01-04 00:39:55 +00:00
background: var(--darken-strong);
2021-01-03 21:53:51 +00:00
z-index: 10;
}
.dialog {
display: flex;
flex-direction: column;
max-width: 100%;
max-height: 100%;
background: var(--background);
box-shadow: 0 0 3px var(--darken-weak);
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
background: var(--primary);
color: var(--text-light);
font-size: 1.5rem;
font-weight: bold;
}
.header-title {
padding: .5rem .5rem .5rem 1rem;
margin: 0;
overflow: hidden;
text-overflow: ellipsis;
font-size: 1.25rem;
}
.close {
height: 100%;
padding: 0 1rem;
fill: var(--lighten);
&:hover {
fill: var(--lighten-strong);
cursor: pointer;
}
}
.body {
display: flex;
flex-direction: column;
flex-grow: 1;
overflow: hidden;
::v-deep(.section) {
padding: 1rem;
}
}
::v-deep(.dialog-body) {
2021-01-03 21:53:51 +00:00
padding: 1rem;
flex-grow: 1;
}
::v-deep(.dialog-section:not(:last-child)) {
border-bottom: solid 1px var(--shadow-hint);
2021-01-03 21:53:51 +00:00
overflow: auto;
}
2021-03-20 02:22:08 +00:00
::v-deep(.dialog-actions) {
display: flex;
margin: 1rem 0 0 0;
2021-03-20 22:03:13 +00:00
&.center {
justify-content: center;
}
2021-03-20 02:22:08 +00:00
&.right {
justify-content: flex-end;
}
}
2021-01-03 21:53:51 +00:00
</style>