Skip to content

Commit

Permalink
feat: added dark/light mode (#13)
Browse files Browse the repository at this point in the history
* feature: added dark/light mode

* Update src/components/Header.jsx

* Update src/App.jsx

---------

Co-authored-by: Dunsin <[email protected]>
  • Loading branch information
Jahkamso and Dun-sin authored Jan 12, 2024
1 parent 1f9eecd commit 96fbe19
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@tailwindcss/typography": "^0.5.8",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^5.0.1",
"spotify-web-api-node": "^5.0.2"
},
"devDependencies": {
Expand Down
5 changes: 3 additions & 2 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const spotifyApi = new SpotifyWebApi({

const App = () => {
const [isConnected, setIsConnected] = useState(false)
const [theme, setTheme] = useState(false)

useEffect(() => {
const hash = window.location.hash;
Expand All @@ -40,8 +41,8 @@ const App = () => {
}

return (
<div className='h-screen flex flex-col gap-10 overflow-hidden'>
<Header />
<div className={`h-screen flex flex-col gap-10 overflow-hidden transition-all ${theme && ' bg-[#001524] text-white'}`}>
<Header theme={theme} setTheme={setTheme} />
<div className='h-[85%] flex flex-col gap-4 items-center justify-center'>
{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 />}
<GeneratePlaylist isConnected={isConnected} logOut={logOut} />
Expand Down
15 changes: 13 additions & 2 deletions src/components/Header.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
import React from 'react'
import React, { useState } from 'react'
import { Icon } from '@iconify/react'
import { MdLightMode } from "react-icons/md";
import { MdDarkMode } from "react-icons/md";

const Header = () => {
const Header = ({theme, setTheme}) => {
return (
<div className='bg-brand flex items-center justify-between p-6 text-white min-h-[5%]'>
<div className='flex flex-col'>
<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>
<p className='text-fsm'>Discover Fresh Tracks that Fit Your Style</p>
</div>
<div className="flex items-center gap-5">
<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'>
Buy Me A Coffee
</a>
<div className='text-xl cursor-pointer' onClick={() => setTheme(prev => !prev)}>
{theme ? (
<MdLightMode />
) : (
<MdDarkMode />
)}
</div>
</div>
</div>
)
}
Expand Down

1 comment on commit 96fbe19

@vercel
Copy link

@vercel vercel bot commented on 96fbe19 Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

hear-it-fresh – ./

hear-it-fresh-git-main-dun-sin.vercel.app
hear-it-fresh-dun-sin.vercel.app
hearitfresh.vercel.app

Please sign in to comment.