({ children, language, code }: CodeWrapperProps)
| 64 | } |
| 65 | |
| 66 | export const CodeWrapper = ({ children, language, code }: CodeWrapperProps) => { |
| 67 | const clipboard = useClipboard({ timeout: 1500 }); |
| 68 | const copyLabel = clipboard.copied ? 'Copied' : 'Copy code'; |
| 69 | |
| 70 | return ( |
| 71 | <figure className={classes.root} translate="no"> |
| 72 | <Text component="span" className={classes.dots} aria-hidden="true"> |
| 73 | ⬤⬤ |
| 74 | </Text> |
| 75 | {children} |
| 76 | <Group gap={0} className={classes.tools} component="figcaption"> |
| 77 | {language ? ( |
| 78 | <div className={classes.language}> |
| 79 | <Text component="span" fw={400} fz={13}> |
| 80 | {displayLanguage(language)} |
| 81 | </Text> |
| 82 | </div> |
| 83 | ) : null} |
| 84 | <Tooltip label={copyLabel} withArrow arrowSize={6} offset={6}> |
| 85 | <ActionIcon |
| 86 | className={classes.copy} |
| 87 | aria-label={copyLabel} |
| 88 | onClick={() => { |
| 89 | clipboard.copy(code); |
| 90 | }} |
| 91 | > |
| 92 | <IconCopy aria-hidden="true" stroke="white" /> |
| 93 | </ActionIcon> |
| 94 | </Tooltip> |
| 95 | </Group> |
| 96 | </figure> |
| 97 | ); |
| 98 | }; |
| 99 | |
| 100 | interface CodeHighlightProps { |
| 101 | code: string; |
nothing calls this directly
no test coverage detected