From cec374fa012985c34927c27579b34953f0eed390 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 26 May 2022 00:18:19 +0100 Subject: [PATCH] [Beta] Remove styled-jsx (#4690) --- beta/src/components/Layout/Toc.tsx | 13 +-- .../src/components/Layout/useTocHighlight.tsx | 2 +- beta/src/components/MDX/Heading.tsx | 92 +++++----------- beta/src/components/MDX/MDXComponents.tsx | 86 +-------------- beta/src/siteConfig.ts | 3 - beta/src/styles/index.css | 101 ++++++++++++++++++ 6 files changed, 133 insertions(+), 164 deletions(-) diff --git a/beta/src/components/Layout/Toc.tsx b/beta/src/components/Layout/Toc.tsx index 40219426..0ae28684 100644 --- a/beta/src/components/Layout/Toc.tsx +++ b/beta/src/components/Layout/Toc.tsx @@ -28,7 +28,7 @@ export function Toc({

On this page

-
+
    {headings && headings.length > 0 && @@ -65,17 +65,6 @@ export function Toc({ })}
- ); } diff --git a/beta/src/components/Layout/useTocHighlight.tsx b/beta/src/components/Layout/useTocHighlight.tsx index a8538381..aa7d5ee7 100644 --- a/beta/src/components/Layout/useTocHighlight.tsx +++ b/beta/src/components/Layout/useTocHighlight.tsx @@ -9,7 +9,7 @@ const TOP_OFFSET = 75; export function getHeaderAnchors(): HTMLAnchorElement[] { return Array.prototype.filter.call( - document.getElementsByClassName(siteConfig.headerIdConfig.className), + document.getElementsByClassName('mdx-header-anchor'), function (testElement) { return ( testElement.parentNode.nodeName === 'H1' || diff --git a/beta/src/components/MDX/Heading.tsx b/beta/src/components/MDX/Heading.tsx index 1a8be7fa..4b177ead 100644 --- a/beta/src/components/MDX/Heading.tsx +++ b/beta/src/components/MDX/Heading.tsx @@ -14,8 +14,6 @@ export interface HeadingProps { as?: any; } -const anchorClassName = siteConfig.headerIdConfig.className; - const Heading = forwardRefWithAs(function Heading( {as: Comp = 'div', className, children, id, isPageAnchor = true, ...props}, ref @@ -26,71 +24,31 @@ const Heading = forwardRefWithAs(function Heading( } return ( - <> - - {children} - {isPageAnchor && ( - - - - - - - - - )} - - - + + {children} + {isPageAnchor && ( + + + + + + + + + )} + ); }); diff --git a/beta/src/components/MDX/MDXComponents.tsx b/beta/src/components/MDX/MDXComponents.tsx index fb662fe6..7b4f9d49 100644 --- a/beta/src/components/MDX/MDXComponents.tsx +++ b/beta/src/components/MDX/MDXComponents.tsx @@ -80,21 +80,11 @@ const Blockquote = ({ ...props }: JSX.IntrinsicElements['blockquote']) => { return ( - <> -
- {children} -
- - +
+ {children} +
); }; @@ -274,72 +264,6 @@ function IllustrationBlock({
{images}
)} {author ? : null} -
); } diff --git a/beta/src/siteConfig.ts b/beta/src/siteConfig.ts index 1ea02933..f82b2ddc 100644 --- a/beta/src/siteConfig.ts +++ b/beta/src/siteConfig.ts @@ -12,7 +12,4 @@ export const siteConfig = { apiKey: '861ccfb8707150c0e776b88357286123', indexName: 'beta-react', }, - headerIdConfig: { - className: `anchor`, - }, }; diff --git a/beta/src/styles/index.css b/beta/src/styles/index.css index 15ed4a10..640ddf25 100644 --- a/beta/src/styles/index.css +++ b/beta/src/styles/index.css @@ -219,3 +219,104 @@ html.dark .code-step * { color: white !important; } + +.mdx-heading { + scroll-margin-top: 2.5em; + /* Space for the anchor */ + padding-right: 1em; +} +.mdx-heading:before { + height: 6rem; + margin-top: -6rem; + visibility: hidden; + content: ''; +} +.mdx-heading .mdx-header-anchor { + /* Prevent the anchor from + overflowing to its own line */ + height: 0px; + width: 0px; +} +.mdx-heading .mdx-header-anchor svg { + display: inline; +} +.mdx-heading .mdx-header-anchor svg { + visibility: hidden; +} +.mdx-heading:hover .mdx-header-anchor svg { + visibility: visible; +} +.mdx-heading .mdx-header-anchor:focus svg { + visibility: visible; +} + +.mdx-blockquote > span > p:first-of-type { + margin-bottom: 0; +} +.mdx-blockquote > span > p:last-of-type { + margin-bottom: 1rem; +} +.mdx-illustration-block { + display: flex; + flex-direction: row; + flex-wrap: nowrap; + justify-content: center; + align-content: stretch; + align-items: stretch; + gap: 42px; +} +ol.mdx-illustration-block { + gap: 60px; +} +.mdx-illustration-block li { + display: flex; + align-items: flex-start; + align-content: stretch; + justify-content: space-around; + position: relative; + padding: 1rem; +} +.mdx-illustration-block figure { + display: flex; + flex-direction: column; + align-content: center; + align-items: center; + + justify-content: space-between; + position: relative; + height: 100%; +} +.mdx-illustration-block li:after { + content: ' '; + display: block; + position: absolute; + top: 50%; + right: 100%; + transform: translateY(-50%); + width: 60px; + height: 49px; + background: center / contain no-repeat url('/images/g_arrow.png'); +} +.mdx-illustration-block li:first-child:after { + content: ' '; + display: none; +} +.mdx-illustration-block img { + max-height: 250px; + width: 100%; +} +@media (max-width: 680px) { + .mdx-illustration-block { + flex-direction: column; + } + .mdx-illustration-block img { + max-height: 200px; + width: auto; + } + .mdx-illustration-block li:after { + top: 0; + left: 50%; + right: auto; + transform: translateX(-50%) translateY(-100%) rotate(90deg); + } +}