-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from ManishMadan2882/main
Feature: Download data as CSV, Dark theme, submit benchmark
- Loading branch information
Showing
7 changed files
with
164 additions
and
48 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React, { createContext, useContext, useState, useEffect, ReactNode } from 'react'; | ||
|
||
interface ThemeContextType { | ||
isDarkTheme: boolean; | ||
toggleTheme: () => void; | ||
} | ||
|
||
const ThemeContext = createContext<ThemeContextType | undefined>(undefined); | ||
|
||
interface ThemeProviderProps { | ||
children: ReactNode; | ||
} | ||
|
||
export const ThemeProvider: React.FC<ThemeProviderProps> = ({ children }) => { | ||
const [isDarkTheme, setIsDarkTheme] = useState<boolean>( | ||
localStorage.getItem('user-theme') === 'dark' || false, | ||
); | ||
|
||
useEffect(() => { | ||
localStorage.setItem('user-theme', isDarkTheme ? 'dark' : 'light'); | ||
if (isDarkTheme) { | ||
document.body.classList.add('dark'); | ||
} else { | ||
document.body.classList.remove('dark'); | ||
} | ||
}, [isDarkTheme]); | ||
|
||
const toggleTheme = () => { | ||
setIsDarkTheme(!isDarkTheme); | ||
}; | ||
|
||
return ( | ||
<ThemeContext.Provider value={{ isDarkTheme, toggleTheme }}> | ||
{children} | ||
</ThemeContext.Provider> | ||
); | ||
}; | ||
|
||
|
||
export const useTheme = (): ThemeContextType => { | ||
const context = useContext(ThemeContext); | ||
if (context === undefined) { | ||
throw new Error('useTheme must be used within a ThemeProvider'); | ||
} | ||
return context; | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,40 @@ | ||
import Compass from '@/assets/compass.svg' | ||
import Sun from '@/assets/day-sunny.svg' | ||
import Moon from '@/assets/moon.svg' | ||
import Github from '@/assets/git.svg' | ||
import Twitter from '@/assets/x.svg' | ||
import { useTheme } from '@/ThemeContext'; | ||
|
||
const Nav = () => { | ||
return ( | ||
<div className='flex justify-between items-baseline'> | ||
<div className='flex gap-2'> | ||
<img src={Compass} className=''/> | ||
<span className='text-[#18181B] font-bold'>Compass</span> | ||
<span className='text-[#8B8989]'>by Arc53</span> | ||
</div> | ||
<div className='flex gap-4'> | ||
<a href='https://github.com/arc53/docsgpt'> | ||
<img src={Github}/> | ||
</a> | ||
<a href='https://x.com/docsgptai'> | ||
<img src={Twitter}/> | ||
</a> | ||
<button> | ||
<img src={Sun}/> | ||
</button> | ||
|
||
const { isDarkTheme, toggleTheme } = useTheme(); | ||
|
||
return ( | ||
<div className='flex justify-between items-baseline'> | ||
<div className='flex gap-2'> | ||
<img src={Compass} className='filter dark:invert' /> | ||
<span className='text-[#18181B] font-bold dark:text-white'>Compass</span> | ||
<span className='text-[#8B8989]'>by Arc53</span> | ||
</div> | ||
<div className='flex gap-4'> | ||
<a target='_blank' href='https://github.com/arc53/docsgpt'> | ||
<img className='filter dark:invert' src={Github} /> | ||
</a> | ||
<a target='_blank' href='https://x.com/docsgptai'> | ||
<img className='filter dark:invert' src={Twitter} /> | ||
</a> | ||
<button | ||
id='theme' | ||
onClick={toggleTheme}>{ | ||
isDarkTheme ? | ||
<img className='filter dark' src={Moon} /> | ||
: | ||
<img className='filter dark:invert' src={Sun} /> | ||
} | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
) | ||
} | ||
|
||
export default Nav |
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
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
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