2024-03-26 03:14:42 +00:00
< template >
2024-06-10 01:24:48 +00:00
< Teleport to = "#container" >
2024-03-26 03:14:42 +00:00
< div
class = "dialog-container"
2024-08-26 04:15:22 +00:00
@ click = "close"
2024-03-26 03:14:42 +00:00
>
< div
class = "dialog"
@ click . stop
>
< div class = "dialog-header" >
< span class = "dialog-title ellipsis" > { { title } } < / span >
< Icon
icon = "cross2"
class = "dialog-close"
2024-08-26 04:15:22 +00:00
@ click = "close"
2024-03-26 03:14:42 +00:00
/ >
< / div >
2024-08-26 04:15:22 +00:00
< slot @ event = "({ type, data }) => emit('event', { type, data })" / >
2024-03-26 03:14:42 +00:00
< / div >
< / div >
< / Teleport >
< / template >
< script setup >
import { onMounted } from 'vue' ;
2024-08-26 04:15:22 +00:00
const props = defineProps ( {
2024-03-26 03:14:42 +00:00
title : {
type : String ,
default : null ,
} ,
2024-08-26 04:15:22 +00:00
confirmClose : {
type : Boolean ,
default : false ,
} ,
2024-03-26 03:14:42 +00:00
} ) ;
2024-08-26 04:15:22 +00:00
const emit = defineEmits ( [ 'open' , 'close' , 'event' ] ) ;
function close ( ) {
if ( ! props . confirmClose || confirm ( 'You have unchanged changes, are you sure you want to close the dialog?' ) ) { // eslint-disable-line no-restricted-globals, no-alert
emit ( 'close' ) ;
}
}
2024-03-26 03:14:42 +00:00
onMounted ( ( ) => emit ( 'open' ) ) ;
< / script >
< style >
. dialog - body {
display : flex ;
flex - direction : column ;
border - radius : 0 0 .25 rem .25 rem ;
background : var ( -- background ) ;
}
2024-04-03 00:13:41 +00:00
. dialog - heading {
color : var ( -- primary ) ;
margin : 0 0 .5 rem 0 ;
font - size : 1 rem ;
}
. dialog - description {
margin : 0 0 .5 rem 0 ;
2024-06-10 01:24:48 +00:00
color : var ( -- glass - strong - 10 ) ;
2024-04-03 00:13:41 +00:00
font - size : .9 rem ;
line - height : 1.5 ;
}
2024-05-19 03:07:35 +00:00
. dialog - error {
padding : .5 rem 1 rem ;
color : var ( -- text - light ) ;
background : var ( -- error ) ;
font - weight : bold ;
}
2024-03-26 03:14:42 +00:00
< / style >
< style scoped >
. dialog - container {
width : 100 % ;
height : 100 % ;
display : flex ;
align - items : center ;
justify - content : center ;
position : fixed ;
top : 0 ;
left : 0 ;
z - index : 900 ;
2024-05-19 03:07:35 +00:00
box - sizing : border - box ;
padding : 1 rem ;
2024-03-26 03:14:42 +00:00
background : var ( -- shadow - strong - 10 ) ;
}
. dialog {
2024-05-19 03:07:35 +00:00
display : flex ;
flex - direction : column ;
2024-03-26 03:14:42 +00:00
border - radius : .25 rem ;
box - shadow : 0 0 3 px var ( -- shadow ) ;
overflow : hidden ;
max - width : 100 % ;
2024-05-19 03:07:35 +00:00
max - height : 100 % ;
2024-03-26 03:14:42 +00:00
margin : 1 rem ;
}
. dialog - header {
display : flex ;
justify - content : space - between ;
align - items : stretch ;
background : var ( -- primary ) ;
border - radius : .25 rem .25 rem 0 0 ;
}
. dialog - title {
padding : .5 rem 1 rem ;
color : var ( -- text - light ) ;
font - size : 1.1 rem ;
font - weight : bold ;
}
. dialog - close {
height : auto ;
padding : 0 .75 rem ;
fill : var ( -- highlight ) ;
& : hover {
fill : var ( -- text - light ) ;
cursor : pointer ;
}
}
< / style >