From f73b56cdc43f8b40a57e239b1630de612ce31a68 Mon Sep 17 00:00:00 2001 From: Benjamin Toby Date: Thu, 17 Oct 2024 09:06:54 +0100 Subject: [PATCH] Updates --- components/elements/ColorSchemeSelector.tsx | 14 ++- components/elements/Loading.tsx | 50 +++++++++ components/elements/Toggle.tsx | 15 ++- components/form/Form.tsx | 10 +- components/form/Input.tsx | 11 +- components/form/Textarea.tsx | 24 +++++ components/layout/Button.tsx | 111 ++++++++++++++++++-- components/layout/Container.tsx | 3 +- components/layout/Divider.tsx | 27 +++++ components/layout/Footer.tsx | 8 +- components/layout/H1.tsx | 9 +- components/layout/H2.tsx | 9 +- components/layout/H3.tsx | 9 +- components/layout/H4.tsx | 9 +- components/layout/H5.tsx | 9 +- components/layout/HR.tsx | 7 +- components/layout/Header.tsx | 4 +- components/layout/Link.tsx | 8 ++ components/layout/List.tsx | 54 ++++++++++ components/layout/Main.tsx | 7 +- components/layout/P.tsx | 14 ++- components/layout/Row.tsx | 7 +- components/layout/Section.tsx | 5 + components/layout/Span.tsx | 9 +- components/layout/Stack.tsx | 10 +- 25 files changed, 408 insertions(+), 35 deletions(-) create mode 100644 components/elements/Loading.tsx create mode 100644 components/form/Textarea.tsx create mode 100644 components/layout/Divider.tsx create mode 100644 components/layout/List.tsx 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 ( +