-
-
Notifications
You must be signed in to change notification settings - Fork 747
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: Guide to Creating Responsive Builder's #615
base: main
Are you sure you want to change the base?
Conversation
…me to create a responsive container
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Wow this is a nice addition, thanks a lot! ❤️ Could you run |
Omg yes. I was wondering why the deployment didn't work. I got a little busy but I'll fix this today and get to the second part of the guide sometime this week! |
Alright @prevwong, done. Also I added a few more improvements to the text. Let me know if there is anything you think I should add/rewrite to improve the guide. Otherwise I am still missing the part on styles but that should be it. TODO:
|
Just had a chance to briefly checkout the guide. Here're my thoughts:-
Okay, so when it comes to implementing responsive designs with Craft, the idea is to just use an iframe to wrap the editor contents. This poses some issues as mentioned in the guide, the biggest one being CSS. This is a really complex issue as it largely depends on how the developer implements styling in their editor. If they're using a CSS-in-JS solution like If the developer is using tailwind, then they could also do the same trick as above or they could just inject Tailwind's Play CDN inside the iframe, and the CDN is responsible for catching all tailwind classes used inside the iframe and it dynamically injects tailwind classes into the iframe. This is the approach I used in https://reka.js.org With all of that said, this is more of a general problem with CSS and iframes; rather than a Craft.js one. For example, this entire guide could be written without involving Craft at all. Perhaps, a better way to go about writing this guide is to simply discuss these approaches and maybe just share a simple React example (without Craft) |
Hey! Thanks for the feedback. I think you are totally correct. Here is what I have done:
Two things I would love your opinion on:
|
> **NOTE: if using SSR framework like next** | ||
> You must ensure that this component runs only on the client | ||
|
||
If you did this correctly you should be able you should see the text on the screen and be able to resize the iframe correctly. **But, and this is important** the text will still not change color. So, we are back where we started, see? progress. This is because of the [Iframe CSS Problem](#the-iframe-css-problem) |
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.
Hi! First of all, props for the great addition!
Second, I think you might have here a mistake ... you should be able you should see...
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.
I hope I'm not disturbing with this comment, I just read your stuff and found out this tiny bungling :)
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.
You are totally right. My bad. Will fix this & push the 2nd part of the guide once I have finished my exams in 2 weeks. Thanks for catching it!
The way I did the responsive, is making the Root node (the "page") a simulation of a "real" page, and all its children the contents of the page. I made a context provider that calculates the width of the Root node (viewportWidth) , so when i "resize" through the mobile , dekstop, tablet icons its squeezing the root node and all their children are squeezed consequently. Then when I make layouts or sections, I use the viewportWidth to simulate the responsive (if viewportWidth < 400px, flexDirection = "Column" etc...) This works in editor while making changes and also when I load in the iframe, the same logic is applying. |
Hey! Took me a little longer than I wanted but I have written the first part of the guide that we talked about. I plan on getting to the second part sometime this week and will update PR when its done. For now, since the first part is done (and its somewhat stand alone) I thought I would open this in case there are any changes that need to be made.
The goals for this PR are:
Why make the PR if its still not complete? First part is ready for feedback & I wanted to get this out as soon as possible since its a question that has come up a lot, until this is merge we can probably point people to this PR instead of answering the question again.
What is still TODO?