|
|
@ -33,11 +33,6 @@ class VerticalIconComponent { |
|
|
|
}) |
|
|
|
}) |
|
|
|
this.store.event.on('add', (api) => { }) |
|
|
|
this.store.event.on('add', (api) => { }) |
|
|
|
this.store.event.on('remove', (api) => { }) |
|
|
|
this.store.event.on('remove', (api) => { }) |
|
|
|
|
|
|
|
|
|
|
|
let themeModule = globalRegistry.get('themeModule').api |
|
|
|
|
|
|
|
themeModule.events.on('themeChanged', (type) => { |
|
|
|
|
|
|
|
this.updateIcons(type) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
stopListenOnStatus (api) { |
|
|
|
stopListenOnStatus (api) { |
|
|
@ -63,27 +58,13 @@ class VerticalIconComponent { |
|
|
|
* @param {ModuleProfile} profile The profile of the module |
|
|
|
* @param {ModuleProfile} profile The profile of the module |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
addIcon ({kind, name, icon, displayName}) { |
|
|
|
addIcon ({kind, name, icon, displayName}) { |
|
|
|
this.icons[name] = yo`<div class="${css.icon}" onclick="${(e) => { this._iconClick(name) }}" plugin="${name}" title="${displayName || name}" ><img src="${icon}" alt="${name}" /></div>` |
|
|
|
this.icons[name] = yo` |
|
|
|
|
|
|
|
<div class="${css.icon}" onclick="${(e) => { this._iconClick(name) }}" plugin="${name}" title="${displayName || name}" > |
|
|
|
|
|
|
|
<img class="image" src="${icon}" alt="${name}" /> |
|
|
|
|
|
|
|
</div>` |
|
|
|
this.iconKind[kind || 'other'].appendChild(this.icons[name]) |
|
|
|
this.iconKind[kind || 'other'].appendChild(this.icons[name]) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
updateIcons(type) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (!type) { |
|
|
|
|
|
|
|
type = globalRegistry.get("themeModule").api.currentTheme().quality === 'dark' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let icon |
|
|
|
|
|
|
|
for (icon in this.icons) { |
|
|
|
|
|
|
|
if (type === 'dark') { |
|
|
|
|
|
|
|
this.icons[icon].classList.remove(`${css.light}`) |
|
|
|
|
|
|
|
this.icons[icon].classList.add(`${css.dark}`) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.icons[icon].classList.remove(`${css.dark}`) |
|
|
|
|
|
|
|
this.icons[icon].classList.add(`${css.light}`) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Set a new status for the @arg name |
|
|
|
* Set a new status for the @arg name |
|
|
|
* @param {String} name |
|
|
|
* @param {String} name |
|
|
@ -92,7 +73,7 @@ class VerticalIconComponent { |
|
|
|
setIconStatus (name, status) { |
|
|
|
setIconStatus (name, status) { |
|
|
|
const el = this.icons[name] |
|
|
|
const el = this.icons[name] |
|
|
|
if (!el) return |
|
|
|
if (!el) return |
|
|
|
let statusEl = el.querySelector('i') |
|
|
|
let statusEl = el.querySelector('span') |
|
|
|
if (statusEl) { |
|
|
|
if (statusEl) { |
|
|
|
el.removeChild(statusEl) |
|
|
|
el.removeChild(statusEl) |
|
|
|
} |
|
|
|
} |
|
|
@ -100,7 +81,7 @@ class VerticalIconComponent { |
|
|
|
let key = helper.checkSpecialChars(status.key) ? '' : status.key |
|
|
|
let key = helper.checkSpecialChars(status.key) ? '' : status.key |
|
|
|
let type = helper.checkSpecialChars(status.type) ? '' : status.type |
|
|
|
let type = helper.checkSpecialChars(status.type) ? '' : status.type |
|
|
|
let title = helper.checkSpecialChars(status.title) ? '' : status.title |
|
|
|
let title = helper.checkSpecialChars(status.title) ? '' : status.title |
|
|
|
el.appendChild(yo`<i title="${title}" class="fa fa-${key} ${css.status} text-${type}" aria-hidden="true"></i>`) |
|
|
|
el.appendChild(yo`<span title="${title}" class="fa fa-${key} ${css.status} text-${type}" aria-hidden="true"></span>`) |
|
|
|
|
|
|
|
|
|
|
|
// el.classList = "" doesn't work on all browser use instead
|
|
|
|
// el.classList = "" doesn't work on all browser use instead
|
|
|
|
var classList = el.classList; |
|
|
|
var classList = el.classList; |
|
|
@ -123,20 +104,28 @@ class VerticalIconComponent { |
|
|
|
if (this.icons[name]) this.iconKind[kind || 'other'].removeChild(this.icons[name]) |
|
|
|
if (this.icons[name]) this.iconKind[kind || 'other'].removeChild(this.icons[name]) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Set an icon as active |
|
|
|
|
|
|
|
* @param {string} name Name of profile of the module to activate |
|
|
|
|
|
|
|
*/ |
|
|
|
select (name) { |
|
|
|
select (name) { |
|
|
|
this.updateIcons() |
|
|
|
const themeType = globalRegistry.get("themeModule").api.currentTheme().quality |
|
|
|
let currentActive = this.view.querySelector(`.${css.active}`) |
|
|
|
const invert = themeType === 'dark' ? 1 : 0 |
|
|
|
|
|
|
|
// Remove active for the current activated icons
|
|
|
|
|
|
|
|
const currentActive = this.view.querySelector(`.${css.active}`) |
|
|
|
if (currentActive) { |
|
|
|
if (currentActive) { |
|
|
|
let currentTitle = currentActive.getAttribute('title') |
|
|
|
currentActive.classList.remove(css.active) |
|
|
|
currentActive.classList.toggle(`${css.active}`) |
|
|
|
let image = currentActive.querySelector('.image') |
|
|
|
if (currentTitle !== name) { |
|
|
|
image.style.setProperty('filter', 'invert(0.5)') |
|
|
|
let activate = this.view.querySelector(`[plugin="${name}"]`) |
|
|
|
|
|
|
|
if (activate) activate.classList.toggle(`${css.active}`) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
let activate = this.view.querySelector(`[plugin="${name}"]`) |
|
|
|
|
|
|
|
if (activate) activate.classList.toggle(`${css.active}`) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Add active for the new activated icon
|
|
|
|
|
|
|
|
const nextActive = this.view.querySelector(`[plugin="${name}"]`) |
|
|
|
|
|
|
|
if (nextActive) { |
|
|
|
|
|
|
|
let image = nextActive.querySelector('.image') |
|
|
|
|
|
|
|
nextActive.classList.add(css.active) |
|
|
|
|
|
|
|
image.style.setProperty('filter', `invert(${invert})`) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.events.emit('showContent', name) |
|
|
|
this.events.emit('showContent', name) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -216,36 +205,21 @@ const css = csjs` |
|
|
|
padding: 3px; |
|
|
|
padding: 3px; |
|
|
|
position: relative; |
|
|
|
position: relative; |
|
|
|
border-radius: 8px; |
|
|
|
border-radius: 8px; |
|
|
|
filter: invert(0.5); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.dark{ |
|
|
|
|
|
|
|
filter: invert(0.5); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.light{ |
|
|
|
|
|
|
|
filter: invert(0.5); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
.icon img { |
|
|
|
.icon img { |
|
|
|
width: 28px; |
|
|
|
width: 28px; |
|
|
|
height: 28px; |
|
|
|
height: 28px; |
|
|
|
padding: 4px; |
|
|
|
padding: 4px; |
|
|
|
|
|
|
|
filter: invert(0.5); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.image { |
|
|
|
|
|
|
|
filter: invert(0.5); |
|
|
|
} |
|
|
|
} |
|
|
|
.icon svg { |
|
|
|
.icon svg { |
|
|
|
width: 28px; |
|
|
|
width: 28px; |
|
|
|
height: 28px; |
|
|
|
height: 28px; |
|
|
|
padding: 4px; |
|
|
|
padding: 4px; |
|
|
|
} |
|
|
|
} |
|
|
|
.light.active { |
|
|
|
|
|
|
|
border-radius: 8px; |
|
|
|
|
|
|
|
padding-top: 1px; |
|
|
|
|
|
|
|
padding-left: 1px; |
|
|
|
|
|
|
|
filter: invert(0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.dark.active { |
|
|
|
|
|
|
|
border-radius: 8px; |
|
|
|
|
|
|
|
padding-top: 1px; |
|
|
|
|
|
|
|
padding-left: 1px; |
|
|
|
|
|
|
|
filter: invert(1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.icon[title='settings'] { |
|
|
|
.icon[title='settings'] { |
|
|
|
position: absolute; |
|
|
|
position: absolute; |
|
|
|
bottom: 0; |
|
|
|
bottom: 0; |
|
|
@ -255,4 +229,15 @@ const css = csjs` |
|
|
|
bottom: 0; |
|
|
|
bottom: 0; |
|
|
|
right: 0; |
|
|
|
right: 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.statusWithBG |
|
|
|
|
|
|
|
border-radius: 8px; |
|
|
|
|
|
|
|
background-color: var(--danger); |
|
|
|
|
|
|
|
color: var(--light); |
|
|
|
|
|
|
|
font-size: 12px; |
|
|
|
|
|
|
|
height: 15px; |
|
|
|
|
|
|
|
text-align: center; |
|
|
|
|
|
|
|
font-weight: bold; |
|
|
|
|
|
|
|
padding-left: 5px; |
|
|
|
|
|
|
|
padding-right: 5px; |
|
|
|
|
|
|
|
} |
|
|
|
` |
|
|
|
` |
|
|
|