Reorganize repo structure and standards references

This commit is contained in:
david committed 2026-06-29 05:03:42 +02:00
1 parent 3cb93a81be
commit be2054274d
5885 files changed
+2588 -195

No files matched your search

@@ -0,0 +1,57 @@
import clsx from "clsx";
import { ReactNode, useState } from "react";
import { renderSanitizedMarkdown } from "~/utils/html-sanitizer";
import ButtonSecondary from "../buttons/ButtonSecondary";
import Modal from "../modals/Modal";
import { useTranslation } from "react-i18next";
export default function ShowHtmlModalButton({
html,
title,
link,
size,
}: {
html: string | undefined | null;
title: React.ReactNode;
link?: {
href: string;
target?: undefined | "_blank";
text?: ReactNode;
};
className?: string;
size?: "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "7xl" | "full";
}) {
const { t } = useTranslation();
const [open, setOpen] = useState(false);
return (
<>
<div className="flex space-x-2">
<button type="button" disabled={!html} onClick={() => setOpen(true)} className={clsx(html && "underline")}>
{title}
</button>
</div>
<Modal size={size} open={open} setOpen={setOpen}>
<div>
<div className="flex items-center justify-between space-x-2">
<div className="text-text-neutral-primary text-lg font-medium">{title ?? t("shared.details")}</div>
{link && (
<ButtonSecondary className="group" to={link.href} target={link.target}>
{link.text}
</ButtonSecondary>
)}
</div>
<div className="h-[calc(100vh-10rem)] overflow-y-auto">
<div className="prose border-border-default mt-2 border-t pt-2">
<div
dangerouslySetInnerHTML={{
__html: renderSanitizedMarkdown(html),
}}
/>
</div>
</div>
</div>
</Modal>
</>
);
}
@@ -0,0 +1,69 @@
import clsx from "clsx";
import { ReactNode, useState } from "react";
import Modal from "../modals/Modal";
import ModalOrSlide from "../modals/ModalOrSlide";
import { Button, buttonVariants } from "../button";
interface Props {
title: ReactNode;
children?: ReactNode;
className?: string;
type?: "dialog" | "modal";
size?: "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl";
buttons?: ReactNode;
dialogTitle?: string;
disabled?: boolean;
buttonProps?: {
variant?: "default" | "outline";
size?: "icon" | "xs" | "sm" | "default" | "lg";
};
}
export default function ShowModalButton({
title,
children,
className = "sm:max-w-md",
type = "modal",
size = "lg",
buttons,
dialogTitle,
disabled,
buttonProps,
}: Props) {
const [open, setOpen] = useState(false);
return (
<>
<div className="flex space-x-2">
{buttonProps !== undefined ? (
<Button
{...buttonProps}
disabled={!children || disabled}
onClick={(e) => {
e.stopPropagation();
setOpen(true);
}}
>
{title}
</Button>
) : (
<button
type="button"
disabled={!children || disabled}
onClick={(e) => {
e.stopPropagation();
setOpen(true);
}}
className={clsx(!!children)}
>
{title}
</button>
)}
</div>
<ModalOrSlide title={dialogTitle || title} type={type} size={size} open={open} setOpen={setOpen} buttons={buttons}>
{children}
</ModalOrSlide>
</>
);
}
@@ -0,0 +1,39 @@
import clsx from "clsx";
import { useState } from "react";
export default function ShowMoreLinesText({
lines = "1",
children,
className,
}: {
lines?: "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8";
children?: React.ReactNode;
className?: string;
}) {
const [expanded, setExpanded] = useState(false);
return (
<button
type="button"
onClick={() => setExpanded(!expanded)}
aria-expanded={expanded}
className={clsx(
className,
"cursor-pointer text-left",
expanded
? "line-clamp-none"
: clsx(
lines === "1" && "line-clamp-1",
lines === "2" && "line-clamp-2",
lines === "3" && "line-clamp-3",
lines === "4" && "line-clamp-4",
lines === "5" && "line-clamp-5",
lines === "6" && "line-clamp-6",
lines === "7" && "line-clamp-7",
lines === "8" && "line-clamp-8"
)
)}
>
{children}
</button>
);
}
@@ -0,0 +1,74 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import Modal from "../modals/Modal";
import clsx from "clsx";
import toast from "react-hot-toast";
export default function ShowPayloadModalButton({
payload,
title,
description,
withCopy = true,
className,
size = "xl",
}: {
payload: string;
title?: string;
description?: React.ReactNode;
withCopy?: boolean;
className?: string;
size?: "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "7xl" | "full";
}) {
const { t } = useTranslation();
const [open, setOpen] = useState(false);
function stringifyDetails() {
if (typeof payload === "string") {
return payload;
}
try {
return JSON.stringify(JSON.parse(payload ?? "{}"), null, "\t");
} catch (e) {
return JSON.stringify(payload, null, "\t");
}
}
return (
<>
<div className="flex space-x-2">
{payload !== null && (
<button
type="button"
onClick={() => setOpen(true)}
className={clsx(className, "hover:border-theme-400 border-border-default border-b border-dotted hover:border-dashed")}
>
{/* {t("models.log.details")} */}
{description ?? JSON.stringify(payload)}
</button>
)}
</div>
<Modal size={size} open={open} setOpen={setOpen}>
<div className="flex justify-between space-x-2">
<div className="text-text-neutral-primary text-lg font-medium">{title ?? t("shared.details")}</div>
<div>
{withCopy && (
<button
type="button"
onClick={() => {
navigator.clipboard.writeText(stringifyDetails());
toast.success(t("shared.copied"));
}}
className="bg-theme-100 text-theme-700 hover:bg-theme-200 focus:shadow-focus inline-flex items-center rounded-md border border-transparent px-3 py-2 text-sm font-medium leading-4 focus:outline-hidden"
>
{t("shared.copy")}
</button>
)}
</div>
</div>
<div className="prose bg-foreground/90 border-border-default mt-2 max-h-96 overflow-auto rounded-lg border-2 border-dashed">
<pre>{stringifyDetails()}</pre>
</div>
</Modal>
</>
);
}