-
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
Closed
shrilakshmishastry
wants to merge
2
commits into
AccessibleForAll:main
from
shrilakshmishastry:feat/playground
Closed
feat: add playground #404
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
import dynamic from "next/dynamic" | ||
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"), { | ||
ssr: false, | ||
}) | ||
|
||
export const FormsTemplate = () => { | ||
return ( | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. This needs adding to the in-page navigation |
||
<Playground | ||
files={{ | ||
"/index.html": { | ||
active: true, | ||
code: formatHtml(` | ||
<form> | ||
<label for="phone">Phone Number (XXX-XXX-XXXX):</label> | ||
<input type="tel" id="phone" name="phone"> | ||
</form> | ||
|
||
`), | ||
}, | ||
"/Wrapper.css": { | ||
code: formatCss(`form{ color:blue;} `), | ||
}, | ||
}} | ||
/> | ||
</TemplateSection> | ||
<TemplateSection sectionName="WCAGCriteria" title="WCAG Criteria"> | ||
<ul className="list"> | ||
<li> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.container { | ||
margin-top: 16px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Sandpack, SandpackFile } from "@codesandbox/sandpack-react" | ||
|
||
import styles from "./Playground.module.css" | ||
|
||
type FileType = { | ||
[fileName: string]: SandpackFile | ||
} | ||
|
||
type Props = { | ||
files: FileType | ||
} | ||
|
||
/** | ||
* Playground component | ||
* @returns Ui for playground | ||
*/ | ||
const Playground = (props: Props) => { | ||
return ( | ||
<div className={styles.container}> | ||
<Sandpack theme="auto" template="static" files={{ ...props.files }} /> | ||
</div> | ||
) | ||
} | ||
|
||
export default Playground |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?