Stackedit/src/components/SideBar.vue

160 lines
3.4 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">
2017-10-07 11:22:24 +00:00
<button v-if="panel !== 'menu'" class="side-title__button button" @click="setPanel('menu')" v-title="'Main menu'">
2017-08-06 00:58:39 +00:00
<icon-arrow-left></icon-arrow-left>
</button>
<div class="side-title__title">
{{panelName}}
2017-08-04 08:20:50 +00:00
</div>
2017-10-07 11:22:24 +00:00
<button class="side-title__button button" @click="toggleSideBar(false)" v-title="'Close side bar'">
2017-08-04 08:20:50 +00:00
<icon-close></icon-close>
</button>
</div>
2017-08-04 20:46:06 +00:00
<div class="side-bar__inner">
2017-09-23 19:01:50 +00:00
<main-menu v-if="panel === 'menu'"></main-menu>
<sync-menu v-else-if="panel === 'sync'"></sync-menu>
<publish-menu v-else-if="panel === 'publish'"></publish-menu>
2017-11-26 20:58:24 +00:00
<history-menu v-else-if="panel === 'history'"></history-menu>
2017-09-23 19:01:50 +00:00
<export-menu v-else-if="panel === 'export'"></export-menu>
<more-menu v-else-if="panel === 'more'"></more-menu>
2017-08-06 00:58:39 +00:00
<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-09-23 19:01:50 +00:00
import { mapActions } from 'vuex';
2017-07-23 18:42:08 +00:00
import Toc from './Toc';
2017-09-23 19:01:50 +00:00
import MainMenu from './menus/MainMenu';
import SyncMenu from './menus/SyncMenu';
import PublishMenu from './menus/PublishMenu';
2017-11-26 20:58:24 +00:00
import HistoryMenu from './menus/HistoryMenu';
2017-09-23 19:01:50 +00:00
import ExportMenu from './menus/ExportMenu';
import MoreMenu from './menus/MoreMenu';
2017-08-06 00:58:39 +00:00
import markdownSample from '../data/markdownSample.md';
import markdownConversionSvc from '../services/markdownConversionSvc';
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',
sync: 'Synchronize',
publish: 'Publish',
2017-11-26 20:58:24 +00:00
history: 'File history',
export: 'Export to disk',
more: 'More',
2017-08-04 20:46:06 +00:00
};
2017-07-23 18:42:08 +00:00
export default {
components: {
Toc,
2017-09-23 19:01:50 +00:00
MainMenu,
SyncMenu,
PublishMenu,
2017-11-26 20:58:24 +00:00
HistoryMenu,
2017-09-23 19:01:50 +00:00
ExportMenu,
MoreMenu,
2017-08-04 20:46:06 +00:00
},
data: () => ({
2017-08-06 00:58:39 +00:00
markdownSample: markdownConversionSvc.highlight(markdownSample),
2017-08-04 20:46:06 +00:00
}),
computed: {
panel() {
return this.$store.getters['data/localSettings'].sideBarPanel;
},
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',
]),
...mapActions('data', {
setPanel: 'setSideBarPanel',
}),
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%;
2017-08-25 10:37:46 +00:00
hr {
margin: 10px 40px;
2017-09-23 19:01:50 +00:00
display: none;
2017-11-26 20:58:24 +00:00
border-top: 1px solid $hr-color;
2017-09-23 19:01:50 +00:00
}
* + hr {
display: block;
}
hr + hr {
display: none;
2017-08-25 10:37:46 +00:00
}
2017-08-04 20:46:06 +00:00
}
.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 {
2017-09-23 19:01:50 +00:00
padding: 10px 10px 50px;
2017-08-15 10:43:26 +00:00
}
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-09-23 19:01:50 +00:00
2017-10-05 07:18:21 +00:00
.side-bar__info {
2017-09-23 19:01:50 +00:00
padding: 10px;
margin: 0 -10px;
2017-10-05 07:18:21 +00:00
background-color: $info-bg;
2017-09-23 19:01:50 +00:00
p {
margin: 10px;
line-height: 1.4;
}
}
2017-08-04 08:20:50 +00:00
</style>