Skip to content

Commit

Permalink
fix: do not shrink the toggle when put in a small container (#1450)
Browse files Browse the repository at this point in the history
  • Loading branch information
haideralsh authored Oct 10, 2024
1 parent 07fd0f5 commit 6b3b63f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Toggle/Toggle.story.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, { useRef } from "react";
import { action } from "@storybook/addon-actions";
import { boolean } from "@storybook/addon-knobs";
import { Toggle, Button } from "../index";
import { Toggle, Button, Box } from "../index";
import { Flex } from "../Flex";
import dashed from "../utils/dashed";

const DashedToggle = dashed(Toggle);
const DashedBox = dashed(Box);

export const WithDifferentSizes = () => (
<Flex gap="x2" alignItems="flex-start">
Expand Down Expand Up @@ -112,6 +113,18 @@ WithLongText.story = {
name: "With long text",
};

export const WithContraintWidth = () => (
<DashedBox width="200px" padding="x2">
<Toggle
labelText="Toggle"
onText="This is a long On label for the toggle component."
offText="This is a long Off label for the toggle component."
defaultToggled
onChange={action("on change")}
/>
</DashedBox>
);

export const ControlledToggle = () => (
<Toggle
labelText="Controlled Toggle"
Expand Down
1 change: 1 addition & 0 deletions src/Toggle/ToggleButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function Switch({ children, disabled, toggled, onClick }: SwitchProps) {
return (
<AnimatedBox
position="relative"
flexShrink={0}
height="24px"
width="48px"
bg={disabled ? "grey" : getSwitchBackground(toggled)}
Expand Down

0 comments on commit 6b3b63f

Please sign in to comment.