1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-07-18 20:59:42 +02:00

feat: add copy button to code block

This commit is contained in:
Aleksey Solovyev 2022-11-29 14:09:55 +03:00
parent dc0c32a93f
commit 1c3ada993e
2 changed files with 29 additions and 4 deletions

View file

@ -1,4 +1,12 @@
<div class="block-code">
<div class="block-code__content">{{ code|escape }}</div>
<div class="block-code__wrapper">
<div class="block-code__content">{{ code | escape }}</div>
</div>
{%
include 'components/copy-button.twig' with {
ariaLabel: 'Copy Code to Clipboard',
class: 'block-code__copy-button',
textToCopy: code | escape,
}
%}
</div>

View file

@ -149,8 +149,18 @@
* ==================
*/
.block-code {
@apply --text-code-block;
@apply --squircle;
position: relative;
&:hover {
.block-code__copy-button {
opacity: 1;
}
}
&__wrapper {
@apply --text-code-block;
@apply --squircle;
}
&__content {
display: inline-block !important;
@ -169,6 +179,13 @@
}
}
&__copy-button {
position: absolute;
top: 10px;
right: 10px;
opacity: 0;
}
.hljs-params {
color: var(--color-code-params);
}