1
0
mirror of https://github.com/jenil/chota.git synced 2023-08-10 21:13:07 +03:00

initial dark-mode config

This commit is contained in:
Gaurav Panchal 2020-05-16 12:55:27 +05:30
parent 2806b45f69
commit 8eae720abc
4 changed files with 46 additions and 2 deletions

View File

@ -1,3 +1,10 @@
body.dark {
--body-bg-color: #000;
--font-color: #f5f5f5;
--color-grey: #ccc;
--color-darkGrey: #aaa;
}
body>.container {
max-width: 720px;
}
@ -26,6 +33,10 @@ body>footer {
padding: 4rem;
}
body.dark>footer {
background-color: #1a1a1a;
}
section {
margin: 5rem auto;
}

View File

@ -9,6 +9,7 @@
<title>chota - A micro CSS framework</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://unpkg.com/chota">
<!-- <link rel="stylesheet" href="./dist/chota.css"> -->
<link rel="stylesheet" href="./doc-styles.css">
<link rel="icon" type="image/png" href="favicon.png" />
</head>
@ -26,6 +27,15 @@
<a href="#start">start</a>
<a href="#docs">docs</a>
<a href="https://github.com/jenil/chota">GitHub</a>
<a
href="javascript:void(0)"
onclick="
const bodyClass = document.body.classList;
bodyClass.contains('dark')
? (this.innerHTML = '☀️', bodyClass.remove('dark'))
: (this.innerHTML = '🌙', bodyClass.add('dark'));
"
>☀️</a>
</nav>
</div>
@ -38,6 +48,7 @@
<li>🌈&nbsp; Easy to <a href="#customizing">extend</a> with CSS variables</li>
<li>🎲&nbsp; Comes with a handful of <a href="#components">components</a> &amp; <a href="#utilities">utilities</a></li>
<li>&nbsp; Good Semantics</li>
<li>🌙&nbsp; Easy Dark Mode switch</li>
<li>🤡&nbsp; Supports <a href="#icons">icons</a> out-of-the-box</li>
</ul>
</section>
@ -107,6 +118,24 @@
}
/* Other styles..... */
{% endhighlight %}
<br>
<p>Addtionally, you can add dark mode to you site, to support devices that prefer dark mode.</p>
{% highlight html %}
<style>
body.dark {
--body-bg-color: #000;
--font-color: #f5f5f5;
--color-grey: #ccc;
--color-darkGrey: #aaa;
}
</style>
<script>
if (window.matchMedia &&
window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.body.classList.add('dark');
}
</script>
{% endhighlight %}
</section>
<section id="components">

View File

@ -1,4 +1,5 @@
:root {
--body-bg-color: #ffffff;
--color-primary: #14854F;
--color-lightGrey: #d2d6dd;
--color-grey: #747681;
@ -8,6 +9,7 @@
--grid-maxWidth: 120rem;
--grid-gutter: 2rem;
--font-size: 1.6rem;
--font-color: #333333;
--font-family-sans: -apple-system, BlinkMacSystemFont, Avenir, "Avenir Next",
"Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans",
"Droid Sans", "Helvetica Neue", sans-serif;
@ -27,8 +29,10 @@ html {
}
body {
background-color: var(--body-bg-color);
line-height: 1.6;
font-size: var(--font-size);
color: var(--font-color);
font-family: "Segoe UI", "Helvetica Neue", sans-serif; /*fallback*/
font-family: var(--font-family-sans);
margin: 0;

View File

@ -1,8 +1,8 @@
.card {
padding: 1rem 2rem;
border-radius: 4px;
background: white;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
background: var(--body-bg-color);
box-shadow: 0 1px 3px var(--color-grey);
}
.card p:last-child {