Skip to content

Commit dc006f1

Browse files
lamATnginxnginx-jack
authored andcommitted
feat: Add styling to codeblock copy button
1 parent d52c2ab commit dc006f1

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

assets/css/v2/style.css

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
--color-background: #ffffff;
1919
--color-foreground: #000000;
2020
--color-shadow: #d2d2d2;
21+
--color-codeblock-shadow: #d2d2d2;
2122
--color-footer: #1d1d1d;
2223
--color-footer-text: #e2e2e2;
2324
--color-product-title: #8d8d8d;
@@ -1144,27 +1145,28 @@ li .code-block {
11441145
}
11451146

11461147
.code-copy-button {
1147-
background-color: #f2f2f2;
1148-
border: none;
1148+
background-color: white;
1149+
border: 1px solid black;
11491150
padding: 5px 10px;
11501151
cursor: pointer;
11511152
font-family: "JetBrains Mono", monospace;
11521153
font-size: 12px;
11531154
color: #000;
1154-
display: none;
1155+
/* display: none; */
11551156
position: absolute;
11561157
margin-top: 8px;
11571158
right: 1rem;
1158-
z-index: 2;
1159+
--color-codeblock-shadow: #d2d2d2;
1160+
box-shadow: 0px 2px 0px var(--color-codeblock-shadow);
11591161
}
11601162

11611163
.code-copy-button:hover {
1162-
background-color: #e0e0e0;
1164+
--color-codeblock-shadow: #0096394d;
11631165
}
11641166

11651167
.code-copy-button:focus {
11661168
outline: none;
1167-
box-shadow: 0 0 2px 2px #a5a5a5;
1169+
--color-codeblock-shadow: #009639;
11681170
}
11691171

11701172
.next-prev-icon {

assets/js/code-copy-v2.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const copyToClipBoard = ((clipboard) => async (button, codeBlockId) => {
2626

2727
const updateButtonState = (button, message, revertDelay, disable = false) => {
2828
button.innerHTML = message;
29+
$(button).css('box-shadow', '0px 2px 0px #009639');
2930

3031
if (disable) {
3132
button.disabled = true;
@@ -34,6 +35,7 @@ const updateButtonState = (button, message, revertDelay, disable = false) => {
3435
if (revertDelay) {
3536
setTimeout(() => {
3637
button.innerHTML = 'Copy';
38+
$(button).css('box-shadow', '0px 2px 0px var(--color-codeblock-shadow)');
3739
button.disabled = false;
3840
}, revertDelay);
3941
}

0 commit comments

Comments
 (0)