Unverified Commit 57ce7ab1 authored by yann300's avatar yann300 Committed by GitHub

Merge pull request #2599 from ethereum/themeImgs

added filter invert to images
parents 56eecb30 934acf5c
var yo = require('yo-yo') var yo = require('yo-yo')
var $ = require('jquery') var $ = require('jquery')
const EventEmitter = require('events') const EventEmitter = require('events')
const globalRegistry = require('../../global/registry')
require('remix-tabs') require('remix-tabs')
...@@ -14,6 +15,11 @@ export class TabProxy { ...@@ -14,6 +15,11 @@ export class TabProxy {
this._view = {} this._view = {}
this._handlers = {} this._handlers = {}
globalRegistry.get('themeModule').api.events.on('themeChanged', (theme) => {
// update invert for all icons
this.updateImgStyles()
})
fileManager.events.on('fileRemoved', (name) => { fileManager.events.on('fileRemoved', (name) => {
this.removeTab(name) this.removeTab(name)
}) })
...@@ -77,6 +83,14 @@ export class TabProxy { ...@@ -77,6 +83,14 @@ export class TabProxy {
} }
}) })
} }
updateImgStyles () {
const images = this._view.filetabs.getElementsByClassName('image')
if (images.length !== 0) {
for (let element of images) {
globalRegistry.get('themeModule').api.fixInvert(element)
};
}
}
switchTab (tabName) { switchTab (tabName) {
if (this._handlers[tabName]) { if (this._handlers[tabName]) {
...@@ -129,6 +143,7 @@ export class TabProxy { ...@@ -129,6 +143,7 @@ export class TabProxy {
icon, icon,
tooltip: name tooltip: name
}) })
this.updateImgStyles()
this._handlers[name] = { switchTo, close } this._handlers[name] = { switchTo, close }
} }
......
...@@ -168,12 +168,8 @@ class CompileTab extends ViewPlugin { ...@@ -168,12 +168,8 @@ class CompileTab extends ViewPlugin {
} }
}) })
globalRegistry.get('themeModule').api.events.on('themeChanged', (theme) => { globalRegistry.get('themeModule').api.events.on('themeChanged', () => {
const invert = theme.quality === 'dark' ? 1 : 0 globalRegistry.get('themeModule').api.fixInvert(document.getElementById('swarmLogo'))
const img = document.getElementById('swarmLogo')
if (img) {
img.style.filter = `invert(${invert})`
}
}) })
// Run the compiler instead of trying to save the website // Run the compiler instead of trying to save the website
......
...@@ -68,7 +68,7 @@ module.exports = class SettingsTab extends ViewPlugin { ...@@ -68,7 +68,7 @@ module.exports = class SettingsTab extends ViewPlugin {
if (self._view.el) return self._view.el if (self._view.el) return self._view.el
// Gist settings // Gist settings
var gistAccessToken = yo`<input id="gistaccesstoken" type="password" class="form-control mb-2 ${css.inline}" placeholder="Token">` var gistAccessToken = yo`<input id="gistaccesstoken" type="password" class="border form-control mb-2 ${css.inline}" placeholder="Token">`
var token = this.config.get('settings/gist-access-token') var token = this.config.get('settings/gist-access-token')
if (token) gistAccessToken.value = token if (token) gistAccessToken.value = token
var gistAddToken = yo`<input class="${css.savegisttoken} btn btn-sm btn-primary" id="savegisttoken" onclick=${() => { this.config.set('settings/gist-access-token', gistAccessToken.value); tooltip('Access token saved') }} value="Save" type="button">` var gistAddToken = yo`<input class="${css.savegisttoken} btn btn-sm btn-primary" id="savegisttoken" onclick=${() => { this.config.set('settings/gist-access-token', gistAccessToken.value); tooltip('Access token saved') }} value="Save" type="button">`
......
...@@ -85,7 +85,7 @@ const css = csjs` ...@@ -85,7 +85,7 @@ const css = csjs`
} }
.inline { .inline {
display: inline; display: inline;
width: 50%; width: 40%;
} }
` `
......
...@@ -84,4 +84,15 @@ export class ThemeModule extends Plugin { ...@@ -84,4 +84,15 @@ export class ThemeModule extends Plugin {
this.emit('themeChanged', nextTheme) this.emit('themeChanged', nextTheme)
this.events.emit('themeChanged', nextTheme) this.events.emit('themeChanged', nextTheme)
} }
/**
* fixes the invertion for images since this should be adjusted when we switch between dark/light qualified themes
* @param {element} [image] - the dom element which invert should be fixed to increase visibility
*/
fixInvert (image) {
const invert = this.currentTheme().quality === 'dark' ? 1 : 0
if (image) {
image.style.filter = `invert(${invert})`
}
}
} }
...@@ -163,12 +163,8 @@ export class LandingPage extends ViewPlugin { ...@@ -163,12 +163,8 @@ export class LandingPage extends ViewPlugin {
this.verticalIcons.select('fileExplorers') this.verticalIcons.select('fileExplorers')
} }
globalRegistry.get('themeModule').api.events.on('themeChanged', (theme) => { globalRegistry.get('themeModule').api.events.on('themeChanged', () => {
const invert = theme.quality === 'dark' ? 1 : 0 globalRegistry.get('themeModule').api.fixInvert(document.getElementById('remixLogo'))
const img = document.getElementById('remixLogo')
if (img) {
img.style.filter = `invert(${invert})`
}
}) })
let switchToPreviousVersion = () => { let switchToPreviousVersion = () => {
......
...@@ -3,6 +3,7 @@ const yo = require('yo-yo') ...@@ -3,6 +3,7 @@ const yo = require('yo-yo')
const csjs = require('csjs-inject') const csjs = require('csjs-inject')
const addTooltip = require('./tooltip') const addTooltip = require('./tooltip')
const modalDialog = require('./modaldialog') const modalDialog = require('./modaldialog')
const globalRegistry = require('../../global/registry')
const css = csjs` const css = csjs`
.permission h4 { .permission h4 {
...@@ -140,37 +141,45 @@ export class PermissionHandler { ...@@ -140,37 +141,45 @@ export class PermissionHandler {
: delete this.permissions[to.name][from.name] : delete this.permissions[to.name][from.name]
} }
const rememberSwitch = remember const rememberSwitch = remember
? yo`<input type="checkbox" onchange="${switchMode}" checkbox class="custom-control-input" id="remember" data-id="permissionHandlerRememberChecked">` ? yo`<input type="checkbox" onchange="${switchMode}" checkbox class="form-check-input" id="remember" data-id="permissionHandlerRememberChecked">`
: yo`<input type="checkbox" onchange="${switchMode}" class="custom-control-input" id="remember" data-id="permissionHandlerRememberUnchecked">` : yo`<input type="checkbox" onchange="${switchMode}" class="form-check-input" id="remember" data-id="permissionHandlerRememberUnchecked">`
const message = remember const message = remember
? `"${fromName}" has changed and would like to access "${toName}"` ? `"${fromName}" has changed and would like to access "${toName}"`
: `"${fromName}" would like to access "${toName}"` : `"${fromName}" would like to access "${toName}"`
return yo` const imgFrom = yo`<img id="permissionModalImagesFrom" src="${from.icon}" />`
<section class="${css.permission}"> const imgTo = yo`<img id="permissionModalImagesTo" src="${to.icon}" />`
const pluginsImages = yo`
<article class="${css.images}"> <article class="${css.images}">
<img src="${from.icon}" /> ${imgFrom}
<i class="fas fa-arrow-right"></i> <i class="fas fa-arrow-right"></i>
<img src="${to.icon}" /> ${imgTo}
</article>
<article>
<h4 data-id="permissionHandlerMessage">${message} :</h4>
<h6>${fromName}</h6>
<p>${from.description || yo`<i>No description Provided</i>`}</p>
<h6>${toName} :</p>
<p>${to.description || yo`<i>No description Provided</i>`}</p>
</article> </article>
<article class="${css.remember}"> `
<div class="custom-control custom-checkbox">
${rememberSwitch} globalRegistry.get('themeModule').api.fixInvert(imgFrom)
<label class="custom-control-label" for="remember" data-id="permissionHandlerRememberChoice">Remember this choice</label> globalRegistry.get('themeModule').api.fixInvert(imgTo)
</div>
<button class="btn btn-sm" onclick="${_ => this.clear()}">Reset all Permissions</button> return yo`
</article> <section class="${css.permission}">
${pluginsImages}
<article>
<h4 data-id="permissionHandlerMessage">${message} :</h4>
<h6>${fromName}</h6>
<p>${from.description || yo`<i>No description Provided</i>`}</p>
<h6>${toName} :</p>
<p>${to.description || yo`<i>No description Provided</i>`}</p>
</article>
</section> <article class="${css.remember}">
<div class="form-check">
${rememberSwitch}
<label class="form-check-label" for="remember" data-id="permissionHandlerRememberChoice">Remember this choice</label>
</div>
<button class="btn btn-sm" onclick="${_ => this.clear()}">Reset all Permissions</button>
</article>
</section>
` `
} }
} }
...@@ -23,7 +23,7 @@ module.exports = { ...@@ -23,7 +23,7 @@ module.exports = {
}) })
.modalFooterOKClick() .modalFooterOKClick()
}, },
'Publish on Swarm': function (browser) { 'Publish on Swarm': '' + function (browser) {
browser browser
.click('#publishOnSwarm') .click('#publishOnSwarm')
.getModalBody((value, done) => { .getModalBody((value, done) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment