Skip to content

Commit 96fbe19

Browse files
JahkamsoDun-sin
andauthored
feat: added dark/light mode (#13)
* feature: added dark/light mode * Update src/components/Header.jsx * Update src/App.jsx --------- Co-authored-by: Dunsin <78784850+Dun-sin@users.noreply.github.com>
1 parent 1f9eecd commit 96fbe19

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

package-lock.json

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@tailwindcss/typography": "^0.5.8",
1717
"react": "^18.2.0",
1818
"react-dom": "^18.2.0",
19+
"react-icons": "^5.0.1",
1920
"spotify-web-api-node": "^5.0.2"
2021
},
2122
"devDependencies": {

src/App.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const spotifyApi = new SpotifyWebApi({
1616

1717
const App = () => {
1818
const [isConnected, setIsConnected] = useState(false)
19+
const [theme, setTheme] = useState(false)
1920

2021
useEffect(() => {
2122
const hash = window.location.hash;
@@ -40,8 +41,8 @@ const App = () => {
4041
}
4142

4243
return (
43-
<div className='h-screen flex flex-col gap-10 overflow-hidden'>
44-
<Header />
44+
<div className={`h-screen flex flex-col gap-10 overflow-hidden transition-all ${theme && ' bg-[#001524] text-white'}`}>
45+
<Header theme={theme} setTheme={setTheme} />
4546
<div className='h-[85%] flex flex-col gap-4 items-center justify-center'>
4647
{isConnected ? <p className='bg-brand sm:min-w-[40vw] max-w-[500px] min-w-[300px] flex items-center justify-center rounded text-white h-10 cursor-pointer' onClick={logOut}>Logout</p> : <Login />}
4748
<GeneratePlaylist isConnected={isConnected} logOut={logOut} />

src/components/Header.jsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
1-
import React from 'react'
1+
import React, { useState } from 'react'
22
import { Icon } from '@iconify/react'
3+
import { MdLightMode } from "react-icons/md";
4+
import { MdDarkMode } from "react-icons/md";
35

4-
const Header = () => {
6+
const Header = ({theme, setTheme}) => {
57
return (
68
<div className='bg-brand flex items-center justify-between p-6 text-white min-h-[5%]'>
79
<div className='flex flex-col'>
810
<h1 className='font-bold mb-[-6px] text-fmd flex items-center'>HearItFresh<Icon icon="material-symbols:music-note-rounded" width="20" height="20" inline={true} /></h1>
911
<p className='text-fsm'>Discover Fresh Tracks that Fit Your Style</p>
1012
</div>
13+
<div className="flex items-center gap-5">
1114
<a href='https://www.buymeacoffee.com/dunsinCodes' target='_blank' className='bg-yellow-500 h-8 w-28 text-fxs rounded-lg flex items-center justify-center cursor-pointer sm:w-40 font-semibold'>
1215
Buy Me A Coffee
1316
</a>
17+
<div className='text-xl cursor-pointer' onClick={() => setTheme(prev => !prev)}>
18+
{theme ? (
19+
<MdLightMode />
20+
) : (
21+
<MdDarkMode />
22+
)}
23+
</div>
24+
</div>
1425
</div>
1526
)
1627
}

0 commit comments

Comments
 (0)