Skip to content

Commit

Permalink
fix: copy line in logs not copies
Browse files Browse the repository at this point in the history
feat: hide copy button by default
  • Loading branch information
felixmosh committed Jan 11, 2024
1 parent babcc64 commit 5ba551c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
16 changes: 13 additions & 3 deletions packages/ui/src/components/Highlight/Highlight.module.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
.codeContainerWrapper {
display: flex;
align-items: flex-start;
display: flex;
align-items: flex-start;
gap: 1ch;
}

.codeContainerWrapper pre {
margin-right: 1ch;
flex: 1;
}

.copyBtn {
opacity: 0;
transition: opacity 150ms ease-in;
}

.codeContainerWrapper:hover .copyBtn {
opacity: 1;
}
5 changes: 4 additions & 1 deletion packages/ui/src/components/Highlight/Highlight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ export class Highlight extends React.Component<HighlightProps> {
<pre ref={this.codeRef}>
<code className={cn('hljs', language)} />
</pre>
<Button onClick={() => navigator.clipboard.writeText(this.props.children ?? '')}>
<Button
onClick={() => navigator.clipboard.writeText(this.props.children ?? '')}
className={s.copyBtn}
>
<CopyIcon />
</Button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@

.logLineCopyButton {
opacity: 0;
transition: opacity 150ms ease;
transition: opacity 150ms ease-in;
margin-inline-start: 1ch;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const onClickFullScreen = (el: HTMLElement | null) => async () => {
return document.exitFullscreen();
};

const copyLogToClipboard = (log: LogType) => async () => {
const copyLogToClipboard = (log: LogType) => {
navigator.clipboard.writeText(log.message);
};

Expand Down

0 comments on commit 5ba551c

Please sign in to comment.