diff --git a/sass/_footer.scss b/sass/_footer.scss index 2ab06e1..75c4502 100644 --- a/sass/_footer.scss +++ b/sass/_footer.scss @@ -13,11 +13,11 @@ justify-content: space-between; a { - color: #333; + color: var(--font-color); opacity: 0.4; &:hover { - color: $primary-color; + color: var(--primary-color); opacity: 1; } } diff --git a/sass/_global.scss b/sass/_global.scss index 023021e..86d81b6 100644 --- a/sass/_global.scss +++ b/sass/_global.scss @@ -2,8 +2,9 @@ html, body { font-family: $body-font; font-size: 16px; line-height: 1.5; - background-color: $background-color; - color: $font-color; + background-color: var(--background-color); + color: var(--font-color); + transition: background-color 0.2s ease, color 0.2s ease; @media (max-width: $large-screen) { font-size: 14px; @@ -25,11 +26,11 @@ html, body { } a { - color: $primary-color; + color: var(--primary-color); text-decoration: none; &:hover { - color: rgba($primary-color, 0.8); + color: var(--primary-color-hover); } } diff --git a/sass/_header.scss b/sass/_header.scss index 9e49637..740f96c 100644 --- a/sass/_header.scss +++ b/sass/_header.scss @@ -24,6 +24,7 @@ &-nav { display: flex; + align-items: center; font-size: 1.3rem; @media (max-width: $small-screen) { @@ -31,14 +32,36 @@ } a { - color: #333; + color: var(--font-color); opacity: 0.4; margin-left: 1.5rem; &:hover { - color: $primary-color; + color: var(--primary-color); opacity: 1; } } } + + &-theme-toggle { + background: none; + border: 0; + padding: 0; + margin-left: 1.5rem; + font-family: inherit; + font-size: 1.3rem; + line-height: 1; + color: var(--font-color); + opacity: 0.4; + cursor: pointer; + + @media (max-width: $small-screen) { + font-size: 1.1rem; + } + + &:hover { + color: var(--primary-color); + opacity: 1; + } + } } diff --git a/sass/_theme.scss b/sass/_theme.scss new file mode 100644 index 0000000..78a4269 --- /dev/null +++ b/sass/_theme.scss @@ -0,0 +1,33 @@ +// Theme tokens exposed as CSS custom properties so the palette can switch at +// runtime. SCSS `$` variables (see style.scss) remain the single source of +// truth for the values and are interpolated into the custom properties below. + +@mixin dark-theme { + --background-color: #{$dark-background-color}; + --font-color: #{$dark-font-color}; + color-scheme: dark; +} + +:root { + --primary-color: #{$primary-color}; + --primary-color-hover: #{rgba($primary-color, 0.8)}; + --background-color: #{$background-color}; + --font-color: #{$font-color}; + color-scheme: light; +} + +// Follow the operating system preference, unless the user forced light mode. +@media (prefers-color-scheme: dark) { + :root:not([data-theme='light']) { + @include dark-theme; + } +} + +// Explicit user choice always wins over the system preference. +:root[data-theme='dark'] { + @include dark-theme; +} + +:root[data-theme='light'] { + color-scheme: light; +} diff --git a/sass/style.scss b/sass/style.scss index 91020d2..6b5753a 100755 --- a/sass/style.scss +++ b/sass/style.scss @@ -7,12 +7,17 @@ $primary-color: #FF9900; $background-color: #FFF; $font-color: #333; +// Dark theme colors +$dark-background-color: #121212; +$dark-font-color: #e6e6e6; + // Screen size for responsiveness $small-screen: 400px; $mid-screen: 768px; $large-screen: 1024px; @import './reset'; +@import './theme'; @import './global'; @import './header'; @import './footer'; diff --git a/templates/index.html b/templates/index.html index 2cb01de..0a72569 100644 --- a/templates/index.html +++ b/templates/index.html @@ -11,6 +11,23 @@ /> + + Apoyo +