Download code/web/src/components/segmented.tsx from MiniMaxAI/oss-ecosystem-data: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/datasets/MiniMaxAI/oss-ecosystem-data/resolve/ef05c6c211d29fd6a5000abe9cc8b9939604ef8c/code/web/src/components/segmented.tsx
- Command line
-
hf download hf://datasets/MiniMaxAI/oss-ecosystem-data@ef05c6c211d29fd6a5000abe9cc8b9939604ef8c/code/web/src/components/segmented.tsx
-
curl -L -o segmented.tsx https://huggingface.co/datasets/MiniMaxAI/oss-ecosystem-data/resolve/ef05c6c211d29fd6a5000abe9cc8b9939604ef8c/code/web/src/components/segmented.tsx
1.26 kB
| /** Two-way switch on a white card: the chosen option is a black pill, as on minimax.io's tabs. */ | |
| export function Segmented<T extends string>({ value, options, onChange, label }: { | |
| value: T; options: [{ value: T; label: string }, { value: T; label: string }]; onChange: (v: T) => void; label: string | |
| }) { | |
| const i = options.findIndex((o) => o.value === value) | |
| return ( | |
| <div role="radiogroup" aria-label={label} | |
| className="relative grid h-10 shrink-0 grid-cols-2 rounded-full bg-muted p-1"> | |
| <span aria-hidden className="absolute inset-y-1 left-1 w-[calc(50%-4px)] rounded-full bg-[#171717] transition-transform duration-300 ease-[cubic-bezier(.22,.61,.36,1)]" | |
| style={{ transform: `translateX(${i * 100}%)` }} /> | |
| {options.map((o) => { | |
| const on = o.value === value | |
| return ( | |
| <button key={o.value} type="button" role="radio" aria-checked={on} onClick={() => onChange(o.value)} | |
| className={`relative z-10 rounded-full px-4 text-[15px] font-medium transition-colors duration-300 focus-visible:outline-2 focus-visible:outline-ring ${on ? "text-white" : "text-muted-foreground hover:text-foreground"}`}> | |
| {o.label} | |
| </button> | |
| ) | |
| })} | |
| </div> | |
| ) | |
| } | |