diff options
author | Nick Van Doorn <vandoorn.nick@gmail.com> | 2019-04-05 15:46:27 -0700 |
---|---|---|
committer | Nick Van Doorn <vandoorn.nick@gmail.com> | 2019-04-05 15:46:27 -0700 |
commit | 4827771b0a45b8c66d30f73e4e5d6fd59baa4251 (patch) | |
tree | fee22a18e9a791502350f8fda3c2619d34b5eca8 | |
parent | fa0d37650d6e43bbd846260da5e42f30f354c707 (diff) |
Implement simple theme toggle component
-rw-r--r-- | src/components/theme-switcher.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/components/theme-switcher.js b/src/components/theme-switcher.js new file mode 100644 index 0000000..a24e634 --- /dev/null +++ b/src/components/theme-switcher.js @@ -0,0 +1,30 @@ +import React from 'react' +import { css } from '@emotion/core' + +const buttonStyle = ({ margins, colours, radius }) => css` + border: none; + background: none; + margin: ${margins.sm}px; + font-size: 1.3em; +` + +export const ThemeSwitcher = ({ themes, onClick, currentTheme }) => { + const nextTheme = themes.find(theme => theme.key !== currentTheme) + return ( + <div + css={css` + top: 0; + right: 0; + position: absolute; + `} + > + <button + css={buttonStyle} + key={nextTheme} + onClick={e => onClick(nextTheme.key)} + > + {nextTheme.name} + </button> + </div> + ) +} |