Skip to content

Commit

Permalink
Add dark mode based on prefers-color-scheme CSS media
Browse files Browse the repository at this point in the history
This reverts commit 0090ee61fd61ba27a8ba12e23972eb638af687ea.
  • Loading branch information
danguita committed Jul 25, 2023
1 parent 9561e9d commit c69f713
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 1 deletion.
31 changes: 31 additions & 0 deletions source/assets/stylesheets/base/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ a {
color: $base-link-color--hover;
outline: 0;
}

@include dark-color-scheme {
color: $base-link-color--dark;

&:hover {
color: $base-link-color--hover--dark;
}
}
}

abbr {
Expand All @@ -31,6 +39,11 @@ blockquote {
color: lighten($base-text-color, 25);
margin: 0 0 $base-spacing;
padding-left: 20px;

@include dark-color-scheme {
border-color: $base-border-color--dark;
color: $base-text-color--dark;
}
}

body {
Expand All @@ -43,6 +56,11 @@ body {
overflow-x: hidden;
padding-top: 15px;
border-top: 5px solid $color-green;

@include dark-color-scheme {
background-color: $base-background-color--dark;
color: $base-text-color--dark;
}
}

main {
Expand Down Expand Up @@ -75,6 +93,11 @@ cite {
&:before {
content: '\2014 \00A0';
}

@include dark-color-scheme {
border-color: $base-border-color--dark;
color: $base-text-color--dark;
}
}

code,
Expand All @@ -88,6 +111,10 @@ code {
background: $code-background-color;
border-radius: 3px;
padding: 3px 6px;

@include dark-color-scheme {
background: $code-background-color--dark;
}
}

h1,
Expand All @@ -101,6 +128,10 @@ h6 {
font-weight: bold;
line-height: $heading-line-height;
margin: 0 0 $base-spacing;

@include dark-color-scheme {
color: $heading-color--dark;
}
}

h1 {
Expand Down
6 changes: 6 additions & 0 deletions source/assets/stylesheets/base/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@
@content;
}
}

@mixin dark-color-scheme() {
@media (prefers-color-scheme: dark) {
@content;
}
}
4 changes: 4 additions & 0 deletions source/assets/stylesheets/base/_syntax.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ $block: '.highlight > .highlight';
padding: 15px;
white-space: pre;
word-wrap: normal;

@include dark-color-scheme {
background: $code-background-color--dark;
}
}

#{$block} code {
Expand Down
11 changes: 11 additions & 0 deletions source/assets/stylesheets/base/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,24 @@ $font-family-sans-serif: "Lato", sans-serif;

// Base: Default color scheme
$base-background-color: $color-white;
$base-contrast-background-color: $color-blue-grey--dark;
$base-border-color: $color-grey--light;
$base-text-color: lighten($color-blue-grey--dark, 10);
$base-link-color: $color-green;
$base-link-color--hover: $color-green--dark;
$heading-color: $color-blue-grey--dark;
$code-background-color: #f7f7f7;

// Base: Dark color scheme
$base-background-color--dark: #1d2021;
$base-contrast-background-color--dark: lighten($base-background-color--dark, 5);
$base-border-color--dark: $color-grey--dark;
$base-text-color--dark: $color-grey--light;
$base-link-color--dark: $color-green;
$base-link-color--hover--dark: $color-green--dark;
$heading-color--dark: $color-blue-grey--light;
$code-background-color--dark: $color-blue-grey--dark;

$base-font-family: $font-family-sans-serif;
$base-font-size: 16px;
$base-line-height: 1.5;
Expand Down
4 changes: 4 additions & 0 deletions source/assets/stylesheets/layout/_footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ $block: '.footer';
color: $color-green;
}
}

@include dark-color-scheme {
border-color: $color-grey--dark;
}
}

#{$block}__about {
Expand Down
6 changes: 6 additions & 0 deletions source/assets/stylesheets/modules/_clients.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@ $block: '.clients';
border-width: 1px;
}
}

#{$subblock}__image {
@include dark-color-scheme {
filter: drop-shadow(0 0 5px $base-background-color--dark);
}
}
}
18 changes: 17 additions & 1 deletion source/assets/stylesheets/modules/_home.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ $block: '.home';
margin-top: 10px;
font-family: $font-family-monospace;
font-size: 1rem;
background-color: $color-blue-grey--dark;
background-color: $base-contrast-background-color;
color: $color-white;

@include dark-color-scheme {
background-color: $base-contrast-background-color--dark;
}
}

@include mq-large {
Expand Down Expand Up @@ -66,6 +70,14 @@ $block: '.home';
&:hover {
color: $color-blue-grey--dark;
}

@include dark-color-scheme {
color: $color-blue-grey--light;

&:hover {
color: $color-blue-grey--light;
}
}
}
}
}
Expand All @@ -74,6 +86,10 @@ $block: '.home';
position: relative;
padding: 30px 0 10px;
background-color: $color-grey--light;

@include dark-color-scheme {
background-color: $base-contrast-background-color--dark;
}
}

#{$block}__latest-articles {
Expand Down

0 comments on commit c69f713

Please sign in to comment.