UNPKG

jobiqo-cl

Version:

[![CircleCI](https://circleci.com/gh/jobiqo/jobiqo-cl.svg?style=svg&circle-token=5a24efa5b8bbc4879276123e77d0d3f35ca7144c)](https://circleci.com/gh/jobiqo/jobiqo-cl)

33 lines (30 loc) 1.02 kB
import React__default, { useState } from 'react'; import ToggleSwitch from '../../02-atoms/01-forms/10-toggle/index.js'; /** * @file index.tsx * * @fileoverview A theme toggle to swith between light and dark mode. */ const modes = [ { name: 'light', title: 'Light', icon: 'sun' }, { name: 'dark', title: 'Dark', icon: 'moon' } ]; /** * A theme toggle to swith between light and dark mode. */ const ToggleDarkTheme = ({ onClick }) => { const [currentTheme, setTheme] = useState(modes[0].name); return (React__default.createElement(ToggleSwitch, { id: "toggle-theme-mode", label: modes.filter(f => f.name === currentTheme)[0].title, onChange: () => { setTheme(currentTheme === 'light' ? 'dark' : 'light'); onClick(currentTheme === 'light' ? 'dark' : 'light'); }, switchStyle: "primary", textOn: "\uD83C\uDF19", textOff: "\uD83D\uDD05", width: 50 })); }; export { ToggleDarkTheme };