From 245379740055dfc712ccf362775e243839e44d9d Mon Sep 17 00:00:00 2001 From: Jiiks Date: Sun, 11 Feb 2018 22:35:29 +0200 Subject: [PATCH 1/2] add slider theme setting --- client/src/modules/thememanager.js | 11 ++++++++--- tests/themes/Example/config.json | 12 ++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/client/src/modules/thememanager.js b/client/src/modules/thememanager.js index 94007f9f..cc032e7c 100644 --- a/client/src/modules/thememanager.js +++ b/client/src/modules/thememanager.js @@ -170,10 +170,15 @@ export default class ThemeManager extends ContentManager { let scss_value = null; let scss_line = null; - if (typeof setting.value == 'string') - scss_value = setting.scss_raw ? setting.value : '\'' + setting.value.replace(/\\/g, '\\\\').replace(/'/g, '\\\'') + '\''; - else if (typeof setting.value === 'boolean' || typeof setting.value === 'number') + if (typeof setting.value == 'string') { + scss_value = setting.scss_raw + ? setting.value + : '\'' + setting.value.replace(/\\/g, '\\\\').replace(/'/g, '\\\'') + '\''; + } else if (setting.type === 'slider') { + scss_value = setting.value * setting.multi || 1; + } else if (typeof setting.value === 'boolean' || typeof setting.value === 'number') { scss_value = setting.value.toString(); + } scss_name = setting.id.replace(/[^a-zA-Z0-9-]/g, '-').replace(/--/g, '-'); diff --git a/tests/themes/Example/config.json b/tests/themes/Example/config.json index fa3813d2..187a9bca 100644 --- a/tests/themes/Example/config.json +++ b/tests/themes/Example/config.json @@ -20,6 +20,18 @@ "hint": "A colour setting type would be nice here", "scss_raw": true }, + { + "id": "spanOpacity", + "type": "slider", + "value": 50, + "min": 0, + "max": 100, + "step": 1, + "unit": "%", + "multi": "0.01", + "text": "Span border opacity", + "hint": "test" + }, { "id": "default-0", "type": "text", From fad9a5336a7c2714771f41b74b17799240f78c4d Mon Sep 17 00:00:00 2001 From: Jiiks Date: Sun, 11 Feb 2018 22:41:38 +0200 Subject: [PATCH 2/2] add another test var --- tests/themes/Example/config.json | 11 +++++++++-- tests/themes/Example/index.scss | 6 +++++- tests/themes/Example/vars.scss | 3 ++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/themes/Example/config.json b/tests/themes/Example/config.json index 187a9bca..bd4fda91 100644 --- a/tests/themes/Example/config.json +++ b/tests/themes/Example/config.json @@ -26,11 +26,18 @@ "value": 50, "min": 0, "max": 100, - "step": 1, + "step": 1, "unit": "%", "multi": "0.01", "text": "Span border opacity", - "hint": "test" + "hint": "test" + }, + { + "id": "avatar", + "type": "text", + "value": "https://upload.wikimedia.org/wikipedia/commons/thumb/0/0c/Cow_female_black_white.jpg/220px-Cow_female_black_white.jpg", + "text": "Avatar replace", + "hint": "Replace all avatars" }, { "id": "default-0", diff --git a/tests/themes/Example/index.scss b/tests/themes/Example/index.scss index 97bebc4e..d4a781a5 100644 --- a/tests/themes/Example/index.scss +++ b/tests/themes/Example/index.scss @@ -6,4 +6,8 @@ div { span { border: 1px solid rgba(20, 20, 20, $spanOpacity); -} \ No newline at end of file +} + +.avatar-large { + background-image: url($avatar) !important; +} diff --git a/tests/themes/Example/vars.scss b/tests/themes/Example/vars.scss index 005a4714..472c3a65 100644 --- a/tests/themes/Example/vars.scss +++ b/tests/themes/Example/vars.scss @@ -1,2 +1,3 @@ $divBg: green !default; -$spanOpacity: 0.5 !default; \ No newline at end of file +$spanOpacity: 0.5 !default; +$avatar: "https://upload.wikimedia.org/wikipedia/commons/thumb/0/0c/Cow_female_black_white.jpg/220px-Cow_female_black_white.jpg" !default; \ No newline at end of file