mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 10:20:09 +02:00
refactor(v2): split out dark mode toggle so it is easily swizzle-able (#2013)
This commit is contained in:
parent
d2a095bec0
commit
4fab29fb21
4 changed files with 187 additions and 166 deletions
27
packages/docusaurus-theme-classic/src/theme/Toggle/index.js
Normal file
27
packages/docusaurus-theme-classic/src/theme/Toggle/index.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
/**
|
||||
* Copyright (c) 2017-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import Toggle from 'react-toggle';
|
||||
|
||||
import classnames from 'classnames';
|
||||
import styles from './styles.module.css';
|
||||
|
||||
const Moon = () => <span className={classnames(styles.toggle, styles.moon)} />;
|
||||
const Sun = () => <span className={classnames(styles.toggle, styles.sun)} />;
|
||||
|
||||
export default function(props) {
|
||||
return (
|
||||
<Toggle
|
||||
icons={{
|
||||
checked: <Moon />,
|
||||
unchecked: <Sun />,
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue