-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Added copy code button functionality in code blocks #7701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@shibadityadeb is attempting to deploy a commit to the OpenJS Foundation Team on Vercel. A member of the Team first needs to authorize it. |
package.json
Outdated
| "markdownlint-cli/markdownlint": "^0.37.4" | ||
| } | ||
| }, | ||
| "packageManager": "[email protected]+sha512.4e54aeace9141df2f0177c266b05ec50dc044638157dae128c471ba65994ac802122d7ab35bcd9e81641228b7dcf24867d28e750e0bcae8a05277d600008ad54" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove all changes related to yarn from this PR, only code related to the problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexander-akait okay will make the changes
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
I've authorized a deploy to visually check the changes first. After that, this is how our review will go:
In the code check we will need to check both for a11y and also different browser sizes. |
|
Something is wrong with building, so you will need to fix the build command :) |
|
@evenstensberg will look into the issue |
Summary
This PR adds a "Copy to Clipboard" button feature to all code blocks (
<pre>tags) throughout the/conceptssection and all its child routes on the webpack.js.org documentation site. The implementation enhances user experience by allowing visitors to quickly copy code examples to their clipboard with a single click.Motivation:
Related Issues:
What kind of change does this PR introduce?
This PR introduces a feature enhancement that adds interactive UI elements to documentation pages without modifying any content files or breaking changes.
Changes Include:
CopyCodeButtonReact component with clipboard functionalityPagecomponent for automatic code block enhancementReactDOM.render)Did you add tests for your changes?
Yes, comprehensive tests have been added:
Test Results:
Does this PR introduce a breaking change?
No, this PR introduces zero breaking changes:
If relevant, what needs to be documented once your changes are merged or what have you already documented?
No additional documentation needed:
/concepts/*pagesImplementation Details
Files Added:
src/components/CopyCodeButton/CopyCodeButton.jsx(33 lines)src/components/CopyCodeButton/CopyCodeButton.scss(45 lines)Files Modified:
src/components/Page/Page.jsximport CopyCodeButton from '../CopyCodeButton/CopyCodeButton'import ReactDOM from 'react-dom'useEffecthook to enhance code blocks when content loads/conceptsroutesHow It Works:
/concepts/*loads, thePagecomponent detects content has loaded<pre>elements in the pageCopyCodeButtoncomponent into the wrappertop: 8px, right: 8pxwithz-index: 10dataset.copyButtonAddedflag to avoid duplicatesBrowser Compatibility:
navigator.clipboard.writeText)Performance:
/conceptsroutesquerySelectorAllcall)Visual Representation
Light Mode:
Dark Mode:
After Click:
Testing Evidence
Code Quality:
/conceptspagesManual Testing:
/concepts/*routesDeployment Notes
No special deployment steps required:
PR Checklist
--
Test Cases Passing
--
Copy Button (Before Click)
--
Copy Button (After Click – "Copied!" State)