Skip to content
This repository has been archived by the owner on Feb 3, 2024. It is now read-only.

Commit

Permalink
fixes things
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanVann committed Oct 10, 2020
1 parent 37c9adc commit 48978ef
Show file tree
Hide file tree
Showing 17 changed files with 1,742 additions and 284 deletions.
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# 🌚🌝 Perfect Color Mode

Perfect color mode implementation.

- No flicker.
- Framework agnostic (easily supports React/Vue/Svelte).
- Framework agnostic, supports **React** | **Vue** | **Svelte** | etc.
- Supports SSR.
- Supports no-js.
- Tiny - 498B gzipped.
Expand All @@ -21,6 +19,7 @@ A class indicating the color mode will be added to `<html>` (e.g. `dark` or `lig
This is done before the rest of your page is rendered (that's why it needs to be in head).

To style your color modes you can use CSS variables, e.g.
You can add `@media (prefers-color-scheme: dark/light)` queries to support users with JS disabled.

```css
@media (prefers-color-scheme: dark) {
Expand Down Expand Up @@ -59,12 +58,10 @@ In the rest of your app use `--color` and `--background` as needed.

- You can `subscribe` to the mode, this can be used for rendering a toggle component.
- The first call of your listener is synchronous so you can get the value before rendering.
- You can `get` the mode if you want a more convenient way to synchronously get the mode

```js
const { mode } = window.__perfect_color_mode__
const unsubscribe = mode.subscribe((v) => console.log(v))
const currentMode = mode.get()
```

**Setting:**
Expand Down
91 changes: 2 additions & 89 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion dist/index.min.js

This file was deleted.

134 changes: 0 additions & 134 deletions example.html

This file was deleted.

40 changes: 0 additions & 40 deletions example.pug

This file was deleted.

10 changes: 10 additions & 0 deletions examples/vanilla/features.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- No flicker.
- Framework agnostic, supports **React** | **Vue** | **Svelte** | etc.
- Supports SSR.
- Supports no-js.
- Tiny - 498B gzipped.
- Supports `prefers-color-scheme`.
- Listens for changes to `prefers-color-scheme`.
- Allows user to override and save their preference to `localStorage`.
- Allows clearing the saved preference and falling back to `prefers-color-scheme`.
- Built for the web.
35 changes: 35 additions & 0 deletions examples/vanilla/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@media (prefers-color-scheme: dark) {
:root {
--color: white;
--background: black;
}
}

@media (prefers-color-scheme: light) {
:root {
--color: black;
--background: white;
}
}

:root.light {
--color: black;
--background: white;
}

:root.dark {
--color: white;
--background: black;
}

:root {
color: var(--color);
background: var(--background);
font-family: sans-serif;
transition: all 0.5s;
}

body {
max-width: 60ch;
margin: 0 auto;
}
Loading

0 comments on commit 48978ef

Please sign in to comment.