Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch - add onChange example to Storybook #445

Open
mkernohanbc opened this issue Aug 12, 2024 · 0 comments
Open

Switch - add onChange example to Storybook #445

mkernohanbc opened this issue Aug 12, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@mkernohanbc
Copy link
Contributor

One thing to add either in here or in another PR at some point: onChange example. Here's what I roughed out on the Vite page to make sure the thing worked as I expected:

import { useState } from "react";

import { Switch } from "@/components";

export default function SwitchPage() {
  const [isSelected, setIsSelected] = useState(false);

  return (
    <>
      <h2>Switch</h2>
      <div
        style={{
          display: "flex",
          flexDirection: "column",
          gap: "var(--layout-margin-medium",
        }}
      >
        <Switch>Label</Switch>
        <Switch labelPosition="left">Reversed label position</Switch>
        <Switch isDisabled>Disabled switch</Switch>
        <Switch labelPosition="left" defaultSelected>
          Switch on by default
        </Switch>
        <div>
          <Switch
            id="controlled-switch"
            isSelected={isSelected}
            onChange={() => setIsSelected(!isSelected)}
          >
            <pre>isSelected:</pre> {isSelected ? "true" : "false"}
          </Switch>
        </div>
      </div>
    </>
  );
}

Originally posted by @ty2k in #440 (review)

@mkernohanbc mkernohanbc self-assigned this Aug 12, 2024
@mkernohanbc mkernohanbc added the enhancement New feature or request label Aug 12, 2024
@mkernohanbc mkernohanbc added this to the Components v0.2.0 milestone Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant