File size: 1,157 Bytes
78dd858
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
021b245
78dd858
 
 
 
 
 
 
021b245
78dd858
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import type { ReactNode, ButtonHTMLAttributes } from 'react'

interface Props extends ButtonHTMLAttributes<HTMLButtonElement> {
  children: ReactNode
  /** Render as a small compact button */
  size?: 'sm' | 'md'
  /** If true, renders in "pressed" state */
  pressed?: boolean
}

export default function RetroButton({
  children,
  size = 'md',
  pressed = false,
  className = '',
  disabled,
  type = 'button',
  ...rest
}: Props) {
  const padding = size === 'sm' ? 'px-2 py-[1px]' : 'px-3 py-[3px]'
  const fontSize = size === 'sm' ? 'text-retro-xs' : 'text-retro-sm'

  return (
    <button
      type={type}
      className={`
        ${padding} ${fontSize}
        font-retro font-medium
        bg-retro-gray
        border border-retro-black
        ${pressed
          ? 'shadow-retro-inset'
          : 'shadow-retro-outset active:shadow-retro-inset'
        }
        ${disabled
          ? 'text-retro-darkgray cursor-not-allowed'
          : 'text-retro-black hover:bg-retro-light cursor-pointer'
        }
        select-none
        ${className}
      `}
      disabled={disabled}
      {...rest}
    >
      {children}
    </button>
  )
}