* fix: added close button to accountDetails * fix: fixed the AccountList to load async * fix: fixed the heart size on the AccountStats * fix: added AccountDetails loading state * feat: added migration banner * fix: fixed tests
46 lines
1.0 KiB
TypeScript
46 lines
1.0 KiB
TypeScript
import { useCallback, useEffect } from 'react'
|
|
|
|
import Button from 'components/Button'
|
|
import { Cross } from 'components/Icons'
|
|
import Text from 'components/Text'
|
|
|
|
interface Props {
|
|
enableKeyPress?: boolean
|
|
hideText?: boolean
|
|
className?: string
|
|
onClick: () => void
|
|
}
|
|
|
|
export default function EscButton(props: Props) {
|
|
const handleEscKey = useCallback(
|
|
(event: KeyboardEvent) => {
|
|
if (event.code === 'Escape') {
|
|
props.onClick()
|
|
}
|
|
},
|
|
[props],
|
|
)
|
|
|
|
useEffect(() => {
|
|
if (props.enableKeyPress) {
|
|
document.addEventListener('keydown', handleEscKey)
|
|
}
|
|
return () => {
|
|
document.removeEventListener('keydown', handleEscKey)
|
|
}
|
|
}, [props.onClick, props.enableKeyPress, handleEscKey])
|
|
|
|
return (
|
|
<Button
|
|
onClick={props.onClick}
|
|
leftIcon={<Cross />}
|
|
iconClassName='w-3'
|
|
color='tertiary'
|
|
className={props.className ? props.className : 'h-3 w-13'}
|
|
size='xs'
|
|
>
|
|
{!props.hideText && <Text size='2xs'>ESC</Text>}
|
|
</Button>
|
|
)
|
|
}
|