Created
February 4, 2016 15:22
-
-
Save martinlindhe/5bc834f410f958a65c7d to your computer and use it in GitHub Desktop.
<mdl-dialog> from mdl 1.1, for vue-mdl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<mdl-dialog v-if="alert" title="alert heading" :message="alert"> | |
</mdl-dialog> | |
</div> | |
</template> | |
<script> | |
import MdlDialog from './MdlDialog.vue'; | |
export default { | |
components: { | |
MdlDialog, | |
}, | |
data() { | |
return { | |
alert: '', | |
} | |
}, | |
ready() { | |
this.alert = "hello world"; | |
}, | |
}; | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
/* for dialog-polyfill, from node_modules/dialog-polyfill/dialog-polyfill.css */ | |
dialog { | |
position: absolute; | |
left: 0; right: 0; | |
width: -moz-fit-content; | |
width: -webkit-fit-content; | |
width: fit-content; | |
height: -moz-fit-content; | |
height: -webkit-fit-content; | |
height: fit-content; | |
margin: auto; | |
border: solid; | |
padding: 1em; | |
background: white; | |
color: black; | |
display: none; | |
} | |
dialog[open] { | |
display: block; | |
} | |
dialog + .backdrop { | |
position: fixed; | |
top: 0; right: 0; bottom: 0; left: 0; | |
background: rgba(0,0,0,0.1); | |
} | |
/* for small devices, modal dialogs go full-screen */ | |
@media screen and (max-width: 540px) { | |
dialog[_polyfill_modal] { /* TODO: implement */ | |
top: 0; | |
width: auto; | |
margin: 1em; | |
} | |
} | |
._dialog_overlay { | |
position: fixed; | |
top: 0; right: 0; bottom: 0; left: 0; | |
} | |
</style> | |
<template> | |
<dialog | |
class="mdl-dialog"> | |
<h4 class="mdl-dialog__title">{{ title }}</h4> | |
<div class="mdl-dialog__content"> | |
<p> | |
{{ message }} | |
<p> | |
</div> | |
<div class="mdl-dialog__actions"> | |
<button type="button" class="mdl-button" @click="close">{{ $t('nav.close') }}</button> | |
</div> | |
</dialog> | |
</template> | |
<script> | |
import 'dialog-polyfill'; | |
export default { | |
props: { | |
title: '', | |
message: '', | |
}, | |
ready() { | |
this.$el.showModal(); | |
}, | |
methods: { | |
close() { | |
this.$el.close(); | |
}, | |
}, | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment