File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66} from "react"
77
88import { cva , type VariantProps } from "class-variance-authority"
9+ import { ExternalLink } from "lucide-react"
910import { Link } from "wouter"
1011
1112import { Slot } from "components/utility/slot"
@@ -22,6 +23,9 @@ import { interactive, InteractiveProps } from "utils/styles"
2223import { Icon , IconProps } from "../icon"
2324import { Spinner } from "../spinner"
2425
26+ const isExternalLink = ( href ?: string ) =>
27+ href && URL . canParse ( href ) && ! href . includes ( window . location . origin )
28+
2529const button = cva (
2630 cn (
2731 "relative inline-flex shrink-0 items-center justify-center rounded-md text-sm font-medium whitespace-nowrap"
@@ -105,6 +109,14 @@ export const Button = ({
105109 />
106110 ) : null }
107111 { children }
112+ { isExternalLink ( props . href ) && (
113+ < Icon
114+ icon = { ExternalLink }
115+ size = "xs"
116+ color = "muted"
117+ className = "absolute top-0.5 right-0.5 size-2.5!"
118+ />
119+ ) }
108120 </ Comp >
109121 )
110122}
You can’t perform that action at this time.
0 commit comments