Skip to content

Commit

Permalink
Merge pull request opengaming#474 from JG916/master
Browse files Browse the repository at this point in the history
Dark Theme 3 Fixes
  • Loading branch information
wonea authored Oct 2, 2017
2 parents 6f6ab0e + 86d36ec commit f95b8c3
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 7 deletions.
5 changes: 2 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
{% import 'templates/games.html' as games with context %}

<body>
<script type="text/javascript" src="static/startInDarkMode.js"></script>
<header>
<div class="container">
<input id="filter" type="search" placeholder="Type to filter">
Expand All @@ -43,10 +44,8 @@
</div>
</div>
</li>
<li id='darkThemeButtonLi'>
<span id='darkThemeButton' class="nav-btn">Dark Theme</span>
</li>
</ul>
<span id='darkThemeButton' class="nav-btn">Dark Theme</span>
</div>
</header>

Expand Down
21 changes: 17 additions & 4 deletions static/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ footer { text-align: center; margin-top: 2em; }
#nav { display: inline-block; list-style: none; margin: 0; padding: 0; }
#nav li { display: inline-block; }

#nav .nav-btn {
#nav .nav-btn, #darkThemeButton {
display: inline-block;
font-size: 14px;
line-height: 30px;
Expand Down Expand Up @@ -200,12 +200,25 @@ dd + dt { margin-top: 1em; }

.darkTheme #nav li.active .nav-btn {
color: #000
}
}

.darkTheme #darkThemeButton {
background-color: #E3E3E3
background-color: #323232;
color: #E3E3E3;
}

#darkThemeButtonLi {
#darkThemeButton {
background-color: transparent;
float: right;
}

.darkTheme #nav .tag-group {
background-color: #323232;
border-bottom: 1px solid #1C1C1C;
}


.darkTheme #nav li:hover .nav-btn, .darkTheme #nav li.active .nav-btn {
background-color: #323232;
color: #E3E3E3;
}
2 changes: 2 additions & 0 deletions static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,10 @@ var OSGC = window.OSGC = {};
function toggleDarkTheme() {
if (document.body.classList.contains('darkTheme')) {
document.body.classList.remove('darkTheme');
localStorage.setItem('startInDarkTheme', 'false')
} else {
document.body.classList.add('darkTheme');
localStorage.setItem('startInDarkTheme', 'true')
}
}

Expand Down
17 changes: 17 additions & 0 deletions static/startInDarkMode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function toggleDarkTheme() {
if (document.body.classList.contains('darkTheme')) {
document.body.classList.remove('darkTheme');
localStorage.setItem('startInDarkTheme', 'false')
} else {
document.body.classList.add('darkTheme');
localStorage.setItem('startInDarkTheme', 'true')
}
}

function checkIfShouldStartInDarkTheme() {
if (localStorage.getItem('startInDarkTheme') === 'true') {
toggleDarkTheme();
}
}

checkIfShouldStartInDarkTheme();

0 comments on commit f95b8c3

Please sign in to comment.