-
Notifications
You must be signed in to change notification settings - Fork 505
[WIP] Dark theme #372
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
Draft
aghArdeshir
wants to merge
7
commits into
munificent:master
Choose a base branch
from
aghArdeshir:dark-theme
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
[WIP] Dark theme #372
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6071093
add theme toggler to template
3a766f2
add icon to theme toggler
926f32f
implement dark theme logic + minor random fixes on js
504f589
implement dark theme styles
847db7c
revert unnecessary whitespace changes
550cbf0
update style to support mobile view
92cace8
read theme from system settings
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
body.dark { | ||
background: rgb(51, 51, 51); | ||
|
||
.theme-toggler::before { | ||
content: '☀️'; // used for toggling to light theme | ||
} | ||
|
||
.content { | ||
background-color: rgb(28, 28, 33); | ||
color: rgb(191, 191, 191); | ||
} | ||
|
||
.page { | ||
background: rgb(31, 31, 31); | ||
border-left: 1px solid rgb(94, 94, 94); | ||
border-right: 1px solid rgb(94, 94, 94); | ||
} | ||
|
||
nav { | ||
background-color: rgb(18, 43, 54); | ||
color: rgb(179, 195, 204); | ||
} | ||
|
||
a { | ||
color: rgb(153, 204, 230); | ||
|
||
&:hover { | ||
border-bottom: 1px solid rgb(20, 61, 82); | ||
} | ||
} | ||
|
||
h1 { | ||
border-bottom: 1px solid rgb(43, 43, 43); | ||
|
||
&.book { | ||
color: rgb(191, 191, 191); | ||
} | ||
} | ||
|
||
h2 { | ||
border-left: 8px solid rgb(26, 60, 76); | ||
} | ||
|
||
h3 { | ||
border-left: 8px solid rgb(26, 60, 76); | ||
} | ||
|
||
|
||
@media only screen and (min-width: 800px) { | ||
aside { | ||
border-left: 8px solid rgb(72, 58, 30); | ||
} | ||
} | ||
|
||
aside { | ||
background-color: darkslategrey; | ||
color: rgb(194, 193, 188); | ||
} | ||
|
||
@media only screen and (min-width: 800px) { | ||
aside { | ||
background-color: transparent; | ||
} | ||
} | ||
|
||
img { | ||
border: 1px solid rgb(38, 38, 38); | ||
filter: invert(1); | ||
} | ||
|
||
pre { | ||
background-color: rgb(31, 31, 31); | ||
border-color: rgb(36, 36, 36) rgb(36, 36, 36) rgb(26, 60, 76); | ||
} | ||
|
||
.codehilite .k { | ||
color: rgb(153, 204, 230); | ||
} | ||
|
||
code { | ||
color: rgb(179, 195, 204); | ||
} | ||
|
||
.codehilite .kt { | ||
color: rgb(153, 222, 230); | ||
} | ||
|
||
.codehilite .c1 { | ||
color: rgb(191, 191, 191); | ||
} | ||
|
||
blockquote { | ||
background-color: rgb(31, 31, 31); | ||
border: 1px solid darkgray; | ||
|
||
p { | ||
color: azure; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ $(document).ready(function() { | |
window.setTimeout(refreshAsides, 200); | ||
|
||
refreshAsides(); | ||
loadInitialTheme(); | ||
}); | ||
|
||
function refreshAsides() { | ||
|
@@ -31,12 +32,65 @@ function refreshAsides() { | |
|
||
// Find the span the aside should be anchored next to. | ||
var name = aside.attr("name"); | ||
var span = $("span[name='" + name + "']"); | ||
var span = $("span[name='" + name.replace("'", "\\'") + "']"); | ||
if (span == null) { | ||
window.console.log("Could not find span for '" + name + "'"); | ||
return; | ||
} | ||
|
||
aside.offset({top: span.position().top - 3}); | ||
if (span.position()) { | ||
aside.offset({top: span.position().top - 3}); | ||
} | ||
Comment on lines
+41
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There were cases where |
||
}); | ||
} | ||
|
||
function loadInitialTheme() { | ||
const theme = localStorage.getItem("theme"); | ||
if (theme === "dark") { | ||
toggleTheme(); | ||
return; | ||
} | ||
|
||
const userPrefersDarkTheme = window.matchMedia( | ||
"(prefers-color-scheme: dark)" | ||
).matches; | ||
|
||
if (userPrefersDarkTheme) { | ||
toggleTheme(); | ||
return; | ||
} | ||
} | ||
|
||
function toggleTheme() { | ||
document.body.classList.toggle("dark"); | ||
|
||
if (document.body.classList.contains("dark")) { | ||
document | ||
.querySelector(".theme-toggler") | ||
.setAttribute("title", "light theme"); | ||
localStorage.setItem("theme", "dark"); | ||
} else { | ||
document | ||
.querySelector(".theme-toggler") | ||
.setAttribute("title", "dark theme"); | ||
localStorage.removeItem("theme"); | ||
} | ||
} | ||
|
||
function getCurentTheme() { | ||
return localStorage.getItem("theme") === "dark" ? "dark" : "light"; | ||
} | ||
|
||
window | ||
.matchMedia("(prefers-color-scheme: dark)") | ||
.addEventListener("change", function (e) { | ||
const prefersDarkTheme = e.matches; | ||
const prefersLightTheme = !prefersDarkTheme; | ||
if ( | ||
(prefersDarkTheme && getCurentTheme() !== "dark") || | ||
(prefersLightTheme && getCurentTheme() !== "light") | ||
) { | ||
toggleTheme(); | ||
} | ||
}); | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a case in which the value of
name
waswon't
, and this whole selector would have becomespan[name='won't']
, which is a syntax error. This change tries to prevent such cases.