BetterDiscordApp-v2/client/src/ui/components/BdSettings.vue

134 lines
5.9 KiB
Vue
Raw Normal View History

/**
* BetterDiscord Settings Component
* Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks
* All rights reserved.
* https://betterdiscord.net
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
<template>
<div class="bd-settings" :class="{active: active}" @keyup="close">
<SidebarView :contentVisible="this.activeIndex >= 0" :animating="this.animating" :class="{'bd-stop': !first}">
2018-01-30 10:28:28 +01:00
<Sidebar slot="sidebar">
<div class="bd-settings-x" @click="close">
2018-02-03 01:17:35 +01:00
<MiClose size="17"/>
<span class="bd-x-text">ESC</span>
2018-01-30 10:28:28 +01:00
</div>
<SidebarItem v-for="item in sidebarItems" :item="item" :key="item.id" :onClick="itemOnClick" />
</Sidebar>
<div slot="sidebarfooter" class="bd-info">
<span class="bd-vtext">v2.0.0a by Jiiks/JsSucks</span>
<div @click="openGithub" v-tooltip="'Github'" class="bd-material-button">
<MiGithubCircle size="16" />
</div>
2018-02-03 06:44:18 +01:00
<div @click="openTwitter" v-tooltip="'@Jiiksi'" class="bd-material-button">
<MiTwitterCircle size="16" />
</div>
<div @click="openWebsite" v-tooltip="'BetterDiscord'" class="bd-material-button">
<MiWeb size="16" />
</div>
</div>
2018-01-30 10:28:28 +01:00
<ContentColumn slot="content">
2018-03-02 20:34:53 +01:00
<div v-for="set in Settings.settings" v-if="activeContent(set.id) || animatingContent(set.id)" :class="{active: activeContent(set.id), animating: animatingContent(set.id)}">
<SettingsWrapper :headertext="set.headertext">
2018-03-02 20:34:53 +01:00
<SettingsPanel :settings="set" :schemes="set.schemes" />
</SettingsWrapper>
2018-01-30 10:28:28 +01:00
</div>
<div v-if="activeContent('css') || animatingContent('css')" :class="{active: activeContent('css'), animating: animatingContent('css')}">
<CssEditorView />
</div>
<div v-if="activeContent('plugins') || animatingContent('plugins')" :class="{active: activeContent('plugins'), animating: animatingContent('plugins')}">
<PluginsView />
</div>
<div v-if="activeContent('themes') || animatingContent('themes')" :class="{active: activeContent('themes'), animating: animatingContent('themes')}">
<ThemesView />
</div>
2018-01-30 10:28:28 +01:00
</ContentColumn>
</SidebarView>
</div>
</template>
<script>
2018-01-30 10:28:28 +01:00
// Imports
2018-02-02 14:23:02 +01:00
import { shell } from 'electron';
2018-01-30 14:20:24 +01:00
import { Settings } from 'modules';
2018-01-30 10:28:28 +01:00
import { SidebarView, Sidebar, SidebarItem, ContentColumn } from './sidebar';
import { SettingsWrapper, SettingsPanel, CssEditorView, PluginsView, ThemesView } from './bd';
2018-02-03 06:44:18 +01:00
import { SvgX, MiGithubCircle, MiWeb, MiClose, MiTwitterCircle } from './common';
2018-01-30 10:28:28 +01:00
// Constants
const sidebarItems = [
{ text: 'Internal', _type: 'header' },
{ id: 0, contentid: "core", text: 'Core', active: false, _type: 'button' },
{ id: 1, contentid: "ui", text: 'UI', active: false, _type: 'button' },
{ id: 2, contentid: "emotes", text: 'Emotes', active: false, _type: 'button' },
{ id: 3, contentid: "css", text: 'CSS Editor', active: false, _type: 'button' },
{ text: 'External', _type: 'header' },
{ id: 4, contentid: "plugins", text: 'Plugins', active: false, _type: 'button' },
{ id: 5, contentid: "themes", text: 'Themes', active: false, _type: 'button' }
];
export default {
2018-01-30 10:28:28 +01:00
data() {
return {
sidebarItems,
activeIndex: -1,
lastActiveIndex: -1,
animating: false,
2018-01-30 11:01:24 +01:00
first: true,
2018-03-02 20:34:53 +01:00
Settings
};
2018-01-30 10:28:28 +01:00
},
props: ['active', 'close'],
components: {
2018-01-30 11:01:24 +01:00
SidebarView, Sidebar, SidebarItem, ContentColumn,
2018-02-12 18:46:29 +01:00
SettingsWrapper, SettingsPanel, CssEditorView, PluginsView, ThemesView,
2018-02-03 06:44:18 +01:00
MiGithubCircle, MiWeb, MiClose, MiTwitterCircle
2018-01-30 10:28:28 +01:00
},
methods: {
2018-01-30 11:01:24 +01:00
itemOnClick(id) {
if (this.animating || id === this.activeIndex) return;
if (this.activeIndex >= 0) this.sidebarItems.find(item => item.id === this.activeIndex).active = false;
this.sidebarItems.find(item => item.id === id).active = true;
this.animating = true;
this.lastActiveIndex = this.activeIndex;
this.activeIndex = id;
setTimeout(() => {
this.first = false;
2018-01-30 11:01:24 +01:00
this.animating = false;
this.lastActiveIndex = -1;
}, 400);
2018-01-30 10:28:28 +01:00
},
2018-01-30 11:01:24 +01:00
activeContent(s) {
const item = this.sidebarItems.find(item => item.contentid === s);
2018-03-01 20:26:44 +01:00
return item && item.id === this.activeIndex;
2018-01-30 10:28:28 +01:00
},
2018-01-30 11:01:24 +01:00
animatingContent(s) {
const item = this.sidebarItems.find(item => item.contentid === s);
2018-03-01 20:26:44 +01:00
return item && item.id === this.lastActiveIndex;
2018-01-30 12:14:16 +01:00
},
2018-02-02 14:23:02 +01:00
openGithub() {
shell.openExternal('https://github.com/JsSucks/BetterDiscordApp');
},
openWebsite() {
shell.openExternal('https://betterdiscord.net');
2018-02-03 06:44:18 +01:00
},
openTwitter() {
2018-02-03 06:46:18 +01:00
shell.openExternal('https://twitter.com/Jiiksi');
2018-01-30 10:28:28 +01:00
}
},
watch: {
active(newVal, oldVal) {
if (!newVal) {
this.sidebarItems.find(item => item.id === this.activeIndex).active = false;
this.activeIndex = this.lastActiveIndex = -1;
this.animating = false;
this.first = true;
}
}
2018-01-30 10:28:28 +01:00
}
}
2018-01-30 11:01:24 +01:00
</script>