diff --git a/src/components/MDXComponents.tsx b/src/components/MDXComponents.tsx index bfc92fc18c..631544d2d5 100644 --- a/src/components/MDXComponents.tsx +++ b/src/components/MDXComponents.tsx @@ -1,7 +1,8 @@ import { Heading, Link, Stack, Text } from '@chakra-ui/react'; import NextLink from 'next/link'; import { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter'; -import { nightOwl } from 'react-syntax-highlighter/dist/cjs/styles/prism'; + +import { Code } from './UI/docs' import bash from 'react-syntax-highlighter/dist/cjs/languages/prism/bash'; import go from 'react-syntax-highlighter/dist/cjs/languages/prism/go'; @@ -26,8 +27,6 @@ SyntaxHighlighter.registerLanguage('sh', sh); SyntaxHighlighter.registerLanguage('solidity', solidity); SyntaxHighlighter.registerLanguage('swift', swift); -import { getProgrammingLanguageName } from '../utils'; - const MDXComponents = { // paragraphs p: ({ children }: any) => { @@ -86,10 +85,12 @@ const MDXComponents = {
{children}
); - } + }, // code - // code: (code: any) => { - // const language = getProgrammingLanguageName(code); + code: (code: any) => { + return ( + + ) // return !!code.inline ? ( // // ); - // } + } }; export default MDXComponents; diff --git a/src/components/UI/docs/Code.tsx b/src/components/UI/docs/Code.tsx new file mode 100644 index 0000000000..7be53c6ac6 --- /dev/null +++ b/src/components/UI/docs/Code.tsx @@ -0,0 +1,38 @@ +// Libraries +import { Code as ChakraCode, Stack, Text } from '@chakra-ui/react'; +import { FC } from 'react'; + +interface Props { + code: any; +} + +export const Code: FC = ({ code }) => { + return ( + !!code.inline ? + ( + + {code.children[0]} + + ) + : + ( + + + {code.children[0]} + + + ) + ); +}; diff --git a/src/components/UI/docs/index.tsx b/src/components/UI/docs/index.tsx new file mode 100644 index 0000000000..823cfaea66 --- /dev/null +++ b/src/components/UI/docs/index.tsx @@ -0,0 +1 @@ +export * from './Code'; \ No newline at end of file diff --git a/src/theme/foundations/textStyles.ts b/src/theme/foundations/textStyles.ts index b259d4ae0a..720ef0f97f 100644 --- a/src/theme/foundations/textStyles.ts +++ b/src/theme/foundations/textStyles.ts @@ -90,6 +90,20 @@ export const textStyles = { textAlign: 'center', fontSize: 'sm' }, + 'inline-code-snippet': { + fontFamily: '"JetBrains Mono", monospace', + fontWeight: 400, + fontSize: 'md', + lineHeight: 4, + letterSpacing: '1%' + }, + 'code-block': { + fontFamily: '"JetBrains Mono", monospace', + fontWeight: 400, + fontSize: 'md', + lineHeight: '21.12px', + letterSpacing: '1%' + }, // TODO: refactor w/ semantic tokens for light/dark mode 'link-light': {}, // TODO: refactor w/ semantic tokens for light/dark mode diff --git a/src/theme/index.ts b/src/theme/index.ts index ff6c89914e..126e85e865 100644 --- a/src/theme/index.ts +++ b/src/theme/index.ts @@ -29,7 +29,8 @@ const overrides = { body: { _light: 'gray.800', _dark: 'yellow.50' }, 'code-bg': { _light: 'gray.200', _dark: 'gray.700' }, 'code-bg-contrast': { _light: 'gray.800', _dark: 'gray.900' }, - bg: { _light: 'yellow.50', _dark: 'gray.800' } + 'code-text': { _light: 'green.50', _dark: 'green.50' }, + bg: { _light: 'yellow.50', _dark: 'gray.800' }, } } }; diff --git a/src/utils/getProgrammingLanguageName.ts b/src/utils/getProgrammingLanguageName.ts deleted file mode 100644 index 40f454f300..0000000000 --- a/src/utils/getProgrammingLanguageName.ts +++ /dev/null @@ -1,7 +0,0 @@ -// WIP -export const getProgrammingLanguageName = (code: any) => { - // const hasLanguageNameProperty = Object.keys(code.node.properties).length > 0; - console.log({ code }); - - // return hasLanguageNameProperty ? code.node.properties.className[0].split('-')[1] : 'bash'; -}; diff --git a/src/utils/index.ts b/src/utils/index.ts deleted file mode 100644 index e3d2a70842..0000000000 --- a/src/utils/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './getProgrammingLanguageName';