-
Notifications
You must be signed in to change notification settings - Fork 0
/
craft.tsx
131 lines (118 loc) · 3.17 KB
/
craft.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import * as React from "react";
// cn util
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
// Layout Component
type LayoutProps = {
children: React.ReactNode;
className?: string;
};
const Layout = ({ children, className }: LayoutProps) => {
return (
<html
lang="en"
suppressHydrationWarning
className={cn("scroll-smooth antialiased focus:scroll-auto", className)}
>
{children}
</html>
);
};
// Main Component
type MainProps = {
children: React.ReactNode;
className?: string;
id?: string;
};
const Main = ({ children, className, id }: MainProps) => {
return (
<main
className={cn(
// `Main` Specific Styles
"max-w-none prose-p:m-0",
// General Prose
"prose prose-neutral prose:font-sans dark:prose-invert xl:prose-lg",
// Prose Headings
"prose-headings:font-normal",
// Prose Strong
"prose-strong:font-semibold",
// Inline Links
"prose-a:underline prose-a:decoration-primary/50 prose-a:underline-offset-2 prose-a:text-foreground/75 prose-a:transition-all",
// Inline Link Hover
"hover:prose-a:decoration-primary hover:prose-a:text-foreground",
// Blockquotes
"prose-blockquote:not-italic",
// Pre and Code Blocks
"prose-pre:border prose-pre:bg-muted/25 prose-pre:text-foreground",
className
)}
id={id}
>
{children}
</main>
);
};
// Section Component
type SectionProps = {
children: React.ReactNode;
className?: string;
id?: string;
};
const Section = ({ children, className, id }: SectionProps) => {
return (
<section className={cn("py-8 md:py-12", className)} id={id}>
{children}
</section>
);
};
// Container Component
type ContainerProps = {
children: React.ReactNode;
className?: string;
id?: string;
};
const Container = ({ children, className, id }: ContainerProps) => {
return (
<div className={cn("mx-auto max-w-5xl", "p-6 sm:p-8", className)} id={id}>
{children}
</div>
);
};
// Article Component
type ArticleProps = {
children: React.ReactNode;
className?: string;
id?: string;
};
const Article = ({ children, className, id }: ArticleProps) => {
return (
<article
className={cn(
// General Prose
"prose prose-neutral prose:font-sans dark:prose-invert xl:prose-lg max-w-none",
// Prose Headings
"prose-headings:font-normal",
// Prose Paragraphs
"prose-p:mb-0",
// Prose Strong
"prose-strong:font-semibold",
// Inline Links
"prose-a:underline prose-a:decoration-primary/50 prose-a:underline-offset-2 prose-a:text-foreground/75 prose-a:transition-all",
// Inline Link Hover
"hover:prose-a:decoration-primary hover:prose-a:text-foreground",
// Blockquotes
"prose-blockquote:not-italic",
// Pre and Code Blocks
"prose-pre:border prose-pre:bg-muted/25",
className
)}
id={id}
>
{children}
</article>
);
};
export { Layout, Main, Section, Container, Article };