diff --git a/src/components/ThemeMode/ThemeMode.stories.tsx b/src/components/ThemeMode/ThemeMode.stories.tsx new file mode 100644 index 00000000..41348e9e --- /dev/null +++ b/src/components/ThemeMode/ThemeMode.stories.tsx @@ -0,0 +1,10 @@ +import { ThemeMode } from './ThemeMode'; + +export default { + title: 'Components/Theme Mode', + component: ThemeMode, +}; + +export const _ThemeMode = { + render: () => , +}; diff --git a/src/components/ThemeMode/ThemeMode.test.tsx b/src/components/ThemeMode/ThemeMode.test.tsx new file mode 100644 index 00000000..6fc2fd5a --- /dev/null +++ b/src/components/ThemeMode/ThemeMode.test.tsx @@ -0,0 +1,13 @@ +import '@testing-library/jest-dom'; +import { render, screen } from '@testing-library/react'; +import { ThemeMode } from './ThemeMode'; + +describe('Components | Button | ThemeMode', () => { + test('it should render', () => { + render(); + + let button = screen.getByTestId('theme-mode'); + + expect(button).toBeInTheDocument(); + }); +}); diff --git a/src/components/ThemeMode/ThemeMode.tsx b/src/components/ThemeMode/ThemeMode.tsx new file mode 100644 index 00000000..d0736ac1 --- /dev/null +++ b/src/components/ThemeMode/ThemeMode.tsx @@ -0,0 +1,38 @@ +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore +import React from 'react'; + +import { FiMoon, FiSun } from 'react-icons/fi'; +import { useLocalStorage } from '../../util/useLocalStorage'; + +export function ThemeMode() { + const [theme, setTheme] = useLocalStorage( + 'massa-station-theme', + 'dark', + ); + + function handleClick() { + setTheme(theme === 'dark' ? 'light' : 'dark'); + } + + const themeIcons = { + dark: , + light: , + }; + + return ( + + ); +} diff --git a/src/components/ThemeMode/index.ts b/src/components/ThemeMode/index.ts new file mode 100644 index 00000000..d9028641 --- /dev/null +++ b/src/components/ThemeMode/index.ts @@ -0,0 +1 @@ +export * from './ThemeMode'; diff --git a/src/components/index.ts b/src/components/index.ts index 36a66fd4..2558e0f5 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -10,3 +10,4 @@ export * from './SideMenu'; export * from './Icons'; export * from './Toggle'; export * from './Balance'; +export * from './ThemeMode';