From 7c331f261664fb610f9b0905e4220af7bd2b1a8e Mon Sep 17 00:00:00 2001 From: Alexey Pyltsyn Date: Sun, 5 Apr 2020 12:02:43 +0300 Subject: [PATCH 1/2] refactor(v2): make better code blocks --- .../src/theme/CodeBlock/styles.module.css | 12 +----------- .../src/theme/CodeBlock/styles.module.css | 12 +----------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/packages/docusaurus-theme-classic/src/theme/CodeBlock/styles.module.css b/packages/docusaurus-theme-classic/src/theme/CodeBlock/styles.module.css index c699e1d0d247..dda21803f373 100644 --- a/packages/docusaurus-theme-classic/src/theme/CodeBlock/styles.module.css +++ b/packages/docusaurus-theme-classic/src/theme/CodeBlock/styles.module.css @@ -40,16 +40,12 @@ padding: 0.4rem 0.5rem; position: absolute; right: var(--ifm-pre-padding); - top: var(--ifm-pre-padding); + top: calc(var(--ifm-pre-padding) / 2); visibility: hidden; transition: opacity 200ms ease-in-out, visibility 200ms ease-in-out, bottom 200ms ease-in-out; } -.copyButtonWithTitle { - top: calc(var(--ifm-pre-padding)); -} - .codeBlockTitle:hover + .codeBlockContent .copyButton, .codeBlockContent:hover > .copyButton { visibility: visible; @@ -65,9 +61,3 @@ min-width: 100%; padding: var(--ifm-pre-padding); } - -/* Disable top border radius when title is present. */ -.codeBlockTitle + .codeBlockContent .codeBlockLines { - border-top-left-radius: 0; - border-top-right-radius: 0; -} diff --git a/packages/docusaurus-theme-live-codeblock/src/theme/CodeBlock/styles.module.css b/packages/docusaurus-theme-live-codeblock/src/theme/CodeBlock/styles.module.css index c699e1d0d247..dda21803f373 100644 --- a/packages/docusaurus-theme-live-codeblock/src/theme/CodeBlock/styles.module.css +++ b/packages/docusaurus-theme-live-codeblock/src/theme/CodeBlock/styles.module.css @@ -40,16 +40,12 @@ padding: 0.4rem 0.5rem; position: absolute; right: var(--ifm-pre-padding); - top: var(--ifm-pre-padding); + top: calc(var(--ifm-pre-padding) / 2); visibility: hidden; transition: opacity 200ms ease-in-out, visibility 200ms ease-in-out, bottom 200ms ease-in-out; } -.copyButtonWithTitle { - top: calc(var(--ifm-pre-padding)); -} - .codeBlockTitle:hover + .codeBlockContent .copyButton, .codeBlockContent:hover > .copyButton { visibility: visible; @@ -65,9 +61,3 @@ min-width: 100%; padding: var(--ifm-pre-padding); } - -/* Disable top border radius when title is present. */ -.codeBlockTitle + .codeBlockContent .codeBlockLines { - border-top-left-radius: 0; - border-top-right-radius: 0; -} From aa0d85646f97b4bb937ddfb9c7ca3be06533ae41 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Sun, 5 Apr 2020 17:56:11 +0800 Subject: [PATCH 2/2] Update styles.module.css --- .../src/theme/CodeBlock/styles.module.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/docusaurus-theme-live-codeblock/src/theme/CodeBlock/styles.module.css b/packages/docusaurus-theme-live-codeblock/src/theme/CodeBlock/styles.module.css index dda21803f373..9d5e4ad9623a 100644 --- a/packages/docusaurus-theme-live-codeblock/src/theme/CodeBlock/styles.module.css +++ b/packages/docusaurus-theme-live-codeblock/src/theme/CodeBlock/styles.module.css @@ -39,7 +39,7 @@ outline: none; padding: 0.4rem 0.5rem; position: absolute; - right: var(--ifm-pre-padding); + right: calc(var(--ifm-pre-padding) / 2); top: calc(var(--ifm-pre-padding) / 2); visibility: hidden; transition: opacity 200ms ease-in-out, visibility 200ms ease-in-out,