Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

1.9 KB
Raw Blame
import {
  Bot, Code, Feather, BarChart3, Zap, User, Globe, Shield, Flame,
  Skull, GraduationCap, Sword, Clock, Laugh, Crown, Brain, Anchor,
  HelpCircle, Sparkles, Heart, MessageCircle, Search, Mic
} from 'lucide-react'

const iconMap: Record<string, typeof Bot> = {
  Bot, Code, Feather, BarChart3, Zap, User, Globe, Shield, Flame,
  Skull, GraduationCap, Sword, Clock, Laugh, Crown, Brain, Anchor,
  HelpCircle, Sparkles, Heart, MessageCircle, Search, Mic
}

interface Props {
  name: string
  icon: string
  /** A character card's picture, shown instead of the icon. */
  imageDataUrl?: string
  isActive: boolean
  onClick: () => void
}

export function PersonaCard({ name, icon, imageDataUrl, isActive, onClick }: Props) {
  const Icon = iconMap[icon] || Bot

  return (
    <button
      onClick={onClick}
      className={`flex flex-col items-center justify-center gap-1.5 rounded-xl border transition-all hover:scale-[1.03] cursor-pointer w-full aspect-square ${
        isActive
          ? 'bg-gray-200 dark:bg-white/10 border-gray-400 dark:border-white/20'
          : 'bg-gray-50 dark:bg-white/[0.03] border-gray-200 dark:border-white/[0.06] hover:bg-gray-100 dark:hover:bg-white/[0.06]'
      }`}
    >
      {imageDataUrl?.startsWith('data:image/') ? (
        <img src={imageDataUrl} alt="" className="w-8 h-8 rounded-lg object-cover shrink-0" draggable={false} />
      ) : (
        <div className={`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${isActive ? 'bg-gray-300 dark:bg-white/10' : 'bg-gray-100 dark:bg-white/5'}`}>
          <Icon size={16} className={isActive ? 'text-gray-700 dark:text-gray-300' : 'text-gray-400'} />
        </div>
      )}
      <span className={`t-micro font-medium leading-tight text-center line-clamp-2 px-1 ${isActive ? 'text-gray-800 dark:text-white' : 'text-gray-500 dark:text-gray-400'}`}>
        {name}
      </span>
    </button>
  )
}