Skip to content

Commit

Permalink
Improve playground save flow (#1775)
Browse files Browse the repository at this point in the history
* FIx appended `}` to generated url

* Improve playground save flow
  • Loading branch information
anubra266 authored Dec 6, 2023
1 parent 04fd01f commit e35d01e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion playground/src/components/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const Playground = (props: UsePlayGroundProps) => {
setState,
onShare,
onShareDiff,
diffState,
isSharing,
isResponsive,
setExample,
Expand Down Expand Up @@ -111,7 +112,12 @@ export const Playground = (props: UsePlayGroundProps) => {
className={splitter()}
>
<SplitterPanel id="editor">
<Editor value={state} onChange={setState} artifacts={artifacts} diffState={props.diffState} />
<Editor
value={state}
onChange={setState}
artifacts={artifacts}
diffState={diffState ?? props.diffState}
/>
</SplitterPanel>

<ArtifactsPanel panda={panda} />
Expand Down
5 changes: 5 additions & 0 deletions playground/src/hooks/usePlayground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const usePlayground = (props: UsePlayGroundProps) => {
}

const [state, setState] = useState(initialState ?? example)
const [diffState, setDiffState] = useState<State | null>(null)

function copyCurrentURI() {
const currentURI = window.location.href
Expand Down Expand Up @@ -128,6 +129,9 @@ export const usePlayground = (props: UsePlayGroundProps) => {
share({
onDone(id) {
history.pushState({ id }, '', `${original}/${id}`)
if (!initialState) return
setDiffState(state)
setState(initialState)
},
})
}
Expand Down Expand Up @@ -159,6 +163,7 @@ export const usePlayground = (props: UsePlayGroundProps) => {
setExample,
onShare,
onShareDiff,
diffState,
isSharing,
isResponsive,
}
Expand Down

3 comments on commit e35d01e

@vercel
Copy link

@vercel vercel bot commented on e35d01e Dec 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

panda-docs – ./website

panda-docs-git-main-chakra-ui.vercel.app
panda-docs.vercel.app
panda-docs-chakra-ui.vercel.app
panda-css.com

@vercel
Copy link

@vercel vercel bot commented on e35d01e Dec 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

panda-studio – ./

panda-studio-chakra-ui.vercel.app
panda-app.vercel.app
panda-studio-git-main-chakra-ui.vercel.app

@vercel
Copy link

@vercel vercel bot commented on e35d01e Dec 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.