added filter invert to images

pull/1/head
LianaHus 5 years ago
parent 0e478cc22a
commit 42a5705215
  1. 2
      package-lock.json
  2. 15
      src/app/panels/tab-proxy.js
  3. 8
      src/app/tabs/compile-tab.js
  4. 2
      src/app/tabs/settings-tab.js
  5. 2
      src/app/tabs/styles/settings-tab-styles.js
  6. 13
      src/app/tabs/theme-module.js
  7. 8
      src/app/ui/landing-page/landing-page.js
  8. 31
      src/app/ui/persmission-handler.js

2
package-lock.json generated

@ -17777,7 +17777,7 @@
"requires": { "requires": {
"underscore": "1.8.3", "underscore": "1.8.3",
"web3-core-helpers": "1.0.0-beta.27", "web3-core-helpers": "1.0.0-beta.27",
"websocket": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible" "websocket": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2"
}, },
"dependencies": { "dependencies": {
"debug": { "debug": {

@ -1,6 +1,7 @@
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 {
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)
}) })
@ -78,6 +84,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]) {
@ -130,6 +144,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 {
} }
}) })
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 {
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`
} }
.inline { .inline {
display: inline; display: inline;
width: 50%; width: 40%;
} }
` `

@ -24,7 +24,7 @@ const themes = [
const profile = { const profile = {
name: 'theme', name: 'theme',
events: ['themeChanged'], events: ['themeChanged'],
methods: ['switchTheme', 'getThemes', 'currentTheme'], methods: ['switchTheme', 'getThemes', 'currentTheme', 'fixInvert'],
version: packageJson.version, version: packageJson.version,
kind: 'theme' kind: 'theme'
} }
@ -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 {
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')
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,20 +141,26 @@ 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 pluginsImages = yo`
<section class="${css.permission}"> <article id="permissionModalImages" class="${css.images}">
<article class="${css.images}">
<img src="${from.icon}" /> <img src="${from.icon}" />
<i class="fas fa-arrow-right"></i> <i class="text-warning fas fa-arrow-right"></i>
<img src="${to.icon}" /> <img src="${to.icon}" />
</article> </article>
`
globalRegistry.get('themeModule').api.fixInvert(pluginsImages)
return yo`
<section class="${css.permission}">
${pluginsImages}
<article> <article>
<h4 data-id="permissionHandlerMessage">${message} :</h4> <h4 data-id="permissionHandlerMessage">${message} :</h4>
<h6>${fromName}</h6> <h6>${fromName}</h6>
@ -163,9 +170,9 @@ export class PermissionHandler {
</article> </article>
<article class="${css.remember}"> <article class="${css.remember}">
<div class="custom-control custom-checkbox"> <div class="form-check">
${rememberSwitch} ${rememberSwitch}
<label class="custom-control-label" for="remember" data-id="permissionHandlerRememberChoice">Remember this choice</label> <label class="form-check-label" for="remember" data-id="permissionHandlerRememberChoice">Remember this choice</label>
</div> </div>
<button class="btn btn-sm" onclick="${_ => this.clear()}">Reset all Permissions</button> <button class="btn btn-sm" onclick="${_ => this.clear()}">Reset all Permissions</button>
</article> </article>
@ -173,4 +180,12 @@ export class PermissionHandler {
</section> </section>
` `
} }
listenOnThemeChange (images) {
// update invert for Plugin icons
if (!globalRegistry.get('themeModule')) return
globalRegistry.get('themeModule').api.events.on('themeChanged', (theme) => {
globalRegistry.get('themeModule').api.fixInvert(images)
})
}
} }

Loading…
Cancel
Save