From 7a710cbb55d1130e1ea145dce56dcc714a2d9265 Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Sun, 12 Jun 2022 14:23:26 +0000 Subject: [PATCH] feat: add style to new codeblock --- assets/scss/partials/layout/article.scss | 48 ++++++++++++++---------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/assets/scss/partials/layout/article.scss b/assets/scss/partials/layout/article.scss index 6199118..90d0ce8 100644 --- a/assets/scss/partials/layout/article.scss +++ b/assets/scss/partials/layout/article.scss @@ -286,10 +286,12 @@ line-height: 1.428571429; word-break: break-all; padding: var(--card-padding); + // keep Codeblocks LTR [dir="rtl"] & { direction: ltr; } + code { color: unset; border: none; @@ -303,15 +305,11 @@ padding: var(--card-padding); position: relative; - &:hover { - .copyCodeButton { - opacity: 1; - } - } // keep Codeblocks LTR [dir="rtl"] & { direction: ltr; } + pre { margin: initial; padding: 0; @@ -320,20 +318,30 @@ } } - .copyCodeButton { - position: absolute; - top: calc(var(--card-padding)); - right: calc(var(--card-padding)); - background: var(--card-background); - border: none; - box-shadow: var(--shadow-l2); - border-radius: var(--tag-border-radius); - padding: 8px 16px; - color: var(--card-text-color-main); - cursor: pointer; - font-size: 14px; - opacity: 0; - transition: opacity 0.3s ease; + .codeblock { + header { + background-color: var(--card-background-selected); + padding: 5px var(--card-padding); + display: flex; + justify-content: space-between; + box-shadow: var(--shadow-l1); + + span { + text-transform: uppercase; + font-weight: bold; + color: var(--card-text-color-secondary); + } + } + + .codeblock-copy { + cursor: pointer; + background-color: transparent; + border: none; + padding: 8px 16px; + color: var(--card-text-color-secondary); + font-size: 14px; + font-weight: bold; + } } .table-wrapper { @@ -402,7 +410,7 @@ /// Negative margins blockquote, figure, - .highlight, + .codeblock, pre, .gallery, .video-wrapper,