upgrade the project

This commit is contained in:
PrinOrange
2024-04-03 22:08:27 +08:00
parent a615511139
commit ea3597d62f
313 changed files with 10677 additions and 7069 deletions

View File

@@ -0,0 +1,13 @@
const Blockquote = (props: JSX.IntrinsicElements["blockquote"]) => {
return (
<blockquote
className={
"not-prose scroll-mt-20 my-5 px-5 py-4 bg-gray-100 dark:bg-gray-800 dark:border-gray-700 border-gray-300 border-l-4"
}
>
{props.children}
</blockquote>
);
};
export default Blockquote;

View File

@@ -1,9 +1,9 @@
import { fontFangZhengXiaoBiaoSongCN } from "@/styles/font";
export const H2 = (props: JSX.IntrinsicElements["h2"]) => {
const H2 = (props: JSX.IntrinsicElements["h2"]) => {
return (
<h2 className={`${fontFangZhengXiaoBiaoSongCN.className} mt-4 mb-2 scroll-mt-20`} id={props.id}>
<h2 className={`font-fang-zheng-xiao-biao-song scroll-mt-20`} id={props.id}>
{props.children}
</h2>
);
};
export default H2;

View File

@@ -1,4 +1,7 @@
import { useRef, useState } from "react";
import { FaCheck } from "react-icons/fa";
import { IoCopyOutline } from "react-icons/io5";
import { Button } from "../ui/button";
const PreWrapper = ({ children }: { children: JSX.Element }) => {
const textInput = useRef(null);
@@ -16,51 +19,23 @@ const PreWrapper = ({ children }: { children: JSX.Element }) => {
setCopied(true);
//@ts-ignore
textInput.current && navigator.clipboard.writeText(textInput.current.textContent);
setTimeout(() => {
setCopied(false);
}, 2000);
};
return (
<div ref={textInput} onMouseEnter={onEnter} onMouseLeave={onExit} className="relative flat-scrollbar-normal">
<div className="relative flat-scrollbar-normal" onMouseLeave={onExit} onMouseMove={onEnter} ref={textInput}>
{hovered && (
<button
<Button
aria-label="Copy code"
className={`absolute right-2 top-2 h-8 w-8 rounded border-2 bg-gray-700 p-1 dark:bg-gray-800 ${
copied ? "border-green-400 focus:border-green-400 focus:outline-none" : "border-gray-300"
}`}
className={`absolute right-2 top-2 h-8 w-8 rounded p-1 ${copied ? "hover:text-green-500 text-green-500" : ""}`}
onClick={onCopy}
variant={"outline"}
>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
stroke="currentColor"
fill="none"
className={copied ? "text-green-400" : "text-gray-300"}
>
{copied ? (
<>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"
/>
</>
) : (
<>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"
/>
</>
)}
</svg>
</button>
{copied ? <FaCheck /> : <IoCopyOutline />}
</Button>
)}
<pre className="flat-scrollbar-normal">{children}</pre>
<pre className="p-2 dark:bg-[#0d1117] bg-[#F6F8FA] rounded-md flat-scrollbar-normal not-prose text-sm dark:selection:bg-gray-700 selection:bg-gray-300 selection:text-inherit">
{children}
</pre>
</div>
);
};

View File

@@ -1,4 +1,5 @@
import { H2 } from "./H2";
import Blockquote from "./Blockquote";
import H2 from "./H2";
import ImageWrapper from "./ImageWrapper";
import PreWrapper from "./PreWrapper";
import TableWrapper from "./TableWrapper";
@@ -8,4 +9,5 @@ export const MDXComponentsSet = {
table: TableWrapper,
img: ImageWrapper,
h2: H2,
blockquote: Blockquote,
};