Skip to content

Conversation

@CompuIves
Copy link
Contributor

In this PR I have replaced some code examples with remark-codesandbox. In the repo we specify some template projects, which we then can refer to in our code blocks. For example:

image

This code will take the umd template (defined in /codesandbox/examples/umd), and replace the entry file with this contents, and then create an embed with those contents included. Like this:

image

We can specify as many templates as we want. For example, right now I've defined umd (using script tags), simple (single file) and cra (CRA).

I've also included some examples with line highlights! 😄

I'm curious what you think, I think another improvement would be to let this plugin replace the code blocks with something created with react-sandpack. The advantages of using this are:

  1. They're "just" React components, so you can customize visuals/behaviour as much as you want
  2. Faster performance, as there's no iframe to load for the editor
  3. Self-hosted, the bundler can be self-hosted here and will allow you to apply versioning to the bundler + if CSB ever would go down, the examples will stay up

I can work on a second version where we use react-sandpack if you're interested!

@CompuIves CompuIves force-pushed the add/codesandbox-integration branch from ed210b8 to 466918b Compare July 11, 2020 15:27
Copy link
Member

@rickhanlonii rickhanlonii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so cool

">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
Copy link
Member

@rickhanlonii rickhanlonii Jul 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know what will happen when people browse embedded codesandboxes on unsupported browsers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, yes this is a good point. Most probably it will just be a console error, but I can catch this maybe and show a better message. By the way, which browsers do you aim to support with the runnable examples? I'll make sure they'll work in those browsers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good question, these supported browser options seem fair to me but I defer to @gaearon.

@bvaughn
Copy link
Contributor

bvaughn commented Jul 12, 2020

Nice work @CompuIves !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants