-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #377 from ably/checkbox-and-toggles
[WEB-3846] Add Toggles and prioritise disabled state for Checkboxes
- Loading branch information
Showing
11 changed files
with
445 additions
and
619 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
@layer components { | ||
.ui-toggle { | ||
@apply h-32 w-[56px] rounded-full relative inline-block; | ||
} | ||
|
||
.ui-toggle:has(:disabled) { | ||
@apply pointer-events-none; | ||
} | ||
|
||
.ui-toggle input { | ||
@apply w-0 h-0 opacity-0; | ||
} | ||
|
||
.ui-toggle-slider { | ||
@apply absolute cursor-pointer inset-0 transition-all bg-neutral-600 rounded-full; | ||
} | ||
|
||
.ui-toggle-slider:before { | ||
@apply absolute h-[28px] w-[28px] left-2 bottom-2 bg-white rounded-full transition-transform drop-shadow-toggle; | ||
content: ""; | ||
} | ||
|
||
.ui-toggle input:checked + .ui-toggle-slider { | ||
@apply bg-orange-600; | ||
} | ||
|
||
.ui-toggle input:disabled + .ui-toggle-slider { | ||
@apply bg-gui-unavailable; | ||
} | ||
|
||
.ui-toggle input:checked + .ui-toggle-slider:before { | ||
@apply translate-x-24; | ||
} | ||
|
||
.ui-toggle input:disabled + .ui-toggle-slider:before { | ||
@apply bg-neutral-500; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Meta, Unstyled } from "@storybook/blocks"; | ||
import { togglesHtml } from "./utils.ts"; | ||
import Code from "../core/Code"; | ||
|
||
<Meta title="Brand/Toggles" /> | ||
|
||
<Unstyled> | ||
<h1 className="ui-text-h1 mb-32">Toggles</h1> | ||
|
||
<div className="flex items-center gap-24 mb-24"> | ||
<label className="ui-toggle"> | ||
<input type="checkbox" /> | ||
<span className="ui-toggle-slider"></span> | ||
</label> | ||
Default | ||
</div> | ||
<div className="flex items-center gap-24 mb-24"> | ||
<label className="ui-toggle"> | ||
<input type="checkbox" checked /> | ||
<span className="ui-toggle-slider"></span> | ||
</label> | ||
Toggled | ||
</div> | ||
<div className="flex items-center gap-24 mb-24"> | ||
<label className="ui-toggle"> | ||
<input type="checkbox" disabled /> | ||
<span className="ui-toggle-slider"></span> | ||
</label> | ||
Disabled | ||
</div> | ||
<div className="flex items-center gap-24 mb-24"> | ||
<label className="ui-toggle"> | ||
<input type="checkbox" /> | ||
<span className="ui-toggle-slider bg-neutral-800"></span> | ||
</label> | ||
Customised slider colour | ||
</div> | ||
<div className="ui-divider-spacing"> | ||
<h4 className="ui-text-h3 mb-16">Example HTML</h4> | ||
<Code language="html" snippet={togglesHtml} /> | ||
</div> | ||
</Unstyled> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.