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
Docs enhancement - add a copy button to code examples #5030
Comments
@shannonbux I didn't do the copy stuff yet! But you can definitely do the code title stuff if you're interested! |
This would be an awesome improvement for users browsing gatsby documentation. I'm sure @fk has some ideas regarding design, but let's build it out functionally first and then we can augment that existing functionality with a sweet design. I think it's a fair assumption that users of this plugin will also be users of Further Detail
// gatsby-config.js
plugins: [
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
{
resolve: `gatsby-remark-prismjs`,
options: {
copy: true
}
}
]
}
}
] or an alternative approach is a standalone plugin that depends on the structure created by // gatsby-config.js
plugins: [
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
`gatsby-remark-prismjs`,
`gatsby-remark-copy-snippet`
]
}
}
] there are pro's and con's to both approaches, so this should be a fun one to work on 💪 |
I think I can help with this one |
@felipecaputo I can mark this as taken if you're interested! Let me know! |
That would be great. I'll take a look at the plugin tonight and get back to
you
…On Thu, Oct 4, 2018 at 4:31 PM Dustin Schau ***@***.***> wrote:
@felipecaputo <https://github.com/felipecaputo> I can mark this as taken
if you're interested! Let me know!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#5030 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHZHGQDA9sqXglyvXVDEyWUM8MTkbJu5ks5uhmIKgaJpZM4TZRnC>
.
|
@marcysutton I currently don't have the capacity to test and implement accessibility features, but I will be more than happy to merge these PRs in gatsby-remark-code-buttons. |
@iamskok Does gatsby-remark-code-buttons work with gatsby-mdx as of now? I'm encountering these issues. |
@ar-stackrox it was never tested with |
@iamskok I can't right now because the repo is private, but all I did was an npm install, and then add it to the gatsby-config / gatsby-remark-plugin like so - |
@ar-stackrox if at all possible--I'd request that you please re-open the issue in the package itself. Thanks @iamskok for chiming in and being so helpful--we sincerely appreciate it! |
@iamskok I can confirm the same issue when using MDX as reported by @ar-stackrox |
If anyone can reproduce this bug, please share it here |
This component was spec'd as part of #14095 (currently needing to be prioritized amongst other work, so if anyone wants to pick this up that would be fine by us as long as it meets the requirements). Here are some success criteria for what we need for this component to be successful: Success criteria
Potential icon: Alternatively, there could be a button that just visually says "copy" without an icon. |
@marcysutton thanks for providing all the requirements. I can continue working on this issue, but I will need some guidelines with reproducing and fixing MDX compatibility bug. Do you know anyone who will be able to help me with it? |
Hey @iamskok, I'm not sure I can provide a ton of help on debugging remark plugins as sub-plugins of
This is a great use case for MDX, but maybe @DSchau has an opinion since it would probably require reworking packages like I think using the remark plugin is still a good possibility and I don't have the most context around this either. |
This plugin seems to have conflicts with |
@Blackglade can you please provide more information on styling conflicts you are talking about? Not sure about ETA, I’ll need help from someone who is familiar with MDX to make it work. We are also waiting for @DSchau recommendations, because he has a lot of context on this issue . |
@iamskok So I have the following plugins listed under
Anytime I include |
@Blackglade please try this order:
The working example of using all of these plugins together can be found in gatsby-dev-blog-starter. gatsby-remark-code-buttons provides generic styles to make positioning and adding tooltips easier, but the developer is responsible for tweaking the button styles to match a syntax highlighting theme. |
👍 to doing this — just saw someone again at a workshop run into an error with a graphql query because they didn’t copy the closing backtick. |
Summary
Code examples in tutorials, READme files, and guides could use a copy button so people don't miss a single thing when they copy code.
Motivation
When we did a Gatsby workshop a while ago, many workshop attendees' computer screens didn't show backtics very clearly and they missed copying them a lot.
Another related issue brought up by @twhiteaker is that when copying code from Firefox to VS code (and Notepad ++), the code ended up having two carriage returns added to the top and bottom. This actually mattered for a markdown file, it appears.
Acceptance criteria (by @marcysutton)
${filename}: copy code to clipboard
to know which file I’m copying to the clipboard.${filename} copied to clipboard
after activating the button.Potential icon:
Alternatively, there could be a button that just visually says "copy" without an icon.
The text was updated successfully, but these errors were encountered: