Skip to content
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 ContentSlot component #1014

Merged
merged 2 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions packages/react-board/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,30 @@ createBoard({
});
```

You can also create boards with separation between the actual content and the board environment (context providers, board styling).
This will be helpful in board templates, to indicate to Codux where to put the component in the generated board.
Or in boards, so that when the board is converted to a code snippet, only the children of the `<ContentSlot>` will be included in the snippet.
This is useful when the board is wrapped in a router or a context provider that shouldn't be included in the snippet.

```tsx
// hello.board.tsx

import { createBoard, ContentSlot } from '@wixc3/react-board';
import { Hello } from './hello';

createBoard({
name: 'hello board',
board: () => (
<SomeWrappingComponent>
<p>description</p>
<ContentSlot>
<Hello name="World" />,
</ContentSlot>
<SomeWrappingComponent>
)
});
```

## License

MIT
3 changes: 3 additions & 0 deletions packages/react-board/src/content-slot.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function ContentSlot(props: { children?: React.ReactNode; name?: string }) {
return props.children;
}
1 change: 1 addition & 0 deletions packages/react-board/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './create-board';
export * from './types';
export * from './content-slot';