Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable25] Invert header icons on bright preset backgrounds #34686

Merged
merged 1 commit into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions apps/dashboard/src/DashboardApp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -148,8 +144,6 @@ export default {
modal: false,
appStoreUrl: generateUrl('/settings/apps/dashboard'),
statuses: {},
background,
themingDefaultBackground,
}
},
computed: {
Expand Down Expand Up @@ -240,7 +234,6 @@ export default {
},

mounted() {
this.updateGlobalStyles()
this.updateSkipLink()
window.addEventListener('scroll', this.handleScroll)

Expand All @@ -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
*
Expand Down
1 change: 1 addition & 0 deletions apps/theming/css/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions apps/theming/lib/Themes/CommonThemeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,16 @@ protected function generateUserBackgroundVariables(): array {
// 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 [
Expand Down
1 change: 1 addition & 0 deletions apps/theming/lib/Themes/DefaultTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public function getCSSVariables(): array {
'--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') . "')",
Expand Down
28 changes: 7 additions & 21 deletions apps/theming/src/UserThemes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -123,6 +123,7 @@ export default {
themes() {
return this.availableThemes.filter(theme => theme.type === 1)
},

fonts() {
return this.availableThemes.filter(theme => theme.type === 2)
},
Expand All @@ -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',
Expand All @@ -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">'
},
Expand All @@ -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 => {
Expand All @@ -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 => {
Expand Down
2 changes: 1 addition & 1 deletion core/css/server.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/css/styles.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/css/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ span.ui-icon {
content: ' ';
// Force white
background-image: var(--original-icon-contacts-white);
filter: var(--primary-invert-if-bright);
filter: var(--background-image-invert-if-bright);
}

&:hover,
Expand Down
3 changes: 1 addition & 2 deletions core/src/components/AppMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ $header-icon-size: 20px;
position: relative;
display: flex;
opacity: .7;
filter: var(--background-image-invert-if-bright);

&.app-menu-entry__active {
opacity: 1;
Expand Down Expand Up @@ -183,7 +184,6 @@ $header-icon-size: 20px;
width: $header-icon-size;
height: $header-icon-size;
padding: calc((100% - $header-icon-size) / 2);
filter: var(--primary-invert-if-bright);
}

.app-menu-entry--label {
Expand Down Expand Up @@ -269,7 +269,6 @@ $header-icon-size: 20px;
}

img {
filter: var(--background-invert-if-bright);
width: $header-icon-size;
height: $header-icon-size;
padding: calc((50px - $header-icon-size) / 2);
Expand Down
4 changes: 4 additions & 0 deletions core/src/views/UnifiedSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,10 @@ $input-height: 34px;
$input-padding: 6px;

.unified-search {
&__trigger {
filter: var(--background-image-invert-if-bright);
}

&__input-wrapper {
position: sticky;
// above search results
Expand Down
4 changes: 2 additions & 2 deletions dist/core-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-unified-search.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-unified-search.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/dashboard-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dashboard-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/theming-theming-settings.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/theming-theming-settings.js.map

Large diffs are not rendered by default.