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

CxJS Template #628

Closed
mstijak opened this issue Mar 7, 2018 · 7 comments
Closed

CxJS Template #628

mstijak opened this issue Mar 7, 2018 · 7 comments

Comments

@mstijak
Copy link
Contributor

mstijak commented Mar 7, 2018

CodeSandbox is truly an amazing project and I would love to see CxJS on the list of the supported frameworks. It's a perfect solution for prototyping, sharing examples and tutorials.

I made a couple of CxJS examples based on the vanilla template to see if it works. Except some linting and SCSS (#627), everything seems fine.

https://codesandbox.io/s/qv2w1v5qlw
https://codesandbox.io/s/mqqwo5v7lj
https://codesandbox.io/s/383p1491m
https://codesandbox.io/s/316wlj6wmq
https://codesandbox.io/s/kx79xlvqwr

We're using CxFiddle at the moment. Moving to CodeSandbox would be a big improvement for us and we would be able to contribute some development time to the project.

Please note that CxJS is a primarily a commercial product. It's free only for small teams and startups.

@CompuIves
Copy link
Member

That sounds like a great idea! I'm going to start writing custom documentation this weekend on how to write custom templates in CodeSandbox and open a PR for it, would you be interested in opening a PR with CxJS support using that?

@mstijak
Copy link
Contributor Author

mstijak commented Mar 7, 2018

Definitely. I was going to try to do it on my own, but having the documentation will surely make things much easier. Thanks!

@mstijak
Copy link
Contributor Author

mstijak commented Mar 23, 2018

I need help. It was pretty straightforward to add a new template in the UI, but I have problems understanding how the rest works. Where do template files live?

https://github.com/mstijak/codesandbox-client/tree/cxjs-template

@CompuIves
Copy link
Member

Ah, yep that's understandable.

To define a new template we need to change three things:

Template Definition

We need to add a template definition, this is used for our editor and the homepage to determine what the template is and what it can do. All templates are stored here: https://github.com/CompuIves/codesandbox-client/blob/master/packages/common/templates/index.js. You can create one by creating a new file (like cxjs.js) and filling it like the other templates, then by adding it to index.js.

Preset Configuration

We also need to configure the CodeSandbox bundler to transpile the CxJS template correctly. This can be done by creating a preset. A preset can be defined like here as example: https://github.com/CompuIves/codesandbox-client/blob/master/packages/app/src/sandbox/eval/presets/create-react-app/index.js. You'll need to add a new preset and add it to here: https://github.com/CompuIves/codesandbox-client/blob/master/packages/common/templates/index.js.

The last thing that needs to be done is marking a sandbox with a template. This is pretty hard currently, I suggest to set the template property manually on the sandbox when you fetch it. Like adding it here: https://github.com/CompuIves/codesandbox-client/blob/master/packages/app/src/app/store/actions.js#L11.

Let me know if there are more questions, I'd be glad to answer them! 😄

@mstijak
Copy link
Contributor Author

mstijak commented Mar 23, 2018

The thing is that when a new sandbox is created (based on the CxJS template) the app tries to fetch /s/cxjs which is currently non-existent. How to create that initial sandbox with default project files?

Regarding the template field, should I save the project afterward to persist the change? The problem is that I'm not able to log in with GitHub in development mode. Page not found /auth/github. Am I missing something?

@CompuIves
Copy link
Member

Hmm, you could just create a new sandbox at a random ID and manually set the template field of that sandbox to cxjs for now. That's how I do most development for templates as well.

should I save the project afterward to persist the change

No, that's not needed. If you just set your receiving side to override the field you will get the cxjs for every template, which is desired behaviour when you're developing for that template I believe.

The problem is that I'm not able to log in with GitHub in development mode.

We're setting up a staging that allows you to log in into development, but it's not here yet. You should be able to edit and save sandboxes when you're not signed in though.

@mstijak mstijak mentioned this issue Apr 1, 2018
4 tasks
@lbogdan
Copy link
Contributor

lbogdan commented Apr 28, 2018

Added in #683 .

@lbogdan lbogdan closed this as completed Apr 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants