1
1
import { clsx } from 'clsx' ;
2
+ import { ComponentPropsWithoutRef } from 'react' ;
2
3
3
4
import { Link } from '~/components/link' ;
4
5
5
- export type Props = React . AnchorHTMLAttributes < HTMLAnchorElement > & {
6
+ export interface ButtonLinkProps extends ComponentPropsWithoutRef < typeof Link > {
6
7
variant ?: 'primary' | 'secondary' | 'tertiary' | 'ghost' ;
7
8
size ?: 'large' | 'medium' | 'small' | 'x-small' ;
8
9
shape ?: 'pill' | 'rounded' | 'square' | 'circle' ;
9
- href : string ;
10
- } ;
10
+ }
11
11
12
12
// eslint-disable-next-line valid-jsdoc
13
13
/**
@@ -20,19 +20,19 @@ export type Props = React.AnchorHTMLAttributes<HTMLAnchorElement> & {
20
20
* --button-font-family: var(--font-family-body);
21
21
* --button-primary-background: hsl(var(--primary));
22
22
* --button-primary-background-hover: color-mix(in oklab, hsl(var(--primary)), white 75%);
23
- * --button-primary-foreground : hsl(var(--foreground));
23
+ * --button-primary-text : hsl(var(--foreground));
24
24
* --button-primary-border: hsl(var(--primary));
25
25
* --button-secondary-background: hsl(var(--foreground));
26
26
* --button-secondary-background-hover: hsl(var(--background));
27
- * --button-secondary-foreground : hsl(var(--background));
27
+ * --button-secondary-text : hsl(var(--background));
28
28
* --button-secondary-border: hsl(var(--foreground));
29
29
* --button-tertiary-background: hsl(var(--background));
30
30
* --button-tertiary-background-hover: hsl(var(--contrast-100));
31
- * --button-tertiary-foreground : hsl(var(--foreground));
31
+ * --button-tertiary-text : hsl(var(--foreground));
32
32
* --button-tertiary-border: hsl(var(--contrast-200));
33
33
* --button-ghost-background: transparent;
34
34
* --button-ghost-background-hover: hsl(var(--foreground) / 5%);
35
- * --button-ghost-foreground : hsl(var(--foreground));
35
+ * --button-ghost-text : hsl(var(--foreground));
36
36
* --button-ghost-border: transparent;
37
37
* }
38
38
* ```
@@ -41,25 +41,24 @@ export function ButtonLink({
41
41
variant = 'primary' ,
42
42
size = 'large' ,
43
43
shape = 'pill' ,
44
- href,
45
44
className,
46
45
children,
47
46
...props
48
- } : Props ) {
47
+ } : ButtonLinkProps ) {
49
48
return (
50
49
< Link
51
50
{ ...props }
52
51
className = { clsx (
53
- 'relative z-0 inline-flex h-fit select-none items-center justify-center overflow-hidden border text-center font-[family-name:var(--button-font-family)] font-semibold leading-normal after:absolute after:inset-0 after:-z-10 after:-translate-x-[105%] after:transition-[opacity,transform] after:duration-300 after:[animation-timing-function:cubic-bezier(0,0.25,0,1)] hover:after:translate-x-0 focus-visible:outline-none focus-visible:ring-2' ,
52
+ 'relative z-0 inline-flex h-fit select-none items-center justify-center overflow-hidden border text-center font-[family-name:var(--button-font-family)] font-semibold leading-normal after:absolute after:inset-0 after:-z-10 after:-translate-x-[105%] after:transition-[opacity,transform] after:duration-300 after:[animation-timing-function:cubic-bezier(0,0.25,0,1)] hover:after:translate-x-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--button-focus,hsl(var(--primary)))] focus-visible:ring-offset-2 ' ,
54
53
{
55
54
primary :
56
- 'border-[var(--button-primary-border,hsl(var(--primary)))] bg-[var(--button-primary-background,hsl(var(--primary)))] text-[var(--button-primary-foreground )] after:bg-[var(--button-primary-background-hover,color-mix(in_oklab,hsl(var(--primary)),white_75%))]' ,
55
+ 'border-[var(--button-primary-border,hsl(var(--primary)))] bg-[var(--button-primary-background,hsl(var(--primary)))] text-[var(--button-primary-text )] after:bg-[var(--button-primary-background-hover,color-mix(in_oklab,hsl(var(--primary)),white_75%))]' ,
57
56
secondary :
58
- 'border-[var(--button-secondary-border,hsl(var(--foreground)))] bg-[var(--button-secondary-background,hsl(var(--foreground)))] text-[var(--button-secondary-foreground ,hsl(var(--background)))] after:bg-[var(--button-secondary-background-hover,hsl(var(--background)))]' ,
57
+ 'border-[var(--button-secondary-border,hsl(var(--foreground)))] bg-[var(--button-secondary-background,hsl(var(--foreground)))] text-[var(--button-secondary-text ,hsl(var(--background)))] after:bg-[var(--button-secondary-background-hover,hsl(var(--background)))]' ,
59
58
tertiary :
60
- 'border-[var(--button-tertiary-border,hsl(var(--contrast-200)))] bg-[var(--button-tertiary-background,hsl(var(--background)))] text-[var(--button-tertiary-foreground ,hsl(var(--foreground)))] after:bg-[var(--button-tertiary-background-hover,hsl(var(--contrast-100)))]' ,
59
+ 'border-[var(--button-tertiary-border,hsl(var(--contrast-200)))] bg-[var(--button-tertiary-background,hsl(var(--background)))] text-[var(--button-tertiary-text ,hsl(var(--foreground)))] after:bg-[var(--button-tertiary-background-hover,hsl(var(--contrast-100)))]' ,
61
60
ghost :
62
- 'border-[var(--button-ghost-border,transparent)] bg-[var(--button-ghost-background,transparent)] text-[var(--button-ghost-foreground ,hsl(var(--foreground)))] after:bg-[var(--button-ghost-background-hover,hsl(var(--foreground)/5%))]' ,
61
+ 'border-[var(--button-ghost-border,transparent)] bg-[var(--button-ghost-background,transparent)] text-[var(--button-ghost-text ,hsl(var(--foreground)))] after:bg-[var(--button-ghost-background-hover,hsl(var(--foreground)/5%))]' ,
63
62
} [ variant ] ,
64
63
{
65
64
'x-small' : 'min-h-8 text-xs' ,
@@ -82,7 +81,6 @@ export function ButtonLink({
82
81
} [ shape ] ,
83
82
className ,
84
83
) }
85
- href = { href }
86
84
>
87
85
< span className = { clsx ( variant === 'secondary' && 'mix-blend-difference' ) } > { children } </ span >
88
86
</ Link >
0 commit comments