feat(dark): add dark mode support

This commit is contained in:
Rafael Bardini 2021-03-07 14:50:42 +01:00
parent 7b34043765
commit 21843b6456
4 changed files with 24 additions and 1 deletions

View File

@ -12,6 +12,7 @@ Inspired by [jsonresume-theme-flat](https://github.com/erming/jsonresume-theme-f
- 💄 Markdown support - 💄 Markdown support
- 📐 CSS grid layout - 📐 CSS grid layout
- 🌗 Light and dark modes
- 🧩 Standalone CLI - 🧩 Standalone CLI
[View demo →](https://jsonresume-theme-even.netlify.app) [View demo →](https://jsonresume-theme-even.netlify.app)

View File

@ -23,7 +23,7 @@
"style.css" "style.css"
], ],
"scripts": { "scripts": {
"build:demo": "mkdir public && cat node_modules/resume-schema/sample.resume.json | ./bin/cli.js > public/index.html", "build:demo": "mkdir -p public && cat node_modules/resume-schema/sample.resume.json | ./bin/cli.js > public/index.html",
"format": "prettier --write .", "format": "prettier --write .",
"lint": "eslint .", "lint": "eslint .",
"postinstall": "husky install", "postinstall": "husky install",

View File

@ -1,5 +1,6 @@
:root { :root {
/* Colors */ /* Colors */
--backgroundColor: #ffffff;
--primaryColor: #212529; --primaryColor: #212529;
--secondaryColor: #95a5a6; --secondaryColor: #95a5a6;
--accentColor: #f1c40f; --accentColor: #f1c40f;
@ -16,6 +17,15 @@
--scale5: calc(var(--scale4) * var(--ratio)); --scale5: calc(var(--scale4) * var(--ratio));
} }
@media (prefers-color-scheme: dark) {
:root {
--backgroundColor: #181a1b;
--primaryColor: #d1cdc7;
--secondaryColor: #aaa398;
--mutedColor: #1e2021;
}
}
* { * {
box-sizing: border-box; box-sizing: border-box;
margin: 0; margin: 0;
@ -27,6 +37,7 @@ html {
} }
body { body {
background: var(--backgroundColor);
color: var(--primaryColor); color: var(--primaryColor);
display: grid; display: grid;
font: 1em/1.5 Lato, sans-serif; font: 1em/1.5 Lato, sans-serif;

View File

@ -16,6 +16,7 @@ exports[`test/render.js TAP renders a resume > must match snapshot 1`] = `
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,700&display=swap"> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,700&display=swap">
<style>:root { <style>:root {
/* Colors */ /* Colors */
--backgroundColor: #ffffff;
--primaryColor: #212529; --primaryColor: #212529;
--secondaryColor: #95a5a6; --secondaryColor: #95a5a6;
--accentColor: #f1c40f; --accentColor: #f1c40f;
@ -32,6 +33,15 @@ exports[`test/render.js TAP renders a resume > must match snapshot 1`] = `
--scale5: calc(var(--scale4) * var(--ratio)); --scale5: calc(var(--scale4) * var(--ratio));
} }
@media (prefers-color-scheme: dark) {
:root {
--backgroundColor: #181a1b;
--primaryColor: #d1cdc7;
--secondaryColor: #aaa398;
--mutedColor: #1e2021;
}
}
* { * {
box-sizing: border-box; box-sizing: border-box;
margin: 0; margin: 0;
@ -43,6 +53,7 @@ html {
} }
body { body {
background: var(--backgroundColor);
color: var(--primaryColor); color: var(--primaryColor);
display: grid; display: grid;
font: 1em/1.5 Lato, sans-serif; font: 1em/1.5 Lato, sans-serif;