-
Notifications
You must be signed in to change notification settings - Fork 98
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 playground #404
feat: add playground #404
Conversation
Hello @shrilakshmishastry, thanks for raising a pull request in this project. The maintainers of this project are volunteers so please be understanding if it takes time before you get a response. We still appreciate your help with creating pull requests! |
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.
Some nice work so far. Things I'm concerned about:
- The current colours in the sandbox do not meet colour contrast thresholds of 4.5:1. Is there a way to update the theme to find one that has good colour contrast and also matches the current site theme in light/dark mode?
- The component is not keyboard accessible meaning anyone using a keyboard is unable to edit the code. Is there something that can be done about this?
- How does it work with JS?
- I tried making edits to the code and nothing happened. Then after about 3 minutes the preview crashed. I would expect if it was an interactive playground that any edits I make would be reflected in place without me having to go to open the sandbox in full.
import { formsPageNavigation } from "../../data/pageNavigationLists" | ||
import { CodeBlock } from "../CodeBlock/CodeBlock" | ||
import { NavPage } from "../NavPage/NavPage" | ||
import { PageUpdated } from "../PageUpdated/PageUpdated" | ||
import { TemplateSection } from "../TemplateSection/TemplateSection" | ||
import { formatCss, formatHtml } from "../../utils" | ||
|
||
const Playground = dynamic(() => import("../Playground/Playground"), { |
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 there any reason this needs to be dynamic? Why can't it be server side rendered like the rest of the content on the page?
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.
By default, sandpack provides client-side rendering. When not imported dynamically like above where I set ssr: false, it was causing Hydration problem. To avoid it, I used dynamic rendering as a first step. But it's possible to server render . More on it
I need your opinion here, whether I should use server side rendering here or go ahead with default client side?
@@ -216,6 +222,25 @@ export const FormsTemplate = () => { | |||
screen reader user. | |||
</p> | |||
</TemplateSection> | |||
<TemplateSection sectionName="playground" title="Playground"> |
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.
This needs adding to the in-page navigation
Hey @EmmaDawsonDev 👋 (Answering to above points according to their numbers)
Replace the react with the template you require. More about templates.
|
reported accessibility issue in sandpack codesandbox/sandpack#1173 |
Solving editor accessibility here codesandbox/sandpack#1184 |
Apologies for not getting to this very quickly! I've just started a new job so I've been a bit overwhelmed with new information and will also be away quite a bit in the next couple of weeks travelling. |
Hey @Yoggie9477 , please don't merge this PR, I have a few things to take care. I will resume work from 2nd week of October . |
I want to thank you so much for your work on this and apologise for being so slow to get back to you. This does look promising but for ease of maintenance just now I think it would be easier to go with embedded codepens. |
Describe your changes
Introduce a playground where users can interact with code and look at live demos. The idea is to introduce playground initially and later maybe convert it into a challenge ground, like we have in reactdev
what is Playground?
There are 4-5 options available to embed editor, I have listed them here.
I am currently using sandpack-react. An open source, well-documented library with a lot of functionality out of the box.
I have tried out this in the form component. Need opinion and corrections to improve.
Screenshots
Screen.Recording.2024-08-10.at.4.55.32.PM.mov
Link to issue
Closes # issue-403
Checklist before requesting a review
and it shows no errors.