Skip to content

Commit 31d3a21

Browse files
committed
Merge branch 'main' into copy-update-tbtc
2 parents ea991e2 + 9d4ce43 commit 31d3a21

File tree

35 files changed

+226
-359
lines changed

35 files changed

+226
-359
lines changed

src/components/AnnouncementBanner/index.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import { FC } from "react"
2-
import { Link as RouterLink } from "react-router-dom"
32
import {
43
Card,
54
H4,
65
LabelMd,
7-
Button,
86
CloseButton,
97
Stack,
108
useDisclosure,
119
Image,
1210
BoxProps,
1311
useMultiStyleConfig,
1412
} from "@threshold-network/components"
13+
import ButtonLink from "../ButtonLink"
1514

1615
interface AnnouncementBannerProps {
1716
imgSrc: any
@@ -59,9 +58,9 @@ const AnnouncementBanner: FC<AnnouncementBannerProps & BoxProps> = ({
5958
{preTitle && <LabelMd sx={styles.preTitle}>{preTitle}</LabelMd>}
6059
<H4 sx={styles.title}>{title}</H4>
6160
</Stack>
62-
<Button as={RouterLink} to={href} sx={styles.ctaButton}>
61+
<ButtonLink to={href} sx={styles.ctaButton}>
6362
{buttonText}
64-
</Button>
63+
</ButtonLink>
6564
</Stack>
6665
</Card>
6766
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { FC } from "react"
2+
import { Button, ButtonProps, forwardRef } from "@threshold-network/components"
3+
import Link, { LinkProps } from "../Link"
4+
5+
const style = {
6+
textDecoration: "none",
7+
}
8+
9+
const ButtonLink: FC<ButtonProps & LinkProps> = forwardRef(
10+
({ ...props }, ref) => {
11+
return <Button as={Link} ref={ref} style={style} {...props} />
12+
}
13+
)
14+
15+
export default ButtonLink

src/components/DetailedLinkListItem/index.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import { FC } from "react"
2-
import { Link as RouterLink } from "react-router-dom"
32
import {
43
BodyLg,
54
BodySm,
65
BoxProps,
7-
Button,
86
Flex,
97
Image,
108
Square,
119
Stack,
1210
useMultiStyleConfig,
1311
} from "@threshold-network/components"
14-
import ExternalLink from "../ExternalLink"
12+
import Link from "../Link"
13+
import ButtonLink from "../ButtonLink"
1514

1615
export interface DetailedLinkListItemProps extends BoxProps {
1716
imgSrc?: any
@@ -55,17 +54,18 @@ const DetailedLinkListItem: FC<DetailedLinkListItemProps> = ({
5554
<BodySm sx={styles.subtitle}>{subtitle}</BodySm>
5655
</Stack>
5756
{isExternal ? (
58-
<ExternalLink
57+
<Link
58+
isExternal
5959
href={href}
6060
sx={styles.link}
61-
text={_linkText}
62-
withArrow
6361
color={styles.link.color as string}
64-
/>
62+
>
63+
{_linkText}
64+
</Link>
6565
) : (
66-
<Button sx={styles.link} variant="link" as={RouterLink} to={href}>
66+
<ButtonLink sx={styles.link} variant="link" to={href}>
6767
{_linkText}
68-
</Button>
68+
</ButtonLink>
6969
)}
7070
</Flex>
7171
)

src/components/ExternalLink/index.tsx

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/components/InternalLink/index.tsx

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/components/ExternalLink/SharedLinks.tsx renamed to src/components/Link/SharedLinks.tsx

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { BodySm } from "@threshold-network/components"
44
import ViewInBlockExplorer from "../ViewInBlockExplorer"
55
import { useTStakingContract } from "../../web3/hooks"
66
import { ExplorerDataType } from "../../utils/createEtherscanLink"
7-
import { ExternalHref } from "../../enums"
8-
import ExternalLink from "."
97

108
type StakingContractLearnMoreProps = ComponentProps<typeof BodySm>
119

@@ -30,17 +28,3 @@ export const StakingContractLearnMore: FC<StakingContractLearnMoreProps> = (
3028

3129
return null
3230
}
33-
34-
type StakingBonusReadMoreProps = ComponentProps<typeof BodySm>
35-
36-
export const StakingBonusReadMore: FC<StakingBonusReadMoreProps> = (props) => {
37-
return (
38-
<BodySm mt="16" textAlign="center" {...props}>
39-
Read more about the{" "}
40-
<ExternalLink
41-
href={ExternalHref.stakingBonusDocs}
42-
text="Staking Bonus."
43-
/>
44-
</BodySm>
45-
)
46-
}

src/components/Link/index.tsx

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { FC, ReactElement } from "react"
2+
import { Link as RouterLink } from "react-router-dom"
3+
import {
4+
forwardRef,
5+
Icon,
6+
Link as ChakraLink,
7+
LinkProps as ChakraLinkProps,
8+
useColorModeValue,
9+
} from "@threshold-network/components"
10+
import { FiArrowUpRight } from "react-icons/all"
11+
12+
interface CommonLinkProps {
13+
icon?: ReactElement
14+
}
15+
16+
type ConditionalLinkProps =
17+
| { isExternal?: false; to: string; href?: never }
18+
| { isExternal: true; to?: never; href: string }
19+
20+
export type LinkProps = CommonLinkProps & ConditionalLinkProps
21+
22+
const Link: FC<ChakraLinkProps & LinkProps> = forwardRef(
23+
({ isExternal, href, to, icon, children, ...props }, ref) => {
24+
const defaultColor = useColorModeValue("brand.500", "white")
25+
const finalColor = props.color ? props.color : defaultColor
26+
27+
return (
28+
<ChakraLink
29+
as={isExternal ? "a" : RouterLink}
30+
ref={isExternal ? ref : undefined}
31+
href={isExternal ? href : undefined}
32+
to={isExternal ? undefined : to}
33+
target={isExternal ? "_blank" : undefined}
34+
rel={isExternal ? "noopener noreferrer" : undefined}
35+
color={finalColor}
36+
textDecoration="underline"
37+
{...props}
38+
>
39+
{children}
40+
{icon ? (
41+
icon
42+
) : isExternal ? (
43+
<Icon boxSize="12px" ml="1" as={FiArrowUpRight} />
44+
) : null}
45+
</ChakraLink>
46+
)
47+
}
48+
)
49+
50+
export * from "./SharedLinks"
51+
52+
export default Link

src/components/Modal/ClaimingRewards/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
ListItem,
1717
} from "@threshold-network/components"
1818
import { useDispatch, useSelector } from "react-redux"
19-
import { StakingContractLearnMore } from "../../ExternalLink/SharedLinks"
19+
import { StakingContractLearnMore } from "../../Link/SharedLinks"
2020
import InfoBox from "../../InfoBox"
2121
import { BaseModalProps } from "../../../types"
2222
import withBaseModal from "../withBaseModal"

src/components/Modal/ConfirmStakingParams/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import AdvancedParamsForm, { FormValues } from "./AdvancedParamsForm"
1919
import { useStakingState } from "../../../hooks/useStakingState"
2020
import { ModalType } from "../../../enums"
2121
import InfoBox from "../../InfoBox"
22-
import { StakingContractLearnMore } from "../../ExternalLink"
22+
import { StakingContractLearnMore } from "../../Link"
2323
import StakingStats from "../../StakingStats"
2424
import useCheckDuplicateProviderAddress from "../../../web3/hooks/useCheckDuplicateProviderAddress"
2525
import { featureFlags } from "../../../constants"

src/components/Modal/NewAppsToAuthorizeModal/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import withBaseModal from "../withBaseModal"
2626
import { useStakingState } from "../../../hooks/useStakingState"
2727
import { getStakeTitle } from "../../../utils/getStakeTitle"
2828
import { isAddress, isSameETHAddress } from "../../../web3/utils"
29+
import ButtonLink from "../../ButtonLink"
2930

3031
const NewAppsToAuthorizeModal: FC<BaseModalProps> = ({ closeModal }) => {
3132
const { stakes } = useStakingState()
@@ -108,16 +109,15 @@ const NewAppsToAuthorizeModal: FC<BaseModalProps> = ({ closeModal }) => {
108109
<Button onClick={closeModal} variant="outline" mr={2}>
109110
Dismiss
110111
</Button>
111-
<Button
112+
<ButtonLink
112113
mr={2}
113-
as={RouterLink}
114114
to={`/staking/${selectedProviderAddress}/authorize`}
115115
onClick={closeModal}
116116
disabled={!selectedProviderAddress}
117117
style={{ pointerEvents: selectedProviderAddress ? "auto" : "none" }}
118118
>
119119
Continue
120-
</Button>
120+
</ButtonLink>
121121
</ModalFooter>
122122
</>
123123
)

0 commit comments

Comments
 (0)