Skip to content

Commit e3eb1e2

Browse files
committed
feat: add heading styles and inline code handling in ViewMarkdown component
1 parent ef96d00 commit e3eb1e2

File tree

2 files changed

+56
-2
lines changed

2 files changed

+56
-2
lines changed

src/components/ViewMarkdown/index.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,22 @@ const ViewMarkdown: React.FC<ViewMarkdownProps> = ({ content }) => {
8484
th: S.Th,
8585
td: S.Td,
8686
em: S.Em,
87+
h2: S.H2,
88+
h3: S.H3,
89+
h4: S.Default,
90+
h5: S.Default,
91+
h6: S.Default,
8792
code: ({ node, className, children, ...props }) => {
93+
const isInline = !node?.properties?.className;
94+
95+
if (isInline) {
96+
return (
97+
<S.Code className={className} {...props}>
98+
{children}
99+
</S.Code>
100+
);
101+
}
102+
88103
return (
89104
<CodeBlock className={className} {...props} node={node}>
90105
{children}

src/components/ViewMarkdown/styles.ts

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,37 @@ const defaultStyle = css`
66
word-wrap: break-word;
77
/* overflow-x: scroll;
88
white-space: pre-wrap; */
9+
font-size: 1rem;
10+
`;
11+
12+
const headingStyle = css`
13+
font-weight: 600;
14+
font-family: "Love Ya Like A Sister", cursive;
15+
margin: 10px 0;
916
`;
1017

1118
export const H1 = styled.h1`
1219
${defaultStyle}
13-
font-size: 1rem;
14-
font-weight: 600;
20+
${headingStyle}
21+
font-size: 1.4rem;
22+
`;
23+
24+
export const H2 = styled.h2`
25+
${defaultStyle}
26+
${headingStyle}
27+
font-size: 1.3rem;
28+
`;
29+
30+
export const H3 = styled.h3`
31+
${defaultStyle}
32+
${headingStyle}
33+
font-size: 1.2rem;
34+
`;
35+
36+
export const Default = styled.h4`
37+
${defaultStyle}
38+
${headingStyle}
39+
font-size: 1.1rem;
1540
`;
1641

1742
export const Break = styled.br`
@@ -20,6 +45,7 @@ export const Break = styled.br`
2045

2146
export const P = styled.p`
2247
${defaultStyle}
48+
margin: 2px 0;
2349
`;
2450

2551
export const Div = styled.div`
@@ -187,3 +213,16 @@ export const Input = styled.input`
187213
&:checked {
188214
}
189215
`;
216+
217+
export const strong = styled.strong`
218+
${defaultStyle}
219+
font-weight: bold;
220+
`;
221+
222+
export const Code = styled.code`
223+
${defaultStyle}
224+
background-color: #282a36;
225+
border-radius: 4px;
226+
padding: 2px 6px;
227+
font-size: 0.9rem;
228+
`;

0 commit comments

Comments
 (0)