Download code/web/src/components/segmented.tsx from MiniMaxAI/oss-ecosystem-data: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/datasets/MiniMaxAI/oss-ecosystem-data/resolve/cbc9cf220e1bfe14bbd7c11b38fd030c7d39865e/code/web/src/components/segmented.tsx
- Command line
-
hf download hf://datasets/MiniMaxAI/oss-ecosystem-data@cbc9cf220e1bfe14bbd7c11b38fd030c7d39865e/code/web/src/components/segmented.tsx
-
curl -L -o segmented.tsx https://huggingface.co/datasets/MiniMaxAI/oss-ecosystem-data/resolve/cbc9cf220e1bfe14bbd7c11b38fd030c7d39865e/code/web/src/components/segmented.tsx
1.32 kB
| /** Two-way switch on the dark stage: a white pill slides under the chosen option. */ | |
| 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 border border-white/15 bg-white/[0.06] p-1 backdrop-blur"> | |
| <span aria-hidden className="absolute inset-y-1 left-1 w-[calc(50%-4px)] rounded-full bg-white shadow-[0_4px_14px_rgba(0,0,0,0.3)] 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-white/60 ${on ? "text-[#171717]" : "text-white/70 hover:text-white"}`}> | |
| {o.label} | |
| </button> | |
| ) | |
| })} | |
| </div> | |
| ) | |
| } | |