From e99534ef717881d71a6fa975bb5e81fad6399b15 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Fri, 31 Aug 2018 04:06:00 +0300 Subject: [PATCH] added option for logo in navbar to follow color scheme of the rest of the site also fixed potential mess-up between api/static configs --- src/App.js | 31 +++++++++++++++++++++++++++++-- src/App.scss | 33 ++++++++++++++++++++++++++++++--- src/App.vue | 6 +++++- src/main.js | 30 ++++++++++++++++++------------ static/config.json | 2 ++ 5 files changed, 84 insertions(+), 18 deletions(-) diff --git a/src/App.js b/src/App.js index a9a46fadbb..c455c18cfd 100644 --- a/src/App.js +++ b/src/App.js @@ -18,7 +18,14 @@ export default { ChatPanel }, data: () => ({ - mobileActivePanel: 'timeline' + mobileActivePanel: 'timeline', + supportsMask: window.CSS && window.CSS.supports && ( + window.CSS.supports('mask-size', 'contain') || + window.CSS.supports('-webkit-mask-size', 'contain') || + window.CSS.supports('-moz-mask-size', 'contain') || + window.CSS.supports('-ms-mask-size', 'contain') || + window.CSS.supports('-o-mask-size', 'contain') + ) }), created () { // Load the locale from the storage @@ -29,7 +36,27 @@ export default { background () { return this.currentUser.background_image || this.$store.state.config.background }, - logoStyle () { return { 'background-image': `url(${this.$store.state.config.logo})` } }, + enableMask () { return this.supportsMask && this.$store.state.config.logoMask }, + logoStyle () { + return { + 'visibility': this.enableMask ? 'hidden' : 'visible' + } + }, + logoMaskStyle () { + return this.enableMask ? { + 'mask-image': `url(${this.$store.state.config.logo})` + } : { + 'background-color': this.enableMask ? '' : 'transparent' + } + }, + logoBgStyle () { + return Object.assign({ + 'margin': `${this.$store.state.config.logoMargin} 0` + }, this.enableMask ? {} : { + 'background-color': this.enableMask ? '' : 'transparent' + }) + }, + logo () { return this.$store.state.config.logo }, style () { return { 'background-image': `url(${this.background})` } }, sitename () { return this.$store.state.config.name }, chat () { return this.$store.state.chat.channel.state === 'joined' }, diff --git a/src/App.scss b/src/App.scss index 21279f15a7..09014c15b3 100644 --- a/src/App.scss +++ b/src/App.scss @@ -236,6 +236,36 @@ nav { position: fixed; height: 50px; + .logo { + display: flex; + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + + align-items: stretch; + justify-content: center; + flex: 0 0 auto; + z-index: -1; + .mask { + mask-repeat: no-repeat; + mask-position: center; + mask-size: contain; + background-color: $fallback--fg; + background-color: var(--fg, $fallback--fg); + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + } + img { + display: block; + flex: 0; + } + } + .inner-nav { padding-left: 20px; padding-right: 20px; @@ -244,9 +274,6 @@ nav { flex-basis: 970px; margin: auto; height: 50px; - background-repeat: no-repeat; - background-position: center; - background-size: auto 80%; a i { color: $fallback--link; diff --git a/src/App.vue b/src/App.vue index 71e9028919..fc446c57ab 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,7 +1,11 @@