-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into remove-max-limit
- Loading branch information
Showing
10 changed files
with
173 additions
and
13 deletions.
There are no files selected for viewing
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,73 @@ | ||
import React from "react" | ||
import { Info } from "#/assets/icons" | ||
import { | ||
Popover, | ||
PopoverTrigger, | ||
PopoverContent, | ||
PopoverCloseButton, | ||
PopoverBody, | ||
PopoverProps, | ||
IconButton, | ||
} from "@chakra-ui/react" | ||
import { SizeType } from "#/types" | ||
import { useDocsDrawer, useWalletContext } from "#/hooks" | ||
import { TextMd, TextSm } from "./shared/Typography" | ||
import Alert from "./shared/Alert" | ||
import { CurrencyBalance } from "./shared/CurrencyBalance" | ||
|
||
type LiquidStakingTokenPopoverProps = PopoverProps & { popoverSize: SizeType } | ||
|
||
export function LiquidStakingTokenPopover({ | ||
popoverSize, | ||
...props | ||
}: LiquidStakingTokenPopoverProps) { | ||
const { isConnected } = useWalletContext() | ||
const { onOpen: openDocsDrawer } = useDocsDrawer() | ||
|
||
return ( | ||
<Popover variant="no-transform" {...props}> | ||
<PopoverTrigger> | ||
<IconButton | ||
variant="ghost" | ||
justifyContent="end" | ||
icon={ | ||
<Info boxSize={5} color={isConnected ? "grey.700" : "grey.400"} /> | ||
} | ||
_disabled={{ | ||
cursor: "default", | ||
}} | ||
isDisabled={!isConnected} | ||
aria-label="Liquid staking details" | ||
/> | ||
</PopoverTrigger> | ||
<PopoverContent | ||
width={popoverSize.width + 16} | ||
height={popoverSize.height} | ||
top={-2} | ||
left={-2} | ||
> | ||
<PopoverCloseButton /> | ||
<PopoverBody p={0}> | ||
<TextMd fontWeight="bold">Liquid staking token</TextMd> | ||
<CurrencyBalance | ||
amount="912312331" | ||
variant="greater-balance-xl" | ||
currency="stbtc" | ||
/> | ||
<Alert | ||
mt={5} | ||
status="info" | ||
withAlertIcon={false} | ||
withActionIcon | ||
onclick={openDocsDrawer} | ||
> | ||
<TextSm> | ||
Your tokens are this Ethereum address once the staking transaction | ||
is finalized. | ||
</TextSm> | ||
</Alert> | ||
</PopoverBody> | ||
</PopoverContent> | ||
</Popover> | ||
) | ||
} |
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,33 @@ | ||
import { useRef, useState, useEffect } from "react" | ||
import { SizeType } from "#/types" | ||
|
||
const initialSize = { | ||
width: 0, | ||
height: 0, | ||
} | ||
|
||
export function useSize() { | ||
const ref = useRef<HTMLDivElement>() | ||
const [size, setSize] = useState<SizeType>(initialSize) | ||
|
||
useEffect(() => { | ||
const onResize = () => { | ||
const newSize = ref.current | ||
? { | ||
width: ref.current.clientWidth, | ||
height: ref.current.clientHeight, | ||
} | ||
: initialSize | ||
|
||
setSize(newSize) | ||
} | ||
|
||
onResize() | ||
window.addEventListener("resize", onResize) | ||
return () => { | ||
window.removeEventListener("resize", onResize) | ||
} | ||
}, []) | ||
|
||
return { ref, size } | ||
} |
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,9 @@ | ||
import { defineStyle, defineStyleConfig } from "@chakra-ui/react" | ||
|
||
const baseStyle = defineStyle({ | ||
bg: "transparent", | ||
}) | ||
|
||
export const closeButtonTheme = defineStyleConfig({ | ||
baseStyle, | ||
}) |
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,41 @@ | ||
import { popoverAnatomy as parts } from "@chakra-ui/anatomy" | ||
import { createMultiStyleConfigHelpers, defineStyle } from "@chakra-ui/react" | ||
|
||
const multiStyleConfig = createMultiStyleConfigHelpers(parts.keys) | ||
|
||
const baseStyleCloseButton = defineStyle({ | ||
top: 5, | ||
right: 5, | ||
}) | ||
|
||
const baseStyleContent = defineStyle({ | ||
borderRadius: "xl", | ||
bg: "gold.100", | ||
borderWidth: 0.5, | ||
borderColor: "white", | ||
p: 5, | ||
|
||
_focusVisible: { | ||
boxShadow: "none", | ||
}, | ||
}) | ||
|
||
const variantNoTransform = multiStyleConfig.definePartsStyle({ | ||
popper: { | ||
transform: "none !important", | ||
}, | ||
}) | ||
|
||
const variants = { | ||
"no-transform": variantNoTransform, | ||
} | ||
|
||
const baseStyle = multiStyleConfig.definePartsStyle({ | ||
content: baseStyleContent, | ||
closeButton: baseStyleCloseButton, | ||
}) | ||
|
||
export const popoverTheme = multiStyleConfig.defineMultiStyleConfig({ | ||
baseStyle, | ||
variants, | ||
}) |
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,4 @@ | ||
export type SizeType = { | ||
width: number | ||
height: number | ||
} |