diff --git a/components/elements/ColorSchemeSelector.tsx b/components/elements/ColorSchemeSelector.tsx index 61ea54c..8663151 100644 --- a/components/elements/ColorSchemeSelector.tsx +++ b/components/elements/ColorSchemeSelector.tsx @@ -1,4 +1,4 @@ -import { DetailedHTMLProps, HTMLAttributes } from "react"; +import React, { DetailedHTMLProps, HTMLAttributes } from "react"; import { twMerge } from "tailwind-merge"; import Toggle, { TWUI_TOGGLE_PROPS } from "./Toggle"; @@ -8,12 +8,22 @@ export default function ColorSchemeSelector({ }: DetailedHTMLProps, HTMLDivElement> & { toggleProps?: TWUI_TOGGLE_PROPS; }) { + const [active, setActive] = React.useState(false); + + React.useEffect(() => { + if (active) { + document.documentElement.className = "dark"; + } else { + document.documentElement.className = ""; + } + }, [active]); + return (
- +
); } diff --git a/components/elements/Loading.tsx b/components/elements/Loading.tsx new file mode 100644 index 0000000..2d2d75d --- /dev/null +++ b/components/elements/Loading.tsx @@ -0,0 +1,50 @@ +import { DetailedHTMLProps, HTMLAttributes } from "react"; +import { twMerge } from "tailwind-merge"; + +type Props = DetailedHTMLProps< + HTMLAttributes, + HTMLDivElement +> & { + size?: "small" | "normal" | "medium" | "large"; +}; + +export default function Loading({ size, ...props }: Props) { + const sizeClassName = (() => { + switch (size) { + case "small": + return "w-2 h-2"; + case "normal": + return "w-4 h-4"; + case "normal": + return "w-6 h-6"; + case "large": + return "w-8 h-8"; + + default: + return "w-4 h-4"; + } + })(); + return ( +
+ +
+ ); +} diff --git a/components/elements/Toggle.tsx b/components/elements/Toggle.tsx index 76f993a..ad276c4 100644 --- a/components/elements/Toggle.tsx +++ b/components/elements/Toggle.tsx @@ -6,6 +6,7 @@ export type TWUI_TOGGLE_PROPS = DetailedHTMLProps< HTMLDivElement > & { active?: boolean; + setActive?: React.Dispatch>; circleProps?: DetailedHTMLProps< HTMLAttributes, HTMLDivElement @@ -20,24 +21,28 @@ export type TWUI_TOGGLE_PROPS = DetailedHTMLProps< export default function Toggle({ circleProps, active, + setActive, ...props }: TWUI_TOGGLE_PROPS) { return (
setActive?.(!active)} >
, HTMLFormElement>) { @@ -8,10 +12,12 @@ export default function Form({
+ > + {props.children} + ); } diff --git a/components/form/Input.tsx b/components/form/Input.tsx index 516f99c..66a915c 100644 --- a/components/form/Input.tsx +++ b/components/form/Input.tsx @@ -1,6 +1,10 @@ import { DetailedHTMLProps, InputHTMLAttributes } from "react"; import { twMerge } from "tailwind-merge"; +/** + * # Input Element + * @className twui-input + */ export default function Input({ ...props }: DetailedHTMLProps, HTMLInputElement>) { @@ -8,7 +12,12 @@ export default function Input({ , + HTMLTextAreaElement +>) { + return ( +