2021-04-14 05:01:58 -07:00
|
|
|
import { useEffect, useState } from 'react'
|
|
|
|
import { useTheme } from 'next-themes'
|
|
|
|
import { MoonIcon, SunIcon } from '@heroicons/react/outline'
|
|
|
|
import DropMenu from './DropMenu'
|
2021-04-15 06:22:39 -07:00
|
|
|
import { MangoIcon } from './icons'
|
2021-10-20 05:42:40 -07:00
|
|
|
import { useTranslation } from 'next-i18next'
|
2021-04-14 05:01:58 -07:00
|
|
|
|
|
|
|
const THEMES = [
|
2021-05-07 12:41:26 -07:00
|
|
|
{ name: 'Light', icon: <SunIcon className="h-4 w-4" /> },
|
|
|
|
{ name: 'Dark', icon: <MoonIcon className="h-4 w-4" /> },
|
|
|
|
{ name: 'Mango', icon: <MangoIcon className="stroke-current h-4 w-4" /> },
|
2021-04-14 05:01:58 -07:00
|
|
|
]
|
|
|
|
|
|
|
|
const ThemeSwitch = () => {
|
2021-10-20 05:42:40 -07:00
|
|
|
const { t } = useTranslation('common')
|
2021-04-14 05:01:58 -07:00
|
|
|
const [mounted, setMounted] = useState(false)
|
|
|
|
const { theme, setTheme } = useTheme()
|
|
|
|
|
|
|
|
// When mounted on client, now we can show the UI
|
|
|
|
useEffect(() => setMounted(true), [])
|
|
|
|
|
User account page (#22)
* layout, overview, start on assets, borrows and open orders
* trade history, sortable data hook for tables, borrow page
* handle deposit and withdraw buttons
* borrow modal ui and integration + settle borrow for individual assets
* in orders balance to asset table and totals, responsive css, new connected wallet button + small tweaks
* account switch/creation flow
* accounts modal, update to usebalances hook
* handle settle, deposit before settle, save last account
* disable borrow/withdraw button when no account
2021-06-05 07:11:44 -07:00
|
|
|
return mounted ? (
|
2021-04-14 05:01:58 -07:00
|
|
|
<DropMenu
|
|
|
|
button={
|
2021-07-30 03:30:58 -07:00
|
|
|
<div className="bg-th-bkg-4 flex items-center justify-center rounded-full w-8 h-8 text-th-fgd-1 focus:outline-none hover:text-th-primary">
|
|
|
|
{THEMES.find((t) => t.name === theme).icon}
|
|
|
|
</div>
|
2021-04-14 05:01:58 -07:00
|
|
|
}
|
|
|
|
value={theme}
|
|
|
|
onChange={(theme) => setTheme(theme)}
|
|
|
|
options={THEMES}
|
2021-10-20 05:42:40 -07:00
|
|
|
toolTipContent={t('change-theme')}
|
2021-04-14 05:01:58 -07:00
|
|
|
/>
|
User account page (#22)
* layout, overview, start on assets, borrows and open orders
* trade history, sortable data hook for tables, borrow page
* handle deposit and withdraw buttons
* borrow modal ui and integration + settle borrow for individual assets
* in orders balance to asset table and totals, responsive css, new connected wallet button + small tweaks
* account switch/creation flow
* accounts modal, update to usebalances hook
* handle settle, deposit before settle, save last account
* disable borrow/withdraw button when no account
2021-06-05 07:11:44 -07:00
|
|
|
) : (
|
|
|
|
<div className="bg-th-bkg-3 rounded-full w-8 h-8" />
|
2021-04-14 05:01:58 -07:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ThemeSwitch
|