-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
153 additions
and
126 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const plugin = require("tailwindcss/plugin"); | ||
const theme = require("./theme"); | ||
const svgToDataUri = require("mini-svg-data-uri"); | ||
|
||
module.exports = plugin.withOptions( | ||
() => { | ||
return ({ addComponents, theme }) => { | ||
addComponents([ | ||
{ | ||
select: { | ||
"background-image": `url("${svgToDataUri( | ||
`<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20"><path stroke="${theme( | ||
"colors.gray.500" | ||
)}" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M6 8l4 4 4-4"/></svg>` | ||
)}")`, | ||
"background-position": `right ${theme("spacing.2")} center`, | ||
"background-repeat": `no-repeat`, | ||
"background-size": `1.5em 1.5em`, | ||
"padding-right": theme("spacing.10"), | ||
"color-adjust": `exact`, | ||
}, | ||
"[multiple]": { | ||
"background-image": "initial", | ||
"background-position": "initial", | ||
"background-repeat": "unset", | ||
"background-size": "initial", | ||
"padding-right": theme("spacing.3"), | ||
"color-adjust": "unset", | ||
}, | ||
}, | ||
]); | ||
}; | ||
}, | ||
() => ({ theme }) | ||
); |
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,25 @@ | ||
export default { | ||
title: "Forms/Select", | ||
}; | ||
|
||
const SelectTemplate = () => { | ||
return ` | ||
<select> | ||
<option value="option-1">option-1</option> | ||
<option value="option-2">option-2</option> | ||
<option value="option-3">option-3</option> | ||
</select> | ||
`; | ||
}; | ||
export const Select = SelectTemplate.bind({}); | ||
|
||
const SelectMultipleTemplate = () => { | ||
return ` | ||
<select multiple> | ||
<option value="option-1">option-1</option> | ||
<option value="option-2">option-2</option> | ||
<option value="option-3">option-3</option> | ||
</select> | ||
`; | ||
}; | ||
export const SelectMultiple = SelectMultipleTemplate.bind({}); |
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,14 @@ | ||
export default { | ||
title: "Forms/ToggleSwitch", | ||
}; | ||
|
||
const ToggleSwitchTemplate = () => { | ||
return ` | ||
<div class="switch"> | ||
<input id="toggle" class="switch-input" type='checkbox' /> | ||
<label for="toggle" class="switch-label"/> | ||
<span></span> | ||
</div> | ||
`; | ||
}; | ||
export const Default = ToggleSwitchTemplate.bind({}); |
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,62 @@ | ||
const plugin = require("tailwindcss/plugin"); | ||
const theme = require("./theme"); | ||
|
||
module.exports = plugin.withOptions( | ||
() => { | ||
return ({ addComponents, theme }) => { | ||
addComponents([ | ||
{ | ||
".switch": { | ||
position: "relative", | ||
width: theme("spacing.16"), | ||
height: theme("spacing.8"), | ||
input: { | ||
position: "absolute", | ||
left: 0, | ||
top: 0, | ||
width: "100%", | ||
height: "100%", | ||
"z-index": 5, | ||
opacity: 0, | ||
cursor: "pointer", | ||
}, | ||
|
||
label: { | ||
width: theme("width.full"), | ||
height: theme("height.full"), | ||
background: theme("colors.gray.300"), | ||
position: "relative", | ||
display: "inline-block", | ||
"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%", | ||
left: 0, | ||
top: 0, | ||
"z-index": 2, | ||
background: theme("colors.white"), | ||
"box-shadow": "0 0 5px rgba(0, 0, 0, 0.2)", | ||
transition: "0.2s", | ||
}, | ||
}, | ||
|
||
"input:checked": { | ||
"+label": { | ||
"background-color": theme("colors.primary.500"), | ||
span: { | ||
transform: "translateX(100%)", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
]); | ||
}; | ||
}, | ||
() => ({ theme }) | ||
); |