Skip to content

Commit

Permalink
chore: fix useId problem in playroom
Browse files Browse the repository at this point in the history
The code now exposes the provider and a wrapper div, also allowing for more customization
  • Loading branch information
DSil committed Jan 14, 2025
1 parent 1b9e1de commit 830e11b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
13 changes: 13 additions & 0 deletions packages/orbit-components/playroom.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ module.exports = {
outputPath: "./.playroom",
frameComponent: "./playroom/FrameComponent.tsx",
snippets: "./playroom/snippets.ts",
scope: "./playroom/scope.ts",
port: 9000,
openBrowser: false,
widths: Object.values(defaultFoundation.breakpoint),
defaultVisibleWidths: [
defaultFoundation.breakpoint.mediumMobile,
defaultFoundation.breakpoint.desktop,
],
baseUrl: "/",
webpackConfig: () => ({
resolve: {
Expand Down Expand Up @@ -58,4 +63,12 @@ module.exports = {
],
},
}),
exampleCode: `
<OrbitProvider theme={theme} useId={useId}>
<div className="bg-white-normal p-300 h-screen">
{ /* Write your code below this line */ }
<Button type="primary">Hello World</Button>
</div>
</OrbitProvider>
`,
};
11 changes: 2 additions & 9 deletions packages/orbit-components/playroom/FrameComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import * as React from "react";
import "./index.css";

import { OrbitProvider } from "../src";
import defaultTheme from "../src/defaultTheme";

// Wrap all examples in OrbitProvider for proper theming
const FrameComponent = ({ children }) => {
return (
<OrbitProvider theme={defaultTheme} useId={React.useId}>
<div style={{ padding: "20px" }}>{children}</div>
</OrbitProvider>
);
return <div id="playroom-frame">{children}</div>;
};

export default FrameComponent;
12 changes: 12 additions & 0 deletions packages/orbit-components/playroom/scope.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from "react";

import { useTheme } from "../src";

const useScope = () => {
return {
useId: React.useId,
theme: useTheme(),
};
};

export default useScope;

0 comments on commit 830e11b

Please sign in to comment.