CommandOption.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { Command } from 'lucide-react'
  2. import { ReactNode } from 'react'
  3. import { cn } from 'ui'
  4. import { detectOS } from '@/lib/helpers'
  5. interface CommandOptionProps {
  6. icon: ReactNode
  7. label: string
  8. shortcut: string
  9. onClick: () => void
  10. }
  11. export const CommandOption = ({ icon, label, shortcut, onClick }: CommandOptionProps) => {
  12. const os = detectOS()
  13. return (
  14. <div
  15. className="px-2 py-1 transition hover:bg-surface-100 flex items-center justify-between rounded-sm cursor-pointer"
  16. onClick={onClick}
  17. >
  18. <div className="flex items-center gap-x-2">
  19. {icon}
  20. <p className="text-sm">{label}</p>
  21. </div>
  22. <div
  23. className={cn(
  24. 'flex items-center gap-1',
  25. 'h-6 py-1.5 px-2 leading-none',
  26. 'bg-surface-100 text-foreground-lighter',
  27. 'border border-default rounded-md',
  28. 'shadow-xs shadow-background-surface-100'
  29. )}
  30. >
  31. {/* Issue with `os` and hydration fail */}
  32. {os === 'macos' || true ? (
  33. <Command size={11.5} strokeWidth={1.5} />
  34. ) : (
  35. <p className="text-xs">CTRL</p>
  36. )}
  37. <p className="text-xs font-mono">{shortcut}</p>
  38. </div>
  39. </div>
  40. )
  41. }