Skip to content
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

feat: Add support for code titles, language info and copy button #225

Closed
wants to merge 3 commits into from

Conversation

jletey
Copy link
Contributor

@jletey jletey commented Jul 26, 2019

  • Code titles
  • Language info
  • Copy button

Closes #212
Related gatsbyjs/gatsby#15834

packages/prism/package.json Outdated Show resolved Hide resolved
@jletey
Copy link
Contributor Author

jletey commented Jul 26, 2019

@jxnblk Also, what are your opinion on #212 (comment), as we should include all of the language colors built in for the language info

Also, which one of these icons do you like better? #212 (comment) These would be for the copy button, which has been decided that it should have an icon instead of the "Copy"/"Copied" text #212 (comment) (although I think that this shouldn't be default, and could maybe be stored in a variant?)

@jxnblk
Copy link
Member

jxnblk commented Jul 26, 2019

Personally, I'd rather see a text label for copy, but I think we can add a prop to the Prism component to allow any element to be passed in

@jletey
Copy link
Contributor Author

jletey commented Jul 28, 2019

@jxnblk and whoever else is following this PR, I have just pushed a commit with code that I believe adds support for a copy button!

I'm not exactly quite if it works (as I have yet to find a way of testing the code locally), so would love feedback!

Please note that the code for this feature was either adapted or lifted from the Gatsby source, which should be fine as they are using the MIT license

Also note that I have yet to add support for custom icons instead of just the plain "Copy" text

@sonapraneeth-a
Copy link

@johnletey , Do you have a screenshot of the rendered output?

@jletey
Copy link
Contributor Author

jletey commented Jul 31, 2019

@sonapraneeth-a Like I said above, I don't know how to run the package locally ... would love some advice and I'd be happy to try to run it locally!

@jxnblk
Copy link
Member

jxnblk commented Jul 31, 2019

@johnletey if you're able to run the docs site locally with yarn start, it should render all code examples with the Prism component, see: https://github.com/system-ui/theme-ui/blob/master/packages/docs/src/gatsby-plugin-theme-ui/components.js#L26

This line could change to pass props to the component:

// example
code: props => <Prism {...props} copy={true} />,

@jletey
Copy link
Contributor Author

jletey commented Jul 31, 2019

Wow ... I'll have to try this out! Thanks @jxnblk

Overall though, how does the code look?

@jxnblk
Copy link
Member

jxnblk commented Dec 4, 2019

@johnletey are you still interested in working on this? If not, I think we can close this PR out for the time being

@jletey
Copy link
Contributor Author

jletey commented Dec 11, 2019

@jxnblk Sorry for the late reply. Unfortunately, I don't think I will have much time to work on this in the future, so I am going to go ahead and close this.

If there is anyone that wants to continue on this, go for it!

@jletey jletey closed this Dec 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[@theme-ui/prism] Add support for code titles, language info and copy button
3 participants