mango-ui-v3/components/ResetLayout.tsx

31 lines
891 B
TypeScript
Raw Normal View History

import { TemplateIcon } from '@heroicons/react/outline'
2021-05-01 21:31:55 -07:00
import { defaultLayouts, GRID_LAYOUT_KEY } from './TradePageGrid'
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'
import { useTranslation } from 'next-i18next'
const ResetLayout = ({ className = '' }) => {
const { t } = useTranslation('common')
const [, setSavedLayouts] = useLocalStorageState(
2021-05-01 21:31:55 -07:00
GRID_LAYOUT_KEY,
defaultLayouts
)
2021-04-22 06:10:43 -07:00
const handleResetLayout = () => {
setSavedLayouts(defaultLayouts)
}
return (
<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}>
<TemplateIcon className="h-4 w-4" />
2021-07-29 06:19:32 -07:00
</IconButton>
2021-04-22 07:45:36 -07:00
</Tooltip>
</div>
)
}
export default ResetLayout