From 667ea3f6d804fa7421382bfdf4f762c553ef4232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rialland?= Date: Thu, 6 Oct 2022 15:25:53 +0200 Subject: [PATCH] Replace CodeBlock by Pre + Code --- site/source/components/utils/markdown.tsx | 51 ++++++++++------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/site/source/components/utils/markdown.tsx b/site/source/components/utils/markdown.tsx index 20ab726f1..d09514e1f 100644 --- a/site/source/components/utils/markdown.tsx +++ b/site/source/components/utils/markdown.tsx @@ -7,6 +7,7 @@ import { Body } from '@/design-system/typography/paragraphs' import MarkdownToJsx, { MarkdownToJSX } from 'markdown-to-jsx' import React, { useContext, useEffect } from 'react' import { useLocation } from 'react-router-dom' +import styled from 'styled-components' import { SiteNameContext } from '../../Provider' import { isIterable } from '../../utils' import Emoji from './Emoji' @@ -74,33 +75,26 @@ type MarkdownProps = React.ComponentProps & { renderers?: Record } -const CodeBlock = ({ - children, - className, -}: { - children: string - className?: string -}) => ( -
-
-			{children}
-		
- {className?.includes('lang-yaml') && ( - - Lancer le calcul - - )} -
-) +const Code = styled.code` + overflow: auto; + padding: 0.25rem; + background-color: ${({ theme }) => theme.colors.extended.grey[300]}; + border-radius: 0.25rem; +` + +const Pre = styled.pre` + overflow: auto; + padding: 0.5rem; + background-color: ${({ theme }) => theme.colors.extended.grey[300]}; + border-radius: 0.25rem; + + & ${Code} { + overflow: initial; + padding: 0; + background-color: initial; + border-radius: initial; + } +` export const Markdown = ({ children, @@ -126,7 +120,8 @@ export const Markdown = ({ ul: Ul, ol: Ol, li: Li, - code: CodeBlock, + code: Code, + pre: Pre, span: TextRenderer, blockquote: (props) => (