Merge remote-tracking branch 'origin/backgroundimage' into all_ui_elements

This commit is contained in:
arcbtc
2024-12-20 01:56:18 +00:00
5 changed files with 151 additions and 27 deletions

View File

@@ -422,6 +422,22 @@
</q-btn> </q-btn>
</div> </div>
</div> </div>
<div class="row q-mb-md">
<div class="col-4">
<span v-text="$t('background_image')"></span>
</div>
<div class="col-8">
<q-input
v-model="backgroundImage"
:label="$t('background_image')"
@update:model-value="backgroundImageFunc"
>
<q-tooltip
><span v-text="$t('background_image')"></span
></q-tooltip>
</q-input>
</div>
</div>
<div class="row q-mb-md"> <div class="row q-mb-md">
<div class="col-4"> <div class="col-4">
<span v-text="$t('gradient_background')"></span> <span v-text="$t('gradient_background')"></span>

File diff suppressed because one or more lines are too long

View File

@@ -26,6 +26,7 @@ window.localisation.en = {
close_channel: 'Close Channel', close_channel: 'Close Channel',
close: 'Close', close: 'Close',
restart: 'Restart server', restart: 'Restart server',
background_image: 'Background Image',
save: 'Save', save: 'Save',
save_tooltip: 'Save your changes', save_tooltip: 'Save your changes',
credit_debit: 'Credit / Debit', credit_debit: 'Credit / Debit',

View File

@@ -12,7 +12,12 @@ window.app = Vue.createApp({
'confettiFireworks', 'confettiFireworks',
'confettiStars' 'confettiStars'
], ],
borderOptions: ['retro-border', 'hard-border', 'no-border'], borderOptions: [
'retro-border',
'hard-border',
'neon-border',
'no-border'
],
tab: 'user', tab: 'user',
credentialsData: { credentialsData: {
show: false, show: false,
@@ -40,28 +45,72 @@ window.app = Vue.createApp({
} }
}, },
applyGradient() { applyGradient() {
darkBgColor = this.$q.localStorage.getItem('lnbits.darkBgColor') this.$q.localStorage.set('lnbits.gradientBg', this.gradientChoice)
primaryColor = this.$q.localStorage.getItem('lnbits.primaryColor') if (this.$q.localStorage.getItem('lnbits.gradientBg')) {
if (this.gradientChoice) {
if (!this.$q.dark.isActive) { if (!this.$q.dark.isActive) {
this.toggleDarkMode() this.toggleDarkMode()
} }
this.setColors()
darkBgColor = this.$q.localStorage.getItem('lnbits.darkBgColor')
primaryColor = this.$q.localStorage.getItem('lnbits.primaryColor')
const gradientStyle = `linear-gradient(to bottom right, ${LNbits.utils.hexDarken(String(primaryColor), -70)}, #0a0a0a)` const gradientStyle = `linear-gradient(to bottom right, ${LNbits.utils.hexDarken(String(primaryColor), -70)}, #0a0a0a)`
document.body.style.setProperty( document.body.style.setProperty(
'background-image', 'background-image',
gradientStyle, gradientStyle,
'important' 'important'
) )
const gradientStyleCards = `background-color: ${LNbits.utils.hexAlpha(String(darkBgColor), 0.4)} !important` const gradientStyleCards = `background-color: ${LNbits.utils.hexAlpha(String(darkBgColor), 0.55)} !important`
const style = document.createElement('style') const style = document.createElement('style')
style.innerHTML = style.innerHTML = `
`body[data-theme="${this.$q.localStorage.getItem('lnbits.theme')}"] .q-card:not(.q-dialog .q-card, .lnbits__dialog-card, .q-dialog-plugin--dark), body.body${this.$q.dark.isActive ? '--dark' : ''} .q-header, body.body${this.$q.dark.isActive ? '--dark' : ''} .q-drawer { ${gradientStyleCards} }` + body[data-theme="${this.$q.localStorage.getItem('lnbits.theme')}"] .q-card:not(.q-dialog .q-card, .lnbits__dialog-card, .q-dialog-plugin--dark),
`body[data-theme="${this.$q.localStorage.getItem('lnbits.theme')}"].body--dark{background: ${LNbits.utils.hexDarken(String(primaryColor), -88)} !important; }` + body.body${this.$q.dark.isActive ? '--dark' : ''} .q-header,
`[data-theme="${this.$q.localStorage.getItem('lnbits.theme')}"] .q-card--dark{background: ${String(darkBgColor)} !important;} }` body.body${this.$q.dark.isActive ? '--dark' : ''} .q-drawer,
body.body${this.$q.dark.isActive ? '--dark' : ''} .q-tab-panels {
${gradientStyleCards}
}
body[data-theme="${this.$q.localStorage.getItem('lnbits.theme')}"].body--dark {
background: ${LNbits.utils.hexDarken(String(primaryColor), -88)} !important;
}
[data-theme="${this.$q.localStorage.getItem('lnbits.theme')}"] .q-card--dark {
background: ${String(darkBgColor)} !important;
}
`
document.head.appendChild(style)
}
},
applyBackgroundImage() {
if (this.backgroundImage) {
this.$q.localStorage.set('lnbits.backgroundImage', this.backgroundImage)
this.gradientChoice = true
this.applyGradient()
}
let bgImage = this.$q.localStorage.getItem('lnbits.backgroundImage')
if (bgImage) {
this.backgroundImage = bgImage
const style = document.createElement('style')
style.innerHTML = `
body[data-theme="${this.$q.localStorage.getItem('lnbits.theme')}"]::before {
content: '';
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: url(${bgImage});
background-size: cover;
filter: blur(8px);
z-index: -1;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
body[data-theme="${this.$q.localStorage.getItem('lnbits.theme')}"] .q-page-container {
backdrop-filter: none; /* Ensure the page content is not affected */
}`
document.head.appendChild(style) document.head.appendChild(style)
this.$q.localStorage.set('lnbits.gradientBg', true)
} else {
this.$q.localStorage.set('lnbits.gradientBg', false)
} }
}, },
applyBorder() { applyBorder() {
@@ -74,6 +123,9 @@ window.app = Vue.createApp({
if (borderStyle == 'hard-border') { if (borderStyle == 'hard-border') {
borderStyleCSS = `box-shadow: 0 0 0 1px rgba(0,0,0,.12), 0 0 0 1px #ffffff47; border: none;` borderStyleCSS = `box-shadow: 0 0 0 1px rgba(0,0,0,.12), 0 0 0 1px #ffffff47; border: none;`
} }
if (borderStyle == 'neon-border') {
borderStyleCSS = `border: 2px solid ${this.$q.localStorage.getItem('lnbits.primaryColor')}; box-shadow: none;`
}
if (borderStyle == 'no-border') { if (borderStyle == 'no-border') {
borderStyleCSS = `box-shadow: none; border: none;` borderStyleCSS = `box-shadow: none; border: none;`
} }
@@ -87,6 +139,8 @@ window.app = Vue.createApp({
toggleGradient() { toggleGradient() {
this.gradientChoice = !this.gradientChoice this.gradientChoice = !this.gradientChoice
this.applyGradient() this.applyGradient()
this.$q.localStorage.set('lnbits.backgroundImage', '')
this.applyBorder()
if (!this.gradientChoice) { if (!this.gradientChoice) {
window.location.reload() window.location.reload()
} }
@@ -95,13 +149,17 @@ window.app = Vue.createApp({
reactionChoiceFunc() { reactionChoiceFunc() {
this.$q.localStorage.set('lnbits.reactions', this.reactionChoice) this.$q.localStorage.set('lnbits.reactions', this.reactionChoice)
}, },
changeColor(newValue) { backgroundImageFunc() {
this.$q.localStorage.set('lnbits.backgroundImage', this.backgroundImage)
this.applyBackgroundImage()
},
changeColor: function (newValue) {
document.body.setAttribute('data-theme', newValue) document.body.setAttribute('data-theme', newValue)
this.$q.localStorage.set('lnbits.theme', newValue) this.$q.localStorage.set('lnbits.theme', newValue)
this.setColors() this.setColors()
if (this.$q.localStorage.getItem('lnbits.gradientBg')) { this.applyGradient()
this.applyGradient() this.applyBackgroundImage()
} this.applyBorder()
}, },
async updateAccount() { async updateAccount() {
try { try {
@@ -208,15 +266,12 @@ window.app = Vue.createApp({
} catch (e) { } catch (e) {
LNbits.utils.notifyApiError(e) LNbits.utils.notifyApiError(e)
} }
if (this.$q.localStorage.getItem('lnbits.gradientBg')) {
this.applyGradient()
}
if (this.$q.localStorage.getItem('lnbits.border')) {
this.applyBorder()
}
const hash = window.location.hash.replace('#', '') const hash = window.location.hash.replace('#', '')
if (hash) { if (hash) {
this.tab = hash this.tab = hash
} }
this.applyGradient()
this.applyBackgroundImage()
this.applyBorder()
} }
}) })

View File

@@ -456,6 +456,7 @@ window.windowMixin = {
walletFlip: true, walletFlip: true,
reactionChoice: 'confettiBothSides', reactionChoice: 'confettiBothSides',
borderChoice: '', borderChoice: '',
backgroundImage: '',
gradientChoice: gradientChoice:
this.$q.localStorage.getItem('lnbits.gradientBg') || false, this.$q.localStorage.getItem('lnbits.gradientBg') || false,
isUserAuthorized: false, isUserAuthorized: false,
@@ -499,12 +500,54 @@ window.windowMixin = {
gradientStyle, gradientStyle,
'important' 'important'
) )
const gradientStyleCards = `background-color: ${LNbits.utils.hexAlpha(String(darkBgColor), 0.4)} !important` const gradientStyleCards = `background-color: ${LNbits.utils.hexAlpha(String(darkBgColor), 0.55)} !important`
const style = document.createElement('style') const style = document.createElement('style')
style.innerHTML = style.innerHTML = `
`body[data-theme="${this.$q.localStorage.getItem('lnbits.theme')}"] .q-card:not(.q-dialog .q-card, .lnbits__dialog-card, .q-dialog-plugin--dark), body.body${this.$q.dark.isActive ? '--dark' : ''} .q-header, body.body${this.$q.dark.isActive ? '--dark' : ''} .q-drawer { ${gradientStyleCards} }` + body[data-theme="${this.$q.localStorage.getItem('lnbits.theme')}"] .q-card:not(.q-dialog .q-card, .lnbits__dialog-card, .q-dialog-plugin--dark),
`body[data-theme="${this.$q.localStorage.getItem('lnbits.theme')}"].body--dark{background: ${LNbits.utils.hexDarken(String(primaryColor), -88)} !important; }` + body.body${this.$q.dark.isActive ? '--dark' : ''} .q-header,
`[data-theme="${this.$q.localStorage.getItem('lnbits.theme')}"] .q-card--dark{background: ${String(darkBgColor)} !important;} }` body.body${this.$q.dark.isActive ? '--dark' : ''} .q-drawer,
body.body${this.$q.dark.isActive ? '--dark' : ''} .q-tab-panels {
${gradientStyleCards}
}
body[data-theme="${this.$q.localStorage.getItem('lnbits.theme')}"].body--dark {
background: ${LNbits.utils.hexDarken(String(primaryColor), -88)} !important;
}
[data-theme="${this.$q.localStorage.getItem('lnbits.theme')}"] .q-card--dark {
background: ${String(darkBgColor)} !important;
}
`
document.head.appendChild(style)
}
},
applyBackgroundImage() {
if (this.backgroundImage) {
this.$q.localStorage.set('lnbits.backgroundImage', this.backgroundImage)
}
let bgImage = this.$q.localStorage.getItem('lnbits.backgroundImage')
if (bgImage) {
const style = document.createElement('style')
style.innerHTML = `
body[data-theme="${this.$q.localStorage.getItem('lnbits.theme')}"]::before {
content: '';
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: url(${bgImage});
background-size: cover;
filter: blur(8px);
z-index: -1;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
body[data-theme="${this.$q.localStorage.getItem('lnbits.theme')}"] .q-page-container {
backdrop-filter: none; /* Ensure the page content is not affected */
}`
document.head.appendChild(style) document.head.appendChild(style)
} }
}, },
@@ -522,6 +565,9 @@ window.windowMixin = {
if (borderStyle == 'hard-border') { if (borderStyle == 'hard-border') {
borderStyleCSS = `box-shadow: 0 0 0 1px rgba(0,0,0,.12), 0 0 0 1px #ffffff47; border: none;` borderStyleCSS = `box-shadow: 0 0 0 1px rgba(0,0,0,.12), 0 0 0 1px #ffffff47; border: none;`
} }
if (borderStyle == 'neon-border') {
borderStyleCSS = `border: 2px solid ${this.$q.localStorage.getItem('lnbits.primaryColor')}; box-shadow: none;`
}
if (borderStyle == 'no-border') { if (borderStyle == 'no-border') {
borderStyleCSS = `box-shadow: none; border: none;` borderStyleCSS = `box-shadow: none; border: none;`
} }
@@ -698,6 +744,7 @@ window.windowMixin = {
this.applyGradient() this.applyGradient()
this.applyBorder() this.applyBorder()
this.applyBackgroundImage()
if (window.user) { if (window.user) {
this.g.user = Object.freeze(window.LNbits.map.user(window.user)) this.g.user = Object.freeze(window.LNbits.map.user(window.user))