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:
parent
dc0c32a93f
commit
1c3ada993e
2 changed files with 29 additions and 4 deletions
|
@ -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>
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue