-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea77b03
commit 668640e
Showing
10 changed files
with
242 additions
and
110 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
apps/evm/src/components/ConnectButton/ConnectButton.style.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { DrawerClose, hexToRgba } from '@gobob/ui'; | ||
import styled from 'styled-components'; | ||
|
||
type StyledCloseButtonProps = { | ||
$isOpen?: boolean; | ||
}; | ||
|
||
const StyledCloseButton = styled(DrawerClose)<StyledCloseButtonProps>` | ||
background-color: transparent; | ||
border: 0; | ||
border-top-left-radius: ${({ theme }) => theme.rounded('lg')}; | ||
border-bottom-left-radius: ${({ theme }) => theme.rounded('lg')}; | ||
width: 3.5rem; | ||
height: 100%; | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
bottom: 0; | ||
z-index: -1; | ||
display: flex; | ||
padding-top: ${({ theme }) => theme.spacing('3xl')}; | ||
padding-left: ${({ theme }) => theme.spacing('lg')}; | ||
transform: ${({ $isOpen }) => ($isOpen ? 'translateX(-95%)' : 'translateX(0%)')}; | ||
${({ theme }) => theme.transition('common', 'normal')} | ||
&:hover, &:focus-visible { | ||
background-color: ${({ theme }) => hexToRgba(theme.color('grey-300'), 40)}; | ||
transform: ${({ $isOpen }) => $isOpen && 'translateX(-75%)'}; | ||
} | ||
`; | ||
|
||
export { StyledCloseButton }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
'use client'; | ||
|
||
import { Button, Flex, Power, Span } from '@gobob/ui'; | ||
import { Trans } from '@lingui/macro'; | ||
import { useEffect, useRef, useState } from 'react'; | ||
|
||
type DisconnectButtonProps = { | ||
onConfirmPress: () => void; | ||
}; | ||
|
||
const DisconnectButton = ({ onConfirmPress }: DisconnectButtonProps): JSX.Element => { | ||
const [isFocused, setFocused] = useState(false); | ||
|
||
const timeoutRef = useRef<ReturnType<typeof setTimeout>>(); | ||
|
||
useEffect(() => { | ||
return () => { | ||
if (timeoutRef.current) { | ||
clearTimeout(timeoutRef.current); | ||
} | ||
}; | ||
}, []); | ||
|
||
const handleMouseLeave = () => { | ||
timeoutRef.current = setTimeout(() => { | ||
setFocused(false); | ||
timeoutRef.current = undefined; | ||
}, 500); | ||
}; | ||
|
||
const handlePress = () => { | ||
if (!isFocused) { | ||
return setFocused(true); | ||
} | ||
onConfirmPress(); | ||
}; | ||
|
||
const handleMouseEnter = () => { | ||
if (isFocused && timeoutRef.current) { | ||
clearTimeout(timeoutRef.current); | ||
timeoutRef.current = undefined; | ||
} | ||
}; | ||
|
||
const handleBlur = () => setFocused(false); | ||
|
||
return ( | ||
<Button | ||
size='s' | ||
variant='ghost' | ||
onBlur={handleBlur} | ||
onMouseEnter={handleMouseEnter} | ||
onMouseLeave={handleMouseLeave} | ||
onPress={handlePress} | ||
> | ||
<Power size='s' /> | ||
<Flex | ||
alignItems='center' | ||
elementType='span' | ||
style={{ | ||
display: 'grid', | ||
gridTemplateColumns: isFocused ? '1fr' : '0fr', | ||
transition: 'all 200ms ease 0ms' | ||
}} | ||
> | ||
<Span size='s' style={{ overflow: 'hidden', marginLeft: isFocused ? 4 : 0 }}> | ||
<Trans>Disconnect</Trans> | ||
</Span> | ||
</Flex> | ||
</Button> | ||
); | ||
}; | ||
|
||
export { DisconnectButton }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.