MCPcopy Create free account
hub / github.com/chakra-ui/panda / CodeBlock

Function CodeBlock

website/src/mdx/code-block.tsx:10–46  ·  view source on GitHub ↗
(props: CodeBlockProps)

Source from the content-addressed store, hash-verified

8}
9
10export const CodeBlock = (props: CodeBlockProps) => {
11 const { title, lang, children, ...rest } = props
12
13 const extLang = title.split('.').pop()
14 const resolvedLang = extLang !== lang ? extLang : lang
15
16 return (
17 <Box
18 {...rest}
19 data-lang={lang}
20 spaceY="0!"
21 marginY="1.6em"
22 rounded="10px"
23 css={{
24 '& pre.shiki': {
25 roundedTop: '0!',
26 roundedBottom: 'lg!',
27 shadow: 'none!'
28 }
29 }}
30 >
31 <HStack
32 bg="bg.muted"
33 px="4"
34 py="3"
35 roundedTop="lg"
36 borderBottomWidth="1px"
37 >
38 {resolvedLang && <CodeLangIcon type={resolvedLang} />}
39 <Box as="p" textStyle="sm" fontFamily="mono">
40 {title}
41 </Box>
42 </HStack>
43 {children}
44 </Box>
45 )
46}
47
48type CodeLang =
49 | 'tsx'

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected