Stackedit/src/components/SideBar.vue

145 lines
3.6 KiB
Vue
Raw Normal View History

2017-07-23 18:42:08 +00:00
<template>
2017-08-04 08:20:50 +00:00
<div class="side-bar flex flex--column">
2017-08-06 00:58:39 +00:00
<div class="side-title flex flex--row">
<button v-if="panel !== 'menu'" class="side-title__button button" @click="panel = 'menu'">
<icon-arrow-left></icon-arrow-left>
</button>
<div class="side-title__title">
{{panelName}}
2017-08-04 08:20:50 +00:00
</div>
<button class="side-title__button button" @click="toggleSideBar(false)">
<icon-close></icon-close>
</button>
</div>
2017-08-04 20:46:06 +00:00
<div class="side-bar__inner">
<div v-if="panel === 'menu'" class="side-bar__panel side-bar__panel--menu">
2017-08-15 10:43:26 +00:00
<side-bar-item v-if="!loginToken" @click.native="signin">
2017-08-04 20:46:06 +00:00
<icon-login slot="icon"></icon-login>
<div>Sign in with Google</div>
<span>Have all your files and settings backed up and synced.</span>
2017-08-06 00:58:39 +00:00
</side-bar-item>
2017-08-15 10:43:26 +00:00
<!-- <side-bar-item @click.native="signin">
<icon-login slot="icon"></icon-login>
<div>Sign in on CouchDB</div>
<span>Save and collaborate on a CouchDB hosted by you.</span>
</side-bar-item> -->
2017-08-06 00:58:39 +00:00
<side-bar-item @click.native="panel = 'toc'">
2017-08-04 20:46:06 +00:00
<icon-toc slot="icon"></icon-toc>
2017-08-06 00:58:39 +00:00
Table of contents
</side-bar-item>
<side-bar-item @click.native="panel = 'help'">
2017-08-04 20:46:06 +00:00
<icon-help-circle slot="icon"></icon-help-circle>
2017-08-06 00:58:39 +00:00
Markdown cheat sheet
</side-bar-item>
</div>
<div v-else-if="panel === 'help'" class="side-bar__panel side-bar__panel--help">
<pre class="markdown-highlighting" v-html="markdownSample"></pre>
2017-08-04 20:46:06 +00:00
</div>
<div class="side-bar__panel side-bar__panel--toc" :class="{'side-bar__panel--hidden': panel !== 'toc'}">
<toc>
</toc>
</div>
2017-08-04 08:20:50 +00:00
</div>
2017-07-23 18:42:08 +00:00
</div>
</template>
<script>
2017-08-15 10:43:26 +00:00
import { mapGetters, mapActions } from 'vuex';
2017-07-23 18:42:08 +00:00
import Toc from './Toc';
2017-08-06 00:58:39 +00:00
import SideBarItem from './SideBarItem';
import markdownSample from '../data/markdownSample.md';
import markdownConversionSvc from '../services/markdownConversionSvc';
2017-08-15 10:43:26 +00:00
import googleHelper from '../services/helpers/googleHelper';
import syncSvc from '../services/syncSvc';
2017-08-04 20:46:06 +00:00
const panelNames = {
menu: 'Menu',
2017-08-06 00:58:39 +00:00
help: 'Markdown cheat sheet',
toc: 'Table of contents',
2017-08-04 20:46:06 +00:00
};
2017-07-23 18:42:08 +00:00
export default {
components: {
Toc,
2017-08-06 00:58:39 +00:00
SideBarItem,
2017-08-04 20:46:06 +00:00
},
data: () => ({
panel: 'menu',
panelNames: {
menu: 'Menu',
toc: 'Table of Contents',
2017-08-06 00:58:39 +00:00
help: 'Markdown cheat sheet',
2017-08-04 20:46:06 +00:00
},
2017-08-06 00:58:39 +00:00
markdownSample: markdownConversionSvc.highlight(markdownSample),
2017-08-04 20:46:06 +00:00
}),
computed: {
2017-08-15 10:43:26 +00:00
...mapGetters('data', [
'loginToken',
]),
2017-08-04 20:46:06 +00:00
panelName() {
return panelNames[this.panel];
},
2017-07-23 18:42:08 +00:00
},
2017-08-04 08:20:50 +00:00
methods: {
...mapActions('data', [
'toggleSideBar',
]),
2017-08-06 00:58:39 +00:00
signin() {
2017-08-15 10:43:26 +00:00
googleHelper.startOauth2([
'openid',
'https://www.googleapis.com/auth/drive.appdata',
]).then(() => syncSvc.requestSync());
2017-08-06 00:58:39 +00:00
},
2017-08-04 08:20:50 +00:00
},
2017-07-23 18:42:08 +00:00
};
</script>
2017-08-04 08:20:50 +00:00
<style lang="scss">
@import 'common/variables.scss';
.side-bar {
overflow: hidden;
2017-08-04 20:46:06 +00:00
height: 100%;
}
.side-bar__inner {
2017-08-06 00:58:39 +00:00
position: relative;
2017-08-04 20:46:06 +00:00
height: 100%;
2017-08-04 08:20:50 +00:00
}
.side-bar__panel {
position: absolute;
width: 100%;
height: 100%;
2017-08-06 00:58:39 +00:00
overflow: auto;
2017-08-04 08:20:50 +00:00
}
2017-08-04 20:46:06 +00:00
.side-bar__panel--hidden {
2017-08-04 08:20:50 +00:00
left: 1000px;
}
2017-08-06 00:58:39 +00:00
2017-08-15 10:43:26 +00:00
.side-bar__panel--menu {
padding: 5px;
}
2017-08-06 00:58:39 +00:00
.side-bar__panel--help {
padding: 0 10px 40px 20px;
pre {
font-size: 0.9em;
font-variant-ligatures: no-common-ligatures;
line-height: 1.25;
white-space: pre-wrap;
word-break: break-word;
word-wrap: break-word;
}
.code,
.img,
.imgref,
.cl-toc {
background-color: rgba(0, 0, 0, 0.05);
}
}
2017-08-04 08:20:50 +00:00
</style>