Skip to content

Commit

Permalink
Update Theme Manager
Browse files Browse the repository at this point in the history
Added button to update the inbuilt dark theme whenever user wants to
  • Loading branch information
amanharwara committed Mar 27, 2019
1 parent ae7f28e commit bc5227e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
43 changes: 34 additions & 9 deletions src/windows/themeManager/js/themeManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ const settings = new Store({

if (settings.get('customTitlebar.value') === true) {
mainTitlebar = new customTitlebar.Titlebar({
backgroundColor: customTitlebar.Color.fromHex('#21252B'),
icon: '../assets/icons/icon.ico',
menu: process.platform === 'darwin' ? Menu.getApplicationMenu() : new Menu(),
minimizable: false,
maximizable: false,
closeable: true
})
// Setting title explicitly
backgroundColor: customTitlebar.Color.fromHex('#21252B'),
icon: '../assets/icons/icon.ico',
menu: process.platform === 'darwin' ? Menu.getApplicationMenu() : new Menu(),
minimizable: false,
maximizable: false,
closeable: true
})
// Setting title explicitly
mainTitlebar.updateTitle(`Theme Manager`);
}

Expand Down Expand Up @@ -58,6 +58,31 @@ for (theme of themesList) {
document.querySelector('.ui.divided.list').appendChild(themeElement);
}

document.querySelector('#update-dark-theme').addEventListener('click', e => {
window.fetch('https://raw.githubusercontent.com/ShadyThGod/shadythgod.github.io/master/css/altus-dark-theme.css', {
cache: 'no-store',
headers: {
'cache-control': 'no-store'
}
})
.then(res => res.text())
.then(css => {
let currentThemes = themes.get('themes');
let darkTheme = currentThemes.find(x => x.name === 'Dark');
let themeIndex = currentThemes.indexOf(darkTheme);
currentThemes[themeIndex] = {
name: 'Dark',
css: css
};
themes.set('themes', currentThemes);
window.close();
ipcRenderer.send('new-themes-added', true);
})
.catch(e => {
console.log(e);
});
});

document.querySelectorAll('.removetheme').forEach(e => {
e.addEventListener('click', () => {
let parentEl = e.parentElement.parentElement;
Expand All @@ -75,4 +100,4 @@ document.getElementById('save-button').addEventListener('click', () => {
window.close();
});

document.getElementById('reload-button').addEventListener('click', () => window.location.reload());
document.getElementById('reload-button').addEventListener('click', () => window.location.reload());
3 changes: 3 additions & 0 deletions src/windows/themeManager/window.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ <h1 class="ui header">
<button class="ui icon button black" id="reload-button" type="button" title="Click to reload page if themes haven't loaded">
<i class="redo alternate icon fitted"></i>
</button>
<button type="button" class="ui button blue" id="update-dark-theme" title="Update the inbuilt dark theme if there are any updates. Click this if you there are issues with the inbuilt dark theme">
<i class="arrow alternate circle down icon"></i> Update Dark Theme
</button>
</div>
</div>
</div>
Expand Down

0 comments on commit bc5227e

Please sign in to comment.