1.0.0 • Published 3 years ago

gatsby-plugin-perfect-dark-mode v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
3 years ago

gatsby-plugin-perfect-dark-mode

Version Size

This plugin makes it easy to add perfect-dark-mode to Gatsby.

Installation

You do not need to add perfect-dark-mode to <head> like you do for react-perfect-dark-mode. This plugin puts perfect-dark-mode in <head> for you.

yarn add gatsby-plugin-perfect-dark-mode

Add gatsby-plugin-perfect-dark-mode to your gatsby-config.js file.

Usage

In a component you can use the hook:

import React from 'react'
import { usePerfectDarkMode } from 'gatsby-plugin-perfect-dark-mode'

export const Toggle = () => {
  const { mode, updateMode } = usePerfectDarkMode()
  return (
    <button
      style={{ visibility: mode !== undefined ? 'visible' : 'hidden' }}
      onClick={() =>
        updateMode(
          (mode, modes, modeIndex) => modes[(modeIndex + 1) % modes.length],
        )
      }
    >
      {mode}
    </button>
  )
}
1.0.0

3 years ago

0.0.25

3 years ago

0.0.19

3 years ago

0.0.18

4 years ago

0.0.17

4 years ago

0.0.14

4 years ago

0.0.15

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.7

4 years ago