Stackedit/src/components/SideBar.vue

158 lines
3.3 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="setPanel('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>
<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">
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>
<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 MenuEntry from './menus/MenuEntry';
import MainMenu from './menus/MainMenu';
import SyncMenu from './menus/SyncMenu';
import PublishMenu from './menus/PublishMenu';
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',
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,
MenuEntry,
2017-09-23 19:01:50 +00:00
MainMenu,
SyncMenu,
PublishMenu,
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;
2017-09-23 19:01:50 +00:00
display: none;
}
* + 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
.side-bar__warning {
padding: 10px;
margin: 0 -10px;
color: darken($error-color, 10);
background-color: transparentize($error-color, 0.925);
p {
margin: 10px;
line-height: 1.4;
}
}
2017-08-04 08:20:50 +00:00
</style>