diff --git a/apps/_components/src/ClipboardButton/ClipboardButton.tsx b/apps/_components/src/ClipboardButton/ClipboardButton.tsx index d21df7faa1..0f7545317e 100644 --- a/apps/_components/src/ClipboardButton/ClipboardButton.tsx +++ b/apps/_components/src/ClipboardButton/ClipboardButton.tsx @@ -34,7 +34,7 @@ export const ClipboardButton = ({ title={title} icon={!text} variant='tertiary' - color='neutral' + data-color='neutral' data-size='sm' > diff --git a/apps/_components/src/CodeSnippet/CodeSnippet.module.css b/apps/_components/src/CodeSnippet/CodeSnippet.module.css index 40776471c0..ddbcf60327 100644 --- a/apps/_components/src/CodeSnippet/CodeSnippet.module.css +++ b/apps/_components/src/CodeSnippet/CodeSnippet.module.css @@ -8,7 +8,16 @@ } .codeSnippet > pre { - padding-right: var(--ds-spacing-11) !important; + padding-right: var(--ds-spacing-18) !important; + background-color: var(--ds-color-neutral-background-subtle) !important; +} + +.codeSnippet > pre > code { + padding: 0; +} + +.codeSnippet > pre > code span:empty { + display: none; } .copyButton { diff --git a/apps/_components/src/CodeSnippet/CodeSnippet.tsx b/apps/_components/src/CodeSnippet/CodeSnippet.tsx index c63de3aff0..bf00ef571e 100644 --- a/apps/_components/src/CodeSnippet/CodeSnippet.tsx +++ b/apps/_components/src/CodeSnippet/CodeSnippet.tsx @@ -10,8 +10,8 @@ import * as prettierCSS from 'prettier/plugins/postcss.js'; import * as prettierTypescript from 'prettier/plugins/typescript.js'; import { format } from 'prettier/standalone.js'; import { useEffect, useState } from 'react'; -import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'; -import { nightOwl } from 'react-syntax-highlighter/dist/esm/styles/prism'; +import SyntaxHighlighter from 'react-syntax-highlighter'; +import { stackoverflowDark } from 'react-syntax-highlighter/dist/esm/styles/hljs'; import classes from './CodeSnippet.module.css'; @@ -27,15 +27,13 @@ const plugins = [ ]; type CodeSnippetProps = { - language?: 'css' | 'html' | 'ts' | 'markdown' | 'json'; - syntax?: string; + language?: 'css' | 'html' | 'ts' | 'markdown' | 'json' | 'shell' | 'tsx'; children: string; } & React.HTMLAttributes; const CodeSnippet = ({ language = 'markdown', className, - syntax = 'js', children, ...rest }: CodeSnippetProps) => { @@ -49,7 +47,8 @@ const CodeSnippet = ({ ) { try { const formatted = await format(children, { - parser: language === 'ts' ? 'babel-ts' : language, + parser: + language === 'ts' || language === 'tsx' ? 'babel-ts' : language, plugins, }); setSnippet(formatted); @@ -76,6 +75,7 @@ const CodeSnippet = ({
{snippet && ( @@ -87,15 +87,15 @@ const CodeSnippet = ({ className={classes.copyButton} aria-label='Kopier' icon - color='neutral' + data-color='neutral' data-size='sm' > {
    {links.map((item, index) => (
  • - + {item.prefix} {item.text} @@ -64,7 +64,12 @@ export const Footer = forwardRef(function Footer(
-