2021-05-17 22:33:04 -07:00
|
|
|
import { TemplateIcon } from '@heroicons/react/outline'
|
2021-05-01 21:31:55 -07:00
|
|
|
import { defaultLayouts, GRID_LAYOUT_KEY } from './TradePageGrid'
|
2021-04-22 05:33:35 -07:00
|
|
|
import useLocalStorageState from '../hooks/useLocalStorageState'
|
2021-04-22 07:45:36 -07:00
|
|
|
import Tooltip from './Tooltip'
|
2021-07-29 06:19:32 -07:00
|
|
|
import { IconButton } from './Button'
|
2021-10-20 05:42:40 -07:00
|
|
|
import { useTranslation } from 'next-i18next'
|
2021-04-22 05:33:35 -07:00
|
|
|
|
|
|
|
const ResetLayout = ({ className = '' }) => {
|
2021-10-20 05:42:40 -07:00
|
|
|
const { t } = useTranslation('common')
|
2021-04-22 05:33:35 -07:00
|
|
|
const [, setSavedLayouts] = useLocalStorageState(
|
2021-05-01 21:31:55 -07:00
|
|
|
GRID_LAYOUT_KEY,
|
2021-04-22 05:33:35 -07:00
|
|
|
defaultLayouts
|
|
|
|
)
|
|
|
|
|
2021-04-22 06:10:43 -07:00
|
|
|
const handleResetLayout = () => {
|
|
|
|
setSavedLayouts(defaultLayouts)
|
|
|
|
}
|
|
|
|
|
2021-04-22 05:33:35 -07:00
|
|
|
return (
|
2022-03-09 12:53:11 -08:00
|
|
|
<div className={`relative inline-flex ${className}`}>
|
|
|
|
<Tooltip content={t('tooltip-reset-layout')} className="py-1 text-xs">
|
2021-07-29 06:19:32 -07:00
|
|
|
<IconButton onClick={handleResetLayout}>
|
2022-03-09 12:53:11 -08:00
|
|
|
<TemplateIcon className="h-4 w-4" />
|
2021-07-29 06:19:32 -07:00
|
|
|
</IconButton>
|
2021-04-22 07:45:36 -07:00
|
|
|
</Tooltip>
|
2021-04-22 05:33:35 -07:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ResetLayout
|