Whalebird-desktop-client-ma.../src/renderer/components/TimelineSpace/Contents/SideBar.vue

130 lines
2.8 KiB
Vue
Raw Normal View History

2018-03-29 15:41:28 +02:00
<template>
<transition name="slide-detail">
<div id="side_bar" v-if="openSideBar" v-shortkey="shortcutEnabled ? { close: ['esc'] } : {}" @shortkey="handleKey">
<div class="header">
<i class="el-icon-loading" v-show="loading"></i>
<i class="el-icon-refresh" @click="reload"></i>
<i class="el-icon-close" @click="close"></i>
</div>
<div id="sidebar_scrollable">
<account-profile v-if="component === 1" v-on:change-loading="changeLoading"></account-profile>
<toot-detail v-else-if="component === 2"></toot-detail>
<div
class="loading"
v-loading="true"
:element-loading-text="$t('message.loading')"
element-loading-spinner="el-icon-loading"
:element-loading-background="backgroundColor"
v-else
></div>
</div>
</div>
</transition>
2018-03-29 15:41:28 +02:00
</template>
<script>
import { mapState } from 'vuex'
import TootDetail from './SideBar/TootDetail'
import AccountProfile from './SideBar/AccountProfile'
2018-03-29 15:41:28 +02:00
export default {
name: 'side-bar',
components: {
TootDetail,
AccountProfile
},
2018-08-30 02:03:38 +02:00
props: {
overlaid: {
type: Boolean,
default: false
}
},
data() {
return {
loading: false
}
},
2018-03-29 15:41:28 +02:00
computed: {
...mapState({
openSideBar: state => state.TimelineSpace.Contents.SideBar.openSideBar,
component: state => state.TimelineSpace.Contents.SideBar.component,
backgroundColor: state => state.App.theme.background_color
2018-08-30 02:03:38 +02:00
}),
shortcutEnabled: function() {
2018-08-30 02:03:38 +02:00
return !this.overlaid
}
2018-03-29 15:41:28 +02:00
},
beforeDestroy() {
this.close()
},
2018-03-29 15:41:28 +02:00
methods: {
close() {
this.$store.dispatch('TimelineSpace/Contents/SideBar/close')
},
changeLoading(value) {
this.loading = value
2018-08-30 02:03:38 +02:00
},
reload() {
this.$store.dispatch('TimelineSpace/Contents/SideBar/reload')
},
handleKey(event) {
2018-08-30 02:03:38 +02:00
switch (event.srcKey) {
case 'close':
this.close()
break
}
2018-03-29 15:41:28 +02:00
}
}
}
</script>
<style lang="scss" scoped>
#side_bar {
position: fixed;
top: 48px;
right: 0;
2018-11-26 14:33:31 +01:00
width: 360px;
height: calc(100% - 48px);
border-left: solid 1px var(--theme-border-color);
.header {
background-color: var(--theme-selected-background-color);
padding: 4px 8px;
border-top: solid 1px var(--theme-border-color);
border-bottom: solid 1px var(--theme-border-color);
text-align: right;
height: 36px;
box-sizing: border-box;
font-size: 18px;
.el-icon-close {
cursor: pointer;
}
.el-icon-refresh {
cursor: pointer;
}
}
#sidebar_scrollable {
overflow: auto;
height: calc(100% - 30px);
}
.loading {
height: 100%;
}
2018-03-29 15:41:28 +02:00
}
2018-04-13 11:01:19 +02:00
.slide-detail-enter-active,
.slide-detail-leave-active {
2018-04-13 11:01:19 +02:00
transition: all 0.5s;
}
.slide-detail-enter,
.slide-detail-leave-to {
2018-11-26 14:33:31 +01:00
margin-right: -360px;
2018-04-13 11:01:19 +02:00
opacity: 0;
}
2018-03-29 15:41:28 +02:00
</style>