parent
9095f35545
commit
282d64a923
33 changed files with 167 additions and 33 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -35,6 +35,7 @@ eggs/
|
||||||
|
|
||||||
lib/
|
lib/
|
||||||
!src/newsreader/scss/lib
|
!src/newsreader/scss/lib
|
||||||
|
!src/newsreader/js/lib
|
||||||
|
|
||||||
lib64/
|
lib64/
|
||||||
parts/
|
parts/
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import './lib/index.js';
|
||||||
import './pages/homepage/index.js';
|
import './pages/homepage/index.js';
|
||||||
import './pages/categories/index.js';
|
import './pages/categories/index.js';
|
||||||
import './pages/rules/index.js';
|
import './pages/rules/index.js';
|
||||||
|
|
|
||||||
1
src/newsreader/js/lib/index.js
Normal file
1
src/newsreader/js/lib/index.js
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
import './theme.js';
|
||||||
76
src/newsreader/js/lib/theme.js
Normal file
76
src/newsreader/js/lib/theme.js
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
function isCSSVariablesSupported() {
|
||||||
|
return window.CSS && window.CSS.supports('color', 'var(--fake-color');
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeTheme(e) {
|
||||||
|
const currentPref = sessionStorage.getItem('t-dark');
|
||||||
|
const isDark = currentPref && currentPref === 'true' ? true : false;
|
||||||
|
|
||||||
|
if (isDark) {
|
||||||
|
document.documentElement.classList.remove('dark-theme');
|
||||||
|
} else {
|
||||||
|
document.documentElement.classList.add('dark-theme');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
sessionStorage.setItem('t-dark', !isDark);
|
||||||
|
} catch (e) {
|
||||||
|
// do nothing.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function prefersDarkTheme() {
|
||||||
|
try {
|
||||||
|
const currentPref = sessionStorage.getItem('t-dark');
|
||||||
|
|
||||||
|
if (currentPref && currentPref === 'true') {
|
||||||
|
return true;
|
||||||
|
} else if (
|
||||||
|
!currentPref &&
|
||||||
|
window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleDarkTheme(isDark) {
|
||||||
|
if (isDark) {
|
||||||
|
document.documentElement.classList.add('dark-theme');
|
||||||
|
} else {
|
||||||
|
document.documentElement.classList.remove('dark-theme');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
sessionStorage.setItem('t-dark', isDark);
|
||||||
|
} catch (e) {
|
||||||
|
// do nothing.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function initThemeSelector() {
|
||||||
|
const themeButton = document.getElementsByClassName('theme-switcher')[0];
|
||||||
|
const mqPrefersDarkTheme = window.matchMedia('(prefers-color-scheme: dark)');
|
||||||
|
|
||||||
|
if (prefersDarkTheme()) {
|
||||||
|
toggleDarkTheme(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
themeButton.addEventListener('click', changeTheme);
|
||||||
|
|
||||||
|
mqPrefersDarkTheme.addListener(mq => {
|
||||||
|
toggleDarkTheme(mq.matches);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
if (isCSSVariablesSupported()) {
|
||||||
|
initThemeSelector();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
init();
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|
||||||
font-family: Rubik, sans-serif;
|
font-family: Rubik, sans-serif;
|
||||||
color: $font-color;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
width: 50%;
|
width: 50%;
|
||||||
|
|
||||||
background-color: $white;
|
background-color: var(--background-color);
|
||||||
|
|
||||||
&__header {
|
&__header {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
padding: 15px 0;
|
padding: 15px 0;
|
||||||
|
|
||||||
border-bottom: 2px $gray solid;
|
border-bottom: 2px var(--lightest-accent-color) solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__content {
|
&__content {
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
&--selected, &:hover {
|
&--selected, &:hover {
|
||||||
background-color: $gray;
|
background-color: var(--lighter-accent-color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
width: 70%;
|
width: 70%;
|
||||||
|
|
||||||
background-color: $white;
|
background-color: var(--background-color);
|
||||||
|
|
||||||
&__section {
|
&__section {
|
||||||
&--last {
|
&--last {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
@import './main/index';
|
@import './main/index';
|
||||||
@import './navbar/index';
|
@import './navbar/index';
|
||||||
@import './loading-indicator/index';
|
@import './loading-indicator/index';
|
||||||
|
@import './theme-switcher/index';
|
||||||
|
|
||||||
@import './modal/index';
|
@import './modal/index';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
width: 60%;
|
width: 60%;
|
||||||
|
|
||||||
background-color: $white;
|
background-color: var(--accent-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
&__header {
|
&__header {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
.nav {
|
.nav {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
margin: 0 0 5px 0;
|
margin: 0 0 5px 0;
|
||||||
padding: 10px 0;
|
padding: 10px 0;
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,6 @@
|
||||||
width: 60%;
|
width: 60%;
|
||||||
height: 80vh;
|
height: 80vh;
|
||||||
|
|
||||||
background-color: $white;
|
|
||||||
|
|
||||||
&__message {
|
&__message {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
|
||||||
background-color: $white;
|
background-color: var(--background-color);
|
||||||
|
|
||||||
cursor: initial;
|
cursor: initial;
|
||||||
|
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
&__title {
|
&__title {
|
||||||
&--read {
|
&--read {
|
||||||
color: $gainsboro;
|
color: var(--read-color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
&__rule, &__category {
|
&__rule, &__category {
|
||||||
background-color: $orange !important;
|
background-color: var(--lightest-accent-color) !important;
|
||||||
|
|
||||||
& a {
|
& a {
|
||||||
color: $black;
|
color: $black;
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
& .badge {
|
& .badge {
|
||||||
background-color: $orange;
|
background-color: var(--lightest-accent-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:last-child {
|
&:last-child {
|
||||||
|
|
@ -48,7 +48,7 @@
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
|
|
||||||
&--read {
|
&--read {
|
||||||
color: darken($gainsboro, +10%);
|
color: var(--read-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
background-color: $gray;
|
background-color: var(--lighter-accent-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
&--selected {
|
&--selected {
|
||||||
background-color: $gray;
|
background-color: var(--lighter-accent-color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
.table {
|
.table {
|
||||||
table-layout: fixed;
|
table-layout: fixed;
|
||||||
|
|
||||||
background-color: $white;
|
background-color: var(--background-color);
|
||||||
width: 90%;
|
width: 90%;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
.theme-switcher {
|
||||||
|
&:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
1
src/newsreader/scss/components/theme-switcher/index.scss
Normal file
1
src/newsreader/scss/components/theme-switcher/index.scss
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
@import './theme-switcher';
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
background-color: $gainsboro;
|
background-color: var(--lighter-accent-color);
|
||||||
|
|
||||||
font-size: small;
|
font-size: small;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
&:checked + .checkbox__label {
|
&:checked + .checkbox__label {
|
||||||
.checkbox__box {
|
.checkbox__box {
|
||||||
background-color: $checkbox-blue;
|
background-color: var(--lightest-accent-color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border: 2px solid darken($gainsboro, 10%);
|
border: 2px solid var(--lighter-accent-color);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
.h1 {
|
.h1 {
|
||||||
color: $header-color;
|
color: var(--font-color);
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
.h2 {
|
.h2 {
|
||||||
color: $header-color;
|
color: var(--font-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
.h3 {
|
.h3 {
|
||||||
color: $header-color;
|
color: var(--font-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
h3 {
|
h3 {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
.h4 {
|
.h4 {
|
||||||
color: $header-color;
|
color: var(--font-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
h4 {
|
h4 {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
.h5 {
|
.h5 {
|
||||||
color: $header-color;
|
color: var(--font-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
h5 {
|
h5 {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
.input {
|
.input {
|
||||||
@include text-padding;
|
@include text-padding;
|
||||||
|
|
||||||
border: 1px $gray solid;
|
color: var(--font-color);
|
||||||
|
background-color: var(--accent-color);
|
||||||
|
border: 1px var(--lighter-accent-color) solid;
|
||||||
|
|
||||||
&:focus {
|
&:focus {
|
||||||
border: 1px $focus-blue solid;
|
border: 1px var(--lightest-accent-color) solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
&[type="file"] {
|
&[type="file"] {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
.link {
|
.link {
|
||||||
color: darken($azureish-white, 30%);
|
color: var(--link-color);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
.small {
|
.small {
|
||||||
color: $nickel;
|
color: var(--font-color);
|
||||||
font-size: small;
|
font-size: small;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
@import '~css.gg/icons-scss/icons';
|
@import '~css.gg/icons-scss/icons';
|
||||||
|
|
||||||
.gg-link {
|
.gg-link {
|
||||||
color: initial;
|
color: var(--font-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.gg-pen {
|
.gg-pen {
|
||||||
|
color: var(--font-color);
|
||||||
transform: rotate(-45deg) scale(var(--ggs, 0.8));
|
transform: rotate(-45deg) scale(var(--ggs, 0.8));
|
||||||
color: initial;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,6 @@ $white: rgba(255, 255, 255, 1);
|
||||||
$black: rgba(0, 0, 0, 1);
|
$black: rgba(0, 0, 0, 1);
|
||||||
$dark: rgba(0, 0, 0, 0.4);
|
$dark: rgba(0, 0, 0, 0.4);
|
||||||
|
|
||||||
$font-color: rgba(48, 51, 53, 1);
|
|
||||||
$header-color: rgba(100, 101, 102, 1);
|
|
||||||
|
|
||||||
$reddit-orange: rgba(255, 69, 0, 1);
|
$reddit-orange: rgba(255, 69, 0, 1);
|
||||||
$twitter-blue: rgba(29, 155, 240, 1);
|
$twitter-blue: rgba(29, 155, 240, 1);
|
||||||
|
|
||||||
|
|
@ -26,3 +23,25 @@ $lavendal-pink: rgba(162, 155, 254, 1);
|
||||||
|
|
||||||
$focus-blue: darken($azureish-white, +10%);
|
$focus-blue: darken($azureish-white, +10%);
|
||||||
$checkbox-blue: rgba(34, 170, 253, 1);
|
$checkbox-blue: rgba(34, 170, 253, 1);
|
||||||
|
|
||||||
|
// White theme
|
||||||
|
$background-color: $white;
|
||||||
|
|
||||||
|
$font-color: rgba(48, 51, 53, 1);
|
||||||
|
$link-color: darken($azureish-white, 30%);
|
||||||
|
$read-color: darken($gainsboro, 10%);
|
||||||
|
|
||||||
|
$accent-color: $gainsboro;
|
||||||
|
$lighter-accent-color: $gainsboro;
|
||||||
|
$lightest-accent-color: $orange;
|
||||||
|
|
||||||
|
// Dark theme
|
||||||
|
$dark-background-color: rgba(29, 45, 80, 1);
|
||||||
|
|
||||||
|
$dark-font-color: darken($gray, 10%);
|
||||||
|
$dark-link-color: $link-color;
|
||||||
|
$dark-read-color: darken($dark-font-color, 20%);
|
||||||
|
|
||||||
|
$dark-accent-color: rgba(19, 59, 92, 1);
|
||||||
|
$dark-lighter-accent-color: rgba(30, 95, 116, 1);
|
||||||
|
$dark-lightest-accent-color: rgba(252, 218, 183, 1);
|
||||||
|
|
|
||||||
26
src/newsreader/scss/partials/_root.scss
Normal file
26
src/newsreader/scss/partials/_root.scss
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
:root {
|
||||||
|
--background-color: #{$background-color};
|
||||||
|
|
||||||
|
--font-color: #{$font-color};
|
||||||
|
--link-color: #{$link-color};
|
||||||
|
--read-color: #{$read-color};
|
||||||
|
|
||||||
|
--accent-color: #{$accent-color};
|
||||||
|
--lighter-accent-color: #{$lighter-accent-color};
|
||||||
|
--lightest-accent-color: #{$lightest-accent-color};
|
||||||
|
|
||||||
|
&.dark-theme {
|
||||||
|
--background-color: #{$dark-background-color};
|
||||||
|
|
||||||
|
--font-color: #{$dark-font-color};
|
||||||
|
--link-color: #{$dark-link-color};
|
||||||
|
--read-color: #{$dark-read-color};
|
||||||
|
|
||||||
|
--accent-color: #{$dark-accent-color};
|
||||||
|
--lighter-accent-color: #{$dark-lighter-accent-color};
|
||||||
|
--lightest-accent-color: #{$dark-lightest-accent-color};
|
||||||
|
}
|
||||||
|
|
||||||
|
color: var(--font-color);
|
||||||
|
background-color: var(--background-color);
|
||||||
|
}
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
@import './colors';
|
@import './colors';
|
||||||
@import './fonts';
|
@import './fonts';
|
||||||
|
@import './root';
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@
|
||||||
<li class="nav__item"><a href="{% url 'accounts:register' %}">Register</a></li>
|
<li class="nav__item"><a href="{% url 'accounts:register' %}">Register</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
|
<i class="theme-switcher gg-dark-mode"></i>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
{% if messages %}
|
{% if messages %}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue