First Commit

This commit is contained in:
Benjamin Toby 2024-12-09 16:36:17 +01:00
parent f24b493566
commit b037cec100
128 changed files with 3281 additions and 193 deletions

1
.npmrc Normal file
View File

@ -0,0 +1 @@
@moduletrace:registry=https://git.tben.me/api/packages/moduletrace/npm/

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"css.lint.unknownAtRules": "ignore"
}

27
Dockerfile Normal file
View File

@ -0,0 +1,27 @@
# Set Node.js version
FROM node:20-alpine
RUN apk update && apk add --no-cache curl bash nano
SHELL ["/bin/bash", "-c"]
RUN curl -fsSL https://bun.sh/install | bash
ENV PATH="/root/.bun/bin:${PATH}"
RUN mkdir /app
# Set working directory
WORKDIR /app
RUN touch /root/.bashrc
RUN echo 'alias ll="ls -laF"' >/root/.bashrc
COPY . /app/.
# Install dependencies
RUN bun install
RUN bun run build
# Run the app
CMD ["bun", "start"]

View File

@ -1,40 +1 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/pages/api-reference/create-next-app). # Welcome to Tben
## Getting Started
First, run the development server:
```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
[API routes](https://nextjs.org/docs/pages/building-your-application/routing/api-routes) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`.
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/pages/building-your-application/routing/api-routes) instead of React pages.
This project uses [`next/font`](https://nextjs.org/docs/pages/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
## Learn More
To learn more about Next.js, take a look at the following resources:
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn-pages-router) - an interactive Next.js tutorial.
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
## Deploy on Vercel
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/pages/building-your-application/deploying) for more details.

BIN
bun.lockb

Binary file not shown.

View File

@ -0,0 +1,22 @@
type Props = {
size?: number;
};
export default function Logo({ size }: Props) {
const sizeRatio = 50 / 100;
const width = size || 50;
const height = width * sizeRatio;
return (
<a href="/">
<img
src="/images/logo-white.svg"
alt="Main Logo"
width={width}
height={height}
style={{
minWidth: width + "px",
}}
/>
</a>
);
}

View File

@ -0,0 +1,136 @@
import { AceEditorAcceptedModes } from "@/components/general/data/partials/EditDataListButton";
import React, { MutableRefObject } from "react";
import { twMerge } from "tailwind-merge";
export type AceEditorComponentType = {
editorRef?: MutableRefObject<AceAjax.Editor>;
readOnly?: boolean;
/** Function to call when Ctrl+Enter is pressed */
ctrlEnterFn?: (editor: AceAjax.Editor) => void;
content?: string;
placeholder?: string;
mode?: AceEditorAcceptedModes;
fontSize?: string;
previewMode?: boolean;
onChange?: (value: string) => void;
delay?: number;
};
let timeout: any;
/**
* # Powerful Ace Editor
* @note **NOTE** head scripts required
* @script `https://cdnjs.cloudflare.com/ajax/libs/ace/1.22.0/ace.min.js`
* @script `https://cdnjs.cloudflare.com/ajax/libs/ace/1.22.0/ext-language_tools.min.js`
*/
export default function AceEditor({
editorRef,
readOnly,
ctrlEnterFn,
content = "",
placeholder,
mode,
fontSize,
previewMode,
onChange,
delay = 500,
}: AceEditorComponentType) {
try {
const editorElementRef = React.useRef<HTMLDivElement>();
const editorRefInstance = React.useRef<AceAjax.Editor>();
const [refresh, setRefresh] = React.useState(0);
const [darkMode, setDarkMode] = React.useState(false);
const [ready, setReady] = React.useState(false);
React.useEffect(() => {
if (!ready) return;
if (!ace?.edit || !editorElementRef.current) {
setTimeout(() => {
setRefresh((prev) => prev + 1);
}, 1000);
return;
}
const editor = ace.edit(editorElementRef.current);
editor.setOptions({
mode: `ace/mode/${mode ? mode : "javascript"}`,
theme: darkMode
? "ace/theme/tomorrow_night_bright"
: "ace/theme/ace_light",
value: content,
placeholder: placeholder ? placeholder : "",
enableBasicAutocompletion: true,
enableLiveAutocompletion: true,
readOnly: readOnly ? true : false,
fontSize: fontSize ? fontSize : null,
showLineNumbers: previewMode ? false : true,
wrap: true,
wrapMethod: "code",
// onchange: (e) => {
// console.log(e);
// },
});
editor.commands.addCommand({
name: "myCommand",
bindKey: { win: "Ctrl-Enter", mac: "Command-Enter" },
exec: function (editor) {
if (ctrlEnterFn) ctrlEnterFn(editor);
},
readOnly: true,
});
editor.getSession().on("change", function (e) {
if (onChange) {
clearTimeout(timeout);
setTimeout(() => {
onChange(editor.getValue());
console.log(editor.getValue());
}, delay);
}
});
editorRefInstance.current = editor;
if (editorRef) editorRef.current = editor;
}, [refresh, darkMode, ready]);
React.useEffect(() => {
const htmlClassName = document.documentElement.className;
if (htmlClassName.match(/dark/i)) setDarkMode(true);
setTimeout(() => {
setReady(true);
}, 200);
}, []);
return (
<React.Fragment>
<div
className={twMerge(
"w-full h-[400px] block rounded-md overflow-hidden",
"border border-slate-200 border-solid",
"dark:border-white/20"
)}
>
<div
ref={editorElementRef as any}
className="w-full h-full"
></div>
</div>
</React.Fragment>
);
} catch (error: any) {
return (
<React.Fragment>
<span className="text-sm m-0">
Editor Error:{" "}
<b className="text-red-600">{error.message}</b>
</span>
</React.Fragment>
);
}
}

View File

@ -0,0 +1,36 @@
import { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
export type TWUI_BORDER_PROPS = DetailedHTMLProps<
HTMLAttributes<HTMLDivElement>,
HTMLDivElement
> & {
spacing?: "normal" | "loose" | "tight" | "wide" | "tightest";
};
/**
* # Toggle Component
* @className_wrapper twui-border
*/
export default function Border({ spacing, ...props }: TWUI_BORDER_PROPS) {
return (
<div
{...props}
className={twMerge(
"relative flex items-center gap-2 border rounded",
"border-slate-300 dark:border-white/20",
spacing
? spacing == "normal"
? "px-3 py-2"
: spacing == "tight"
? "px-2 py-1"
: ""
: "px-3 py-2",
"twui-border",
props.className
)}
>
{props.children}
</div>
);
}

View File

@ -0,0 +1,94 @@
import React from "react";
import Link from "../layout/Link";
import Divider from "../layout/Divider";
import Row from "../layout/Row";
import lowerToTitleCase from "@/server-client-shared/utils/lower-to-title-case";
type LinkObject = {
title: string;
path: string;
};
export default function Breadcrumbs() {
const [links, setLinks] = React.useState<LinkObject[] | null>(null);
React.useEffect(() => {
let pathname = window.location.pathname;
let pathLinks = pathname.split("/");
let validPathLinks = [];
validPathLinks.push({
title: "Home",
path: pathname.match(/admin/) ? "/admin" : "/",
});
pathLinks.forEach((linkText, index, array) => {
if (!linkText?.match(/./) || index == 1) {
return;
}
validPathLinks.push({
title: lowerToTitleCase(linkText),
path: (() => {
let path = "";
for (let i = 0; i < array.length; i++) {
const lnText = array[i];
if (i > index || !lnText.match(/./)) continue;
path += `/${lnText}`;
}
return path;
})(),
});
});
setLinks(validPathLinks);
return function () {
setLinks(null);
};
}, []);
if (!links?.[1]) {
return <React.Fragment></React.Fragment>;
}
return (
<Row className="gap-4">
{links.map((linkObject, index, array) => {
if (index === links.length - 1) {
return (
<Link
key={index}
href={linkObject.path}
className="text-slate-400 dark:text-slate-500 pointer-events-none text-xs"
>
{linkObject.title}
</Link>
);
} else {
return (
<React.Fragment key={index}>
<Link href={linkObject.path} className="text-xs">
{linkObject.title}
</Link>
<Divider vertical />
</React.Fragment>
);
}
})}
</Row>
);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
}
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */

View File

@ -0,0 +1,45 @@
import React, { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
/**
* # General Card
* @className_wrapper twui-card
*/
export default function Card({
href,
variant,
linkProps,
...props
}: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
variant?: "normal";
href?: string;
linkProps?: DetailedHTMLProps<
React.AnchorHTMLAttributes<HTMLAnchorElement>,
HTMLAnchorElement
>;
}) {
const component = (
<div
{...props}
className={twMerge(
"flex flex-row items-center p-4 rounded bg-white dark:bg-white/10",
"border border-slate-200 dark:border-white/10 border-solid",
href ? "hover:bg-slate-100 dark:hover:bg-white/30" : "",
"twui-card",
props.className
)}
>
{props.children}
</div>
);
if (href) {
return (
<a href={href} {...linkProps}>
{component}
</a>
);
}
return component;
}

View File

@ -0,0 +1,39 @@
import React, { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
import Toggle, { TWUI_TOGGLE_PROPS } from "./Toggle";
/**
* # Color Scheme Loader
* @className_wrapper twui-color-scheme-selector
*/
export default function ColorSchemeSelector({
active,
setActive,
toggleProps,
...props
}: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
toggleProps?: TWUI_TOGGLE_PROPS;
active: boolean;
setActive: React.Dispatch<React.SetStateAction<boolean>>;
}) {
React.useEffect(() => {
if (active) {
document.documentElement.className = "dark";
} else {
document.documentElement.className = "";
}
}, [active]);
return (
<div
{...props}
className={twMerge(
"flex flex-row items-center",
"twui-color-scheme-selector",
props.className
)}
>
<Toggle active={active} setActive={setActive} {...toggleProps} />
</div>
);
}

View File

@ -0,0 +1,58 @@
import { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
type Props = DetailedHTMLProps<
HTMLAttributes<HTMLDivElement>,
HTMLDivElement
> & {
size?: "small" | "normal" | "medium" | "large" | "smaller";
svgClassName?: string;
};
/**
* # Loading Component
* @className_wrapper twui-loading
*/
export default function Loading({ size, svgClassName, ...props }: Props) {
const sizeClassName = (() => {
switch (size) {
case "smaller":
return "w-4 h-4";
case "small":
return "w-5 h-5";
case "normal":
return "w-6 h-6";
case "large":
return "w-7 h-7";
default:
return "w-6 h-6";
}
})();
return (
<div role="status" {...props}>
<svg
aria-hidden="true"
className={twMerge(
"text-gray-200 animate-spin dark:text-gray-600 fill-blue-600",
"twui-loading",
sizeClassName,
svgClassName
)}
viewBox="0 0 100 101"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
fill="currentColor"
/>
<path
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
fill="currentFill"
/>
</svg>
</div>
);
}

View File

@ -0,0 +1,24 @@
import React, { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
/**
* # General paper
* @className_wrapper twui-loading-block
*/
export default function LoadingBlock({
...props
}: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>) {
return (
<div
{...props}
className={twMerge(
"bg-slate-200 dark:bg-white/10",
"rounded animate-pulse w-full h-[60px]",
"twui-loading-block",
props.className
)}
>
{props.children}
</div>
);
}

View File

@ -0,0 +1,71 @@
import React, { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
import { createRoot } from "react-dom/client";
import Paper from "./Paper";
type Props = DetailedHTMLProps<
HTMLAttributes<HTMLDivElement>,
HTMLDivElement
> & {
target: React.ReactNode;
};
/**
* # Modal Component
* @className_wrapper twui-modal-root
* @className_wrapper twui-modal
*/
export default function Modal({ target, ...props }: Props) {
const [wrapper, setWrapper] = React.useState<HTMLDivElement | null>(null);
React.useEffect(() => {
const wrapperEl = document.createElement("div");
wrapperEl.className = twMerge(
"fixed z-[200000] top-0 left-0 w-screen h-screen",
"flex flex-col items-center justify-center",
"twui-modal-root"
);
setWrapper(wrapperEl);
}, []);
const modalEl = (
<React.Fragment>
<div
className={twMerge(
"absolute top-0 left-0 bg-slate-900/80 z-0",
"w-screen h-screen"
)}
onClick={(e) => {
closeModal({ wrapperEl: wrapper });
}}
></div>
<Paper
{...props}
className={twMerge("z-10 max-w-[500px]", props.className)}
>
{props.children}
</Paper>
</React.Fragment>
);
const targetEl = (
<div
onClick={(e) => {
if (!wrapper) return;
document.body.appendChild(wrapper);
const root = createRoot(wrapper);
root.render(modalEl);
}}
>
{target}
</div>
);
return targetEl;
}
function closeModal({ wrapperEl }: { wrapperEl: HTMLDivElement | null }) {
if (!wrapperEl) return;
wrapperEl.parentElement?.removeChild(wrapperEl);
}

View File

@ -0,0 +1,32 @@
import React, { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
/**
* # General paper
* @className_wrapper twui-paper
*/
export default function Paper({
variant,
linkProps,
...props
}: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
variant?: "normal";
linkProps?: DetailedHTMLProps<
React.AnchorHTMLAttributes<HTMLAnchorElement>,
HTMLAnchorElement
>;
}) {
return (
<div
{...props}
className={twMerge(
"flex flex-row items-center p-4 rounded bg-white dark:bg-white/10",
"border border-slate-200 dark:border-white/10 border-solid w-full",
"twui-paper",
props.className
)}
>
{props.children}
</div>
);
}

View File

@ -0,0 +1,110 @@
import { twMerge } from "tailwind-merge";
import Input from "../form/Input";
import Button from "../layout/Button";
import Row from "../layout/Row";
import { Search as SearchIcon } from "lucide-react";
import React, {
DetailedHTMLProps,
InputHTMLAttributes,
TextareaHTMLAttributes,
} from "react";
let timeout: any;
export type SearchProps = DetailedHTMLProps<
React.HTMLAttributes<HTMLDivElement>,
HTMLDivElement
> & {
dispatch?: (value?: string) => void;
delay?: number;
inputProps?: DetailedHTMLProps<
InputHTMLAttributes<HTMLInputElement>,
HTMLInputElement
> &
DetailedHTMLProps<
TextareaHTMLAttributes<HTMLTextAreaElement>,
HTMLTextAreaElement
>;
buttonProps?: DetailedHTMLProps<
React.ButtonHTMLAttributes<HTMLButtonElement>,
HTMLButtonElement
>;
};
/**
* # Search Component
* @className_wrapper twui-search-wrapper
* @className_circle twui-search-input
* @className_circle twui-search-button
*/
export default function Search({
dispatch,
delay = 500,
inputProps,
buttonProps,
...props
}: SearchProps) {
const [input, setInput] = React.useState("");
React.useEffect(() => {
clearTimeout(timeout);
timeout = setTimeout(() => {
dispatch?.(input);
}, delay);
}, [input]);
const inputRef = React.useRef<HTMLInputElement>();
React.useEffect(() => {
if (props.autoFocus) {
inputRef.current?.focus();
}
}, []);
return (
<Row
{...props}
className={twMerge(
"relative xl:flex-nowrap items-stretch gap-0",
"twui-search-wrapper",
props?.className
)}
>
<Input
type="search"
placeholder="Search"
{...inputProps}
value={input}
onChange={(e) => setInput(e.target.value)}
className={twMerge(
"rounded-r-none",
"twui-search-input",
inputProps?.className
)}
wrapperProps={{
className: "rounded-r-none",
}}
componentRef={inputRef}
/>
<Button
{...buttonProps}
variant="outlined"
color="gray"
className={twMerge(
"rounded-l-none my-[1px]",
"twui-search-button",
buttonProps?.className
)}
onClick={() => {
dispatch?.(input);
}}
>
<SearchIcon
className="text-slate-800 dark:text-white"
size={20}
/>
</Button>
</Row>
);
}

View File

@ -0,0 +1,52 @@
import { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
export type TWUI_TOGGLE_PROPS = DetailedHTMLProps<
HTMLAttributes<HTMLDivElement>,
HTMLDivElement
> & {
active?: boolean;
setActive?: React.Dispatch<React.SetStateAction<boolean>>;
circleProps?: DetailedHTMLProps<
HTMLAttributes<HTMLDivElement>,
HTMLDivElement
>;
};
/**
* # Toggle Component
* @className_wrapper twui-toggle-wrapper
* @className_circle twui-toggle-circle
*/
export default function Toggle({
circleProps,
active,
setActive,
...props
}: TWUI_TOGGLE_PROPS) {
return (
<div
{...props}
className={twMerge(
"flex flex-row items-center w-[40px] p-[3px] transition-all",
"border border-slate-300 dark:border-white/30 border-solid rounded-full",
active ? "justify-end" : "justify-start",
"twui-toggle-wrapper",
props.className
)}
onClick={() => setActive?.(!active)}
>
<div
{...circleProps}
className={twMerge(
"w-3.5 h-3.5 rounded-full ",
active
? "bg-blue-600 dark:bg-blue-500"
: "bg-slate-300 dark:bg-white/40",
"twui-toggle-circle",
circleProps?.className
)}
></div>
</div>
);
}

View File

@ -0,0 +1,23 @@
import { DetailedHTMLProps, FormHTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
/**
* # Form Element
* @className twui-form
*/
export default function Form({
...props
}: DetailedHTMLProps<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>) {
return (
<form
{...props}
className={twMerge(
"flex flex-col items-stretch gap-2 w-full bg-transparent",
"twui-form",
props.className
)}
>
{props.children}
</form>
);
}

View File

@ -0,0 +1,109 @@
import Button from "@/components/lib/layout/Button";
import Stack from "@/components/lib/layout/Stack";
import { ImagePlus, X } from "lucide-react";
import React, { DetailedHTMLProps } from "react";
import Card from "@/components/lib/elements/Card";
import Span from "@/components/lib/layout/Span";
import Center from "@/components/lib/layout/Center";
import imageInputToBase64, {
ImageInputToBase64FunctionReturn,
} from "../utils/form/imageInputToBase64";
import { twMerge } from "tailwind-merge";
type ImageUploadProps = {
onChange?: (imgData: ImageInputToBase64FunctionReturn | undefined) => any;
fileInputProps?: DetailedHTMLProps<
React.InputHTMLAttributes<HTMLInputElement>,
HTMLInputElement
>;
wrapperProps?: DetailedHTMLProps<
React.HTMLAttributes<HTMLDivElement>,
HTMLDivElement
>;
placeHolderWrapper?: DetailedHTMLProps<
React.HTMLAttributes<HTMLDivElement>,
HTMLDivElement
>;
previewImageWrapperProps?: DetailedHTMLProps<
React.HTMLAttributes<HTMLDivElement>,
HTMLDivElement
>;
previewImageProps?: DetailedHTMLProps<
React.ImgHTMLAttributes<HTMLImageElement>,
HTMLImageElement
>;
};
export default function ImageUpload({
onChange,
fileInputProps,
wrapperProps,
placeHolderWrapper,
previewImageWrapperProps,
previewImageProps,
}: ImageUploadProps) {
const [src, setSrc] = React.useState<string | undefined>(undefined);
const inputRef = React.useRef<HTMLInputElement>();
return (
<Stack
className={twMerge("w-full", wrapperProps?.className)}
{...wrapperProps}
>
<input
type="file"
className={twMerge("hidden", fileInputProps?.className)}
{...fileInputProps}
onChange={(e) => {
imageInputToBase64({ imageInput: e.target }).then((res) => {
setSrc(res.imageBase64Full);
onChange?.(res);
fileInputProps?.onChange?.(e);
});
}}
ref={inputRef as any}
/>
{src ? (
<Card className="w-full relative" {...previewImageWrapperProps}>
<img
src={src}
className="w-full h-[300px] object-contain"
{...previewImageProps}
/>
<Button
variant="ghost"
className="absolute p-2 top-2 right-2 z-20"
onClick={(e) => {
setSrc(undefined);
onChange?.(undefined);
}}
>
<X className="text-slate-950" />
</Button>
</Card>
) : (
<Card
className={twMerge(
"w-full h-[300px] cursor-pointer hover:bg-slate-100 dark:hover:bg-white/20",
placeHolderWrapper?.className
)}
onClick={(e) => {
inputRef.current?.click();
placeHolderWrapper?.onClick?.(e);
}}
{...placeHolderWrapper}
>
<Center>
<Stack className="items-center gap-2">
<ImagePlus className="text-slate-400" />
<Span size="smaller" variant="faded">
Click to Upload Image
</Span>
</Stack>
</Center>
</Card>
)}
</Stack>
);
}

View File

@ -0,0 +1,136 @@
import React, {
DetailedHTMLProps,
InputHTMLAttributes,
LabelHTMLAttributes,
RefObject,
TextareaHTMLAttributes,
} from "react";
import { twMerge } from "tailwind-merge";
export type InputProps = DetailedHTMLProps<
InputHTMLAttributes<HTMLInputElement>,
HTMLInputElement
> &
DetailedHTMLProps<
TextareaHTMLAttributes<HTMLTextAreaElement>,
HTMLTextAreaElement
> & {
label?: string;
variant?: "normal" | "warning" | "error" | "inactive";
prefix?: string | React.ReactNode;
suffix?: string | React.ReactNode;
showLabel?: boolean;
istextarea?: boolean;
wrapperProps?: DetailedHTMLProps<
InputHTMLAttributes<HTMLDivElement>,
HTMLDivElement
>;
labelProps?: DetailedHTMLProps<
LabelHTMLAttributes<HTMLLabelElement>,
HTMLLabelElement
>;
componentRef?: RefObject<any>;
};
/**
* # Input Element
* @className twui-input
*/
export default function Input({
label,
variant,
prefix,
suffix,
componentRef,
labelProps,
wrapperProps,
showLabel,
istextarea,
...props
}: InputProps) {
const [focus, setFocus] = React.useState(false);
const targetComponent = istextarea ? (
<textarea
{...props}
className={twMerge(
"w-full outline-none bg-transparent",
"twui-textarea",
props.className
)}
ref={componentRef}
onFocus={(e) => {
setFocus(true);
props?.onFocus?.(e);
}}
onBlur={(e) => {
setFocus(false);
props?.onBlur?.(e);
}}
/>
) : (
<input
{...props}
className={twMerge(
"w-full outline-none bg-transparent",
"twui-input",
props.className
)}
ref={componentRef}
onFocus={(e) => {
setFocus(true);
props?.onFocus?.(e);
}}
onBlur={(e) => {
setFocus(false);
props?.onBlur?.(e);
}}
/>
);
return (
<div
{...wrapperProps}
className={twMerge(
"relative flex items-center gap-2 border rounded-md px-3 py-2 outline outline-1",
focus
? "border-slate-700 dark:border-white/50"
: "border-slate-300 dark:border-white/20",
focus
? "outline-slate-700 dark:outline-white/50"
: "outline-transparent",
variant == "warning" &&
"border-yellow-500 dark:border-yellow-300 outline-yellow-500 dark:outline-yellow-300",
variant == "error" &&
"border-red-500 dark:border-red-300 outline-red-500 dark:outline-red-300",
variant == "inactive" && "opacity-40 pointer-events-none",
"bg-white dark:bg-black",
wrapperProps?.className
)}
>
{showLabel && (
<label
htmlFor={props.name}
{...labelProps}
className={twMerge(
"text-xs absolute -top-2.5 left-2 text-slate-500 bg-white px-1.5 rounded-t",
"dark:text-white/60 dark:bg-black",
labelProps?.className
)}
>
{label || props.placeholder || props.name}
</label>
)}
{prefix && (
<div className="opacity-60 pointer-events-none">{prefix}</div>
)}
{targetComponent}
{suffix && (
<div className="opacity-60 pointer-events-none">{suffix}</div>
)}
</div>
);
}

View File

@ -0,0 +1,117 @@
import { ChevronDown, LucideProps } from "lucide-react";
import {
DetailedHTMLProps,
ForwardRefExoticComponent,
InputHTMLAttributes,
LabelHTMLAttributes,
RefAttributes,
RefObject,
SelectHTMLAttributes,
} from "react";
import { twMerge } from "tailwind-merge";
type SelectOptionObject = {
title: string;
value: string;
default?: boolean;
};
type SelectOption = SelectOptionObject | SelectOptionObject[];
/**
* # Select Element
* @className twui-select-wrapper
* @className twui-select
* @className twui-select-dropdown-icon
*/
export default function Select({
label,
options,
componentRef,
labelProps,
wrapperProps,
showLabel,
iconProps,
...props
}: DetailedHTMLProps<
SelectHTMLAttributes<HTMLSelectElement>,
HTMLSelectElement
> & {
options: SelectOptionObject[];
label?: string;
showLabel?: boolean;
wrapperProps?: DetailedHTMLProps<
InputHTMLAttributes<HTMLDivElement>,
HTMLDivElement
>;
labelProps?: DetailedHTMLProps<
LabelHTMLAttributes<HTMLLabelElement>,
HTMLLabelElement
>;
componentRef?: RefObject<HTMLSelectElement>;
iconProps?: LucideProps;
}) {
return (
<div
{...wrapperProps}
className={twMerge(
"relative w-full flex items-center",
wrapperProps?.className
)}
>
{showLabel && (
<label
htmlFor={props.name}
{...labelProps}
className={twMerge(
"text-xs absolute -top-2 left-4 text-slate-600 bg-white px-2",
"dark:text-white/60 dark:bg-black",
labelProps?.className
)}
>
{label || props.name}
</label>
)}
<select
{...props}
className={twMerge(
"w-full pl-3 py-2 border rounded-md appearance-none pr-8",
"border-slate-300 dark:border-white/20",
"focus:border-slate-700 dark:focus:border-white/50",
"outline-slate-300 dark:outline-white/20",
"focus:outline-slate-700 dark:focus:outline-white/50",
"bg-white dark:bg-black",
"twui-select",
props.className
)}
ref={componentRef}
defaultValue={
options.flat().find((opt) => opt.default)?.value ||
undefined
}
>
{options.flat().map((option, index) => {
return (
<option
key={index}
value={option.value}
// selected={option.default || undefined}
>
{option.title}
</option>
);
})}
</select>
<ChevronDown
size={20}
{...iconProps}
className={twMerge(
"absolute right-2 pointer-events-none",
iconProps?.className
)}
/>
</div>
);
}

View File

@ -0,0 +1,9 @@
import Input, { InputProps } from "./Input";
/**
* # Textarea Component
* @className twui-textarea
*/
export default function Textarea({ componentRef, ...props }: InputProps) {
return <Input istextarea {...props} componentRef={componentRef} />;
}

View File

@ -0,0 +1,204 @@
import {
AnchorHTMLAttributes,
ButtonHTMLAttributes,
DetailedHTMLProps,
HTMLAttributeAnchorTarget,
HTMLAttributes,
} from "react";
import { twMerge } from "tailwind-merge";
import Loading from "../elements/Loading";
/**
* # Buttons
* @className twui-button-general
* @className twui-button-content-wrapper
* @className twui-button-primary
* @className twui-button-primary-outlined
* @className twui-button-primary-ghost
* @className twui-button-secondary
* @className twui-button-secondary-outlined
* @className twui-button-secondary-ghost
* @className twui-button-accent
* @className twui-button-accent-outlined
* @className twui-button-accent-ghost
* @className twui-button-gray
* @className twui-button-gray-outlined
* @className twui-button-gray-ghost
*/
export default function Button({
href,
target,
variant,
color,
size,
buttonContentProps,
linkProps,
beforeIcon,
afterIcon,
loading,
...props
}: DetailedHTMLProps<
ButtonHTMLAttributes<HTMLButtonElement>,
HTMLButtonElement
> & {
variant?: "normal" | "ghost" | "outlined";
color?:
| "primary"
| "secondary"
| "accent"
| "gray"
| "error"
| "warning"
| "success";
size?: "small" | "smaller" | "normal" | "large" | "larger";
href?: string;
target?: HTMLAttributeAnchorTarget;
loading?: boolean;
linkProps?: DetailedHTMLProps<
AnchorHTMLAttributes<HTMLAnchorElement>,
HTMLAnchorElement
>;
beforeIcon?: React.ReactNode;
afterIcon?: React.ReactNode;
buttonContentProps?: DetailedHTMLProps<
HTMLAttributes<HTMLDivElement>,
HTMLDivElement
>;
}) {
const finalClassName: string = (() => {
if (variant == "normal" || !variant) {
if (color == "primary" || !color)
return twMerge(
"bg-blue-500 hover:bg-blue-600 text-white",
"twui-button-primary"
);
if (color == "secondary")
return twMerge(
"bg-emerald-500 hover:bg-emerald-600 text-white",
"twui-button-secondary"
);
if (color == "accent")
return twMerge(
"bg-violet-500 hover:bg-violet-600 text-white",
"twui-button-accent"
);
if (color == "gray")
return twMerge(
"bg-slate-300 hover:bg-slate-200 text-slate-800",
"twui-button-gray"
);
} else if (variant == "outlined") {
if (color == "primary" || !color)
return twMerge(
"bg-transparent outline outline-1 outline-blue-500",
"text-blue-500 dark:text-blue-400 dark:outline-blue-300",
"twui-button-primary-outlined"
);
if (color == "secondary")
return twMerge(
"bg-transparent outline outline-1 outline-emerald-500",
"text-emerald-500",
"twui-button-secondary-outlined"
);
if (color == "accent")
return twMerge(
"bg-transparent outline outline-1 outline-violet-500",
"text-violet-500",
"twui-button-accent-outlined"
);
if (color == "gray")
return twMerge(
"bg-transparent outline outline-1 outline-slate-300",
"text-slate-600 dark:text-white/60 dark:outline-white/30",
"twui-button-gray-outlined"
);
} else if (variant == "ghost") {
if (color == "primary" || !color)
return twMerge(
"bg-transparent outline-none p-2",
"text-blue-500",
"twui-button-primary-ghost"
);
if (color == "secondary")
return twMerge(
"bg-transparent outline-none p-2",
"text-emerald-500",
"twui-button-secondary-ghost"
);
if (color == "accent")
return twMerge(
"bg-transparent outline-none p-2",
"text-violet-500",
"twui-button-accent-ghost"
);
if (color == "gray")
return twMerge(
"bg-transparent outline-none p-2",
"text-slate-600 dark:text-white/70",
"twui-button-gray-ghost"
);
if (color == "error")
return twMerge(
"bg-transparent outline-none p-2",
"text-red-600 dark:text-red-400",
"twui-button-error-ghost"
);
if (color == "warning")
return twMerge(
"bg-transparent outline-none p-2",
"text-yellow-600",
"twui-button-warning-ghost"
);
if (color == "success")
return twMerge(
"bg-transparent outline-none p-2",
"text-emerald-600",
"twui-button-success-ghost"
);
}
return "";
})();
const buttonComponent = (
<button
{...props}
className={twMerge(
"bg-blue-600 text-white text-base font-medium px-4 py-2 rounded",
"flex items-center justify-center relative transition-all",
"twui-button-general",
size == "small" && "px-3 py-1.5 text-sm",
size == "smaller" && "px-2 py-1 text-xs",
size == "large" && "text-lg",
size == "larger" && "px-5 py-3 text-xl",
finalClassName,
props.className,
loading ? "pointer-events-none opacity-80" : "l"
)}
>
<div
{...buttonContentProps}
className={twMerge(
"flex flex-row items-center gap-2",
loading ? "opacity-0" : "",
"twui-button-content-wrapper",
buttonContentProps?.className
)}
>
{beforeIcon && beforeIcon}
{props.children}
{afterIcon && afterIcon}
</div>
{loading && <Loading className="absolute" />}
</button>
);
if (href)
return (
<a {...linkProps} href={href} target={target}>
{buttonComponent}
</a>
);
return buttonComponent;
}

View File

@ -0,0 +1,23 @@
import { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
/**
* # Flexbox Column
* @className twui-center
*/
export default function Center({
...props
}: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>) {
return (
<div
{...props}
className={twMerge(
"flex flex-col items-center justify-center gap-4 p-2 w-full",
"twui-center",
props.className
)}
>
{props.children}
</div>
);
}

View File

@ -0,0 +1,24 @@
import { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
/**
* # Default Container
* @className twui-container
*/
export default function Container({
...props
}: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>) {
return (
<div
{...props}
className={twMerge(
"flex w-full max-w-[1200px] gap-4 justify-between",
"flex-wrap flex-col xl:flex-row items-start xl:items-center",
"twui-container",
props.className
)}
>
{props.children}
</div>
);
}

View File

@ -0,0 +1,30 @@
import { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
/**
* # Vertical and Horizontal Divider
* @className twui-divider
* @className twui-divider-horizontal
* @className twui-divider-vertical
*/
export default function Divider({
vertical,
...props
}: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
vertical?: boolean;
}) {
return (
<div
{...props}
className={twMerge(
"border-slate-200 dark:border-white/10",
vertical
? "border-0 border-l h-full min-h-5"
: "border-0 border-t w-full",
"twui-divider",
vertical ? "twui-divider-vertical" : "twui-divider-horizontal",
props.className
)}
/>
);
}

View File

@ -0,0 +1,25 @@
import { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
/**
* # General Footer
* @className twui-footer
*/
export default function Footer({
...props
}: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>) {
return (
<footer
{...props}
className={twMerge(
"flex flex-col items-center justify-center",
"px-4 sm:px-10 py-2",
"border-0 border-b border-slate-200 border-solid",
"twui-footer",
props.className
)}
>
{props.children}
</footer>
);
}

View File

@ -0,0 +1,19 @@
import { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
/**
* # H1 Headers
* @className twui-h1
*/
export default function H1({
...props
}: DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>) {
return (
<h1
{...props}
className={twMerge("text-5xl mb-4", "twui-h1", props.className)}
>
{props.children}
</h1>
);
}

View File

@ -0,0 +1,19 @@
import { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
/**
* # H2 Headers
* @className twui-h2
*/
export default function H2({
...props
}: DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>) {
return (
<h2
{...props}
className={twMerge("text-3xl mb-4", "twui-h2", props.className)}
>
{props.children}
</h2>
);
}

View File

@ -0,0 +1,19 @@
import { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
/**
* # H3 Headers
* @className twui-h3
*/
export default function H3({
...props
}: DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>) {
return (
<h3
{...props}
className={twMerge("text-xl mb-4", "twui-h3", props.className)}
>
{props.children}
</h3>
);
}

View File

@ -0,0 +1,19 @@
import { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
/**
* # H4 Headers
* @className twui-h4
*/
export default function H4({
...props
}: DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>) {
return (
<h4
{...props}
className={twMerge("text-base mb-4", "twui-h4", props.className)}
>
{props.children}
</h4>
);
}

View File

@ -0,0 +1,19 @@
import { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
/**
* # H5 Headers
* @className twui-h5
*/
export default function H5({
...props
}: DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>) {
return (
<h5
{...props}
className={twMerge("text-sm mb-4", "twui-h5", props.className)}
>
{props.children}
</h5>
);
}

View File

@ -0,0 +1,21 @@
import { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
/**
* # Horizonta Rule (hr)
* @className twui-hr
*/
export default function HR({
...props
}: DetailedHTMLProps<HTMLAttributes<HTMLHRElement>, HTMLHRElement>) {
return (
<hr
{...props}
className={twMerge(
"border-slate-200 dark:border-white/20 w-full my-4",
"twui-hr",
props.className
)}
/>
);
}

View File

@ -0,0 +1,25 @@
import { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
/**
* # Default Header
* @className twui-header
*/
export default function Header({
...props
}: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>) {
return (
<header
{...props}
className={twMerge(
"flex flex-col items-center justify-center",
"px-4 sm:px-10 py-3 flex-wrap",
"border-0 border-b border-slate-200 dark:border-white/10 border-solid",
"twui-header",
props.className
)}
>
{props.children}
</header>
);
}

View File

@ -0,0 +1,30 @@
import { AnchorHTMLAttributes, DetailedHTMLProps } from "react";
import { twMerge } from "tailwind-merge";
/**
* # General Anchor Elements
* @className twui-a | twui-anchor
*/
export default function Link({
...props
}: DetailedHTMLProps<
AnchorHTMLAttributes<HTMLAnchorElement>,
HTMLAnchorElement
>) {
return (
<a
{...props}
className={twMerge(
"text-base text-link-500 no-underline hover:text-link-500/50",
"text-blue-600 dark:text-blue-400 hover:opacity-60 transition-all",
"border-0 border-b border-blue-300 dark:border-blue-200/30 border-solid leading-4",
// "focus:text-red-600",
"twui-anchor",
"twui-a",
props.className
)}
>
{props.children}
</a>
);
}

View File

@ -0,0 +1,54 @@
import {
AnchorHTMLAttributes,
DetailedHTMLProps,
HTMLAttributes,
OlHTMLAttributes,
} from "react";
import { twMerge } from "tailwind-merge";
/**
* # Ordered and unorder Lists
* @className twui-ol
* @className twui-ul
*/
export default function List({
ordered,
items,
...props
}: DetailedHTMLProps<HTMLAttributes<HTMLUListElement>, HTMLUListElement> &
DetailedHTMLProps<OlHTMLAttributes<HTMLOListElement>, HTMLOListElement> & {
items: {
content: React.ReactNode | string;
}[];
ordered?: boolean;
}) {
const listContent = (
<>
{items.map((item, index) => (
<li key={index}>{item.content}</li>
))}
</>
);
const className = "flex flex-col items-start gap-4";
if (ordered) {
return (
<ol
{...props}
className={twMerge(className, "twui-ol", props.className)}
>
{listContent}
</ol>
);
}
return (
<ul
{...props}
className={twMerge(className, "twui-ul", props.className)}
>
{listContent}
</ul>
);
}

View File

@ -0,0 +1,28 @@
import { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
export type LoadingRectangleBlockProps = DetailedHTMLProps<
HTMLAttributes<HTMLDivElement>,
HTMLDivElement
>;
/**
* # A loading Rectangle block
* @className twui-loading-rectangle-block
*/
export default function LoadingRectangleBlock({
...props
}: LoadingRectangleBlockProps) {
return (
<div
{...props}
className={twMerge(
"flex items-center w-full h-10 animate-pulse bg-slate-200 rounded",
"twui-loading-rectangle-block",
props.className
)}
>
{props.children}
</div>
);
}

View File

@ -0,0 +1,23 @@
import { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
/**
* # Main Wrapper
* @className twui-h1
*/
export default function Main({
...props
}: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>) {
return (
<main
{...props}
className={twMerge(
"flex flex-col items-center w-full",
"twui-main",
props.className
)}
>
{props.children}
</main>
);
}

View File

@ -0,0 +1,24 @@
import { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
/**
* # Paragraph Tag
* @className twui-p | twui-paragraph
*/
export default function P({
...props
}: DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>) {
return (
<p
{...props}
className={twMerge(
"text-base py-4",
"twui-p",
"twui-paragraph",
props.className
)}
>
{props.children}
</p>
);
}

View File

@ -0,0 +1,23 @@
import { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
/**
* # Flexbox Row
* @className twui-row
*/
export default function Row({
...props
}: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>) {
return (
<div
{...props}
className={twMerge(
"flex flex-row items-center gap-2 flex-wrap",
"twui-row",
props.className
)}
>
{props.children}
</div>
);
}

View File

@ -0,0 +1,24 @@
import { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
/**
* # General Section
* @className twui-section
*/
export default function Section({
...props
}: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>) {
return (
<section
{...props}
className={twMerge(
"flex flex-col items-center w-full",
"px-4 sm:px-10 py-10",
"twui-section",
props.className
)}
>
{props.children}
</section>
);
}

View File

@ -0,0 +1,33 @@
import { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
/**
* # Span element
* @className twui-span
*/
export default function Span({
size,
variant,
...props
}: DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement> & {
size?: "normal" | "small" | "smaller" | "large" | "larger";
variant?: "normal" | "faded";
}) {
return (
<span
{...props}
className={twMerge(
"text-base",
size == "small" && "text-sm",
size == "smaller" && "text-xs",
size == "large" && "text-lg",
size == "larger" && "text-xl",
variant == "faded" && "opacity-50",
"twui-span",
props.className
)}
>
{props.children}
</span>
);
}

View File

@ -0,0 +1,23 @@
import { DetailedHTMLProps, HTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";
/**
* # Flexbox Column
* @className twui-stack
*/
export default function Stack({
...props
}: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>) {
return (
<div
{...props}
className={twMerge(
"flex flex-col items-start gap-4",
"twui-stack",
props.className
)}
>
{props.children}
</div>
);
}

View File

@ -0,0 +1,106 @@
import { AuthCsrfHeaderName } from "@/server-client-shared/types/admin/auth";
import _ from "lodash";
type FetchApiOptions = {
method:
| "POST"
| "GET"
| "DELETE"
| "PUT"
| "PATCH"
| "post"
| "get"
| "delete"
| "put"
| "patch";
body?: object | string;
headers?: FetchHeader;
};
type FetchHeader = HeadersInit & {
[key in AuthCsrfHeaderName]?: string | null;
};
export type FetchApiReturn = {
success: boolean;
payload: any;
msg?: string;
[key: string]: any;
};
export default async function fetchApi(
url: string,
options?: FetchApiOptions,
csrf?: boolean
): Promise<any> {
let data;
if (typeof options === "string") {
try {
let fetchData;
const csrfValue = localStorage.getItem("csrf");
switch (options) {
case "post":
fetchData = await fetch(url, {
method: options,
headers: {
"Content-Type": "application/json",
"x-csrf-auth": csrf ? csrfValue : "",
} as FetchHeader,
} as RequestInit);
data = fetchData.json();
break;
default:
fetchData = await fetch(url);
data = fetchData.json();
break;
}
} catch (error: any) {
console.log("FetchAPI error #1:", error.message);
data = null;
}
} else if (typeof options === "object") {
try {
let fetchData;
const csrfValue = localStorage.getItem("csrf");
if (options.body && typeof options.body === "object") {
let oldOptionsBody = _.cloneDeep(options.body);
options.body = JSON.stringify(oldOptionsBody);
}
if (options.headers) {
options.headers["x-csrf-auth"] = csrf ? csrfValue : "";
const finalOptions: any = { ...options };
fetchData = await fetch(url, finalOptions);
} else {
fetchData = await fetch(url, {
...options,
headers: {
"Content-Type": "application/json",
"x-csrf-auth": csrf ? csrfValue : "",
} as FetchHeader,
} as RequestInit);
}
data = fetchData.json();
} catch (error: any) {
console.log("FetchAPI error #2:", error.message);
data = null;
}
} else {
try {
let fetchData = await fetch(url);
data = fetchData.json();
} catch (error: any) {
console.log("FetchAPI error #3:", error.message);
data = null;
}
}
return data;
}

View File

@ -0,0 +1,93 @@
export type ImageInputToBase64FunctionReturn = {
imageBase64?: string;
imageBase64Full?: string;
imageName?: string;
};
export type ImageInputToBase64FunctioParam = {
imageInput: HTMLInputElement;
maxWidth?: number;
mimeType?: string;
};
export default async function imageInputToBase64({
imageInput,
maxWidth,
mimeType,
}: ImageInputToBase64FunctioParam): Promise<ImageInputToBase64FunctionReturn> {
try {
if (!imageInput.files?.[0]) {
throw new Error("No Files found in this image input");
}
let imagePreviewNode = document.querySelector(
`[data-imagepreview='image']`
);
let imageName = imageInput.files[0].name.replace(/\..*/, "");
let imageDataBase64: string | undefined;
const MIME_TYPE = mimeType ? mimeType : "image/jpeg";
const QUALITY = 0.95;
const MAX_WIDTH = maxWidth ? maxWidth : null;
const file = imageInput.files[0];
const blobURL = URL.createObjectURL(file);
const img = new Image();
img.src = blobURL;
imageDataBase64 = await new Promise((res, rej) => {
img.onerror = function () {
URL.revokeObjectURL(this.src);
window.alert("Cannot load image!");
};
img.onload = function () {
URL.revokeObjectURL(img.src);
const canvas = document.createElement("canvas");
if (MAX_WIDTH) {
const scaleSize = MAX_WIDTH / img.naturalWidth;
canvas.width =
img.naturalWidth < MAX_WIDTH
? img.naturalWidth
: MAX_WIDTH;
canvas.height =
img.naturalWidth < MAX_WIDTH
? img.naturalHeight
: img.naturalHeight * scaleSize;
} else {
canvas.width = img.naturalWidth;
canvas.height = img.naturalHeight;
}
const ctx = canvas.getContext("2d");
ctx?.drawImage(img, 0, 0, canvas.width, canvas.height);
const srcEncoded = canvas.toDataURL(MIME_TYPE, QUALITY);
res(srcEncoded);
};
});
return {
imageBase64: imageDataBase64?.replace(/.*?base64,/, ""),
imageBase64Full: imageDataBase64,
imageName: imageName,
};
} catch (error: any) {
console.log("Image Processing Error! =>", error.message);
return {
imageBase64: undefined,
imageBase64Full: undefined,
imageName: undefined,
};
}
}
/** ********************************************** */
/** ********************************************** */
/** ********************************************** */

View File

@ -0,0 +1,167 @@
export const skills = {
Devops: {
description: "Server management, deployment, and automation",
href: "/work/devops",
portfolio: [
{
title: "Server Management",
description: "Server management, deployment, and automation",
href: "/work/devops/server-management",
image: "/images/work/devops/server-management.png",
technologies: [
"Linux",
"Docker",
"Shell Scripting",
"Kubernetes",
"Terraform",
"AWS",
"Hetzner",
"Azure",
"Google Cloud",
"Debian",
"Ubuntu",
"Alpine",
"...",
],
},
{
title: "Email Server Setup",
description:
"Self Hosted Email solution. Setup and Deployment.",
href: "/work/devops/server-management",
image: "/images/work/devops/server-management.png",
technologies: ["Linux", "Docker", "Mailinabox", "Hetzner"],
},
{
title: "DNS Configuration",
description: "Domain names setup, configuration, and security.",
image: "/images/work/devops/server-management.png",
technologies: [
"Cloudflare DNS",
"Cloudflare Zero Trust",
"Cloudflare Registry",
],
},
{
title: "Web Servers and Reverse Proxies",
description:
"Web Server Configuration and deployment. Plus SSL Certificates provisioning.",
image: "/images/work/devops/server-management.png",
technologies: [
"NGINX",
"Node JS",
"Bun JS",
"Certbot",
"Let's Encrypt",
],
},
{
title: "Continuous Integration and Deployment",
description:
"Self hosted and managed solutions for deployment and continuous integration",
image: "/images/work/devops/server-management.png",
technologies: [
"Coolify",
"Vercel",
"Github Runners",
"Gitea Runners",
"Dokploy",
],
},
{
title: "Customer Service",
description:
"Self hosted and managed solutions for handling customers",
image: "/images/work/devops/server-management.png",
technologies: ["Chatwoot", "Tidio"],
},
],
},
"Full Stack": {
description: "Frontend and Backend development",
href: "/work/devops",
portfolio: [
{
title: "Server Development",
description:
"Easy development and development of Web servers and APIs",
image: "/images/work/devops/server-management.png",
technologies: ["Node JS", "Bun JS", "Shell Script", "Python"],
},
{
title: "React JS",
description: "Development of React JS applications for the web",
image: "/images/work/devops/server-management.png",
technologies: [
"React",
"Next JS",
"Vite",
"React Hooks",
"Functional Components",
],
},
{
title: "HTML & CSS",
description: "HTML and CSS Development for the web",
image: "/images/work/devops/server-management.png",
technologies: [
"HTML 5",
"CSS 3",
"SCSS",
"Less",
"Tailwind CSS",
],
},
{
title: "Database",
description: "Database Development and Management",
image: "/images/work/devops/server-management.png",
technologies: [
"MySQL",
"Mariadb",
"PostgreSQL",
"MongoDB",
"Redis",
"SQLite",
"Firebase",
"Supabase",
"Prisma",
"Mongoose",
],
},
{
title: "User Authentication",
description: "User Authentication and Authorization",
image: "/images/work/devops/server-management.png",
technologies: [
"Google Login",
"Github Login",
"Next Auth",
"Firebase",
"Cloudflare Zero Trust",
"Clerk",
],
},
],
},
"Software Development": {
description: "Application development for server, desktop, and web",
href: "/work/devops",
portfolio: [
{
title: "Node Modules Development",
description:
"Development of Node Modules for server, desktop, and web. Deployed on NPM package registry.",
image: "/images/work/devops/server-management.png",
technologies: ["Node JS", "Bun JS", "Shell Scripting", "Rsync"],
},
{
title: "Shell Scripting",
description:
"Development of shell scripts for automation and task execution",
image: "/images/work/devops/server-management.png",
technologies: ["Shell Script", "Bash Scripting", "GNU/Linux"],
},
],
},
};

View File

@ -0,0 +1,92 @@
export const work = {
Fullstack: {
href: "/work/full-stack",
portfolio: [
{
title: "Datasquirel",
description: "Clould-based SQL data management system.",
href: "https://datasquirel.com",
image: "/images/work/devops/server-management.png",
technologies: [
"Node JS",
"SQL",
"Mariadb",
"Shell Scripting",
"Docker",
"Docker Compose",
"Next JS",
"Tailwind CSS",
"Cloudflare Zero Trust",
],
},
{
title: "Summit Lending",
description: "Mortgage Broker in Utah",
href: "https://summitlending.com",
image: "/images/work/devops/server-management.png",
technologies: [
"Next JS",
"Tailwind CSS",
"Zapier",
"Google APIs",
"SQL",
"Spreadsheet to JSON",
],
},
{
title: "Coderank",
description: "A new age of remote work. Targeted at developers",
href: "https://summitlending.com",
image: "/images/work/devops/server-management.png",
technologies: [
"Next JS",
"Docker",
"VSCode Web Editor",
"NGINX Reverse Proxy",
],
},
],
},
Devops: {
href: "/work/devops",
portfolio: [
{
title: "Personal Mail Server",
description:
"Self Hosted Email solution for all my personal projects",
href: "https://box.mailben.xyz/mail",
image: "/images/work/devops/server-management.png",
technologies: ["Linux", "Docker", "Mailinabox"],
},
{
title: "Git, Packge, Container repository",
description:
"Self Hosted repository for Git projects, NPM modules, Docker images, and more",
href: "https://git.tben.me/tben",
image: "/images/work/devops/server-management.png",
technologies: ["Gitea", "Linux"],
},
],
},
Software: {
description: "Application development for server, desktop, and web",
href: "/work/devops",
portfolio: [
{
title: "Turbo Sync NPM Module",
description:
"The easiest way to synchronize local and remote directories in real time",
href: "https://git.tben.me/Moduletrace/-/packages/npm/turbosync",
image: "/images/work/devops/server-management.png",
technologies: ["Node JS", "Bun JS", "Shell Scripting", "Rsync"],
},
{
title: "Batchrun",
description: "Run multiple concurrent processes",
href: "https://git.tben.me/Moduletrace/-/packages/npm/@moduletrace%2Fbatchrun",
image: "/images/work/devops/server-management.png",
technologies: ["Node JS"],
},
],
},
};

View File

@ -0,0 +1,18 @@
import H2 from "@/components/lib/layout/H2";
import Section from "@/components/lib/layout/Section";
import Span from "@/components/lib/layout/Span";
import Stack from "@/components/lib/layout/Stack";
export default function AboutSection() {
return (
<Section>
<Stack className="w-full max-w-full xl:max-w-[50vw]">
<H2 className="leading-snug">About Me</H2>
<Span>
I'm passionate and dedicated to solving problems using the
best technologies available.
</Span>
</Stack>
</Section>
);
}

View File

@ -0,0 +1,159 @@
import Card from "@/components/lib/elements/Card";
import H2 from "@/components/lib/layout/H2";
import H3 from "@/components/lib/layout/H3";
import Section from "@/components/lib/layout/Section";
import Span from "@/components/lib/layout/Span";
import Stack from "@/components/lib/layout/Stack";
import { skills } from "../(data)/skills";
import React from "react";
import Row from "@/components/lib/layout/Row";
import { twMerge } from "tailwind-merge";
import Divider from "@/components/lib/layout/Divider";
type Props = {
noTitle?: boolean;
expand?: boolean;
};
export default function MySkillsSection({ noTitle, expand }: Props) {
const [category, setCategory] =
React.useState<keyof typeof skills>("Devops");
const categories = Object.keys(skills) as (keyof typeof skills)[];
if (expand) {
return (
<Section>
<Stack className="w-full">
{!noTitle && (
<React.Fragment>
<H2 className="leading-snug m-0">My Skills</H2>
<Span>
A summary of the vast array of tools I've
mastered over the years
</Span>
<Divider className="opacity-0 my-2" />
</React.Fragment>
)}
<Stack className="items-stretch gap-20 flex-row xl:flex-col flex-wrap md:flex-nowrap">
{categories.map((ctgr, i) => {
return (
<Stack key={i}>
<Stack className="gap-6">
<Stack className="gap-2">
<H3 className="m-0 text-lg">
{ctgr}
</H3>
<Span className="text-sm !leading-5">
{skills[ctgr].description}
</Span>
</Stack>
<div className="grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 w-full">
{skills[ctgr].portfolio.map(
(portfolio, index) => {
return (
<MySkillsCard
portfolio={
portfolio
}
key={index}
/>
);
}
)}
</div>
</Stack>
</Stack>
);
})}
</Stack>
</Stack>
</Section>
);
}
return (
<Section>
<Stack className="w-full">
{!noTitle && (
<React.Fragment>
<H2 className="leading-snug m-0">My Skills</H2>
<Span>
A summary of the vast array of tools I've mastered
over the years
</Span>
<Divider className="opacity-0 my-2" />
</React.Fragment>
)}
<Row className="flex-nowrap items-start gap-x-10 flex-col xl:flex-row gap-y-10">
<Stack className="xl:max-w-[200px] items-stretch gap-10 flex-row xl:flex-col flex-wrap md:flex-nowrap">
{categories.map((ctgr, i) => {
const isActive = category === ctgr;
return (
<Stack
key={i}
className={twMerge(
"cursor-pointer",
isActive
? ""
: "opacity-40 hover:opacity-70"
)}
onClick={() => setCategory(ctgr)}
>
<Stack className="gap-1">
<H3 className="m-0 text-lg">{ctgr}</H3>
<Span className="text-sm !leading-5">
{skills[ctgr].description}
</Span>
</Stack>
</Stack>
);
})}
</Stack>
<div className="grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 w-full">
{skills[category].portfolio.map((portfolio, index) => {
return (
<MySkillsCard
portfolio={portfolio}
key={index}
/>
);
})}
</div>
</Row>
</Stack>
</Section>
);
}
export function MySkillsCard({
portfolio,
}: {
portfolio: (typeof skills.Devops.portfolio)[number];
}) {
return (
<Card className="grow w-full items-start">
<Stack className="gap-4">
<H3 className="m-0">{portfolio.title}</H3>
<Span>{portfolio.description}</Span>
{portfolio.technologies?.[0] && (
<Row className="gap-4">
{portfolio.technologies.map((tch, _i) => (
<React.Fragment key={_i}>
<Span className="text-sm dark:text-white/40">
{tch}
</Span>
{_i < portfolio.technologies.length - 1 && (
<Divider vertical />
)}
</React.Fragment>
))}
</Row>
)}
</Stack>
</Card>
);
}

View File

@ -0,0 +1,154 @@
import Card from "@/components/lib/elements/Card";
import H2 from "@/components/lib/layout/H2";
import H3 from "@/components/lib/layout/H3";
import Section from "@/components/lib/layout/Section";
import Span from "@/components/lib/layout/Span";
import Stack from "@/components/lib/layout/Stack";
import { work } from "../(data)/work";
import Link from "@/components/lib/layout/Link";
import React from "react";
import Row from "@/components/lib/layout/Row";
import Divider from "@/components/lib/layout/Divider";
import { twMerge } from "tailwind-merge";
type Props = {
noTitle?: boolean;
expand?: boolean;
};
export default function MyWorkSection({ noTitle, expand }: Props) {
const categories = Object.keys(work) as (keyof typeof work)[];
const [category, setCategory] = React.useState<keyof typeof work>(
categories[0]
);
if (expand) {
return (
<Section>
<Stack className="w-full">
{!noTitle && (
<React.Fragment>
<H2 className="leading-snug m-0">My Work</H2>
<Span>Some work I've done in the past</Span>
<Divider className="opacity-0 my-2" />
</React.Fragment>
)}
<Stack className="items-stretch gap-20 flex-row xl:flex-col flex-wrap md:flex-nowrap">
{categories.map((ctgr, i) => {
const isActive = category === ctgr;
return (
<Stack key={i}>
<Stack className="gap-6">
<H3 className="m-0 text-lg">{ctgr}</H3>
<div className="grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 w-full">
{work[ctgr].portfolio.map(
(portfolio, index) => {
return (
<MyWorkPortfolioCard
portfolio={
portfolio
}
key={index}
/>
);
}
)}
</div>
</Stack>
</Stack>
);
})}
</Stack>
</Stack>
</Section>
);
}
return (
<Section>
<Stack className="w-full">
{!noTitle && (
<React.Fragment>
<H2 className="leading-snug m-0">My Work</H2>
<Span>Some work I've done in the past</Span>
<Divider className="opacity-0 my-2" />
</React.Fragment>
)}
<Row className="flex-nowrap items-start gap-x-14 flex-col xl:flex-row gap-y-10">
<Stack className="xl:max-w-[200px] items-stretch gap-6 flex-row xl:flex-col flex-wrap md:flex-nowrap">
{categories.map((ctgr, i) => {
const isActive = category === ctgr;
return (
<Stack
key={i}
className={twMerge(
"cursor-pointer",
isActive
? ""
: "opacity-40 hover:opacity-70"
)}
onClick={() => setCategory(ctgr)}
>
<Stack className="gap-1">
<H3 className="m-0 text-lg">{ctgr}</H3>
</Stack>
</Stack>
);
})}
</Stack>
<div className="grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 w-full">
{work[category].portfolio.map((portfolio, index) => {
return (
<MyWorkPortfolioCard
portfolio={portfolio}
key={index}
/>
);
})}
</div>
</Row>
</Stack>
</Section>
);
}
export function MyWorkPortfolioCard({
portfolio,
}: {
portfolio: (typeof work.Devops.portfolio)[number];
}) {
return (
<Card className="grow w-full items-start">
<Stack className="gap-4">
<H3 className="m-0">{portfolio.title}</H3>
<Link
target="_blank"
href={portfolio.href}
className="text-sm text-wrap break-all border-none"
>
{portfolio.href}
</Link>
<Span>{portfolio.description}</Span>
{portfolio.technologies?.[0] && (
<Row className="gap-4">
{portfolio.technologies.map((tch, _i) => (
<React.Fragment key={_i}>
<Span className="text-sm dark:text-white/40">
{tch}
</Span>
{_i < portfolio.technologies.length - 1 && (
<Divider vertical />
)}
</React.Fragment>
))}
</Row>
)}
</Stack>
</Card>
);
}

View File

@ -0,0 +1,42 @@
import Button from "@/components/lib/layout/Button";
import H1 from "@/components/lib/layout/H1";
import Row from "@/components/lib/layout/Row";
import Section from "@/components/lib/layout/Section";
import Span from "@/components/lib/layout/Span";
import Stack from "@/components/lib/layout/Stack";
import { Contact, ScrollText } from "lucide-react";
export default function Main() {
return (
<Section>
<Stack className="w-full max-w-full xl:max-w-[50vw]">
<Span>Howdy Tech Enthusiasts! I'm Benjamin Toby</Span>
<H1 className="leading-snug">
Software Engineer, DevOps Engineer, Full Stack Developer,
Software Architect, Philosopher, Solar Energy Enthusiast.
</H1>
<Row className="items-stretch flex-col md:flex-row w-full md:w-auto">
<Button
beforeIcon={
<Contact size={17} className="font-normal" />
}
href="/contact"
className="grow w-full"
>
Contact Me
</Button>
<Button
beforeIcon={
<ScrollText size={17} className="font-normal" />
}
href="/contact"
variant="outlined"
className="grow w-full"
>
Resume
</Button>
</Row>
</Stack>
</Section>
);
}

View File

@ -0,0 +1,22 @@
import H1 from "@/components/lib/layout/H1";
import Link from "@/components/lib/layout/Link";
import Row from "@/components/lib/layout/Row";
import Section from "@/components/lib/layout/Section";
import Span from "@/components/lib/layout/Span";
import Stack from "@/components/lib/layout/Stack";
import { Mail } from "lucide-react";
export default function Main() {
return (
<Section>
<Stack className="w-full max-w-full xl:max-w-[50vw]">
<H1 className="leading-snug">About Me</H1>
<Span>
I'm a man of few words. My{" "}
<Link href="/skills">Skills</Link> and{" "}
<Link href="/work">Work</Link> speaks for themselves.
</Span>
</Stack>
</Section>
);
}

View File

@ -0,0 +1,28 @@
import H1 from "@/components/lib/layout/H1";
import Link from "@/components/lib/layout/Link";
import Row from "@/components/lib/layout/Row";
import Section from "@/components/lib/layout/Section";
import Span from "@/components/lib/layout/Span";
import Stack from "@/components/lib/layout/Stack";
import { Mail } from "lucide-react";
export default function Main() {
return (
<Section>
<Stack className="w-full max-w-full xl:max-w-[50vw]">
<H1 className="leading-snug">Contact Me</H1>
<Span>
Have a great idea? Want to collaborate? Let's make it
happen.
</Span>
<Link href="mailto:ben@tben.me" className="border-none">
<Row className="items-center">
<Mail size={20} className="mt-1" />
<Span className="text-2xl">ben@tben.me</Span>
</Row>
</Link>
</Stack>
</Section>
);
}

View File

@ -0,0 +1,18 @@
import H1 from "@/components/lib/layout/H1";
import Section from "@/components/lib/layout/Section";
import Span from "@/components/lib/layout/Span";
import Stack from "@/components/lib/layout/Stack";
export default function Main() {
return (
<Section>
<Stack className="w-full max-w-full xl:max-w-[50vw]">
<H1 className="leading-snug">My Skills</H1>
<Span>
A summary of the vast array of tools I've mastered over the
years
</Span>
</Stack>
</Section>
);
}

View File

@ -0,0 +1,15 @@
import H1 from "@/components/lib/layout/H1";
import Section from "@/components/lib/layout/Section";
import Span from "@/components/lib/layout/Span";
import Stack from "@/components/lib/layout/Stack";
export default function Main() {
return (
<Section>
<Stack className="w-full max-w-full xl:max-w-[50vw]">
<H1 className="leading-snug">My Work</H1>
<Span>Some of My Work</Span>
</Stack>
</Section>
);
}

View File

@ -0,0 +1,70 @@
import { GitBranch, Github, Linkedin, Mail, Users } from "lucide-react";
import { ReactNode } from "react";
export type HeaderLinkType = {
name: string;
href: string;
current?: boolean;
};
export const HeaderLinks: HeaderLinkType[] = [
{
name: "Home",
href: "/",
current: true,
},
{
name: "About",
href: "/about",
},
{
name: "Skills",
href: "/skills",
},
{
name: "Work",
href: "/work",
},
{
name: "Blog",
href: "/blog",
},
{
name: "Contact",
href: "/contact",
},
];
export type SocialLinksType = {
name?: string;
href: string;
icon: ReactNode;
};
export const SocialLinks: SocialLinksType[] = [
{
name: "Github",
href: "https://github.com/BenjaminToby",
icon: <Github size={17} />,
},
{
name: "Linkedin",
href: "https://www.linkedin.com/in/benjamin-toby/",
icon: <Linkedin size={17} />,
},
{
name: "Teams",
href: "https://team.tben.me/",
icon: <Users size={17} />,
},
{
name: "Git",
href: "https://git.tben.me",
icon: <GitBranch size={17} />,
},
{
name: "Mail",
href: "mailto:ben@tben.me",
icon: <Mail size={17} />,
},
];

View File

@ -0,0 +1,13 @@
import { HeaderLinkType } from "../(data)/links";
type Props = {
link: HeaderLinkType;
};
export default function HeaderLink({ link }: Props) {
return (
<a href={link.href} className="text-white hover:text-gray-300">
{link.name}
</a>
);
}

View File

@ -0,0 +1,18 @@
import { SocialLinksType } from "../(data)/links";
type Props = {
link: SocialLinksType;
};
export default function SocialLink({ link }: Props) {
return (
<a
href={link.href}
title={link.name}
className="text-white hover:text-gray-300"
target="_blank"
>
{link.icon}
</a>
);
}

View File

@ -0,0 +1,56 @@
import Logo from "@/components/general/Logo";
import Stack from "@/components/lib/layout/Stack";
import { twMerge } from "tailwind-merge";
import { HeaderLinks, SocialLinks } from "../(data)/links";
import HeaderLink from "../(partials)/HeaderLink";
import React from "react";
import Divider from "@/components/lib/layout/Divider";
import Button from "@/components/lib/layout/Button";
import { X } from "lucide-react";
import SocialLink from "../(partials)/SocialLink";
import Row from "@/components/lib/layout/Row";
type Props = {
menuOpen: boolean;
setMenuOpen: React.Dispatch<React.SetStateAction<boolean>>;
};
export default function MobileMenu({ menuOpen, setMenuOpen }: Props) {
return (
<div
className={twMerge(
"fixed top-0 bg-[var(--bg-color)] w-full h-full overflow-y-auto",
"z-[100] p-10",
menuOpen ? "right-0" : "right-[100vw]"
)}
>
<Button
variant="ghost"
className="absolute top-10 right-10"
onClick={() => setMenuOpen(false)}
>
<X />
</Button>
<Stack className="w-full h-full">
<Logo size={40} />
<Divider />
<Stack className="w-full items-stretch">
{HeaderLinks.map((link, index) => {
return (
<React.Fragment key={index}>
<HeaderLink key={index} link={link} />
{index < HeaderLinks.length - 1 && <Divider />}
</React.Fragment>
);
})}
</Stack>
<Divider />
<Row className="items-center w-full py-6 mt-auto gap-10 mt-auto">
{SocialLinks.map((link, index) => {
return <SocialLink key={index} link={link} />;
})}
</Row>
</Stack>
</div>
);
}

40
layouts/main/Aside.tsx Normal file
View File

@ -0,0 +1,40 @@
import Logo from "@/components/general/Logo";
import Stack from "@/components/lib/layout/Stack";
import { PropsWithChildren } from "react";
import { twMerge } from "tailwind-merge";
import { SocialLinks } from "./(data)/links";
import SocialLink from "./(partials)/SocialLink";
type Props = {};
export default function Aside({}: Props) {
return (
<aside
className={twMerge(
"max-w-[100px] border-0 border-r max-h-[100vh]",
"border-white/10 border-solid flex flex-col",
"items-start hidden md:flex sticky top-0"
)}
>
<div
className={twMerge(
"px-6 py-4 h-[var(--header-height)] border-0",
"border-b border-white/10"
)}
>
<Logo size={28} />
</div>
<Stack className="items-center w-full py-6 mt-auto">
{SocialLinks.map((link, index) => {
return <SocialLink key={index} link={link} />;
})}
</Stack>
<div
className={twMerge(
"px-6 py-4 h-[var(--header-height)] border-0",
"border-t border-white/10 w-full"
)}
></div>
</aside>
);
}

22
layouts/main/Footer.tsx Normal file
View File

@ -0,0 +1,22 @@
import Span from "@/components/lib/layout/Span";
import { PropsWithChildren } from "react";
import { twMerge } from "tailwind-merge";
type Props = {};
export default function Footer({}: Props) {
const date = new Date();
return (
<footer
className={twMerge(
"h-[var(--header-height)] border-0 border-t border-white/10",
"w-full flex flex-row items-center px-6 mt-auto"
)}
>
<Span className="text-sm opacity-40">
Copyright © {date.getFullYear()} Tben.me. All Rights Reserved.
</Span>
</footer>
);
}

37
layouts/main/Header.tsx Normal file
View File

@ -0,0 +1,37 @@
import { twMerge } from "tailwind-merge";
import { HeaderLinks } from "./(data)/links";
import HeaderLink from "./(partials)/HeaderLink";
import Row from "@/components/lib/layout/Row";
import Logo from "@/components/general/Logo";
import { Menu } from "lucide-react";
import Button from "@/components/lib/layout/Button";
import React from "react";
type Props = {
menuOpen: boolean;
setMenuOpen: React.Dispatch<React.SetStateAction<boolean>>;
};
export default function Header({ menuOpen, setMenuOpen }: Props) {
return (
<header
className={twMerge(
"h-[var(--header-height)] border-0 border-b border-white/10",
"w-full flex flex-row items-center px-6 sticky top-0",
"bg-[var(--bg-color)] z-10"
)}
>
<Row className="gap-6 ml-auto hidden md:flex">
{HeaderLinks.map((link, index) => {
return <HeaderLink key={index} link={link} />;
})}
</Row>
<Row className="flex md:hidden w-full justify-between">
<Logo size={25} />
<Button variant="ghost" onClick={() => setMenuOpen(!menuOpen)}>
<Menu />
</Button>
</Row>
</header>
);
}

30
layouts/main/index.tsx Normal file
View File

@ -0,0 +1,30 @@
import Main from "@/components/lib/layout/Main";
import React, { PropsWithChildren } from "react";
import Aside from "./Aside";
import Header from "./Header";
import Footer from "./Footer";
import { twMerge } from "tailwind-merge";
import Stack from "@/components/lib/layout/Stack";
import { HeaderLinks } from "./(data)/links";
import HeaderLink from "./(partials)/HeaderLink";
import MobileMenu from "./(sections)/MobileMenu";
type Props = PropsWithChildren & {};
export default function Layout({ children }: Props) {
const [menuOpen, setMenuOpen] = React.useState(false);
return (
<div className="flex flex-row items-stretch w-full min-h-screen">
<Aside />
<div className={twMerge("flex flex-col items-start gap-0", "grow")}>
<Header {...{ menuOpen, setMenuOpen }} />
<main className="w-full items-start flex flex-col gap-0">
{children}
</main>
<Footer />
</div>
<MobileMenu {...{ menuOpen, setMenuOpen }} />
</div>
);
}

View File

@ -9,9 +9,12 @@
"lint": "next lint" "lint": "next lint"
}, },
"dependencies": { "dependencies": {
"@moduletrace/datasquirel": "^2.7.4",
"lucide-react": "^0.462.0",
"next": "15.0.3",
"react": "19.0.0-rc-66855b96-20241106", "react": "19.0.0-rc-66855b96-20241106",
"react-dom": "19.0.0-rc-66855b96-20241106", "react-dom": "19.0.0-rc-66855b96-20241106",
"next": "15.0.3" "tailwind-merge": "^2.5.5"
}, },
"devDependencies": { "devDependencies": {
"typescript": "^5", "typescript": "^5",

51
pages/404.tsx Normal file
View File

@ -0,0 +1,51 @@
import Button from "@/components/lib/layout/Button";
import H1 from "@/components/lib/layout/H1";
import Row from "@/components/lib/layout/Row";
import Section from "@/components/lib/layout/Section";
import Span from "@/components/lib/layout/Span";
import Stack from "@/components/lib/layout/Stack";
import Layout from "@/layouts/main";
import { Antenna, UtilityPole } from "lucide-react";
export default function Home() {
return (
<Layout>
<Section>
<Stack>
<Row className="items-center gap-20">
<UtilityPole
size={100}
strokeWidth={1}
className="mt-4"
opacity={0.5}
/>
<Stack className="gap-4">
<H1 className="text-[60px] m-0 leading-[50px]">
404
</H1>
<Span>Page Not Found!</Span>
<Row className="gap-4 max-w-[400px] w-[400px]">
<Button
onClick={() => window.history.back()}
className="grow"
>
Go Back
</Button>
<Button
href="/"
variant="outlined"
linkProps={{
className: "grow",
}}
className="w-full"
>
Home
</Button>
</Row>
</Stack>
</Row>
</Stack>
</Section>
</Layout>
);
}

View File

@ -2,5 +2,5 @@ import "@/styles/globals.css";
import type { AppProps } from "next/app"; import type { AppProps } from "next/app";
export default function App({ Component, pageProps }: AppProps) { export default function App({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />; return <Component {...pageProps} />;
} }

View File

@ -1,13 +1,13 @@
import { Html, Head, Main, NextScript } from "next/document"; import { Html, Head, Main, NextScript } from "next/document";
export default function Document() { export default function Document() {
return ( return (
<Html lang="en"> <Html lang="en" className="dark">
<Head /> <Head />
<body className="antialiased"> <body className="antialiased">
<Main /> <Main />
<NextScript /> <NextScript />
</body> </body>
</Html> </Html>
); );
} }

10
pages/about.tsx Normal file
View File

@ -0,0 +1,10 @@
import Layout from "@/layouts/main";
import Main from "@/components/pages/about";
export default function ContactPage() {
return (
<Layout>
<Main />
</Layout>
);
}

10
pages/contact.tsx Normal file
View File

@ -0,0 +1,10 @@
import Layout from "@/layouts/main";
import Main from "@/components/pages/contact";
export default function ContactPage() {
return (
<Layout>
<Main />
</Layout>
);
}

View File

@ -1,115 +1,21 @@
import Image from "next/image"; import Layout from "@/layouts/main";
import localFont from "next/font/local"; import H1 from "@/components/lib/layout/H1";
import Main from "@/components/pages/Home";
const geistSans = localFont({ import AboutSection from "@/components/pages/Home/(sections)/AboutSection";
src: "./fonts/GeistVF.woff", import Divider from "@/components/lib/layout/Divider";
variable: "--font-geist-sans", import MySkillsSection from "@/components/pages/Home/(sections)/MySkillsSection";
weight: "100 900", import MyWorkSection from "@/components/pages/Home/(sections)/MyWorkSection";
});
const geistMono = localFont({
src: "./fonts/GeistMonoVF.woff",
variable: "--font-geist-mono",
weight: "100 900",
});
export default function Home() { export default function Home() {
return ( return (
<div <Layout>
className={`${geistSans.variable} ${geistMono.variable} grid grid-rows-[20px_1fr_20px] items-center justify-items-center min-h-screen p-8 pb-20 gap-16 sm:p-20 font-[family-name:var(--font-geist-sans)]`} <Main />
> <Divider />
<main className="flex flex-col gap-8 row-start-2 items-center sm:items-start"> <AboutSection />
<Image <Divider />
className="dark:invert" <MySkillsSection />
src="/next.svg" <Divider />
alt="Next.js logo" <MyWorkSection />
width={180} </Layout>
height={38} );
priority
/>
<ol className="list-inside list-decimal text-sm text-center sm:text-left font-[family-name:var(--font-geist-mono)]">
<li className="mb-2">
Get started by editing{" "}
<code className="bg-black/[.05] dark:bg-white/[.06] px-1 py-0.5 rounded font-semibold">
pages/index.tsx
</code>
.
</li>
<li>Save and see your changes instantly.</li>
</ol>
<div className="flex gap-4 items-center flex-col sm:flex-row">
<a
className="rounded-full border border-solid border-transparent transition-colors flex items-center justify-center bg-foreground text-background gap-2 hover:bg-[#383838] dark:hover:bg-[#ccc] text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5"
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<Image
className="dark:invert"
src="/vercel.svg"
alt="Vercel logomark"
width={20}
height={20}
/>
Deploy now
</a>
<a
className="rounded-full border border-solid border-black/[.08] dark:border-white/[.145] transition-colors flex items-center justify-center hover:bg-[#f2f2f2] dark:hover:bg-[#1a1a1a] hover:border-transparent text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5 sm:min-w-44"
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=default-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
Read our docs
</a>
</div>
</main>
<footer className="row-start-3 flex gap-6 flex-wrap items-center justify-center">
<a
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=default-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<Image
aria-hidden
src="/file.svg"
alt="File icon"
width={16}
height={16}
/>
Learn
</a>
<a
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=default-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<Image
aria-hidden
src="/window.svg"
alt="Window icon"
width={16}
height={16}
/>
Examples
</a>
<a
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
href="https://nextjs.org?utm_source=create-next-app&utm_medium=default-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<Image
aria-hidden
src="/globe.svg"
alt="Globe icon"
width={16}
height={16}
/>
Go to nextjs.org
</a>
</footer>
</div>
);
} }

14
pages/skills.tsx Normal file
View File

@ -0,0 +1,14 @@
import Layout from "@/layouts/main";
import Main from "@/components/pages/skills";
import Divider from "@/components/lib/layout/Divider";
import MySkillsSection from "@/components/pages/Home/(sections)/MySkillsSection";
export default function SkillsPage() {
return (
<Layout>
<Main />
<Divider />
<MySkillsSection noTitle expand />
</Layout>
);
}

14
pages/work.tsx Normal file
View File

@ -0,0 +1,14 @@
import Layout from "@/layouts/main";
import Main from "@/components/pages/work";
import Divider from "@/components/lib/layout/Divider";
import MyWorkSection from "@/components/pages/Home/(sections)/MyWorkSection";
export default function WorkPage() {
return (
<Layout>
<Main />
<Divider />
<MyWorkSection noTitle expand />
</Layout>
);
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 320 B

BIN
public/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 B

View File

@ -1 +0,0 @@
<svg fill="none" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 13.5V5.41a1 1 0 0 0-.3-.7L9.8.29A1 1 0 0 0 9.08 0H1.5v13.5A2.5 2.5 0 0 0 4 16h8a2.5 2.5 0 0 0 2.5-2.5m-1.5 0v-7H8v-5H3v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1M9.5 5V2.12L12.38 5zM5.13 5h-.62v1.25h2.12V5zm-.62 3h7.12v1.25H4.5zm.62 3h-.62v1.25h7.12V11z" clip-rule="evenodd" fill="#666" fill-rule="evenodd"/></svg>

Before

Width:  |  Height:  |  Size: 391 B

View File

@ -1 +0,0 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 984 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 983 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 785 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 919 B

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!-- Generator: Gravit.io --><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="isolation:isolate" viewBox="0 0 611 611" width="611pt" height="611pt"><defs><clipPath id="_clipPath_2zfa3boh6FNyOkB9zT4Cm84iY9vA0NWV"><rect width="611" height="611"/></clipPath></defs><g clip-path="url(#_clipPath_2zfa3boh6FNyOkB9zT4Cm84iY9vA0NWV)"><rect x="0" y="0" width="610.63" height="610.63" transform="matrix(1,0,0,1,0,0)" fill="none"/><clipPath id="_clipPath_7KSpsgRxupOAmqFAFnlf5LCTNooKCwdC"><rect x="0" y="0" width="610.63" height="610.63" transform="matrix(1,0,0,1,0,0)" fill="rgb(255,255,255)"/></clipPath><g clip-path="url(#_clipPath_7KSpsgRxupOAmqFAFnlf5LCTNooKCwdC)"><g><g><g><path d=" M 610.63 515.37 L 610.63 619.37 L 590.72 607.63 L 461.72 531.55 L 306.83 617 L 151.94 702.39 L 138.33 709.89 L 0 786.14 L 0 0 L 362 0 C 434.173 0 490.98 15.707 532.42 47.12 C 534.38 48.613 536.297 50.137 538.17 51.69 C 575.177 82.423 593.98 125.773 594.58 181.74 L 594.58 184.49 C 594.58 225.95 583.717 260.877 561.99 289.27 C 540.263 317.663 511.353 336.547 475.26 345.92 C 518.027 355.92 551.283 376.477 575.03 407.59 C 598.777 438.703 610.643 474.63 610.63 515.37 Z M 368.49 519.89 C 378.163 512.21 383 499.673 383 482.28 C 383 448.193 363.28 431.15 323.84 431.15 L 222.6 431.15 L 222.6 531.42 L 323.87 531.42 C 343.923 531.42 358.797 527.577 368.49 519.89 Z M 368 227.61 C 368 210.23 363.153 197.36 353.46 189 C 343.767 180.64 328.893 176.463 308.84 176.47 L 222.6 176.47 L 222.6 276.74 L 308.83 276.74 C 328.877 276.74 343.75 272.74 353.45 264.74 C 363.15 256.74 368 244.363 368 227.61 Z " fill="rgb(255,255,255)"/></g></g></g></g></g></svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

Some files were not shown because too many files have changed in this diff Show More