Skip to content

Commit

Permalink
feat: toggleSwitchのsmallバリエーションを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
Hidetaro7 committed Sep 3, 2021
1 parent 50bdcf5 commit a95957e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
23 changes: 17 additions & 6 deletions packages/tailwindcss/stories/ToggleSwitch.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,24 @@ export default {
title: "Forms/ToggleSwitch",
};

const ToggleSwitchTemplate = () => {
const Template = () => {
return `
<div class="switch">
<input id="toggle" class="switch-input" type='checkbox' />
<label for="toggle" class="switch-label"/>
<span></span>
<div class="toggle-switch w-16 h-8">
<input id="default" type='checkbox' />
<label for="default" />
<span class="w-8 h-8"></span>
</div>
`;
};
export const Default = ToggleSwitchTemplate.bind({});
export const Default = Template.bind({});

const SmallTemplate = () => {
return `
<div class="toggle-switch w-8 h-4">
<input id="small" type='checkbox' />
<label for="small" />
<span class="w-4 h-4"></span>
</div>
`;
};
export const Small = SmallTemplate.bind({});
15 changes: 6 additions & 9 deletions packages/tailwindcss/toggleSwitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ module.exports = plugin.withOptions(
return ({ addComponents, theme }) => {
addComponents([
{
".switch": {
".toggle-switch": {
position: "relative",
width: theme("spacing.16"),
height: theme("spacing.8"),

input: {
position: "absolute",
left: 0,
top: 0,
width: "100%",
height: "100%",
width: theme("width.full"),
height: theme("height.full"),
"z-index": 5,
opacity: 0,
cursor: "pointer",
Expand All @@ -30,12 +29,10 @@ module.exports = plugin.withOptions(
"border-radius": theme("borderRadius.full"),
transition: "0.2s",
"box-sizing": "border-box",

span: {
content: "",
position: "absolute",
width: theme("spacing.8"),
height: theme("height.full"),
"border-radius": "100%",
"border-radius": theme("borderRadius.full"),
left: 0,
top: 0,
"z-index": 2,
Expand Down

0 comments on commit a95957e

Please sign in to comment.