Add some more examples

This commit is contained in:
Ryan Gossiaux
2021-12-18 16:39:05 -08:00
parent 2c8be5047d
commit 39cc12c8ef
5 changed files with 491 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
<script lang="ts">
import { Switch, SwitchGroup, SwitchLabel } from "$lib";
function classNames(...classes) {
return classes.filter(Boolean).join(" ");
}
let state = false;
</script>
<div class="flex items-start justify-center w-screen h-full p-12 bg-gray-50">
<SwitchGroup as="div" class="flex items-center space-x-4">
<SwitchLabel>Enable notifications</SwitchLabel>
<Switch
as="button"
checked={state}
on:updateValue={(event) => (state = event.detail)}
class={({ checked }) =>
classNames(
"relative inline-flex flex-shrink-0 h-6 border-2 border-transparent rounded-full cursor-pointer w-11 focus:outline-none focus:shadow-outline transition-colors ease-in-out duration-200",
checked ? "bg-indigo-600" : "bg-gray-200"
)}
let:checked
>
<span
class={classNames(
"inline-block w-5 h-5 bg-white rounded-full transform transition ease-in-out duration-200",
checked ? "translate-x-5" : "translate-x-0"
)}
/>
</Switch>
</SwitchGroup>
</div>