2021-04-13 09:51:42 -07:00
|
|
|
import { LockClosedIcon, LockOpenIcon } from '@heroicons/react/outline'
|
2021-04-22 05:33:35 -07:00
|
|
|
import { Transition } from '@headlessui/react'
|
2021-04-13 09:51:42 -07:00
|
|
|
import useMangoStore from '../stores/useMangoStore'
|
2021-04-22 05:33:35 -07:00
|
|
|
import ResetLayout from './ResetLayout'
|
2021-04-24 15:02:13 -07:00
|
|
|
import Tooltip from './Tooltip'
|
2021-04-13 09:51:42 -07:00
|
|
|
|
|
|
|
const UiLock = ({ className = '' }) => {
|
|
|
|
const set = useMangoStore((s) => s.set)
|
|
|
|
const uiLocked = useMangoStore((s) => s.settings.uiLocked)
|
|
|
|
|
|
|
|
const handleClick = () => {
|
|
|
|
set((state) => {
|
|
|
|
state.settings.uiLocked = !uiLocked
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2021-04-22 05:33:35 -07:00
|
|
|
<>
|
|
|
|
{!uiLocked ? (
|
|
|
|
<Transition
|
|
|
|
appear={true}
|
|
|
|
show={!uiLocked}
|
|
|
|
enter="transition-opacity duration-500"
|
|
|
|
enterFrom="opacity-0"
|
|
|
|
enterTo="opacity-100"
|
|
|
|
leave="transition-opacity duration-500"
|
|
|
|
leaveFrom="opacity-100"
|
|
|
|
leaveTo="opacity-0"
|
|
|
|
>
|
|
|
|
<ResetLayout />
|
|
|
|
</Transition>
|
|
|
|
) : null}
|
2021-04-24 15:02:13 -07:00
|
|
|
<div className={`${className} flex relative mr-4`}>
|
|
|
|
<Tooltip
|
|
|
|
content={uiLocked ? 'Unlock Layout' : 'Lock Layout'}
|
|
|
|
className="text-xs py-1"
|
2021-04-22 05:33:35 -07:00
|
|
|
>
|
2021-04-24 15:02:13 -07:00
|
|
|
<button
|
|
|
|
onClick={handleClick}
|
|
|
|
className="flex items-center justify-center rounded-full bg-th-bkg-3 w-8 h-8 hover:text-th-primary focus:outline-none"
|
|
|
|
>
|
|
|
|
{uiLocked ? (
|
|
|
|
<LockClosedIcon className="w-5 h-5" />
|
|
|
|
) : (
|
|
|
|
<LockOpenIcon className="w-5 h-5 animate-bounce" />
|
|
|
|
)}
|
|
|
|
</button>
|
|
|
|
</Tooltip>
|
2021-04-22 05:33:35 -07:00
|
|
|
</div>
|
|
|
|
</>
|
2021-04-13 09:51:42 -07:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default UiLock
|