Skip to content

Commit

Permalink
refactor: checkbox and switch to ark
Browse files Browse the repository at this point in the history
  • Loading branch information
segunadebayo committed Jun 19, 2024
1 parent 4478632 commit eb94ad2
Show file tree
Hide file tree
Showing 34 changed files with 339 additions and 1,805 deletions.
7 changes: 5 additions & 2 deletions packages/react/__stories__/checkbox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ export default {
const DemoCheckbox = (props: Checkbox.RootProps) => {
return (
<Checkbox.Root {...props}>
<Checkbox.Control />
<Checkbox.HiddenInput />
<Checkbox.Control>
<Checkbox.Indicator />
</Checkbox.Control>
<Checkbox.Label>{props.children}</Checkbox.Label>
</Checkbox.Root>
)
Expand Down Expand Up @@ -141,7 +144,7 @@ export const WithGroup = () => {
return (
<Checkbox.Group
defaultValue={["one", "two"]}
onChange={(value) => console.log(value)}
onValueChange={(value) => console.log(value)}
>
<Stack align="start">
<DemoCheckbox value="one">One</DemoCheckbox>
Expand Down
29 changes: 10 additions & 19 deletions packages/react/__stories__/switch.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
import {
Box,
Field,
For,
HStack,
Label,
Span,
Switch,
useSlotRecipe,
} from "../src"
import { Box, For, HStack, Span, Switch, useSlotRecipe } from "../src"
import { colorPalettes } from "./shared/color-palettes"
import { PlaygroundTable } from "./shared/playground-table"

Expand All @@ -19,10 +10,13 @@ export default {
const DemoSwitch = (props: Switch.RootProps) => {
return (
<Switch.Root {...props}>
<Switch.Track>
<Switch.HiddenInput />
<Switch.Control>
<Switch.Thumb />
</Switch.Track>
{props.children && <Switch.Label>{props.children}</Switch.Label>}
</Switch.Control>
{props.children && (
<Switch.Label fontWeight="medium">{props.children}</Switch.Label>
)}
</Switch.Root>
)
}
Expand Down Expand Up @@ -112,10 +106,7 @@ export const Sizes = () => {
}

export const WithLabel = () => (
<Field id="email-alerts">
<HStack>
<DemoSwitch colorPalette="green" id="email-alerts" />
<Label htmlFor="email-alerts">Enable email alerts?</Label>
</HStack>
</Field>
<DemoSwitch colorPalette="green" id="email-alerts">
Enable email alerts?
</DemoSwitch>
)
Loading

0 comments on commit eb94ad2

Please sign in to comment.