Skip to content

Commit f85b30b

Browse files
committed
Adjust testing
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
1 parent 9a92fe9 commit f85b30b

27 files changed

+71
-56
lines changed

apps/theming/lib/ThemingDefaults.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,8 @@ public function getShortFooter() {
214214

215215
/**
216216
* Color that is used for the header as well as for mail headers
217-
*
218-
* @return string
219217
*/
220-
public function getColorPrimary() {
218+
public function getColorPrimary(): string {
221219
$user = $this->userSession->getUser();
222220

223221
// admin-defined primary color
@@ -227,20 +225,20 @@ public function getColorPrimary() {
227225
$themingBackground = '';
228226
if (!empty($user)) {
229227
$themingBackground = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'background', '');
230-
231-
// if the user-selected background is a background reference
232-
if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $themingBackground)) {
233-
if ($themingBackground === 'default') {
234-
return BackgroundService::DEFAULT_COLOR;
235-
} else if (isset(BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['primary_color'])) {
236-
return BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['primary_color'];
237-
}
228+
// If the user selected the default background
229+
if ($themingBackground === '') {
230+
return BackgroundService::DEFAULT_COLOR;
238231
}
239232

240233
// If the user selected a specific colour
241234
if (preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $themingBackground)) {
242235
return $themingBackground;
243236
}
237+
238+
// if the user-selected background is a background reference
239+
if (isset(BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['primary_color'])) {
240+
return BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['primary_color'];
241+
}
244242
}
245243

246244
// If the default color is not valid, return the default background one
@@ -254,10 +252,8 @@ public function getColorPrimary() {
254252

255253
/**
256254
* Return the default color primary
257-
*
258-
* @return string
259255
*/
260-
public function getDefaultColorPrimary() {
256+
public function getDefaultColorPrimary(): string {
261257
$color = $this->config->getAppValue(Application::APP_ID, 'color');
262258
if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $color)) {
263259
$color = '#0082c9';

apps/theming/src/components/BackgroundSettings.vue

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,30 @@ export default {
132132
},
133133
134134
methods: {
135+
/**
136+
* Do we need to invert the text if color is too bright?
137+
*
138+
* @param {string} color the hex color
139+
*/
135140
invertTextColor(color) {
136-
const l = this.calculateLuma(color)
137-
if (l > 0.6) {
138-
return true
139-
} else {
140-
return false
141-
}
141+
return this.calculateLuma(color) > 0.6
142142
},
143+
144+
/**
145+
* Calculate luminance of provided hex color
146+
*
147+
* @param {string} color the hex color
148+
*/
143149
calculateLuma(color) {
144150
const [red, green, blue] = this.hexToRGB(color)
145151
return (0.2126 * red + 0.7152 * green + 0.0722 * blue) / 255
146152
},
153+
154+
/**
155+
* Convert hex color to RGB
156+
*
157+
* @param {string} hex the hex color
158+
*/
147159
hexToRGB(hex) {
148160
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)
149161
return result
@@ -166,21 +178,25 @@ export default {
166178
}
167179
image.src = this.backgroundImage
168180
},
181+
169182
async setDefault() {
170183
this.loading = 'default'
171184
const result = await axios.post(generateUrl('/apps/theming/background/default'))
172185
this.update(result.data)
173186
},
187+
174188
async setShipped(shipped) {
175189
this.loading = shipped
176190
const result = await axios.post(generateUrl('/apps/theming/background/shipped'), { value: shipped })
177191
this.update(result.data)
178192
},
193+
179194
async setFile(path) {
180195
this.loading = 'custom'
181196
const result = await axios.post(generateUrl('/apps/theming/background/custom'), { value: path })
182197
this.update(result.data)
183198
},
199+
184200
debouncePickColor: debounce(function() {
185201
this.pickColor(...arguments)
186202
}, 200),
@@ -190,6 +206,7 @@ export default {
190206
const result = await axios.post(generateUrl('/apps/theming/background/color'), { value: color })
191207
this.update(result.data)
192208
},
209+
193210
pickFile() {
194211
window.OC.dialogs.filepicker(t('theming', 'Insert from {productName}', { productName: OC.theme.name }), (path, type) => {
195212
if (type === OC.dialogs.FILEPICKER_TYPE_CHOOSE) {

dist/comments-comments-app.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/comments-comments-app.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-common.js

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

dist/core-common.js.LICENSE.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@
380380

381381
/*! For license information please see NcCheckboxRadioSwitch.js.LICENSE.txt */
382382

383+
/*! For license information please see NcColorPicker.js.LICENSE.txt */
384+
383385
/*! For license information please see NcDatetimePicker.js.LICENSE.txt */
384386

385387
/*! For license information please see NcHighlight.js.LICENSE.txt */

dist/core-common.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-login.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-login.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)