Merge pull request #85 from samfun123/master
Add Number, Radio and Dropdown setting types
This commit is contained in:
commit
6e4f90cdfb
|
@ -96,6 +96,7 @@
|
||||||
|
|
||||||
.bd-form-textinput,
|
.bd-form-textinput,
|
||||||
.bd-form-fileinput,
|
.bd-form-fileinput,
|
||||||
|
.bd-form-numberinput,
|
||||||
.bd-setting-switch {
|
.bd-setting-switch {
|
||||||
.bd-title {
|
.bd-title {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -121,8 +122,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.bd-form-textinput {
|
.bd-form-textinput, .bd-form-numberinput {
|
||||||
input[type="text"] {
|
input[type="text"], input[type="number"] {
|
||||||
background: transparent;
|
background: transparent;
|
||||||
border: none;
|
border: none;
|
||||||
color: #b9bbbe;
|
color: #b9bbbe;
|
||||||
|
@ -179,3 +180,158 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bd-number {
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
input[type=number] {
|
||||||
|
&::-webkit-inner-spin-button,
|
||||||
|
::-webkit-outer-spin-button {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.bd-number-spinner {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 100%;
|
||||||
|
justify-content: space-around;
|
||||||
|
|
||||||
|
.bd-arrow {
|
||||||
|
padding: 3px 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0;
|
||||||
|
|
||||||
|
.bd-up-arrow {
|
||||||
|
border-color: transparent transparent rgb(153, 153, 153);
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 2.5px 5px 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover .bd-up-arrow {
|
||||||
|
border-color: transparent transparent rgb(200, 200, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
.bd-down-arrow {
|
||||||
|
border-color: rgb(153, 153, 153) transparent transparent;
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 5px 5px 2.5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover .bd-down-arrow {
|
||||||
|
border-color: rgb(200, 200, 200) transparent transparent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.bd-radio-option {
|
||||||
|
background: rgb(50, 50, 50);
|
||||||
|
border: 2px solid rgb(39, 39, 39);
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 3px;
|
||||||
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
input[type="radio"] {
|
||||||
|
display: none;
|
||||||
|
|
||||||
|
&:checked + .bd-radio {
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.bd-radio {
|
||||||
|
background: rgb(50, 50, 50);
|
||||||
|
border: 1px solid rgb(114, 118, 125);
|
||||||
|
border-radius: 50%;
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
transition: background-color .1s;
|
||||||
|
}
|
||||||
|
|
||||||
|
span {
|
||||||
|
color: white;
|
||||||
|
margin: 0px 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:not(:last-child) {
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.bd-dropdown {
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.bd-dropdown-current {
|
||||||
|
color: white;
|
||||||
|
background: rgb(50, 50, 50);
|
||||||
|
border: 2px solid rgb(39, 39, 39);
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
.bd-dropdown-arrow {
|
||||||
|
border-color: rgb(153, 153, 153) transparent transparent;
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 5px 5px 2.5px;
|
||||||
|
display: inline-block;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.bd-dropdown-options {
|
||||||
|
position: absolute;
|
||||||
|
top: calc(100% - 2.5px);
|
||||||
|
width: 100%;
|
||||||
|
max-height: 100px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
background: rgb(50, 50, 50);
|
||||||
|
border: 2px solid rgb(39, 39, 39);
|
||||||
|
border-bottom-left-radius: 5px;
|
||||||
|
border-bottom-right-radius: 5px;
|
||||||
|
overflow-y: scroll;
|
||||||
|
|
||||||
|
div {
|
||||||
|
color: white;
|
||||||
|
padding: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: rgb(59, 59, 59);
|
||||||
|
}
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
border-bottom-left-radius: 5px;
|
||||||
|
border-bottom-right-radius: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&::-webkit-scrollbar {
|
||||||
|
width: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::-webkit-scrollbar-thumb {
|
||||||
|
background-color: #1e2124;
|
||||||
|
border-color: #36393e;
|
||||||
|
border-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::-webkit-scrollbar-thumb,
|
||||||
|
&::-webkit-scrollbar-track-piece {
|
||||||
|
background-clip: padding-box;
|
||||||
|
border-width: 3px;
|
||||||
|
border-style: solid;
|
||||||
|
border-radius: 7px;
|
||||||
|
border-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::-webkit-scrollbar-track-piece {
|
||||||
|
background-color: #2f3136;
|
||||||
|
border-color: #36393e;
|
||||||
|
border-color: transparent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
/**
|
||||||
|
* BetterDiscord Plugin Setting Dropdown 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-setting-switch">
|
||||||
|
<div class="bd-title">
|
||||||
|
<h3>{{setting.text}}</h3>
|
||||||
|
<div class="bd-dropdown">
|
||||||
|
<div class="bd-dropdown-current" @click="expanded = true">{{getOptionText(setting.value)}}<span class="bd-dropdown-arrow"></span></div>
|
||||||
|
<div class="bd-dropdown-options bd-flex bd-flex-col" ref="options" v-if="expanded">
|
||||||
|
<div v-for="option in setting.options" @click="selectOption(setting.id, option.value)">{{option.text}}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="bd-hint">{{setting.hint}}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: ['setting', 'change'],
|
||||||
|
data() {
|
||||||
|
return { expanded: false }
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getOptionText(value) {
|
||||||
|
let matching = this.setting.options.filter(opt => opt.value == value);
|
||||||
|
if (matching.length == 0) return "";
|
||||||
|
else return matching[0].text;
|
||||||
|
},
|
||||||
|
selectOption(settingID, value) {
|
||||||
|
this.expanded = false;
|
||||||
|
this.change(settingID, value)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
document.addEventListener("click", e => {
|
||||||
|
let options = this.$refs.options;
|
||||||
|
if (options && !options.contains(e.target) && options !== e.target) {
|
||||||
|
this.expanded = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -0,0 +1,42 @@
|
||||||
|
/**
|
||||||
|
* BetterDiscord Plugin Setting Number 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-form-numberinput">
|
||||||
|
<div class="bd-title">
|
||||||
|
<h3>{{setting.text}}</h3>
|
||||||
|
<div class="bd-number">
|
||||||
|
<input type="number" :value="setting.value" :min="setting.min" :max="setting.max" :step="setting.step" @keyup.stop @input="input"/>
|
||||||
|
<div class="bd-number-spinner bd-flex bd-flex-col">
|
||||||
|
<div class="bd-arrow" @click="changeBy(true)"><div class="bd-up-arrow"></div></div>
|
||||||
|
<div class="bd-arrow" @click="changeBy(false)"><div class="bd-down-arrow"></div></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="bd-hint">{{setting.hint}}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: ['setting', 'change'],
|
||||||
|
methods: {
|
||||||
|
input(e) {
|
||||||
|
let number = parseFloat(e.target.value)
|
||||||
|
if (Number.isNaN(number)) return;
|
||||||
|
|
||||||
|
this.change(this.setting.id, number);
|
||||||
|
},
|
||||||
|
changeBy(positive) {
|
||||||
|
let step = this.setting.step == undefined ? 1 : this.settings.step;
|
||||||
|
this.change(this.setting.id, this.setting.value + (positive ? step : -step));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -11,6 +11,9 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="bd-form-item">
|
<div class="bd-form-item">
|
||||||
<BoolSetting v-if="setting.type === 'bool'" :setting="setting" :change="change"/>
|
<BoolSetting v-if="setting.type === 'bool'" :setting="setting" :change="change"/>
|
||||||
|
<DropdownSetting v-if="setting.type === 'dropdown'" :setting="setting" :change="change"/>
|
||||||
|
<NumberSetting v-if="setting.type === 'number'" :setting="setting" :change="change"/>
|
||||||
|
<RadioSetting v-if="setting.type === 'radio'" :setting="setting" :change="change"/>
|
||||||
<StringSetting v-if="setting.type === 'text'" :setting="setting" :change="change"/>
|
<StringSetting v-if="setting.type === 'text'" :setting="setting" :change="change"/>
|
||||||
<FileSetting v-if="setting.type === 'file'" :setting="setting" :change="change"/>
|
<FileSetting v-if="setting.type === 'file'" :setting="setting" :change="change"/>
|
||||||
<div class="bd-form-divider"></div>
|
<div class="bd-form-divider"></div>
|
||||||
|
@ -19,6 +22,9 @@
|
||||||
<script>
|
<script>
|
||||||
// Imports
|
// Imports
|
||||||
import BoolSetting from './Bool.vue';
|
import BoolSetting from './Bool.vue';
|
||||||
|
import DropdownSetting from './Dropdown.vue';
|
||||||
|
import NumberSetting from './Number.vue';
|
||||||
|
import RadioSetting from './Radio.vue';
|
||||||
import StringSetting from './String.vue';
|
import StringSetting from './String.vue';
|
||||||
import FileSetting from './File.vue';
|
import FileSetting from './File.vue';
|
||||||
|
|
||||||
|
@ -29,6 +35,9 @@
|
||||||
],
|
],
|
||||||
components: {
|
components: {
|
||||||
BoolSetting,
|
BoolSetting,
|
||||||
|
DropdownSetting,
|
||||||
|
NumberSetting,
|
||||||
|
RadioSetting,
|
||||||
StringSetting,
|
StringSetting,
|
||||||
FileSetting
|
FileSetting
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
/**
|
||||||
|
* BetterDiscord Plugin Setting Radio 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-setting-switch">
|
||||||
|
<div class="bd-title">
|
||||||
|
<h3>{{setting.text}}</h3>
|
||||||
|
<div class="bd-flex bd-flex-col">
|
||||||
|
<label class="bd-radio-option bd-flex" v-for="option in setting.options">
|
||||||
|
<input type="radio" :value="option.value" :name="setting.id" :checked="setting.value == option.value" @change="input">
|
||||||
|
<div class="bd-radio"></div>
|
||||||
|
<span>{{option.text}}</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="bd-hint">{{setting.hint}}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: ['setting', 'change'],
|
||||||
|
methods: {
|
||||||
|
input(e) {
|
||||||
|
this.change(this.setting.id, e.target.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -27,10 +27,38 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "default-2",
|
"id": "default-2",
|
||||||
"type": "bool",
|
"type": "dropdown",
|
||||||
"value": false,
|
"value": "opt1",
|
||||||
"text": "Bool Test Setting 3",
|
"text": "Dropdown Test Setting",
|
||||||
"hint": "Bool Test Setting Hint 3"
|
"hint": "Dropdown Test Setting Hint",
|
||||||
|
"options": [
|
||||||
|
{"value": "opt1", "text": "Option 1"},
|
||||||
|
{"value": "opt2", "text": "Option 2"},
|
||||||
|
{"value": "opt3", "text": "Option 3"},
|
||||||
|
{"value": "opt4", "text": "Option 4"},
|
||||||
|
{"value": "opt5", "text": "Option 5"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "default-5",
|
||||||
|
"type": "radio",
|
||||||
|
"value": "opt1",
|
||||||
|
"text": "Radio Test Setting",
|
||||||
|
"hint": "Radio Test Setting Hint",
|
||||||
|
"options": [
|
||||||
|
{"value": "opt1", "text": "Option 1"},
|
||||||
|
{"value": "opt2", "text": "Option 2"},
|
||||||
|
{"value": "opt3", "text": "Option 3"},
|
||||||
|
{"value": "opt4", "text": "Option 4"},
|
||||||
|
{"value": "opt5", "text": "Option 5"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "default-6",
|
||||||
|
"type": "number",
|
||||||
|
"value": 0,
|
||||||
|
"text": "Number Test Setting",
|
||||||
|
"hint": "Number Test Setting Hint"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "default-3",
|
"id": "default-3",
|
||||||
|
|
Loading…
Reference in New Issue