mango-ui-v3/components/FloatingElement.tsx

76 lines
2.3 KiB
TypeScript
Raw Normal View History

2022-03-18 11:41:23 -07:00
import React, { FunctionComponent } from 'react'
// import styled from '@emotion/styled'
2021-07-22 04:34:03 -07:00
import { LinkIcon } from '@heroicons/react/outline'
2021-04-15 06:22:39 -07:00
import useMangoStore from '../stores/useMangoStore'
import { MoveIcon } from './icons'
2021-07-22 04:34:03 -07:00
import EmptyState from './EmptyState'
import { useTranslation } from 'next-i18next'
2022-03-18 11:41:23 -07:00
// const StyledDragWrapperContent = styled.div`
// transition: all 0.25s ease-in;
// opacity: 0;
// `
// const StyledDragBkg = styled.div`
// transition: all 0.25s ease-in;
// opacity: 0;
// `
// const StyledDragWrapper = styled.div`
// :hover {
// ${StyledDragWrapperContent} {
// opacity: 1;
// }
// ${StyledDragBkg} {
// opacity: 0.9;
// }
// }
// `
2021-04-14 23:16:36 -07:00
interface FloatingElementProps {
className?: string
2021-07-22 04:34:03 -07:00
showConnect?: boolean
}
const FloatingElement: FunctionComponent<FloatingElementProps> = ({
className,
children,
2021-07-22 04:34:03 -07:00
showConnect,
}) => {
const { t } = useTranslation('common')
2021-04-15 06:22:39 -07:00
const { uiLocked } = useMangoStore((s) => s.settings)
2021-07-22 04:34:03 -07:00
const connected = useMangoStore((s) => s.wallet.connected)
2022-03-18 11:41:23 -07:00
const wallet = useMangoStore((s) => s.wallet.current)
return (
<div
className={`thin-scroll relative overflow-auto overflow-x-hidden rounded-lg bg-th-bkg-2 p-2.5 md:p-4 ${className}`}
>
{!connected && showConnect ? (
<div className="absolute top-0 left-0 z-10 h-full w-full">
<div className="relative z-10 flex h-full flex-col items-center justify-center">
<EmptyState
buttonText={t('connect')}
icon={<LinkIcon />}
2022-03-18 11:41:23 -07:00
onClickButton={() => (wallet ? wallet.connect() : null)}
title={t('connect-wallet')}
/>
2021-07-22 04:34:03 -07:00
</div>
<div className="absolute top-0 left-0 h-full w-full rounded-lg bg-th-bkg-2 opacity-50" />
</div>
) : null}
{!uiLocked ? (
<div className="absolute top-0 left-0 z-50 h-full w-full cursor-move opacity-80">
<div className="relative z-50 flex h-full flex-col items-center justify-center text-th-fgd-1">
<MoveIcon className="h-8 w-8" />
<div className="mt-2">{t('reposition')}</div>
</div>
<div className="absolute top-0 left-0 h-full w-full rounded-lg bg-th-bkg-3" />
</div>
) : null}
{children}
2021-04-11 14:25:01 -07:00
</div>
)
}
export default FloatingElement