Elffuss BraidHub

kikocis/continue public

main · 830 BRawPermalink
1import { useContext } from "react";
2import styled from "styled-components";
3import { defaultBorderRadius, vscForeground } from "..";
4import { VscThemeContext } from "../../context/VscTheme";
5
6const generateThemeStyles = (theme: any) => {
7 return Object.keys(theme)
8 .map((key) => {
9 return `
10 & ${key} {
11 color: ${theme[key]};
12 }
13 `;
14 })
15 .join("");
16};
17
18const StyledPre = styled.pre<{ theme: any }>`
19 & .hljs {
20 color: ${vscForeground};
21 }
22
23 margin-top: 0;
24 margin-bottom: 0;
25 border-radius: 0 0 ${defaultBorderRadius} ${defaultBorderRadius} !important;
26
27 ${(props) => generateThemeStyles(props.theme)}
28`;
29
30export const SyntaxHighlightedPre = (props: any) => {
31 const currentTheme = useContext(VscThemeContext);
32 return <StyledPre {...props} theme={currentTheme.theme} />;
33};