Skip to content

Instantly share code, notes, and snippets.

@lucasvanhalst
Created April 26, 2016 17:43
Show Gist options
  • Save lucasvanhalst/35dcffa5cbfd704825debc4e83a2e30f to your computer and use it in GitHub Desktop.
Save lucasvanhalst/35dcffa5cbfd704825debc4e83a2e30f to your computer and use it in GitHub Desktop.
Rocketchat night theme
var iconNightMode = document.createElement('i');
iconNightMode.className='icon-toggle-off';
var btnNightMode = document.createElement('div');
btnNightMode.className="tab-button";
btnNightMode.id = 'toggle-nightmode';
btnNightMode.title = 'Toggle night mode';
btnNightMode.appendChild(iconNightMode)
$('.flex-tab-bar').append(btnNightMode)
var rocketChatContainer = $('#rocket-chat');
rocketChatContainer.toggleClass('theme-night', !!JSON.parse(localStorage.getItem('nightmode')));
$('#toggle-nightmode').unbind('click').click(function(){
var $this = $(this);
rocketChatContainer.toggleClass('theme-night');
var isNight = rocketChatContainer.hasClass('theme-night')
$this.find('i').toggleClass('icon-toggle-on', isNight).toggleClass('icon-toggle-off', !isNight);
localStorage.setItem('nightmode', isNight);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment