Skip to content
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

Issue 105 : Dark Mode + Theming #118 #119

Merged
merged 3 commits into from
Oct 5, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@
<link rel="stylesheet" href="{{ '/assets/css/main.css' | relative_url }}">

<link rel="canonical" href="{{ page.url | replace:'index.html','' | relative_url }}">

<!-- Theming-->
<script src="{{ '/assets/js/theme.js' | relative_url }}"></script>
8 changes: 7 additions & 1 deletion _includes/header.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<header>

<!-- Nav Bar -->
<nav id="navbar" class="navbar navbar-light bg-white navbar-expand-sm {% if site.navbar_fixed %}fixed-top{% else %}sticky-top{% endif %}">
<nav id="navbar" class="navbar navbar-light navbar-expand-sm {% if site.navbar_fixed %}fixed-top{% else %}sticky-top{% endif %}">
<div class="container">
{% if page.title != "about" %}
<a class="navbar-brand title font-weight-lighter" href="{{ site.baseurl | prepend: site.url }}/">
Expand Down Expand Up @@ -56,6 +56,12 @@
</li>
{% endif %}
{% endfor %}
<div class = "toggle-container">
<a id = "light-toggle">
<i class="fas fa-moon"></i>
<i class="fas fa-sun"></i>
</a>
</div>
</ul>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions _includes/scripts/misc.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@

<!-- Load Common JS -->
<script src="{{ '/assets/js/common.js' | relative_url }}"></script>

<!-- Load DarkMode JS -->
<script src="{{ '/assets/js/dark_mode.js' | relative_url }}"></script>
81 changes: 50 additions & 31 deletions _sass/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
// Typography

a, table.table a {
color: $theme-color;
color: var(--global-theme-color);
&:hover {
color: $theme-color;
color: var(--global-theme-color);
text-decoration: underline;
}
&:hover:after {
Expand Down Expand Up @@ -65,7 +65,7 @@ a, table.table a {
color: inherit;
font-size: 0.875rem;
&:hover {
color: $theme-color;
color: var(--global-theme-color);
text-decoration: none;
}
}
Expand All @@ -78,6 +78,7 @@ a, table.table a {
box-shadow: none;
border-bottom: 1px solid $grey-color-light;
opacity: 0.95;
background-color: var(--global-bg-color);
}
.navbar.navbar-light {
// Remove link decoration
Expand All @@ -86,25 +87,27 @@ a, table.table a {
text-decoration: none;
}
}
.navbar-brand {
color: var(--global-text-color);
}
.navbar-nav .nav-item .nav-link {
&:hover {
color: $theme-color;
color: var(--global-hover-color);
}
}
.navbar-nav .nav-item.active>.nav-link {
background-color: inherit;
color: $theme-color;
font-weight: bolder;
color: var(--global-theme-color);
&:hover {
color: $theme-color;
color: var(--global-hover-color);
}
}
.contact-icon {
font-size: 2rem;
a {
color: $grey-color-dark;
&:hover {
color: $theme-color;
color: var(--global-hover-color);
}
}
}
Expand Down Expand Up @@ -150,8 +153,12 @@ a, table.table a {

.news table td {
font-size: 1rem;
color: var(--global-text-color);
}

.news table th {
color: var(--global-text-color);
}

// Social (bottom)

Expand All @@ -160,9 +167,9 @@ a, table.table a {
.contact-icon {
font-size: 4rem;
a {
color: $grey-color-dark;
color: var(--global-icon-color);
&:hover {
color: $theme-color;
color: var(--global-theme-color);
}
}
}
Expand All @@ -173,19 +180,18 @@ a, table.table a {


// Footer

footer.fixed-bottom {
color: lighten($grey-color, 25%);
background-color: $grey-color-dark;
color: var(--global-footer-text-color);
background-color: var(--global-footer-bg-color);
font-size: 0.75rem;
.container {
padding-top: 9px;
padding-bottom: 8px;
}
a {
color: white;
color: var(--global-footer-link-color);
&:hover {
color: lighten($theme-color, 25%);
color: pink;
text-decoration: none;
}
}
Expand All @@ -207,7 +213,7 @@ footer.sticky-bottom {
padding-top: 2rem;
padding-bottom: 5rem;
h1 {
color: $theme-color;
color: var(--global-theme-color);
font-size: 5rem;
}
}
Expand All @@ -227,19 +233,19 @@ footer.sticky-bottom {
margin-bottom: 0;
}
a {
color: black;
color: var(--global-text-color);
text-decoration: none;
&:hover {
color: $theme-color;
color: var(--global-theme-color);
}
}
}
}

.pagination .page-item.active .page-link {
background-color: $theme-color;
background-color: var(--global-theme-color);
&:hover {
background-color: $theme-color;
background-color: var(--global-theme-color);
}
}

Expand All @@ -248,7 +254,7 @@ footer.sticky-bottom {

.distill {
a:hover {
border-bottom-color: $theme-color;
border-bottom-color: var(--global-theme-color);
text-decoration: none;
}
}
Expand All @@ -264,7 +270,7 @@ footer.sticky-bottom {
color: black;
text-decoration: none;
&:hover {
color: $theme-color;
color: var(--global-theme-color);
}
}
}
Expand All @@ -279,7 +285,7 @@ footer.sticky-bottom {
.publications {
margin-top: 2rem;
h1 {
color: $theme-color;
color: var(--global-theme-color);
font-size: 2rem;
text-align: center;
margin-top: 1em;
Expand Down Expand Up @@ -311,7 +317,7 @@ footer.sticky-bottom {
margin-bottom: 0.5rem;
abbr {
display: inline-block;
background-color: $theme-color;
background-color: var(--global-theme-color);
padding-left: 1rem;
padding-right: 1rem;
a {
Expand All @@ -322,16 +328,16 @@ footer.sticky-bottom {
}
}
.award {
color: $theme-color !important;
border: 1px solid $theme-color;
color: var(--global-theme-color) !important;
border: 1px solid var(--global-theme-color);
}
}
.title {
font-weight: bolder;
}
.author {
a {
border-bottom: 1px dashed $theme-color;
border-bottom: 1px dashed var(--global-theme-color);
&:hover {
border-bottom-style: solid;
text-decoration: none;
Expand All @@ -344,15 +350,15 @@ footer.sticky-bottom {
}
.links {
a.btn {
color: $text-color;
border: 1px solid $text-color;
color: var(--global-text-color);
border: 1px solid var(--global-text-color);
padding-left: 1rem;
padding-right: 1rem;
padding-top: 0.25rem;
padding-bottom: 0.25rem;
&:hover {
color: $theme-color;
border-color: $theme-color;
color: var(--global-theme-color);
border-color: var(--global-theme-color);
}
}
}
Expand Down Expand Up @@ -394,3 +400,16 @@ footer.sticky-bottom {
}
}
}

// Rouge Color Customization
code {
color: var(--global-theme-color);
}
// Transitioning Themes
html.transition,
html.transition *,
html.transition *:before,
html.transition *:after {
transition: all 750ms !important;
transition-delay: 0 !important;
}
3 changes: 2 additions & 1 deletion _sass/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

body {
padding-bottom: 70px;
color: $text-color;
color: var(--global-text-color);
background-color: var(--global-bg-color);
}

body.fixed-top-nav {
Expand Down
43 changes: 43 additions & 0 deletions _sass/_themes.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*******************************************************************************
* Themes
******************************************************************************/

:root {
--global-bg-color: #{$white-color};
--global-text-color: #{$black-color};
--global-theme-color: #{$purple-color};
--global-hover-color: #{$light-purple-color};
--global-footer-bg-color: #{$grey-color-dark};
--global-footer-text-color: #{$grey-color-light};
--global-footer-link-color: #{$white-color};
--global-icon-color: #{$grey-color-dark};

.fa-sun {
display : none;
}
.fa-moon {
padding-left: 10px;
padding-top: 12px;
display : block;
}
}

html[data-theme='dark'] {
--global-bg-color: #{$grey-color-dark};
--global-text-color: #{$grey-color-light};
--global-theme-color: #{$cyan-color};
--global-hover-color: #{$light-cyan-color};
--global-footer-bg-color: #{$grey-color-light};
--global-footer-text-color: #{$grey-color-dark};
--global-footer-link-color: #{$black-color};
--global-icon-color: navajowhite;

.fa-sun {
padding-left: 10px;
padding-top: 12px;
display : block;
}
.fa-moon {
display : none;
}
}
9 changes: 4 additions & 5 deletions _sass/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ $orange-color: #F29105 !default;
$blue-color: #0076df !default;
$blue-color-dark: #00369f !default;
$cyan-color: #2698BA !default;
$light-cyan-color: lighten($cyan-color, 25%);
$green-color: #00ab37 !default;
$green-color-lime: #B7D12A !default;
$green-color-dark: #009f06 !default;
$green-color-light: #ddffdd !default;
$green-color-bright: #11D68B !default;
$purple-color: #B509AC !default;
$light-purple-color: lighten($purple-color, 25%);
$pink-color: #f92080 !default;
$pink-color-light: #ffdddd !default;
$yellow-color: #efcc00 !default;
Expand All @@ -28,8 +30,5 @@ $grey-color: #828282 !default;
$grey-color-light: lighten($grey-color, 40%);
$grey-color-dark: darken($grey-color, 25%);

/* Set theme colors *************************/
$theme-color: $purple-color;

$link-color: $theme-color;
$text-color: #111 !default;
$white-color: #ffffff !default;
$black-color: #000000 !default;
1 change: 1 addition & 0 deletions assets/css/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

@import
"variables",
"themes",
"layout",
"base"
;
35 changes: 35 additions & 0 deletions assets/js/dark_mode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
$(document).ready(function() {
const mode_toggle = document.getElementById("light-toggle");

mode_toggle.addEventListener("click", function() {
const temp = localStorage.getItem('theme');
toggleTheme(temp);
});

let toggleTheme = (theme) => {
if (theme == "dark") {
setTheme(null);
} else {
setTheme('dark');
}
}

let setTheme = (theme) => {
trans();
if (theme) {
document.documentElement.setAttribute('data-theme', theme)
}
else {
document.documentElement.removeAttribute('data-theme');
}
localStorage.setItem('theme', theme);
};

let trans = () => {
document.documentElement.classList.add('transition');
window.setTimeout(() => {
document.documentElement.classList.remove('transition')
}, 1000)
}
});

Loading