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

added filter invert to images #2599

Merged
merged 5 commits into from
Mar 2, 2020
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
15 changes: 15 additions & 0 deletions src/app/panels/tab-proxy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var yo = require('yo-yo')
var $ = require('jquery')
const EventEmitter = require('events')
const globalRegistry = require('../../global/registry')

require('remix-tabs')

Expand All @@ -14,6 +15,11 @@ export class TabProxy {
this._view = {}
this._handlers = {}

globalRegistry.get('themeModule').api.events.on('themeChanged', (theme) => {
// update invert for all icons
this.updateImgStyles()
})

fileManager.events.on('fileRemoved', (name) => {
this.removeTab(name)
})
Expand Down Expand Up @@ -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) {
if (this._handlers[tabName]) {
Expand Down Expand Up @@ -130,6 +144,7 @@ export class TabProxy {
icon,
tooltip: name
})
this.updateImgStyles()
this._handlers[name] = { switchTo, close }
}

Expand Down
8 changes: 2 additions & 6 deletions src/app/tabs/compile-tab.js

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

2 changes: 1 addition & 1 deletion src/app/tabs/settings-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module.exports = class SettingsTab extends ViewPlugin {
if (self._view.el) return self._view.el

// 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')
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">`
Expand Down
2 changes: 1 addition & 1 deletion src/app/tabs/styles/settings-tab-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const css = csjs`
}
.inline {
display: inline;
width: 50%;
width: 40%;
}
`

Expand Down
11 changes: 11 additions & 0 deletions src/app/tabs/theme-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,15 @@ export class ThemeModule extends Plugin {
this.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})`
}
}
}
8 changes: 2 additions & 6 deletions src/app/ui/landing-page/landing-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,8 @@ export class LandingPage extends ViewPlugin {
this.verticalIcons.select('fileExplorers')
}

globalRegistry.get('themeModule').api.events.on('themeChanged', (theme) => {
const invert = theme.quality === 'dark' ? 1 : 0
const img = document.getElementById('remixLogo')
if (img) {
img.style.filter = `invert(${invert})`
}
globalRegistry.get('themeModule').api.events.on('themeChanged', () => {
globalRegistry.get('themeModule').api.fixInvert(document.getElementById('remixLogo'))
})

let switchToPreviousVersion = () => {
Expand Down
53 changes: 31 additions & 22 deletions src/app/ui/persmission-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const yo = require('yo-yo')
const csjs = require('csjs-inject')
const addTooltip = require('./tooltip')
const modalDialog = require('./modaldialog')
const globalRegistry = require('../../global/registry')

const css = csjs`
.permission h4 {
Expand Down Expand Up @@ -140,37 +141,45 @@ export class PermissionHandler {
: delete this.permissions[to.name][from.name]
}
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}" class="custom-control-input" id="remember" data-id="permissionHandlerRememberUnchecked">`
? yo`<input type="checkbox" onchange="${switchMode}" checkbox class="form-check-input" id="remember" data-id="permissionHandlerRememberChecked">`
: yo`<input type="checkbox" onchange="${switchMode}" class="form-check-input" id="remember" data-id="permissionHandlerRememberUnchecked">`
const message = remember
? `"${fromName}" has changed and would like to access "${toName}"`
: `"${fromName}" would like to access "${toName}"`

return yo`
<section class="${css.permission}">
const imgFrom = yo`<img id="permissionModalImagesFrom" src="${from.icon}" />`
const imgTo = yo`<img id="permissionModalImagesTo" src="${to.icon}" />`
const pluginsImages = yo`
<article class="${css.images}">
<img src="${from.icon}" />
${imgFrom}
<i class="fas fa-arrow-right"></i>
<img src="${to.icon}" />
</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>
${imgTo}
</article>

<article class="${css.remember}">
<div class="custom-control custom-checkbox">
${rememberSwitch}
<label class="custom-control-label" for="remember" data-id="permissionHandlerRememberChoice">Remember this choice</label>
</div>
<button class="btn btn-sm" onclick="${_ => this.clear()}">Reset all Permissions</button>
</article>
`

globalRegistry.get('themeModule').api.fixInvert(imgFrom)
globalRegistry.get('themeModule').api.fixInvert(imgTo)

return yo`
<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>
`
}
}
2 changes: 1 addition & 1 deletion test-browser/tests/publishContract.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
})
.modalFooterOKClick()
},
'Publish on Swarm': function (browser) {
'Publish on Swarm': '' + function (browser) {
browser
.click('#publishOnSwarm')
.getModalBody((value, done) => {
Expand Down