Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactoring #289

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 12 additions & 33 deletions src/components/Prose.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,20 @@
import clsx from "classnames";
import { ReactNode } from "react";

export function Prose<T extends React.ElementType = "div">({
as,
className,
...props
}: React.ComponentPropsWithoutRef<T> & {
as?: T;
}) {
let Component = as ?? "div";
interface Props {
children: ReactNode;
className?: string;
}

export const Prose: React.FC<Props> = ({ children, className }) => {
return (
<Component
<div
className={clsx(
className,
"dark:white prose max-w-none leading-normal dark:prose-invert",
// headings
"prose-headings:mb-2.5 prose-headings:text-2xl prose-h2:mt-10",
// lead
"prose-lead:text-slate-500 dark:prose-lead:text-white",
// links
"prose-a:font-normal dark:prose-a:text-pink",
// link underline
"prose-a:font-normal prose-a:no-underline hover:prose-a:font-normal hover:prose-a:underline ",
// pre
"prose-pre:rounded-xl prose-pre:bg-slate-900 prose-pre:shadow-lg dark:prose-pre:bg-slate-800/60 dark:prose-pre:shadow-none dark:prose-pre:ring-1 dark:prose-pre:ring-slate-300/10",
// hr
"dark:prose-hr:border-slate-800",
//paragraph
"prose-p:my-2.5",
//list
"prose-ul:my-2.5 prose-li:my-0 prose-li:px-0",
//img
"prose-img:my-10",
//code
"prose-code:text-base prose-code:font-normal",
"dark:white prose max-w-none leading-normal dark:prose-invert prose-li:px-0",
)}
{...props}
/>
>
{children}
</div>
);
}
};
29 changes: 19 additions & 10 deletions tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import { Config } from "tailwindcss";

const plugin = require("tailwindcss/plugin");

const typographyHeading = (overrides: any) => ({
const typographyHeading = () => ({
fontFamily: "ES Build",
fontStyle: "normal",
fontWeight: "bold",
lineHeight: "120%",
...overrides,
marginTop: "2.5rem",
marginBottom: "10px",
fontSize: "1.5rem",
});

export default {
Expand Down Expand Up @@ -109,17 +111,23 @@ export default {
css: {
a: {
color: theme("colors.pink.DEFAULT"),
textDecorationLine: "none",
"&:hover": {
color: theme("colors.pink.hover"),
fontWeight: "inherit",
textDecorationLine: "underline",
},
fontWeight: "inherit",
fontWeight: "normal",
},
h1: typographyHeading({ fontSize: "30px" }),
h2: typographyHeading({ fontSize: "26px" }),
h3: typographyHeading({ fontSize: "20px" }),
h4: typographyHeading({ fontSize: "18px" }),
h5: typographyHeading({ fontSize: "14px" }),
h1: typographyHeading(),
h2: typographyHeading(),
h3: typographyHeading(),
h4: typographyHeading(),
h5: typographyHeading(),
img: { marginBottom: theme("spacing.10") },
p: { margin: "10px 0" },
ul: { margin: "10px 0" },
li: { margin: "0" },
code: { fontWeight: theme("fontWeight.normal") },
'[class~="lead"]': { color: "colors.white" },
"code::before": {
content: null,
},
Expand All @@ -142,6 +150,7 @@ export default {
"--tw-prose-invert-counters": theme("colors.black"),
"--tw-prose-quotes": theme("colors.white"),
"--tw-prose-invert-quotes": theme("colors.black"),
"--tw-prose-hr": theme("colors.slate[800]"),
},
},
}),
Expand Down