Skip to content

Commit

Permalink
show copy code button only on hover of container (#751)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaMachina committed Aug 29, 2022
1 parent 5d852b6 commit 71528f1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changeset/strong-toes-decide.md
@@ -0,0 +1,7 @@
---
'nextra': patch
'nextra-theme-blog': patch
'nextra-theme-docs': patch
---

show copy code button only on hover of container
2 changes: 1 addition & 1 deletion packages/nextra/src/components/pre.tsx
Expand Up @@ -32,7 +32,7 @@ export const Pre = ({
{hasCopy && (
<CopyToClipboard
value={children}
className={'absolute m-2 right-0 ' + (filename ? 'top-8' : 'top-0')}
className={'opacity-0 transition-opacity absolute m-2 right-0 ' + (filename ? 'top-8' : 'top-0')}
/>
)}
</>
Expand Down
4 changes: 4 additions & 0 deletions packages/nextra/styles/code-block.css
Expand Up @@ -46,6 +46,10 @@ pre {

[data-rehype-pretty-code-fragment] {
@apply relative;

&:hover > .nextra-copy-button {
@apply opacity-100;
}
}

@supports (
Expand Down

0 comments on commit 71528f1

Please sign in to comment.