diff --git a/lib/component/input/switch/ButtonSwitch.tsx b/lib/component/input/switch/ButtonSwitch.tsx
new file mode 100644
index 0000000..e366aeb
--- /dev/null
+++ b/lib/component/input/switch/ButtonSwitch.tsx
@@ -0,0 +1,35 @@
+import type { MattrixwvButtonSwitchProps } from "$/types/Input";
+import { Switch } from "@headlessui/react";
+
+
+export default function ButtonSwitch({
+ id,
+ className,
+ name,
+ value,
+ defaultChecked,
+ checked,
+ onChange,
+ disabled,
+ onNode,
+ offNode
+}: MattrixwvButtonSwitchProps){
+ return (
+
+ {({ checked }) => (
+ <>
+ {checked ? onNode : offNode}
+ >
+ )}
+
+ );
+}
diff --git a/lib/component/input/switch/DangerSwitch.tsx b/lib/component/input/switch/DangerSwitch.tsx
index 2d07865..47ba406 100644
--- a/lib/component/input/switch/DangerSwitch.tsx
+++ b/lib/component/input/switch/DangerSwitch.tsx
@@ -1,7 +1,31 @@
-export default function DangerSwitch(){
+import type { MattrixwvSwitchProps } from "$/types/Input";
+import clsx from "clsx";
+import MattrixwvSwitch from "./MattrixwvSwitch";
+
+
+export default function DangerSwitch({
+ className,
+ disabled,
+ ...props
+}: MattrixwvSwitchProps){
return (
-
- Danger Switch
-
+
);
}
diff --git a/lib/component/input/switch/DarkSwitch.tsx b/lib/component/input/switch/DarkSwitch.tsx
index e352abe..442cce0 100644
--- a/lib/component/input/switch/DarkSwitch.tsx
+++ b/lib/component/input/switch/DarkSwitch.tsx
@@ -1,7 +1,31 @@
-export default function DarkSwitch(){
+import type { MattrixwvSwitchProps } from "$/types/Input";
+import clsx from "clsx";
+import MattrixwvSwitch from "./MattrixwvSwitch";
+
+
+export default function DarkSwitch({
+ className,
+ disabled,
+ ...props
+}: MattrixwvSwitchProps){
return (
-
- Dark Switch
-
+
);
}
diff --git a/lib/component/input/switch/LightSwitch.tsx b/lib/component/input/switch/LightSwitch.tsx
index 74cc4af..a9350ee 100644
--- a/lib/component/input/switch/LightSwitch.tsx
+++ b/lib/component/input/switch/LightSwitch.tsx
@@ -1,7 +1,31 @@
-export default function LightSwitch(){
+import type { MattrixwvSwitchProps } from "$/types/Input";
+import clsx from "clsx";
+import MattrixwvSwitch from "./MattrixwvSwitch";
+
+
+export default function LightSwitch({
+ className,
+ disabled,
+ ...props
+}: MattrixwvSwitchProps){
return (
-
- Light Switch
-
+
);
}
diff --git a/lib/component/input/switch/MattrixwvSwitch.tsx b/lib/component/input/switch/MattrixwvSwitch.tsx
new file mode 100644
index 0000000..d248f6f
--- /dev/null
+++ b/lib/component/input/switch/MattrixwvSwitch.tsx
@@ -0,0 +1,108 @@
+import type { MattrixwvSwitchProps } from "$/types/Input";
+import { Field, Label, Switch } from "@headlessui/react";
+import clsx from "clsx";
+import { Fragment } from "react/jsx-runtime";
+
+
+export default function MattrixwvSwitch({
+ id,
+ className,
+ knobClassName,
+ size = "sm",
+ wide,
+ name,
+ value,
+ defaultChecked,
+ checked,
+ onChange,
+ disabled,
+ children,
+ offText,
+ onText
+}: MattrixwvSwitchProps){
+ return (
+
+
+ {
+ offText &&
+ {offText}
+ }
+ {
+ onText &&
+ {onText}
+ }
+
+
+
+
+ );
+}
diff --git a/lib/component/input/switch/PlainSwitch.tsx b/lib/component/input/switch/PlainSwitch.tsx
deleted file mode 100644
index 676915c..0000000
--- a/lib/component/input/switch/PlainSwitch.tsx
+++ /dev/null
@@ -1,7 +0,0 @@
-export default function PlainSwitch(){
- return (
-
- Plain Switch
-
- );
-}
\ No newline at end of file
diff --git a/lib/component/input/switch/PrimarySwitch.tsx b/lib/component/input/switch/PrimarySwitch.tsx
index 39cb7ef..c533442 100644
--- a/lib/component/input/switch/PrimarySwitch.tsx
+++ b/lib/component/input/switch/PrimarySwitch.tsx
@@ -1,7 +1,31 @@
-export default function PrimarySwitch(){
+import type { MattrixwvSwitchProps } from "$/types/Input";
+import clsx from "clsx";
+import MattrixwvSwitch from "./MattrixwvSwitch";
+
+
+export default function PrimarySwitch({
+ className,
+ disabled,
+ ...props
+}: MattrixwvSwitchProps){
return (
-
- Primary Switch
-
+
);
}
diff --git a/lib/component/input/switch/SecondarySwitch.tsx b/lib/component/input/switch/SecondarySwitch.tsx
index a2e886b..d568bc2 100644
--- a/lib/component/input/switch/SecondarySwitch.tsx
+++ b/lib/component/input/switch/SecondarySwitch.tsx
@@ -1,7 +1,31 @@
-export default function SecondarySwitch(){
+import type { MattrixwvSwitchProps } from "$/types/Input";
+import clsx from "clsx";
+import MattrixwvSwitch from "./MattrixwvSwitch";
+
+
+export default function SecondarySwitch({
+ className,
+ disabled,
+ ...props
+}: MattrixwvSwitchProps){
return (
-
- Secondary Switch
-
+
);
}
diff --git a/lib/component/input/switch/SuccessDangerSwitch.tsx b/lib/component/input/switch/SuccessDangerSwitch.tsx
index e0df7fa..c097279 100644
--- a/lib/component/input/switch/SuccessDangerSwitch.tsx
+++ b/lib/component/input/switch/SuccessDangerSwitch.tsx
@@ -1,7 +1,30 @@
-export default function SuccessDangerSwitch(){
+import type { MattrixwvSwitchProps } from "$/types/Input";
+import clsx from "clsx";
+import MattrixwvSwitch from "./MattrixwvSwitch";
+
+
+export default function SuccessDangerSwitch({
+ className,
+ disabled,
+ ...props
+}: MattrixwvSwitchProps){
return (
-
- Success Danger Switch
-
+
);
}
diff --git a/lib/component/input/switch/SuccessSwitch.tsx b/lib/component/input/switch/SuccessSwitch.tsx
index 5331d9f..1c45142 100644
--- a/lib/component/input/switch/SuccessSwitch.tsx
+++ b/lib/component/input/switch/SuccessSwitch.tsx
@@ -1,7 +1,31 @@
-export default function SuccessSwitch(){
+import type { MattrixwvSwitchProps } from "$/types/Input";
+import clsx from "clsx";
+import MattrixwvSwitch from "./MattrixwvSwitch";
+
+
+export default function SuccessSwitch({
+ className,
+ disabled,
+ ...props
+}: MattrixwvSwitchProps){
return (
-
- Success Switch
-
+
);
}
diff --git a/lib/component/input/switch/Switch.tsx b/lib/component/input/switch/Switch.tsx
deleted file mode 100644
index 0add28c..0000000
--- a/lib/component/input/switch/Switch.tsx
+++ /dev/null
@@ -1,7 +0,0 @@
-export default function Switch(){
- return (
-
- Switch
-
- );
-}
diff --git a/lib/component/input/switch/TertiarySwitch.tsx b/lib/component/input/switch/TertiarySwitch.tsx
index b699209..9a3e3f5 100644
--- a/lib/component/input/switch/TertiarySwitch.tsx
+++ b/lib/component/input/switch/TertiarySwitch.tsx
@@ -1,7 +1,31 @@
-export default function TertiarySwitch(){
+import type { MattrixwvSwitchProps } from "$/types/Input";
+import clsx from "clsx";
+import MattrixwvSwitch from "./MattrixwvSwitch";
+
+
+export default function TertiarySwitch({
+ className,
+ disabled,
+ ...props
+}: MattrixwvSwitchProps){
return (
-
- Tertiary Switch
-
+
);
}
diff --git a/lib/component/input/switch/WarningSwitch.tsx b/lib/component/input/switch/WarningSwitch.tsx
index f6cf1c9..7c276d3 100644
--- a/lib/component/input/switch/WarningSwitch.tsx
+++ b/lib/component/input/switch/WarningSwitch.tsx
@@ -1,7 +1,31 @@
-export default function WarningSwitch(){
+import type { MattrixwvSwitchProps } from "$/types/Input";
+import clsx from "clsx";
+import MattrixwvSwitch from "./MattrixwvSwitch";
+
+
+export default function WarningSwitch({
+ className,
+ disabled,
+ ...props
+}: MattrixwvSwitchProps){
return (
-
- Warning Switch
-
+
);
}
diff --git a/lib/types/Input.d.ts b/lib/types/Input.d.ts
index d924e94..cc84e2d 100644
--- a/lib/types/Input.d.ts
+++ b/lib/types/Input.d.ts
@@ -1,3 +1,4 @@
+import type React from "react";
import type { ChangeEventHandler } from "react";
@@ -16,7 +17,7 @@ export interface TextInputProps {
export interface SelectInputProps {
label: React.ReactNode;
value?: string;
- onChange?: (newVlaue: string) => void;
+ onChange?: (newValue: string) => void;
children: React.ReactNode;
}
@@ -26,3 +27,35 @@ export interface OptionInputProps {
value: string;
children: React.ReactNode;
}
+
+export type MattrixwvSwitchSize = "none" | "xs" | "sm" | "md" | "lg" | "xl";
+
+export interface MattrixwvSwitchProps {
+ id?: string;
+ className?: string;
+ knobClassName?: string;
+ size?: MattrixwvSwitchSize;
+ wide?: boolean;
+ name?: string;
+ value?: string;
+ defaultChecked?: boolean;
+ checked?: boolean;
+ onChange?: (newChecked: boolean) => void;
+ disabled?: boolean;
+ children?: React.ReactNode;
+ offText?: React.ReactNode;
+ onText?: React.ReactNode;
+}
+
+export interface MattrixwvButtonSwitchProps {
+ id?: string;
+ className?: string;
+ name?: string;
+ value?: string;
+ defaultChecked?: boolean;
+ checked?: boolean;
+ onChange?: (newChecked: boolean) => void;
+ disabled?: boolean;
+ onNode: React.ReactNode;
+ offNode: React.ReactNode;
+}
diff --git a/src/routeTree.gen.ts b/src/routeTree.gen.ts
index 4df05e4..8417225 100644
--- a/src/routeTree.gen.ts
+++ b/src/routeTree.gen.ts
@@ -11,7 +11,6 @@
import { Route as rootRouteImport } from './routes/__root'
import { Route as IndexRouteImport } from './routes/index'
import { Route as TabIndexRouteImport } from './routes/tab/index'
-import { Route as SwitchIndexRouteImport } from './routes/switch/index'
import { Route as ModalIndexRouteImport } from './routes/modal/index'
import { Route as MessageIndexRouteImport } from './routes/message/index'
import { Route as LoadingIndexRouteImport } from './routes/loading/index'
@@ -28,11 +27,6 @@ const TabIndexRoute = TabIndexRouteImport.update({
path: '/tab/',
getParentRoute: () => rootRouteImport,
} as any)
-const SwitchIndexRoute = SwitchIndexRouteImport.update({
- id: '/switch/',
- path: '/switch/',
- getParentRoute: () => rootRouteImport,
-} as any)
const ModalIndexRoute = ModalIndexRouteImport.update({
id: '/modal/',
path: '/modal/',
@@ -66,7 +60,6 @@ export interface FileRoutesByFullPath {
'/loading': typeof LoadingIndexRoute
'/message': typeof MessageIndexRoute
'/modal': typeof ModalIndexRoute
- '/switch': typeof SwitchIndexRoute
'/tab': typeof TabIndexRoute
}
export interface FileRoutesByTo {
@@ -76,7 +69,6 @@ export interface FileRoutesByTo {
'/loading': typeof LoadingIndexRoute
'/message': typeof MessageIndexRoute
'/modal': typeof ModalIndexRoute
- '/switch': typeof SwitchIndexRoute
'/tab': typeof TabIndexRoute
}
export interface FileRoutesById {
@@ -87,7 +79,6 @@ export interface FileRoutesById {
'/loading/': typeof LoadingIndexRoute
'/message/': typeof MessageIndexRoute
'/modal/': typeof ModalIndexRoute
- '/switch/': typeof SwitchIndexRoute
'/tab/': typeof TabIndexRoute
}
export interface FileRouteTypes {
@@ -99,18 +90,9 @@ export interface FileRouteTypes {
| '/loading'
| '/message'
| '/modal'
- | '/switch'
| '/tab'
fileRoutesByTo: FileRoutesByTo
- to:
- | '/'
- | '/buttons'
- | '/input'
- | '/loading'
- | '/message'
- | '/modal'
- | '/switch'
- | '/tab'
+ to: '/' | '/buttons' | '/input' | '/loading' | '/message' | '/modal' | '/tab'
id:
| '__root__'
| '/'
@@ -119,7 +101,6 @@ export interface FileRouteTypes {
| '/loading/'
| '/message/'
| '/modal/'
- | '/switch/'
| '/tab/'
fileRoutesById: FileRoutesById
}
@@ -130,7 +111,6 @@ export interface RootRouteChildren {
LoadingIndexRoute: typeof LoadingIndexRoute
MessageIndexRoute: typeof MessageIndexRoute
ModalIndexRoute: typeof ModalIndexRoute
- SwitchIndexRoute: typeof SwitchIndexRoute
TabIndexRoute: typeof TabIndexRoute
}
@@ -150,13 +130,6 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof TabIndexRouteImport
parentRoute: typeof rootRouteImport
}
- '/switch/': {
- id: '/switch/'
- path: '/switch'
- fullPath: '/switch'
- preLoaderRoute: typeof SwitchIndexRouteImport
- parentRoute: typeof rootRouteImport
- }
'/modal/': {
id: '/modal/'
path: '/modal'
@@ -202,7 +175,6 @@ const rootRouteChildren: RootRouteChildren = {
LoadingIndexRoute: LoadingIndexRoute,
MessageIndexRoute: MessageIndexRoute,
ModalIndexRoute: ModalIndexRoute,
- SwitchIndexRoute: SwitchIndexRoute,
TabIndexRoute: TabIndexRoute,
}
export const routeTree = rootRouteImport
diff --git a/src/routes/__root.tsx b/src/routes/__root.tsx
index b142f6d..d3f17c8 100644
--- a/src/routes/__root.tsx
+++ b/src/routes/__root.tsx
@@ -11,7 +11,6 @@ const navLinks = [
{ to: "/loading", label: "Loading" },
{ to: "/message", label: "Message" },
{ to: "/modal", label: "Modal" },
- { to: "/switch", label: "Switch" },
{ to: "/tab", label: "Tab" },
];
diff --git a/src/routes/input/index.tsx b/src/routes/input/index.tsx
index 155328c..6405a3c 100644
--- a/src/routes/input/index.tsx
+++ b/src/routes/input/index.tsx
@@ -1,4 +1,20 @@
-import { createFileRoute } from '@tanstack/react-router';
+import { Button } from "$/component/button";
+import ButtonSwitch from "$/component/input/switch/ButtonSwitch";
+import DangerSwitch from "$/component/input/switch/DangerSwitch";
+import DarkSwitch from "$/component/input/switch/DarkSwitch";
+import LightSwitch from "$/component/input/switch/LightSwitch";
+import MattrixwvSwitch from "$/component/input/switch/MattrixwvSwitch";
+import PrimarySwitch from "$/component/input/switch/PrimarySwitch";
+import SecondarySwitch from "$/component/input/switch/SecondarySwitch";
+import SuccessDangerSwitch from "$/component/input/switch/SuccessDangerSwitch";
+import SuccessSwitch from "$/component/input/switch/SuccessSwitch";
+import TertiarySwitch from "$/component/input/switch/TertiarySwitch";
+import WarningSwitch from "$/component/input/switch/WarningSwitch";
+import { MattrixwvTabGroup } from "$/component/tab";
+import type { MattrixwvSwitchSize } from "$/types/Input";
+import type { TabGroupContent } from "$/types/Tab";
+import { createFileRoute } from "@tanstack/react-router";
+import { BsCheck, BsX } from "react-icons/bs";
export const Route = createFileRoute('/input/')({
@@ -7,5 +23,433 @@ export const Route = createFileRoute('/input/')({
function InputPage(){
- return Hello "/input/"!
+ const tabs: TabGroupContent[] = [
+ { tab: "Switch", content: }
+ ];
+
+ return (
+
+
+
+ );
+}
+
+function SwitchContent(): React.ReactNode{
+ const sizes: MattrixwvSwitchSize[] = [ "xs", "sm", "md", "lg", "xl" ];
+
+
+ return (
+
+
+ {
+ sizes.map((size) => (
+
+
+ {size} Switch
+
+
+ ))
+ }
+
+
+ {
+ sizes.map((size) => (
+
+ Off}
+ onText="On"
+ >
+ {size} Switch
+
+
+ ))
+ }
+
+
+ {
+ sizes.map((size) => (
+
+ ))
+ }
+
+
+
+
+ {
+ sizes.map((size) => (
+
+
+ {size} Switch
+
+
+ ))
+ }
+
+
+ Disabled Switch
+
+
+
+
+ Disabled Switch
+
+
+
+
+ {
+ sizes.map((size) => (
+
+
+ {size} Switch
+
+
+ ))
+ }
+
+
+ Disabled Switch
+
+
+
+
+ Disabled Switch
+
+
+
+
+ {
+ sizes.map((size) => (
+
+
+ {size} Switch
+
+
+ ))
+ }
+
+
+ Disabled Switch
+
+
+
+
+ Disabled Switch
+
+
+
+
+ {
+ sizes.map((size) => (
+
+
+ {size} Switch
+
+
+ ))
+ }
+
+
+ Disabled Switch
+
+
+
+
+ Disabled Switch
+
+
+
+
+ {
+ sizes.map((size) => (
+
+
+ {size} Switch
+
+
+ ))
+ }
+
+
+ Disabled Switch
+
+
+
+
+ Disabled Switch
+
+
+
+
+ {
+ sizes.map((size) => (
+
+
+ {size} Switch
+
+
+ ))
+ }
+
+
+ Disabled Switch
+
+
+
+
+ Disabled Switch
+
+
+
+
+ {
+ sizes.map((size) => (
+
+
+ {size} Switch
+
+
+ ))
+ }
+
+
+ Disabled Switch
+
+
+
+
+ Disabled Switch
+
+
+
+
+ {
+ sizes.map((size) => (
+
+
+ {size} Switch
+
+
+ ))
+ }
+
+
+ Disabled Switch
+
+
+
+
+ Disabled Switch
+
+
+
+
+
+ }
+ offNode={}
+ />
+
+
+
+ );
+}
+
+function SwitchDisplay({
+ title,
+ children
+}:{
+ title: React.ReactNode;
+ children: React.ReactNode;
+}){
+ return (
+
+
{title}
+
+ {children}
+
+
+ );
}
diff --git a/src/routes/switch/index.tsx b/src/routes/switch/index.tsx
deleted file mode 100644
index fc0e962..0000000
--- a/src/routes/switch/index.tsx
+++ /dev/null
@@ -1,11 +0,0 @@
-import { createFileRoute } from '@tanstack/react-router';
-
-
-export const Route = createFileRoute("/switch/")({
- component: RouteComponent
-});
-
-
-function RouteComponent(){
- return Hello "/switch/"!
-}