File size: 1,215 Bytes
3a944ef
 
 
d160b97
 
 
 
 
 
 
 
3a944ef
 
 
 
8f2b05f
38d787b
 
 
8f2b05f
3a944ef
 
 
 
38d787b
8f2b05f
3a944ef
 
 
d160b97
38d787b
 
 
 
 
3a944ef
 
 
 
 
 
 
 
 
 
 
8f2b05f
 
 
 
 
3a944ef
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { ReactNode } from "react"

import { cn } from "@/lib/utils"

export const actionButtonClassName = cn(
  `flex flex-row space-x-1.5 lg:space-x-2 pl-2 lg:pl-3 pr-3 lg:pr-4 h-8 lg:h-9`,
  `items-center justify-center text-center`,
  `rounded-2xl`,
  `cursor-pointer`,
  `text-xs lg:text-sm font-medium`,
)

export function ActionButton({
  className,
  children,
  href,

  // by default most buttons are just secondary ("neutral") buttons
  variant = "secondary",
  onClick,
}: {
  className?: string
  children?: ReactNode
  href?: string
  variant?: "primary" | "secondary" | "ghost"
  onClick?: () => void
}) {

  const classNames = cn(
    actionButtonClassName,
      variant === "ghost"
      ? `bg-transparent hover:bg-transparent text-zinc-100`
      : variant === "primary"
      ? `bg-lime-700/80 hover:bg-lime-700 text-zinc-100`
      : `bg-neutral-700/50 hover:bg-neutral-700/90 text-zinc-100`,
    className,
  )

  if (href) {
    return (
      <a href={href} className={classNames} target="_blank">
        {children}
      </a>
    )
  }
  return (
    <div className={classNames} onClick={() => {
      try {
        onClick?.()
    } catch (err) {}
    }}>
      {children}
    </div>
  )
}