Skip to content

Commit ea76ca7

Browse files
committed
Separate mdx local components
1 parent ad5206b commit ea76ca7

File tree

7 files changed

+90
-77
lines changed

7 files changed

+90
-77
lines changed

apps/landing/src/app/(detail)/components/button/page.tsx

Lines changed: 8 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,16 @@
1-
import { Box, css, Text, VStack } from '@devup-ui/react'
1+
import { VStack } from '@devup-ui/react'
2+
3+
import { CustomCode } from '@/components/mdx/components/CustomCode'
4+
import { CustomH4 } from '@/components/mdx/components/CustomH4'
5+
import { CustomH6 } from '@/components/mdx/components/CustomH6'
6+
import { CustomParagraph } from '@/components/mdx/components/CustomParagraph'
7+
import { CustomPre } from '@/components/mdx/components/CustomPre'
8+
import { CustomStrong } from '@/components/mdx/components/CustomStrong'
29

310
import Api from './Api.mdx'
411
import Button from './Button.mdx'
512
import Examples from './Examples.mdx'
613

7-
function CustomParagraph({ children }: { children: React.ReactNode }) {
8-
return (
9-
<Text as="p" color="$text" lineHeight="1" m="0" typography="bodyReg">
10-
{children}
11-
</Text>
12-
)
13-
}
14-
15-
function CustomPre({ children }: { children: React.ReactNode }) {
16-
return (
17-
<Box
18-
as="pre"
19-
className={css({
20-
margin: '0',
21-
w: '100%',
22-
whiteSpace: 'pre-wrap',
23-
lineBreak: 'anywhere',
24-
bg: 'transparent',
25-
overflow: 'auto',
26-
})}
27-
selectors={{
28-
'& pre': {
29-
margin: '0',
30-
w: '100%',
31-
whiteSpace: 'pre-wrap',
32-
lineBreak: 'anywhere',
33-
bg: 'transparent',
34-
overflow: 'auto',
35-
},
36-
'& pre, & code, & span, & p': {
37-
margin: '0',
38-
w: '100%',
39-
whiteSpace: 'pre-wrap',
40-
lineBreak: 'anywhere',
41-
bg: 'transparent',
42-
overflow: 'auto',
43-
},
44-
}}
45-
>
46-
{children}
47-
</Box>
48-
)
49-
}
50-
51-
function CustomCode({ children }: { children: string }) {
52-
return (
53-
<Box as="code" color="$primary" whiteSpace="pre-wrap">
54-
{children.replaceAll('<br>', '\n')}
55-
</Box>
56-
)
57-
}
58-
59-
function CustomH4({ children }: { children: React.ReactNode }) {
60-
return (
61-
<Text as="h4" color="$title" m="0" typography="h4">
62-
{children}
63-
</Text>
64-
)
65-
}
66-
67-
function CustomH6({ children }: { children: React.ReactNode }) {
68-
return (
69-
<Text as="h6" color="$title" m="0" typography="h6">
70-
{children}
71-
</Text>
72-
)
73-
}
74-
75-
function CustomStrong({ children }: { children: React.ReactNode }) {
76-
return (
77-
<Text as="strong" color="$primary" m="0" typography="captionBold">
78-
{children}
79-
</Text>
80-
)
81-
}
82-
8314
export default function Page() {
8415
return (
8516
<VStack gap="16px" maxW="100%" overflow="hidden">
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Box } from '@devup-ui/react'
2+
3+
export function CustomCode({ children }: { children: string }) {
4+
return (
5+
<Box as="code" color="$primary" whiteSpace="pre-wrap">
6+
{children.replaceAll('<br>', '\n')}
7+
</Box>
8+
)
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Text } from '@devup-ui/react'
2+
3+
export function CustomH4({ children }: { children: React.ReactNode }) {
4+
return (
5+
<Text as="h4" color="$title" m="0" typography="h4">
6+
{children}
7+
</Text>
8+
)
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Text } from '@devup-ui/react'
2+
3+
export function CustomH6({ children }: { children: React.ReactNode }) {
4+
return (
5+
<Text as="h6" color="$title" m="0" typography="h6">
6+
{children}
7+
</Text>
8+
)
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Text } from '@devup-ui/react'
2+
3+
export function CustomParagraph({ children }: { children: React.ReactNode }) {
4+
return (
5+
<Text as="p" color="$text" lineHeight="1" m="0" typography="bodyReg">
6+
{children}
7+
</Text>
8+
)
9+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { Box, css } from '@devup-ui/react'
2+
3+
export function CustomPre({ children }: { children: React.ReactNode }) {
4+
return (
5+
<Box
6+
as="pre"
7+
className={css({
8+
margin: '0',
9+
w: '100%',
10+
whiteSpace: 'pre-wrap',
11+
lineBreak: 'anywhere',
12+
bg: 'transparent',
13+
overflow: 'auto',
14+
})}
15+
selectors={{
16+
'& pre': {
17+
margin: '0',
18+
w: '100%',
19+
whiteSpace: 'pre-wrap',
20+
lineBreak: 'anywhere',
21+
bg: 'transparent',
22+
overflow: 'auto',
23+
},
24+
'& pre, & code, & span, & p': {
25+
margin: '0',
26+
w: '100%',
27+
whiteSpace: 'pre-wrap',
28+
lineBreak: 'anywhere',
29+
bg: 'transparent',
30+
overflow: 'auto',
31+
},
32+
}}
33+
>
34+
{children}
35+
</Box>
36+
)
37+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Text } from '@devup-ui/react'
2+
3+
export function CustomStrong({ children }: { children: React.ReactNode }) {
4+
return (
5+
<Text as="strong" color="$primary" m="0" typography="captionBold">
6+
{children}
7+
</Text>
8+
)
9+
}

0 commit comments

Comments
 (0)