From 46be19531db99f5e5d7998a773a0398409e04a2d Mon Sep 17 00:00:00 2001 From: Konv Suu <2583695112@qq.com> Date: Fri, 1 Sep 2023 09:35:37 +0800 Subject: [PATCH] docs: add hide code btn in the bottom for code box (#6917) --- site/src/components/DemoBox.vue | 24 +++++++++++++++++++++++- site/src/theme/static/common.less | 1 + 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/site/src/components/DemoBox.vue b/site/src/components/DemoBox.vue index 8a602844b..ebb8ea149 100644 --- a/site/src/components/DemoBox.vue +++ b/site/src/components/DemoBox.vue @@ -82,6 +82,22 @@ +
+ + + expand code + + +
@@ -164,11 +180,17 @@ export default defineComponent({ ).trim() : '', ); - const handleCodeExpand = () => { + const handleCodeExpand = (_, sectionId?) => { if (globalConfig.blocked.value) { warning(); return; } + if (sectionId) { + const element = document.getElementById(sectionId); + if (element) { + element.scrollIntoView(); + } + } codeExpand.value = !codeExpand.value; }; const handleCodeCopied = () => { diff --git a/site/src/theme/static/common.less b/site/src/theme/static/common.less index a40355a17..68f2c9867 100644 --- a/site/src/theme/static/common.less +++ b/site/src/theme/static/common.less @@ -2,6 +2,7 @@ html { &.rtl { direction: rtl; } + scroll-behavior: smooth; } body {