diff --git a/packages/theme-doc/src/Layout/Demo/index.module.less b/packages/theme-doc/src/Layout/Demo/index.module.less index 059ba2b9..7689d485 100644 --- a/packages/theme-doc/src/Layout/Demo/index.module.less +++ b/packages/theme-doc/src/Layout/Demo/index.module.less @@ -55,10 +55,12 @@ } .code { - border-top: 1px dashed @colorSplit; - overflow: auto; + position: relative; + transition: height 0.3s ease-in-out; + overflow: hidden; } .code .codeInner { - padding: 0px 8px; + border-top: 1px dashed @colorSplit; + padding: 1em 8px; } diff --git a/packages/theme-doc/src/Layout/Demo/index.tsx b/packages/theme-doc/src/Layout/Demo/index.tsx index 4fb22ea6..7a8dab96 100644 --- a/packages/theme-doc/src/Layout/Demo/index.tsx +++ b/packages/theme-doc/src/Layout/Demo/index.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react' +import React, { useEffect, useRef, useState } from 'react' import { Code } from './icons' import CodeBlock from '../MDX/CodeBlock' @@ -34,6 +34,15 @@ If you use it in markdown, you should use it exactly like " - {code} - - +
+
+ + {code} +
- )} +
) } diff --git a/packages/theme-doc/src/Layout/MDX/CodeBlock.module.less b/packages/theme-doc/src/Layout/MDX/CodeBlock.module.less index 462583c4..e27be501 100644 --- a/packages/theme-doc/src/Layout/MDX/CodeBlock.module.less +++ b/packages/theme-doc/src/Layout/MDX/CodeBlock.module.less @@ -1,5 +1,6 @@ .pre { position: relative; + margin: 0; .copy { opacity: 0;