Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
Roiocam committed Aug 30, 2024
1 parent 20a996e commit 198965e
Showing 1 changed file with 15 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ export default function CodeBlockString({
const showLineNumbers =
showLineNumbersProp ?? containsLineNumbers(metastring);

function ButtonGroup() {
return <div className={styles.buttonGroup}>
{(wordWrap.isEnabled || wordWrap.isCodeScrollable) && (
<WordWrapButton
className={styles.codeButton}
onClick={() => wordWrap.toggle()}
isEnabled={wordWrap.isEnabled}
/>
)}
<CopyButton className={styles.codeButton} code={code} />
</div>
}

return (
<Container
as="div"
Expand All @@ -74,18 +87,7 @@ export default function CodeBlockString({
{title && (
<div className={styles.codeBlockTitle}>
{title}
{title && (
<div className={styles.buttonGroup}>
{(wordWrap.isEnabled || wordWrap.isCodeScrollable) && (
<WordWrapButton
className={styles.codeButton}
onClick={() => wordWrap.toggle()}
isEnabled={wordWrap.isEnabled}
/>
)}
<CopyButton className={styles.codeButton} code={code} />
</div>
)}
<ButtonGroup />
</div>
)}
<div className={styles.codeBlockContent}>
Expand Down Expand Up @@ -119,18 +121,7 @@ export default function CodeBlockString({
</pre>
)}
</Highlight>
{!title && (
<div className={styles.buttonGroup}>
{(wordWrap.isEnabled || wordWrap.isCodeScrollable) && (
<WordWrapButton
className={styles.codeButton}
onClick={() => wordWrap.toggle()}
isEnabled={wordWrap.isEnabled}
/>
)}
<CopyButton className={styles.codeButton} code={code} />
</div>
)}
{!title && <ButtonGroup />}
</div>
</Container>
);
Expand Down

0 comments on commit 198965e

Please sign in to comment.