Stackedit/src/components/App.vue

83 lines
1.6 KiB
Vue
Raw Normal View History

2017-07-23 18:42:08 +00:00
<template>
2017-10-02 00:34:48 +00:00
<splash-screen v-if="!ready"></splash-screen>
<div v-else class="app">
2017-07-23 18:42:08 +00:00
<layout></layout>
<modal v-if="showModal"></modal>
2017-09-23 19:01:50 +00:00
<notification></notification>
2017-07-23 18:42:08 +00:00
</div>
</template>
<script>
import Vue from 'vue';
import { mapState } from 'vuex';
2017-07-23 18:42:08 +00:00
import Layout from './Layout';
import Modal from './Modal';
2017-09-23 19:01:50 +00:00
import Notification from './Notification';
2017-10-02 00:34:48 +00:00
import SplashScreen from './SplashScreen';
2017-11-15 08:12:56 +00:00
import timeSvc from '../services/timeSvc';
import store from '../store';
2017-07-23 18:42:08 +00:00
// Global directives
Vue.directive('focus', {
inserted(el) {
el.focus();
2017-11-26 20:58:24 +00:00
const value = el.value;
if (value && el.setSelectionRange) {
el.setSelectionRange(0, value.length);
}
},
});
2017-10-07 11:22:24 +00:00
const setVisible = (el, value) => {
el.style.display = value ? '' : 'none';
if (value) {
el.removeAttribute('aria-hidden');
} else {
el.setAttribute('aria-hidden', 'true');
}
};
Vue.directive('show', {
bind(el, { value }) {
setVisible(el, value);
},
update(el, { value, oldValue }) {
if (value !== oldValue) {
setVisible(el, value);
}
},
});
Vue.directive('title', {
bind(el, { value }) {
el.title = value;
el.setAttribute('aria-label', value);
},
});
2017-11-15 08:12:56 +00:00
// Global filters
Vue.filter('formatTime', time =>
// Access the minute counter for reactive refresh
timeSvc.format(time, store.state.minuteCounter));
2017-07-23 18:42:08 +00:00
export default {
components: {
Layout,
Modal,
2017-09-23 19:01:50 +00:00
Notification,
2017-10-02 00:34:48 +00:00
SplashScreen,
2017-07-23 18:42:08 +00:00
},
2017-07-28 07:40:24 +00:00
computed: {
...mapState([
'ready',
]),
showModal() {
2017-09-23 19:01:50 +00:00
return !!this.$store.getters['modal/config'];
},
2017-07-28 07:40:24 +00:00
},
2017-07-23 18:42:08 +00:00
};
</script>
<style lang="scss">
2017-07-28 20:04:12 +00:00
@import 'common/app';
2017-07-23 18:42:08 +00:00
</style>