Skip to content

Commit 58abed2

Browse files
committed
Invert header icons on bright preset backgrounds
Signed-off-by: Christopher Ng <chrng8@gmail.com>
1 parent be892d2 commit 58abed2

18 files changed

+32
-62
lines changed

apps/dashboard/src/DashboardApp.vue

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ import isMobile from './mixins/isMobile.js'
103103
const panels = loadState('dashboard', 'panels')
104104
const firstRun = loadState('dashboard', 'firstRun')
105105
106-
const background = loadState('theming', 'background')
107-
const themingDefaultBackground = loadState('theming', 'themingDefaultBackground')
108-
const shippedBackgroundList = loadState('theming', 'shippedBackgrounds')
109-
110106
const statusInfo = {
111107
weather: {
112108
text: t('dashboard', 'Weather'),
@@ -148,8 +144,6 @@ export default {
148144
modal: false,
149145
appStoreUrl: generateUrl('/settings/apps/dashboard'),
150146
statuses: {},
151-
background,
152-
themingDefaultBackground,
153147
}
154148
},
155149
computed: {
@@ -240,7 +234,6 @@ export default {
240234
},
241235
242236
mounted() {
243-
this.updateGlobalStyles()
244237
this.updateSkipLink()
245238
window.addEventListener('scroll', this.handleScroll)
246239
@@ -257,21 +250,6 @@ export default {
257250
},
258251
259252
methods: {
260-
updateGlobalStyles() {
261-
// Override primary-invert-if-bright and color-primary-text if background is set
262-
const isBackgroundBright = shippedBackgroundList[this.background]?.theming === 'dark'
263-
if (isBackgroundBright) {
264-
document.querySelector('#header').style.setProperty('--primary-invert-if-bright', 'invert(100%)')
265-
document.querySelector('#header').style.setProperty('--color-primary-text', '#000000')
266-
// document.body.removeAttribute('data-theme-dark')
267-
// document.body.setAttribute('data-theme-light', 'true')
268-
} else {
269-
document.querySelector('#header').style.setProperty('--primary-invert-if-bright', 'no')
270-
document.querySelector('#header').style.setProperty('--color-primary-text', '#ffffff')
271-
// document.body.removeAttribute('data-theme-light')
272-
// document.body.setAttribute('data-theme-dark', 'true')
273-
}
274-
},
275253
/**
276254
* Method to register panels that will be called by the integrating apps
277255
*

apps/theming/css/default.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
--breakpoint-mobile: 1024px;
5454
--background-invert-if-dark: no;
5555
--background-invert-if-bright: invert(100%);
56+
--background-image-invert-if-bright: no;
5657
--image-background: url('/core/img/app-background.jpg');
5758
--color-background-plain: #0082c9;
5859
--primary-invert-if-bright: no;

apps/theming/lib/Themes/CommonThemeTrait.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,16 @@ protected function generateUserBackgroundVariables(): array {
133133
// TODO: implement primary color from custom background --color-background-plain
134134
];
135135
}
136-
136+
137137
// The user picked a shipped background
138138
if (isset(BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground])) {
139139
return [
140140
'--image-background' => "url('" . $this->urlGenerator->linkTo(Application::APP_ID, "/img/background/$themingBackground") . "')",
141141
'--color-background-plain' => $this->themingDefaults->getColorPrimary(),
142+
'--background-image-invert-if-bright' => BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['theming'] ?? null === BackgroundService::THEMING_MODE_DARK ? 'invert(100%)' : 'no',
142143
];
143144
}
144-
145+
145146
// The user picked a static colour
146147
if (substr($themingBackground, 0, 1) === '#') {
147148
return [

apps/theming/lib/Themes/DefaultTheme.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ public function getCSSVariables(): array {
189189
'--breakpoint-mobile' => '1024px',
190190
'--background-invert-if-dark' => 'no',
191191
'--background-invert-if-bright' => 'invert(100%)',
192+
'--background-image-invert-if-bright' => 'no',
192193

193194
// Default last fallback values
194195
'--image-background' => "url('" . $this->urlGenerator->imagePath('core', 'app-background.jpg') . "')",

apps/theming/src/UserThemes.vue

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ const shortcutsDisabled = loadState('theming', 'shortcutsDisabled', false)
9494
9595
const background = loadState('theming', 'background')
9696
const themingDefaultBackground = loadState('theming', 'themingDefaultBackground')
97-
const shippedBackgroundList = loadState('theming', 'shippedBackgrounds')
9897
const isUserThemingDisabled = loadState('theming', 'isUserThemingDisabled')
9998
10099
console.debug('Available themes', availableThemes)
101100
102101
export default {
103102
name: 'UserThemes',
103+
104104
components: {
105105
ItemPreview,
106106
NcCheckboxRadioSwitch,
@@ -123,6 +123,7 @@ export default {
123123
themes() {
124124
return this.availableThemes.filter(theme => theme.type === 1)
125125
},
126+
126127
fonts() {
127128
return this.availableThemes.filter(theme => theme.type === 2)
128129
},
@@ -141,9 +142,11 @@ export default {
141142
.replace('{guidelines}', this.guidelinesLink)
142143
.replace('{linkend}', '</a>')
143144
},
145+
144146
guidelinesLink() {
145147
return '<a target="_blank" href="https://www.w3.org/WAI/standards-guidelines/wcag/" rel="noreferrer nofollow">'
146148
},
149+
147150
descriptionDetail() {
148151
return t(
149152
'theming',
@@ -153,9 +156,11 @@ export default {
153156
.replace('{designteam}', this.designteamLink)
154157
.replace(/\{linkend\}/g, '</a>')
155158
},
159+
156160
issuetrackerLink() {
157161
return '<a target="_blank" href="https://github.com/nextcloud/server/issues/" rel="noreferrer nofollow">'
158162
},
163+
159164
designteamLink() {
160165
return '<a target="_blank" href="https://nextcloud.com/design" rel="noreferrer nofollow">'
161166
},
@@ -167,32 +172,12 @@ export default {
167172
},
168173
},
169174
170-
mounted() {
171-
this.updateGlobalStyles()
172-
},
173-
174175
methods: {
175176
updateBackground(data) {
176177
this.background = (data.type === 'custom' || data.type === 'default') ? data.type : data.value
177-
this.updateGlobalStyles()
178178
this.$emit('update:background')
179179
},
180180
181-
updateGlobalStyles() {
182-
// Override primary-invert-if-bright and color-primary-text if background is set
183-
const isBackgroundBright = shippedBackgroundList[this.background]?.theming === 'dark'
184-
if (isBackgroundBright) {
185-
document.querySelector('#header').style.setProperty('--primary-invert-if-bright', 'invert(100%)')
186-
document.querySelector('#header').style.setProperty('--color-primary-text', '#000000')
187-
// document.body.removeAttribute('data-theme-dark')
188-
// document.body.setAttribute('data-theme-light', 'true')
189-
} else {
190-
document.querySelector('#header').style.setProperty('--primary-invert-if-bright', 'no')
191-
document.querySelector('#header').style.setProperty('--color-primary-text', '#ffffff')
192-
// document.body.removeAttribute('data-theme-light')
193-
// document.body.setAttribute('data-theme-dark', 'true')
194-
}
195-
},
196181
changeTheme({ enabled, id }) {
197182
// Reset selected and select new one
198183
this.themes.forEach(theme => {
@@ -206,6 +191,7 @@ export default {
206191
this.updateBodyAttributes()
207192
this.selectItem(enabled, id)
208193
},
194+
209195
changeFont({ enabled, id }) {
210196
// Reset selected and select new one
211197
this.fonts.forEach(font => {

core/css/server.css

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

core/css/styles.css

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

core/css/styles.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ span.ui-icon {
907907
content: ' ';
908908
// Force white
909909
background-image: var(--original-icon-contacts-white);
910-
filter: var(--primary-invert-if-bright);
910+
filter: var(--background-image-invert-if-bright);
911911
}
912912

913913
&:hover,

core/src/components/AppMenu.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ $header-icon-size: 20px;
144144
position: relative;
145145
display: flex;
146146
opacity: .7;
147+
filter: var(--background-image-invert-if-bright);
147148
148149
&.app-menu-entry__active {
149150
opacity: 1;
@@ -183,7 +184,6 @@ $header-icon-size: 20px;
183184
width: $header-icon-size;
184185
height: $header-icon-size;
185186
padding: calc((100% - $header-icon-size) / 2);
186-
filter: var(--primary-invert-if-bright);
187187
}
188188
189189
.app-menu-entry--label {
@@ -269,7 +269,6 @@ $header-icon-size: 20px;
269269
}
270270
271271
img {
272-
filter: var(--background-invert-if-bright);
273272
width: $header-icon-size;
274273
height: $header-icon-size;
275274
padding: calc((50px - $header-icon-size) / 2);

core/src/views/UnifiedSearch.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,10 @@ $input-height: 34px;
718718
$input-padding: 6px;
719719
720720
.unified-search {
721+
&__trigger {
722+
filter: var(--background-image-invert-if-bright);
723+
}
724+
721725
&__input-wrapper {
722726
position: sticky;
723727
// above search results

0 commit comments

Comments
 (0)