Download client/src/components/ArtistScanner.tsx from surekim/tars: direct link, hf CLI and curl.
- Browser
- Download file 3.06 kB
-
https://huggingface.co/spaces/surekim/tars/resolve/main/client/src/components/ArtistScanner.tsx
- Command line
-
hf download hf://spaces/surekim/tars/client/src/components/ArtistScanner.tsx
-
curl -L -o ArtistScanner.tsx https://huggingface.co/spaces/surekim/tars/resolve/main/client/src/components/ArtistScanner.tsx
3.06 kB
| import { useRef, useEffect, useState } from "react"; | |
| import { Loader2, Telescope } from "lucide-react"; | |
| interface ArtistScannerProps { | |
| value: string; | |
| onChange: (val: string) => void; | |
| disabled?: boolean; | |
| onExecute?: () => void; | |
| loading?: boolean; | |
| } | |
| export function ArtistScanner({ value, onChange, disabled, onExecute, loading }: ArtistScannerProps) { | |
| const textareaRef = useRef<HTMLTextAreaElement>(null); | |
| const [isFocused, setIsFocused] = useState(false); | |
| useEffect(() => { | |
| const el = textareaRef.current; | |
| if (el) { | |
| el.style.height = "auto"; | |
| el.style.height = `${Math.max(el.scrollHeight, 56)}px`; | |
| } | |
| }, [value]); | |
| const canExecute = value.length > 3 && !disabled && !loading; | |
| const showCursor = !isFocused && !value; | |
| return ( | |
| <div className="flex flex-col gap-1.5"> | |
| <div className="relative rounded-lg border border-white/40 bg-white/[0.03]"> | |
| <div className="relative"> | |
| <textarea | |
| ref={textareaRef} | |
| data-testid="input-vision" | |
| value={value} | |
| onChange={(e) => onChange(e.target.value)} | |
| onFocus={() => setIsFocused(true)} | |
| onBlur={() => setIsFocused(false)} | |
| disabled={disabled} | |
| placeholder="" | |
| rows={4} | |
| className="w-full bg-transparent rounded-lg px-4 py-4 sm:py-5 pr-20 sm:pr-24 text-[14px] sm:text-[15px] font-sans text-white placeholder:text-white/30 focus:outline-none transition-all duration-200 disabled:opacity-30 resize-none overflow-hidden leading-relaxed min-h-[100px] sm:min-h-[120px]" | |
| autoComplete="off" | |
| autoCorrect="off" | |
| onKeyDown={(e) => { | |
| if (e.key === 'Enter' && !e.shiftKey && canExecute) { | |
| e.preventDefault(); | |
| onExecute?.(); | |
| } | |
| }} | |
| /> | |
| {showCursor && ( | |
| <div className="absolute top-5 left-4 pointer-events-none"> | |
| <span className="text-[14px] sm:text-[15px] text-white/30 font-sans">Artist name, YouTube link, or style description</span> | |
| </div> | |
| )} | |
| <button | |
| data-testid="button-execute" | |
| onClick={onExecute} | |
| disabled={!canExecute} | |
| className={`absolute right-2 bottom-2 px-3.5 py-1.5 rounded-md font-mono text-[12px] font-bold tracking-[0.05em] transition-all duration-200 ${ | |
| loading | |
| ? "bg-emerald-500 text-black go-pulse" | |
| : canExecute | |
| ? "bg-emerald-500 text-black hover:bg-emerald-400 active:scale-[0.97]" | |
| : "bg-white/[0.06] text-white/20 cursor-not-allowed" | |
| }`} | |
| > | |
| {loading ? ( | |
| <span className="flex items-center gap-1.5"> | |
| <Loader2 className="w-3 h-3 animate-spin" /> | |
| <span>SCANNING</span> | |
| </span> | |
| ) : ( | |
| <Telescope className="w-4 h-4" /> | |
| )} | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| ); | |
| } | |