Skip to content

Commit 1ab59a0

Browse files
Pytalnextcloud-command
authored andcommitted
Invert header icons on bright preset backgrounds
Signed-off-by: Christopher Ng <chrng8@gmail.com> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
1 parent 372db92 commit 1ab59a0

16 files changed

+28
-59
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/lib/Themes/DefaultTheme.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ public function getCSSVariables(): array {
201201
'--primary-invert-if-bright' => $this->util->invertTextColor($this->primaryColor) ? 'invert(100%)' : 'no',
202202
'--background-invert-if-dark' => 'no',
203203
'--background-invert-if-bright' => 'invert(100%)',
204+
'--background-image-invert-if-bright' => 'no',
204205

205206
'--image-main-background' => "url('" . $this->urlGenerator->imagePath('core', 'app-background.jpg') . "')",
206207
];

apps/theming/src/UserThemes.vue

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ console.debug('Available themes', availableThemes)
9595
9696
export default {
9797
name: 'UserThemes',
98+
9899
components: {
99100
ItemPreview,
100101
NcCheckboxRadioSwitch,
@@ -116,6 +117,7 @@ export default {
116117
themes() {
117118
return this.availableThemes.filter(theme => theme.type === 1)
118119
},
120+
119121
fonts() {
120122
return this.availableThemes.filter(theme => theme.type === 2)
121123
},
@@ -134,9 +136,11 @@ export default {
134136
.replace('{guidelines}', this.guidelinesLink)
135137
.replace('{linkend}', '</a>')
136138
},
139+
137140
guidelinesLink() {
138141
return '<a target="_blank" href="https://www.w3.org/WAI/standards-guidelines/wcag/" rel="noreferrer nofollow">'
139142
},
143+
140144
descriptionDetail() {
141145
return t(
142146
'theming',
@@ -146,9 +150,11 @@ export default {
146150
.replace('{designteam}', this.designteamLink)
147151
.replace(/\{linkend\}/g, '</a>')
148152
},
153+
149154
issuetrackerLink() {
150155
return '<a target="_blank" href="https://github.com/nextcloud/server/issues/" rel="noreferrer nofollow">'
151156
},
157+
152158
designteamLink() {
153159
return '<a target="_blank" href="https://nextcloud.com/design" rel="noreferrer nofollow">'
154160
},
@@ -160,32 +166,12 @@ export default {
160166
},
161167
},
162168
163-
mounted() {
164-
this.updateGlobalStyles()
165-
},
166-
167169
methods: {
168170
updateBackground(data) {
169171
this.background = (data.type === 'custom' || data.type === 'default') ? data.type : data.value
170-
this.updateGlobalStyles()
171172
this.$emit('update:background')
172173
},
173174
174-
updateGlobalStyles() {
175-
// Override primary-invert-if-bright and color-primary-text if background is set
176-
const isBackgroundBright = shippedBackgroundList[this.background]?.theming === 'dark'
177-
if (isBackgroundBright) {
178-
document.querySelector('#header').style.setProperty('--primary-invert-if-bright', 'invert(100%)')
179-
document.querySelector('#header').style.setProperty('--color-primary-text', '#000000')
180-
// document.body.removeAttribute('data-theme-dark')
181-
// document.body.setAttribute('data-theme-light', 'true')
182-
} else {
183-
document.querySelector('#header').style.setProperty('--primary-invert-if-bright', 'no')
184-
document.querySelector('#header').style.setProperty('--color-primary-text', '#ffffff')
185-
// document.body.removeAttribute('data-theme-light')
186-
// document.body.setAttribute('data-theme-dark', 'true')
187-
}
188-
},
189175
changeTheme({ enabled, id }) {
190176
// Reset selected and select new one
191177
this.themes.forEach(theme => {
@@ -199,6 +185,7 @@ export default {
199185
this.updateBodyAttributes()
200186
this.selectItem(enabled, id)
201187
},
188+
202189
changeFont({ enabled, id }) {
203190
// Reset selected and select new one
204191
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

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.

dist/core-main.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.

0 commit comments

Comments
 (0)