-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
move code to example: composition vs inheritance #913
Conversation
Deploy preview for reactjs failed. Built with commit 5f552b5 https://app.netlify.com/sites/reactjs/deploys/5b0f84e611b73b170df22149 |
); | ||
} | ||
``` | ||
`embed:composition-vs-inheritance/split-pane-example.js` | ||
|
||
[Try it on CodePen.](https://codepen.io/gaearon/pen/gwZOJp?editors=0010) |
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.
Hello!
It's the first time I'm reading the code and I'm wondering.
Why don't we move this example to CodeSandbox?
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.
Yeah my intention was to move it to CodeSandbox. But in this codepen example, we have both css and javascript and I'm not sure about how to do that within a single javascript file in the example
folder. Any thoughts?
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.
One question: Is it possible to reference multiple files through a codesandbox: //
link? If it is possible, I see that it is possible to solve the problem if we create a style.css
file and reference it in index.js
.
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.
Another idea would be to create css-in-js
, but I'm afraid to cause some unnecessary 'complexity' in the documentation.
What you think about ?
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.
Is it possible to reference multiple files through a codesandbox: // link?
I've tried that but it didn't work. Is it a gatsby plugin that we are using? Maybe should see how that works.
Another idea would be to create css-in-js...
For the second approach, I think it could add much extraneous noise to the example snippets, which is meant to be clear and compact.
The short answer is, " add the import". We could do something kind of hacky to expose the import as a global var, but it might confuse users who fork the sandbox.
Might be better to pick a different example for now. CodeSandbox API supports adding multiple files- so we could also send a CSS file. But the Gatsby plug-in I wrote doesn't support that yet. Maybe you'd be interested in adding that ability to the plugin as an initial step? |
@bvaughn That sounds interesting. Could you show me the link to the gatsby plugin you wrote? |
I think it's good to add the plugin's ability to support multiple files. |
@cyan33 I think this is the link: https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-remark-code-repls |
I'm thinking you could pass it a comma-separated list of files. This would be a backwards compatible change too. So a single file would continue to be: [codepen://components-and-props/rendering-a-component.js] And multiple files would become: [codepen://components-and-props/rendering-a-component.js,components-and-props/rendering-a-component.css] |
That seems good. Working on it now. |
2b702fd
to
5f552b5
Compare
used CodeSandox as it's happening upstream: reactjs/react.dev#913 ...which allows uploading CSS (currently we can't with CodePen)
* composition-vs-inheritance: done used CodeSandox as it's happening upstream: reactjs/react.dev#913 ...which allows uploading CSS (currently we can't with CodePen) * Prettier fix/offsets missed on 1 file * Update content/docs/composition-vs-inheritance.md Co-Authored-By: deblasis <[email protected]>
@washingtonsoares Hey Washington, hope you've doing well and thanks for following up on this pull request. I'll take a look after work! |
Hello @cyan33! |
As is mentioned in #246, I'm trying to move the code from
docs/composition-vs-inheritance
to/examples
. Just want to send a small PR to see if I'm doing it the right way so that I could move on for the rest work.There are several things that I noticed though:
React
andReactDOM
in codesandbox. So I had to add it manually throughimport
but it clearly adds noise to the previous compact example. Is there a quick fix about this? (I'm not quite familiar with codesandbox)cc @washingtonsoares @bvaughn