add settings and consistency

This commit is contained in:
Jiiks 2018-01-30 12:01:24 +02:00
parent 30b4a8a55d
commit 9c14b44d22
23 changed files with 246 additions and 24 deletions

View File

@ -0,0 +1,55 @@
[
{
"id": "core",
"text": "Core",
"settings": [
{
"id": "test-setting",
"text": "Test Setting",
"hint": "Test Setting",
"enabled": false,
"disabled": false
},
{
"id": "test-setting2",
"text": "Test Setting 2",
"hint": "Test Setting 2",
"enabled": true,
"disabled": false
},
{
"id": "voice-disconnect",
"text": "Voice Disconnect",
"hint": "Disconnect from voice server when Discord closes",
"enabled": false,
"disabled": true
},
{
"id": "developer-mode",
"text": "Developer Mode",
"hint": "BetterDiscord developer mode",
"enabled": false,
"disabled": true
}
]
},
{
"id": "ui",
"text": "UI",
"settings": [
]
},
{
"id": "emotes",
"text": "Emotes",
"settings": []
},
{
"id": "security",
"text": "Security",
"settings": [
]
}
]

View File

@ -1 +1,2 @@
export { default as Events } from './events';
export { default as Events } from './events';
export { default as Settings } from './settings';

View File

@ -0,0 +1,17 @@
/**
* BetterDiscord Settings Module
* 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.
*/
import defaultSettings from '../data/user.settings.default';
export default class {
static get getSettings() {
return defaultSettings;
}
}

View File

@ -43,7 +43,9 @@
</template>
<script>
// Imports
import { Settings } from '../../modules';
import { SidebarView, Sidebar, SidebarItem, ContentColumn } from './sidebar';
import { CoreSettings } from './bd';
import { SvgX } from './common';
// Constants
@ -65,23 +67,49 @@
activeIndex: -1,
lastActiveIndex: -1,
animating: false,
first: true
first: true,
settings: Settings.getSettings
}
},
props: ['active', 'close'],
computed: {
coreSettings() {
return this.settings.find(settingset => settingset.id === 'core').settings;
}
},
components: {
SidebarView, Sidebar, SidebarItem, ContentColumn, SvgX
SidebarView, Sidebar, SidebarItem, ContentColumn,
CoreSettings,
SvgX
},
methods: {
itemOnClick() {
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;
if (this.first) {
this.first = false;
}
setTimeout(() => {
this.animating = false;
this.lastActiveIndex = -1;
}, 400);
},
activeContent() {
return false;
activeContent(s) {
const item = this.sidebarItems.find(item => item.contentid === s);
if (!item) return false;
return item.id === this.activeIndex;
},
animatingContent() {
return false;
animatingContent(s) {
const item = this.sidebarItems.find(item => item.contentid === s);
if (!item) return false;
return item.id === this.lastActiveIndex;
}
}
}
</script>
</script>

View File

@ -0,0 +1,45 @@
/**
* BetterDiscord Core 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>
<SettingsWrapper headertext="Core Settings">
<div class="bd-form-item" v-for="setting in settings" :key="setting.id">
<SettingSwitch key="setting.id" :setting="setting" :onClick="settingOnClick" :disabled="setting.disabled" />
<div class="bd-form-divider" />
</div>
</SettingsWrapper>
</template>
<script>
// Imports
import { SettingsWrapper } from './';
import { SettingSwitch } from '../common';
/*Methods*/
function settingOnClick(setting) {
if (setting.enabled) return this.disableSetting('core', setting.id);
this.enableSetting('core', setting.id);
}
const methods = { settingOnClick };
export default {
props: ['settings', 'enableSetting', 'disableSetting'],
components: {
SettingsWrapper, SettingSwitch
},
methods: {
settingOnClick(setting) {
if (setting.enabled) return this.disableSetting('core', setting.id);
this.enableSetting('core', setting.id);
}
}
}
</script>

View File

@ -0,0 +1,43 @@
/**
* BetterDiscord Css Editor 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 src="./templates/CssEditor.html">
</template>
<script>
const { CssEditor } = require('../../../');
/*Imports*/
import { SettingsWrapper } from './';
import { SettingSwitch, FormButton } from '../generic';
const components = { SettingsWrapper, SettingSwitch, FormButton };
function openInternalEditor() {
CssEditor.show();
}
function settingClicked() {
this.dummySetting.checked = !this.dummySetting.checked;
}
export default {
components,
methods: { openInternalEditor, settingClicked },
data() {
return {
dummySetting: {
title: "Live Update",
hint: "Automatically update client css when saved.",
checked: true
}
}
}
}
</script>

View File

@ -0,0 +1,29 @@
/**
* BetterDiscord Settings Wrapper 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-settingsWrap">
<div class="bd-settingsWrap-header">{{headertext}}</div>
<ScrollerWrap>
<slot />
</ScrollerWrap>
</div>
</template>
<script>
// Imports
import { ScrollerWrap } from '../common';
export default {
props: ['headertext'],
components: {
ScrollerWrap
}
}
</script>

View File

@ -0,0 +1,2 @@
export { default as SettingsWrapper } from './SettingsWrapper.vue';
export { default as CoreSettings } from './CoreSettings.vue';

View File

@ -18,4 +18,4 @@
export default {
props: ['loading', 'disabled', 'type', 'onClick', 'type']
}
</script>
</script>

View File

@ -16,4 +16,4 @@
<script>
export default {
}
</script>
</script>

View File

@ -18,4 +18,4 @@
export default {
props: ['loading', 'disabled', 'type', 'onClick']
}
</script>
</script>

View File

@ -37,4 +37,4 @@
SvgX
}
}
</script>
</script>

View File

@ -10,7 +10,9 @@
<template>
<div class="bd-scroller-wrap" :class="{'bd-dark': dark}">
<slot />
<div class="bd-scroller">
<slot/>
</div>
</div>
</template>
<script>

View File

@ -24,4 +24,4 @@
export default {
props: ['setting', 'onClick', 'disabled']
}
</script>
</script>

View File

@ -10,4 +10,4 @@
export default {
props: ['size']
}
</script>
</script>

View File

@ -4,4 +4,4 @@ export { default as FormButton } from './FormButton.vue';
export { default as ButtonGroup } from './ButtonGroup.vue';
export { default as Button } from './Button.vue';
export { default as Modal } from './Modal.vue';
export { default as SvgX } from './SvgX.vue';
export { default as SvgX } from './SvgX.vue';

View File

@ -17,4 +17,4 @@
export default {
props: ['item', 'onClick']
}
</script>
</script>

View File

@ -15,4 +15,4 @@
</template>
<script>
export default {}
</script>
</script>

View File

@ -17,4 +17,4 @@
export default {
props: ['item']
}
</script>
</script>

View File

@ -23,4 +23,4 @@
SidebarButton
}
}
</script>
</script>

View File

@ -17,4 +17,4 @@
export default {
}
</script>
</script>

View File

@ -32,4 +32,4 @@
ScrollerWrap
}
}
</script>
</script>

View File

@ -1,2 +1,2 @@
export { default as DOM } from './dom';
export { default as BdUI } from './bdui';
export { default as BdUI } from './bdui';