diff --git a/.changeset/early-clocks-talk.md b/.changeset/early-clocks-talk.md
new file mode 100644
index 0000000..52fa113
--- /dev/null
+++ b/.changeset/early-clocks-talk.md
@@ -0,0 +1,5 @@
+---
+'@jeanne-mas/svelte-ui': minor
+---
+
+Added switch component
diff --git a/package.json b/package.json
index 511509d..696cc08 100644
--- a/package.json
+++ b/package.json
@@ -75,6 +75,10 @@
"types": "./dist/components/select/index.d.ts",
"svelte": "./dist/components/select/index.js"
},
+ "./components/switch": {
+ "types": "./dist/components/switch/index.d.ts",
+ "svelte": "./dist/components/switch/index.js"
+ },
"./package.json": "./package.json",
"./transition/flyAndScale": {
"types": "./dist/transition/flyAndScale.d.ts",
diff --git a/src/lib/components/switch/Switch.svelte b/src/lib/components/switch/Switch.svelte
new file mode 100644
index 0000000..0e9eddf
--- /dev/null
+++ b/src/lib/components/switch/Switch.svelte
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/lib/components/switch/index.ts b/src/lib/components/switch/index.ts
new file mode 100644
index 0000000..d50108b
--- /dev/null
+++ b/src/lib/components/switch/index.ts
@@ -0,0 +1 @@
+export { default, type Attributes, type Events, type Props, type Slots } from './Switch.svelte';
diff --git a/src/routes/button/+page.svelte b/src/routes/button/+page.svelte
index 6e66789..d8c0cde 100644
--- a/src/routes/button/+page.svelte
+++ b/src/routes/button/+page.svelte
@@ -6,6 +6,7 @@
import Button, { variants, type Size, type Variant } from '$lib/components/button/index.js';
import Label from '$lib/components/label/index.js';
import * as Select from '$lib/components/select/index.js';
+ import Switch from '$lib/components/switch/index.js';
const disabledKey = 'disabled';
const sizeKey = 'size';
@@ -36,16 +37,14 @@
-
{
const url = new URL($page.url);
- if (currentTarget.checked) {
+ if (checked) {
url.searchParams.set(disabledKey, '');
} else {
url.searchParams.delete(disabledKey);
diff --git a/src/routes/calendar/+page.svelte b/src/routes/calendar/+page.svelte
index ca3ca95..5f96c51 100644
--- a/src/routes/calendar/+page.svelte
+++ b/src/routes/calendar/+page.svelte
@@ -7,6 +7,7 @@
import * as Calendar from '$lib/components/calendar/index.js';
import Label from '$lib/components/label/index.js';
import * as Select from '$lib/components/select/index.js';
+ import Switch from '$lib/components/switch/index.js';
const calendarLabelKey = 'calendarLabel';
const disabledKey = 'disabled';
@@ -58,16 +59,14 @@
-
{
const url = new URL($page.url);
- if (currentTarget.checked) {
+ if (checked) {
url.searchParams.set(disabledKey, '');
} else {
url.searchParams.delete(disabledKey);
diff --git a/src/routes/container/+page.svelte b/src/routes/container/+page.svelte
index 3543009..f6bc4cd 100644
--- a/src/routes/container/+page.svelte
+++ b/src/routes/container/+page.svelte
@@ -5,6 +5,7 @@
import { page } from '$app/stores';
import Container from '$lib/components/container/index.js';
import Label from '$lib/components/label/index.js';
+ import Switch from '$lib/components/switch/index.js';
const xAxisKey = 'xAxis';
const yAxisKey = 'yAxis';
@@ -21,16 +22,14 @@
-
{
const url = new URL($page.url);
- if (currentTarget.checked) {
+ if (checked) {
url.searchParams.set(xAxisKey, '');
} else {
url.searchParams.delete(xAxisKey);
@@ -42,16 +41,14 @@
-
{
const url = new URL($page.url);
- if (currentTarget.checked) {
+ if (checked) {
url.searchParams.set(yAxisKey, '');
} else {
url.searchParams.delete(yAxisKey);
diff --git a/src/routes/input/+page.svelte b/src/routes/input/+page.svelte
index c2e72cd..635e48a 100644
--- a/src/routes/input/+page.svelte
+++ b/src/routes/input/+page.svelte
@@ -6,6 +6,7 @@
import Input, { type Variant } from '$lib/components/input/index.js';
import Label from '$lib/components/label/index.js';
import * as Select from '$lib/components/select/index.js';
+ import Switch from '$lib/components/switch/index.js';
const disabledKey = 'disabled';
const placeholderKey = 'placeholder';
@@ -34,16 +35,14 @@
-
{
const url = new URL($page.url);
- if (currentTarget.checked) {
+ if (checked) {
url.searchParams.set(disabledKey, '');
} else {
url.searchParams.delete(disabledKey);
diff --git a/src/routes/switch/+page.svelte b/src/routes/switch/+page.svelte
new file mode 100644
index 0000000..0c89c8d
--- /dev/null
+++ b/src/routes/switch/+page.svelte
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+