Created
January 14, 2021 11:23
-
-
Save fResult/581ea6978450f256a000e6398acffdc1 to your computer and use it in GitHub Desktop.
Change your code in App.tsx file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useContext } from 'react'; | |
import './App.css'; | |
import { ThemeContext } from './ThemeProvider'; | |
function App() { | |
const { theme, setTheme } = useContext(ThemeContext) | |
const isDark = theme === 'dark' | |
return ( | |
<div className="bg-light-bg dark:bg-dark-bg text-light-text dark:text-dark-text h-screen flex flex-col justify-center items-center"> | |
<button | |
className="block py-4 px-8 rounded-md bg-light-elem dark:bg-dark-elem shadow-xl focus:outline-none hover:border-green-900 hover:bg-blue-50 dark:hover:bg-gray-600" | |
onClick={() => { | |
setTheme && setTheme(isDark ? 'light' : 'dark') | |
}} | |
> | |
{isDark ? 'Light' : 'Dark'} Mode | |
</button> | |
<div className="my-4 hello"> | |
<label className="mr-6">Your Name:</label> | |
<input className="rounded-md h-14 w-96 p-4 shadow-xl focus:outline-none" /> | |
</div> | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment