Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Download components/editor/main/parameter.tsx from enzostvs/hub-api-playground: direct link, hf CLI and curl.
- Browser
- Download file 761 Bytes
-
https://huggingface.co/spaces/enzostvs/hub-api-playground/resolve/4bc2bc34ae9573e891260f801aa0fe05cc734e4c/components/editor/main/parameter.tsx
- Command line
-
hf download hf://spaces/enzostvs/hub-api-playground@4bc2bc34ae9573e891260f801aa0fe05cc734e4c/components/editor/main/parameter.tsx
-
curl -L -o parameter.tsx https://huggingface.co/spaces/enzostvs/hub-api-playground/resolve/4bc2bc34ae9573e891260f801aa0fe05cc734e4c/components/editor/main/parameter.tsx
761 Bytes
| import { useState } from "react"; | |
| import { useUpdateEffect } from "react-use"; | |
| interface Props { | |
| value: string; | |
| onChange: (value: string, currentValue: string) => void; | |
| } | |
| export const Parameter: React.FC<Props> = ({ value, onChange }) => { | |
| const [state, setState] = useState(value); | |
| const [previousValue, setPreviousValue] = useState<string | undefined>( | |
| undefined | |
| ); | |
| return ( | |
| <input | |
| type="text" | |
| className="bg-indigo-600 !text-white px-1.5 rounded-md outline-none bg-opacity-80 max-w-[80px] text-center truncate" | |
| onBlur={() => { | |
| onChange(state, previousValue ?? `{${value}}`); | |
| setPreviousValue(state as string); | |
| }} | |
| value={state} | |
| onChange={(e) => setState(e.target.value)} | |
| /> | |
| ); | |
| }; | |