mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-01 10:22:30 +02:00
refactor(v2): make code blocks accessible from keyboard (#3649)
This commit is contained in:
parent
2aae77124e
commit
9f66545c8c
1 changed files with 13 additions and 11 deletions
|
@ -207,18 +207,9 @@ export default ({
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className={styles.codeBlockContent}>
|
<div className={styles.codeBlockContent}>
|
||||||
<button
|
|
||||||
tabIndex={0}
|
|
||||||
ref={button}
|
|
||||||
type="button"
|
|
||||||
aria-label="Copy code to clipboard"
|
|
||||||
className={clsx(styles.copyButton, {
|
|
||||||
[styles.copyButtonWithTitle]: codeBlockTitle,
|
|
||||||
})}
|
|
||||||
onClick={handleCopyCode}>
|
|
||||||
{showCopied ? 'Copied' : 'Copy'}
|
|
||||||
</button>
|
|
||||||
<div
|
<div
|
||||||
|
/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
|
||||||
|
tabIndex={0}
|
||||||
className={clsx(className, styles.codeBlock, {
|
className={clsx(className, styles.codeBlock, {
|
||||||
[styles.codeBlockWithTitle]: codeBlockTitle,
|
[styles.codeBlockWithTitle]: codeBlockTitle,
|
||||||
})}>
|
})}>
|
||||||
|
@ -244,6 +235,17 @@ export default ({
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
ref={button}
|
||||||
|
type="button"
|
||||||
|
aria-label="Copy code to clipboard"
|
||||||
|
className={clsx(styles.copyButton, {
|
||||||
|
[styles.copyButtonWithTitle]: codeBlockTitle,
|
||||||
|
})}
|
||||||
|
onClick={handleCopyCode}>
|
||||||
|
{showCopied ? 'Copied' : 'Copy'}
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue