Skip to content

Commit

Permalink
chore(segmented-control): update Solid example
Browse files Browse the repository at this point in the history
  • Loading branch information
srflp committed Oct 2, 2023
1 parent f576885 commit f911ac6
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions examples/solid-ts/src/pages/segment-control.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as radio from "@zag-js/radio-group"
import { radioControls, radioData } from "@zag-js/shared"
import { normalizeProps, useMachine } from "@zag-js/solid"
import { For, createMemo, createUniqueId } from "solid-js"
import { Index, createMemo, createUniqueId } from "solid-js"
import { StateVisualizer } from "../components/state-visualizer"
import { Toolbar } from "../components/toolbar"
import { useControls } from "../hooks/use-controls"
Expand All @@ -20,18 +20,17 @@ export default function Page() {
<main class="segmented-control">
<div {...api().rootProps}>
<div {...api().indicatorProps} />
<For each={radioData}>
<Index each={radioData}>
{(opt) => (
<label data-testid={`radio-${opt.id}`} {...api().getRadioProps({ value: opt.id })}>
<span data-testid={`label-${opt.id}`} {...api().getRadioLabelProps({ value: opt.id })}>
{opt.label}
<label data-testid={`radio-${opt().id}`} {...api().getItemProps({ value: opt().id })}>
<span data-testid={`label-${opt().id}`} {...api().getItemTextProps({ value: opt().id })}>
{opt().label}
</span>
<input data-testid={`input-${opt.id}`} {...api().getRadioHiddenInputProps({ value: opt.id })} />
<input data-testid={`input-${opt().id}`} {...api().getItemHiddenInputProps({ value: opt().id })} />
</label>
)}
</For>
</Index>
</div>

<button onClick={api().clearValue}>reset</button>
</main>

Expand Down

0 comments on commit f911ac6

Please sign in to comment.