Skip to content

Commit

Permalink
chore: add support for state in Playroom
Browse files Browse the repository at this point in the history
  • Loading branch information
DSil committed Jan 15, 2025
1 parent 8a72f12 commit a961646
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/orbit-components/playroom.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,20 @@ module.exports = {
},
exampleCode: `
<div className="bg-white-normal p-300 h-screen">
<Button type="primary">Hello World</Button>
<Context>
{() => {
const [hasError, setHasError] = React.useState(false);
return (
<Button
onClick={() => setHasError(!hasError)}
type={hasError ? "critical" : "primary"}
>
{hasError ? "Ups, click again" : "Click Me"}
</Button>
);
}}
</Context>
</div>
`,
};
2 changes: 2 additions & 0 deletions packages/orbit-components/playroomComponents.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
// Re-export components from Orbit
export * from "@kiwicom/orbit-components";

export const Context = ({ children }) => children();

0 comments on commit a961646

Please sign in to comment.