Skip to content

Commit

Permalink
Merge branch 'main' into minor-updates-site
Browse files Browse the repository at this point in the history
  • Loading branch information
libertymayc committed Sep 5, 2023
2 parents c4e3684 + 63c1f30 commit 2f75831
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion site/src/components/components/LivePreviewControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ export const LivePreviewControls: FC<LivePreviewControlsProps> = ({
setAllExamplesView(event.target.checked);
};

// Only set this handler function when we are displaying the combined list
// view, so that showing/hiding code persists when switching between
// examples. For the "All examples" view, we leave it undefined, which causes
// each LivePreview to show/hide its code individually.
const handleShowCodeToggle = !allExamplesView
? (showCode: boolean) => {
setShowCode(showCode);
}
: undefined;

return (
<>
<SaltProvider density="medium">
Expand Down Expand Up @@ -129,7 +139,12 @@ export const LivePreviewControls: FC<LivePreviewControlsProps> = ({
</div>
</SaltProvider>
<LivePreviewContext.Provider
value={{ density, mode, showCode, onShowCodeToggle: setShowCode }}
value={{
density,
mode,
showCode,
onShowCodeToggle: handleShowCodeToggle,
}}
>
{allExamplesView ? children : <ExamplesListView examples={children} />}
</LivePreviewContext.Provider>
Expand Down

0 comments on commit 2f75831

Please sign in to comment.