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

Commit 6db95bc

Browse files
committed
docs: add links to other packages
1 parent 4de4965 commit 6db95bc

3 files changed

Lines changed: 126 additions & 1 deletion

File tree

packages/docs/markdown/features.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
- No flicker.
2-
- Framework agnostic, supports **React** | **Vue** | **Svelte** | etc.
2+
- Framework agnostic, easily supports **React** | **Vue** | **Svelte** | etc.
3+
- [`react-perfect-dark-mode`](https://github.com/DylanVann/perfect-dark-mode/tree/main/packages/react-perfect-dark-mode)
4+
- [`gatsby-plugin-perfect-dark-mode`](https://github.com/DylanVann/perfect-dark-mode/tree/main/packages/gatsby-plugin-perfect-dark-mode)
35
- Supports SSR.
46
- Supports no-js.
57
- Tiny, less than 1kb.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# gatsby-plugin-perfect-dark-mode
2+
3+
![Example!](https://perfect-dark-mode-gatsby.netlify.app/)
4+
5+
## Installation
6+
7+
```bash
8+
yarn add gatsby-plugin-perfect-dark-mode
9+
```
10+
11+
## Setup
12+
13+
Add `gatsby-plugin-perfect-dark-mode` to your `gatsby-config.js` file.
14+
15+
You'll need to add some CSS.
16+
17+
```css
18+
@media (prefers-color-scheme: light) {
19+
:root {
20+
--color-background: #fff;
21+
--color-primary: #005b99;
22+
--color-text: #2e353f;
23+
--color-text-light: #4f5969;
24+
--color-heading: #1a202c;
25+
--color-heading-black: black;
26+
--color-accent: #d1dce5;
27+
}
28+
}
29+
30+
:root.light {
31+
--color-background: #fff;
32+
--color-primary: #005b99;
33+
--color-text: #2e353f;
34+
--color-text-light: #4f5969;
35+
--color-heading: #1a202c;
36+
--color-heading-black: black;
37+
--color-accent: #d1dce5;
38+
}
39+
40+
@media (prefers-color-scheme: dark) {
41+
:root {
42+
--color-background: #000;
43+
--color-primary: #005b99;
44+
--color-text: #fff;
45+
--color-text-light: #fff;
46+
--color-heading: #fff;
47+
--color-heading-black: white;
48+
--color-accent: #d1dce5;
49+
}
50+
}
51+
52+
:root.dark {
53+
--color-background: #000;
54+
--color-primary: #005b99;
55+
--color-text: #fff;
56+
--color-text-light: #fff;
57+
--color-heading: #fff;
58+
--color-heading-black: white;
59+
--color-accent: #d1dce5;
60+
}
61+
62+
:root {
63+
color: var(--color);
64+
background: var(--color-background);
65+
}
66+
```
67+
68+
## Usage
69+
70+
In a component you can use the hook:
71+
72+
```js
73+
import { usePerfectDarkMode } from 'gatsby-plugin-perfect-dark-mode'
74+
75+
export const Toggle = () => {
76+
const { mode, updateMode } = usePerfectDarkMode()
77+
const [visible, setVisible] = useState(false)
78+
useEffect(() => setVisible(true), [])
79+
return () => (
80+
<button
81+
style={{ visibility: visible ? 'visible' : 'hidden' }}
82+
onClick={() =>
83+
updateMode(
84+
(mode, modes, modeIndex) => modes[(modeIndex + 1) % modes.length],
85+
)
86+
}
87+
>
88+
{mode}
89+
</button>
90+
)
91+
}
92+
```
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# react-perfect-dark-mode
2+
3+
## Installation
4+
5+
```bash
6+
yarn add react-perfect-dark-mode
7+
```
8+
9+
## Usage
10+
11+
```js
12+
import { usePerfectDarkMode } from 'gatsby-plugin-perfect-dark-mode'
13+
14+
export const Toggle = () => {
15+
const { mode, updateMode } = usePerfectDarkMode()
16+
const [visible, setVisible] = useState(false)
17+
useEffect(() => setVisible(true), [])
18+
return () => (
19+
<button
20+
style={{ visibility: visible ? 'visible' : 'hidden' }}
21+
onClick={() =>
22+
updateMode(
23+
(mode, modes, modeIndex) => modes[(modeIndex + 1) % modes.length],
24+
)
25+
}
26+
>
27+
{mode}
28+
</button>
29+
)
30+
}
31+
```

0 commit comments

Comments
 (0)