Skip to content

Commit

Permalink
ButtonLink: extended component as Link (#184)
Browse files Browse the repository at this point in the history
Closes: #180 

Extended `buttonLink` component to handling the href prop, eg. as Link
component
  • Loading branch information
ioay authored Jan 26, 2024
2 parents 3b0662e + a163c9d commit 04b1eb1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
12 changes: 7 additions & 5 deletions dapp/src/components/shared/ButtonLink/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from "react"
import { Button, ButtonProps, Icon } from "@chakra-ui/react"
import { Button, ButtonProps, Icon, Link, LinkProps } from "@chakra-ui/react"
import { ArrowUpRight } from "#/assets/icons"

type ButtonLinkProps = ButtonProps & {
icon?: typeof Icon
iconColor?: string
}
type ButtonLinkProps = ButtonProps &
LinkProps & {
icon?: typeof Icon
iconColor?: string
}

export default function ButtonLink({
children,
Expand All @@ -16,6 +17,7 @@ export default function ButtonLink({
}: ButtonLinkProps) {
return (
<Button
as={Link}
variant={variant}
justifyContent="flex-start"
leftIcon={
Expand Down
8 changes: 8 additions & 0 deletions dapp/src/theme/Button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ export const buttonTheme: ComponentSingleStyleConfig = {
}
return defaultStyles
},
ghost: {
_hover: {
bg: "transparent",
},
_active: {
bg: "transparent",
},
},
// FIXME: It should be removed and replaced by solid/outline variants
card: ({ colorScheme }: StyleFunctionProps) => {
const defaultStyles = {
Expand Down
11 changes: 11 additions & 0 deletions dapp/src/theme/Link.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineStyle, defineStyleConfig } from "@chakra-ui/react"

const baseStyle = defineStyle({
_hover: {
textDecoration: "none",
},
})

export const linkTheme = defineStyleConfig({
baseStyle,
})
2 changes: 2 additions & 0 deletions dapp/src/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { formErrorTheme } from "./FormError"
import { tabsTheme } from "./Tabs"
import { spinnerTheme } from "./Spinner"
import { tableTheme } from "./Table"
import { linkTheme } from "./Link"

const defaultTheme = {
colors,
Expand Down Expand Up @@ -47,6 +48,7 @@ const defaultTheme = {
FormError: formErrorTheme,
Heading: headingTheme,
Input: inputTheme,
Link: linkTheme,
Modal: modalTheme,
Sidebar: sidebarTheme,
Spinner: spinnerTheme,
Expand Down

0 comments on commit 04b1eb1

Please sign in to comment.