From fae6fc8511732ce1b6057510728122ac870e195b Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Mon, 19 Feb 2018 18:19:52 +0000 Subject: [PATCH] Add settings arrays --- .../styles/partials/generic/forms/arrays.scss | 77 +++++++++++ .../styles/partials/generic/forms/index.scss | 1 + .../styles/partials/generic/forms/main.scss | 3 +- client/src/ui/components/bd/setting/Array.vue | 129 ++++++++++++++++++ .../src/ui/components/bd/setting/Setting.vue | 5 +- tests/plugins/Example/config.json | 71 ++++++++++ tests/themes/Example/config.json | 19 +++ 7 files changed, 303 insertions(+), 2 deletions(-) create mode 100644 client/src/styles/partials/generic/forms/arrays.scss create mode 100644 client/src/ui/components/bd/setting/Array.vue diff --git a/client/src/styles/partials/generic/forms/arrays.scss b/client/src/styles/partials/generic/forms/arrays.scss new file mode 100644 index 00000000..873a93e0 --- /dev/null +++ b/client/src/styles/partials/generic/forms/arrays.scss @@ -0,0 +1,77 @@ +.bd-form-settingsarray { + .bd-button.bd-button-primary { + padding: 3px 8px; + border-radius: 3px; + font-size: 12px; + font-weight: 400; + } + + .bd-settingsarray-items { + margin-top: 15px; + + .bd-settingsarray-item { + display: flex; + margin-top: 10px; + + .bd-settingsarray-item-marker { + flex: 0 0 auto; + min-width: 15px; + margin-right: 5px; + color: #aaa; + font-size: 15px; + } + + .bd-settingsarray-item-contents { + flex: 1 1; + } + + .bd-settings-panel { + .bd-settings-categories:last-child .bd-form-item:last-child .bd-form-divider { + margin-bottom: 0; + } + + + .bd-settingsarray-item-controls { + flex-basis: 0%; + } + } + + .bd-settingsarray-item-hint { + color: #aaa; + font-size: 15px; + font-style: italic; + word-wrap: break-word; + + max-width: 385px; + } + + .bd-settingsarray-item-controls { + flex: 0 0 auto; + margin-left: 5px; + } + + .bd-settingsarray-open, + .bd-settingsarray-remove { + margin-left: 5px; + + svg { + width: 16px; + height: 16px; + cursor: pointer; + fill: #ccc; + + &:hover { + fill: #fff; + } + } + } + + &:last-child .bd-settings-categories:last-child .bd-form-item:last-child .bd-form-divider { + display: none; + } + } + } + + &.bd-form-settingsarray-inline .bd-settingsarray-item { + margin-top: 10px; + } +} diff --git a/client/src/styles/partials/generic/forms/index.scss b/client/src/styles/partials/generic/forms/index.scss index f1667cbe..92671d26 100644 --- a/client/src/styles/partials/generic/forms/index.scss +++ b/client/src/styles/partials/generic/forms/index.scss @@ -5,3 +5,4 @@ @import './radios.scss'; @import './sliders.scss'; @import './switches.scss'; +@import './arrays.scss'; diff --git a/client/src/styles/partials/generic/forms/main.scss b/client/src/styles/partials/generic/forms/main.scss index 58e87a04..efb9bc1a 100644 --- a/client/src/styles/partials/generic/forms/main.scss +++ b/client/src/styles/partials/generic/forms/main.scss @@ -5,7 +5,8 @@ .bd-form-radio, .bd-form-numberinput, .bd-form-slider, -.bd-setting-switch { +.bd-setting-switch, +.bd-form-settingsarray { .bd-title { display: flex; diff --git a/client/src/ui/components/bd/setting/Array.vue b/client/src/ui/components/bd/setting/Array.vue new file mode 100644 index 00000000..8228b2bf --- /dev/null +++ b/client/src/ui/components/bd/setting/Array.vue @@ -0,0 +1,129 @@ +/** + * BetterDiscord Setting File 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. +*/ + + + + diff --git a/client/src/ui/components/bd/setting/Setting.vue b/client/src/ui/components/bd/setting/Setting.vue index 9a2d320e..d7c61870 100644 --- a/client/src/ui/components/bd/setting/Setting.vue +++ b/client/src/ui/components/bd/setting/Setting.vue @@ -18,6 +18,7 @@ +
@@ -31,6 +32,7 @@ import MultilineTextSetting from './Multiline.vue'; import SliderSetting from './Slider.vue'; import FileSetting from './File.vue'; + import ArraySetting from './Array.vue'; export default { props: [ @@ -45,7 +47,8 @@ StringSetting, MultilineTextSetting, SliderSetting, - FileSetting + FileSetting, + ArraySetting }, computed: { changed() { diff --git a/tests/plugins/Example/config.json b/tests/plugins/Example/config.json index f6f03a82..25ca74e5 100644 --- a/tests/plugins/Example/config.json +++ b/tests/plugins/Example/config.json @@ -17,6 +17,77 @@ "category_default_comment": "default category has no header and is always displayed first", "category": "default", "settings": [ + { + "id": "array-1", + "type": "array", + "value": null, + "text": "Test settings array", + "hint": "Just a test. Inline should be left as false here in most cases. (Only set it to true if there's only one setting otherwise it takes up too much space. Or you could put it in a drawer.)", + "inline": false, + "min": 1, + "max": 5, + "settings": [ + { + "category_default_comment": "default category has no header and is always displayed first", + "category": "default", + "settings": [ + { + "id": "default-0", + "type": "bool", + "value": false, + "text": "Bool Test Setting 3", + "hint": "Bool Test Setting Hint 3" + }, + { + "id": "default-1", + "type": "text", + "value": "defaultValue", + "text": "Text Test Setting", + "hint": "Text Test Setting Hint" + } + ] + } + ], + "schemes": [ + { + "id": "scheme-1", + "name": "Test scheme", + "hint": "Can even use schemes here.", + "icon_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/0/0c/Cow_female_black_white.jpg/220px-Cow_female_black_white.jpg", + "settings": [ + { + "category": "default", + "settings": [ + { + "id": "default-0", + "value": true + } + ] + } + ] + }, + { + "id": "scheme-2", + "name": "Another test scheme", + "icon_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/0/0c/Cow_female_black_white.jpg/220px-Cow_female_black_white.jpg", + "settings": [ + { + "category": "default", + "settings": [ + { + "id": "default-0", + "value": false + }, + { + "id": "default-1", + "value": "https://upload.wikimedia.org/wikipedia/commons/thumb/0/0c/Cow_female_black_white.jpg/220px-Cow_female_black_white.jpg" + } + ] + } + ] + } + ] + }, { "id": "default-0", "type": "bool", diff --git a/tests/themes/Example/config.json b/tests/themes/Example/config.json index 7efd72ba..ac14927e 100644 --- a/tests/themes/Example/config.json +++ b/tests/themes/Example/config.json @@ -20,6 +20,25 @@ "hint": "A colour setting type would be nice here", "scss_raw": true }, + { + "id": "additional-colours", + "type": "array", + "text": "Additional colours", + "inline": true, + "settings": [ + { + "category": "default", + "settings": [ + { + "id": "colour", + "type": "text", + "value": "#ff0000", + "scss_raw": true + } + ] + } + ] + }, { "id": "spanOpacity", "type": "slider",