diff options
author | Christopher Ng <chrng8@gmail.com> | 2022-10-19 02:07:12 +0000 |
---|---|---|
committer | Christopher Ng <chrng8@gmail.com> | 2022-10-19 19:12:56 +0000 |
commit | 58abed20599d85eb71f70edef77a7b7aaec043bc (patch) | |
tree | 6da880d6287ced11d0fc7511d90c7d48e9523e87 /apps | |
parent | be892d2e283a0a939434650a0c9933308a2cc6bb (diff) | |
download | nextcloud-server-58abed20599d85eb71f70edef77a7b7aaec043bc.tar.gz nextcloud-server-58abed20599d85eb71f70edef77a7b7aaec043bc.zip |
Invert header icons on bright preset backgrounds
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dashboard/src/DashboardApp.vue | 22 | ||||
-rw-r--r-- | apps/theming/css/default.css | 1 | ||||
-rw-r--r-- | apps/theming/lib/Themes/CommonThemeTrait.php | 5 | ||||
-rw-r--r-- | apps/theming/lib/Themes/DefaultTheme.php | 1 | ||||
-rw-r--r-- | apps/theming/src/UserThemes.vue | 28 |
5 files changed, 12 insertions, 45 deletions
diff --git a/apps/dashboard/src/DashboardApp.vue b/apps/dashboard/src/DashboardApp.vue index 4323d8e1192..8a823c48a1b 100644 --- a/apps/dashboard/src/DashboardApp.vue +++ b/apps/dashboard/src/DashboardApp.vue @@ -103,10 +103,6 @@ import isMobile from './mixins/isMobile.js' const panels = loadState('dashboard', 'panels') const firstRun = loadState('dashboard', 'firstRun') -const background = loadState('theming', 'background') -const themingDefaultBackground = loadState('theming', 'themingDefaultBackground') -const shippedBackgroundList = loadState('theming', 'shippedBackgrounds') - const statusInfo = { weather: { text: t('dashboard', 'Weather'), @@ -148,8 +144,6 @@ export default { modal: false, appStoreUrl: generateUrl('/settings/apps/dashboard'), statuses: {}, - background, - themingDefaultBackground, } }, computed: { @@ -240,7 +234,6 @@ export default { }, mounted() { - this.updateGlobalStyles() this.updateSkipLink() window.addEventListener('scroll', this.handleScroll) @@ -257,21 +250,6 @@ export default { }, methods: { - updateGlobalStyles() { - // Override primary-invert-if-bright and color-primary-text if background is set - const isBackgroundBright = shippedBackgroundList[this.background]?.theming === 'dark' - if (isBackgroundBright) { - document.querySelector('#header').style.setProperty('--primary-invert-if-bright', 'invert(100%)') - document.querySelector('#header').style.setProperty('--color-primary-text', '#000000') - // document.body.removeAttribute('data-theme-dark') - // document.body.setAttribute('data-theme-light', 'true') - } else { - document.querySelector('#header').style.setProperty('--primary-invert-if-bright', 'no') - document.querySelector('#header').style.setProperty('--color-primary-text', '#ffffff') - // document.body.removeAttribute('data-theme-light') - // document.body.setAttribute('data-theme-dark', 'true') - } - }, /** * Method to register panels that will be called by the integrating apps * diff --git a/apps/theming/css/default.css b/apps/theming/css/default.css index 666d2781ee2..3bc1fd974cc 100644 --- a/apps/theming/css/default.css +++ b/apps/theming/css/default.css @@ -53,6 +53,7 @@ --breakpoint-mobile: 1024px; --background-invert-if-dark: no; --background-invert-if-bright: invert(100%); + --background-image-invert-if-bright: no; --image-background: url('/core/img/app-background.jpg'); --color-background-plain: #0082c9; --primary-invert-if-bright: no; diff --git a/apps/theming/lib/Themes/CommonThemeTrait.php b/apps/theming/lib/Themes/CommonThemeTrait.php index 8802933d24d..c203b35ed44 100644 --- a/apps/theming/lib/Themes/CommonThemeTrait.php +++ b/apps/theming/lib/Themes/CommonThemeTrait.php @@ -133,15 +133,16 @@ trait CommonThemeTrait { // TODO: implement primary color from custom background --color-background-plain ]; } - + // The user picked a shipped background if (isset(BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground])) { return [ '--image-background' => "url('" . $this->urlGenerator->linkTo(Application::APP_ID, "/img/background/$themingBackground") . "')", '--color-background-plain' => $this->themingDefaults->getColorPrimary(), + '--background-image-invert-if-bright' => BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['theming'] ?? null === BackgroundService::THEMING_MODE_DARK ? 'invert(100%)' : 'no', ]; } - + // The user picked a static colour if (substr($themingBackground, 0, 1) === '#') { return [ diff --git a/apps/theming/lib/Themes/DefaultTheme.php b/apps/theming/lib/Themes/DefaultTheme.php index 11d65de9a80..bb24bb4566b 100644 --- a/apps/theming/lib/Themes/DefaultTheme.php +++ b/apps/theming/lib/Themes/DefaultTheme.php @@ -189,6 +189,7 @@ class DefaultTheme implements ITheme { '--breakpoint-mobile' => '1024px', '--background-invert-if-dark' => 'no', '--background-invert-if-bright' => 'invert(100%)', + '--background-image-invert-if-bright' => 'no', // Default last fallback values '--image-background' => "url('" . $this->urlGenerator->imagePath('core', 'app-background.jpg') . "')", diff --git a/apps/theming/src/UserThemes.vue b/apps/theming/src/UserThemes.vue index 4c92e75199d..5a41c019017 100644 --- a/apps/theming/src/UserThemes.vue +++ b/apps/theming/src/UserThemes.vue @@ -94,13 +94,13 @@ const shortcutsDisabled = loadState('theming', 'shortcutsDisabled', false) const background = loadState('theming', 'background') const themingDefaultBackground = loadState('theming', 'themingDefaultBackground') -const shippedBackgroundList = loadState('theming', 'shippedBackgrounds') const isUserThemingDisabled = loadState('theming', 'isUserThemingDisabled') console.debug('Available themes', availableThemes) export default { name: 'UserThemes', + components: { ItemPreview, NcCheckboxRadioSwitch, @@ -123,6 +123,7 @@ export default { themes() { return this.availableThemes.filter(theme => theme.type === 1) }, + fonts() { return this.availableThemes.filter(theme => theme.type === 2) }, @@ -141,9 +142,11 @@ export default { .replace('{guidelines}', this.guidelinesLink) .replace('{linkend}', '</a>') }, + guidelinesLink() { return '<a target="_blank" href="https://www.w3.org/WAI/standards-guidelines/wcag/" rel="noreferrer nofollow">' }, + descriptionDetail() { return t( 'theming', @@ -153,9 +156,11 @@ export default { .replace('{designteam}', this.designteamLink) .replace(/\{linkend\}/g, '</a>') }, + issuetrackerLink() { return '<a target="_blank" href="https://github.com/nextcloud/server/issues/" rel="noreferrer nofollow">' }, + designteamLink() { return '<a target="_blank" href="https://nextcloud.com/design" rel="noreferrer nofollow">' }, @@ -167,32 +172,12 @@ export default { }, }, - mounted() { - this.updateGlobalStyles() - }, - methods: { updateBackground(data) { this.background = (data.type === 'custom' || data.type === 'default') ? data.type : data.value - this.updateGlobalStyles() this.$emit('update:background') }, - updateGlobalStyles() { - // Override primary-invert-if-bright and color-primary-text if background is set - const isBackgroundBright = shippedBackgroundList[this.background]?.theming === 'dark' - if (isBackgroundBright) { - document.querySelector('#header').style.setProperty('--primary-invert-if-bright', 'invert(100%)') - document.querySelector('#header').style.setProperty('--color-primary-text', '#000000') - // document.body.removeAttribute('data-theme-dark') - // document.body.setAttribute('data-theme-light', 'true') - } else { - document.querySelector('#header').style.setProperty('--primary-invert-if-bright', 'no') - document.querySelector('#header').style.setProperty('--color-primary-text', '#ffffff') - // document.body.removeAttribute('data-theme-light') - // document.body.setAttribute('data-theme-dark', 'true') - } - }, changeTheme({ enabled, id }) { // Reset selected and select new one this.themes.forEach(theme => { @@ -206,6 +191,7 @@ export default { this.updateBodyAttributes() this.selectItem(enabled, id) }, + changeFont({ enabled, id }) { // Reset selected and select new one this.fonts.forEach(font => { |