Download frontend/src/shared/components/ui.tsx from modventures/character-studio: direct link, hf CLI and curl.
- Browser
- Download file 2.56 kB
-
https://huggingface.co/spaces/modventures/character-studio/resolve/main/frontend/src/shared/components/ui.tsx
- Command line
-
hf download hf://spaces/modventures/character-studio/frontend/src/shared/components/ui.tsx
-
curl -L -o ui.tsx https://huggingface.co/spaces/modventures/character-studio/resolve/main/frontend/src/shared/components/ui.tsx
2.56 kB
| import { useEffect, useRef, type ReactNode } from 'react'; | |
| import { X, LoaderCircle, AlertCircle, ArrowUpRight, AudioLines } from 'lucide-react'; | |
| import type { Character } from '../api/types'; | |
| import { assetUrl } from '../api/client'; | |
| export function ErrorNotice({ error }: { error: unknown }) { | |
| return error ? ( | |
| <div className="notice error" role="alert"> | |
| <AlertCircle size={16} /> | |
| <span>{error instanceof Error ? error.message : String(error)}</span> | |
| </div> | |
| ) : null; | |
| } | |
| export function Loading() { | |
| return ( | |
| <div className="loading" role="status"> | |
| <LoaderCircle className="spin" size={22} /> Loading your studio… | |
| </div> | |
| ); | |
| } | |
| export function Avatar({ character, large = false }: { character: Character; large?: boolean }) { | |
| return ( | |
| <div className={`avatar ${large ? 'large' : ''}`} style={{ background: character.color }}> | |
| {character.image_asset_id ? ( | |
| <img src={assetUrl(character.image_asset_id)} alt={character.name} /> | |
| ) : ( | |
| <span> | |
| {character.name | |
| .split(/[ .]+/) | |
| .map((n) => n[0]) | |
| .slice(0, 2) | |
| .join('')} | |
| </span> | |
| )} | |
| </div> | |
| ); | |
| } | |
| export function PageTitle({ | |
| eyebrow, | |
| title, | |
| description, | |
| action, | |
| }: { | |
| eyebrow: string; | |
| title: string; | |
| description: string; | |
| action?: ReactNode; | |
| }) { | |
| return ( | |
| <header className="page-heading"> | |
| <div> | |
| <div className="eyebrow">{eyebrow}</div> | |
| <h1>{title}</h1> | |
| <p>{description}</p> | |
| </div> | |
| {action} | |
| </header> | |
| ); | |
| } | |
| export function Empty({ title, children }: { title: string; children: ReactNode }) { | |
| return ( | |
| <div className="empty"> | |
| <AudioLines size={30} /> | |
| <h3>{title}</h3> | |
| <p>{children}</p> | |
| </div> | |
| ); | |
| } | |
| export function Modal({ | |
| title, | |
| children, | |
| onClose, | |
| }: { | |
| title: string; | |
| children: ReactNode; | |
| onClose: () => void; | |
| }) { | |
| const ref = useRef<HTMLDialogElement>(null); | |
| useEffect(() => { | |
| ref.current?.showModal(); | |
| }, []); | |
| return ( | |
| <dialog ref={ref} onCancel={onClose} className="modal"> | |
| <header> | |
| <h2>{title}</h2> | |
| <button className="icon-button" aria-label="Close dialog" onClick={onClose}> | |
| <X size={20} /> | |
| </button> | |
| </header> | |
| {children} | |
| </dialog> | |
| ); | |
| } | |
| export function External({ href, children }: { href: string; children: ReactNode }) { | |
| return ( | |
| <a href={href} target="_blank" rel="noreferrer" className="text-link"> | |
| {children} | |
| <ArrowUpRight size={15} /> | |
| </a> | |
| ); | |
| } | |