summaryrefslogtreecommitdiffstats
path: root/apps/theming/src
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2022-10-13 12:10:56 +0200
committernextcloud-command <nextcloud-command@users.noreply.github.com>2022-10-13 14:31:20 +0000
commit2f8601a27edc1d63b2607539982e8959533f0f40 (patch)
treee7029d712d1167f608b16883030d363a9156f847 /apps/theming/src
parent9a92fe9b29fb0db0486cebdc869627e0ac3bd4ea (diff)
downloadnextcloud-server-2f8601a27edc1d63b2607539982e8959533f0f40.tar.gz
nextcloud-server-2f8601a27edc1d63b2607539982e8959533f0f40.zip
Adjust testing
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
Diffstat (limited to 'apps/theming/src')
-rw-r--r--apps/theming/src/components/BackgroundSettings.vue29
1 files changed, 23 insertions, 6 deletions
diff --git a/apps/theming/src/components/BackgroundSettings.vue b/apps/theming/src/components/BackgroundSettings.vue
index 1c0b68ac9a9..6d2fcecbd3b 100644
--- a/apps/theming/src/components/BackgroundSettings.vue
+++ b/apps/theming/src/components/BackgroundSettings.vue
@@ -132,18 +132,30 @@ export default {
},
methods: {
+ /**
+ * Do we need to invert the text if color is too bright?
+ *
+ * @param {string} color the hex color
+ */
invertTextColor(color) {
- const l = this.calculateLuma(color)
- if (l > 0.6) {
- return true
- } else {
- return false
- }
+ return this.calculateLuma(color) > 0.6
},
+
+ /**
+ * Calculate luminance of provided hex color
+ *
+ * @param {string} color the hex color
+ */
calculateLuma(color) {
const [red, green, blue] = this.hexToRGB(color)
return (0.2126 * red + 0.7152 * green + 0.0722 * blue) / 255
},
+
+ /**
+ * Convert hex color to RGB
+ *
+ * @param {string} hex the hex color
+ */
hexToRGB(hex) {
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)
return result
@@ -166,21 +178,25 @@ export default {
}
image.src = this.backgroundImage
},
+
async setDefault() {
this.loading = 'default'
const result = await axios.post(generateUrl('/apps/theming/background/default'))
this.update(result.data)
},
+
async setShipped(shipped) {
this.loading = shipped
const result = await axios.post(generateUrl('/apps/theming/background/shipped'), { value: shipped })
this.update(result.data)
},
+
async setFile(path) {
this.loading = 'custom'
const result = await axios.post(generateUrl('/apps/theming/background/custom'), { value: path })
this.update(result.data)
},
+
debouncePickColor: debounce(function() {
this.pickColor(...arguments)
}, 200),
@@ -190,6 +206,7 @@ export default {
const result = await axios.post(generateUrl('/apps/theming/background/color'), { value: color })
this.update(result.data)
},
+
pickFile() {
window.OC.dialogs.filepicker(t('theming', 'Insert from {productName}', { productName: OC.theme.name }), (path, type) => {
if (type === OC.dialogs.FILEPICKER_TYPE_CHOOSE) {