Skip to content

Instantly share code, notes, and snippets.

@sharvit
Created August 18, 2019 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sharvit/a8cfd14dd69ba33285af9428902fa42f to your computer and use it in GitHub Desktop.
Save sharvit/a8cfd14dd69ba33285af9428902fa42f to your computer and use it in GitHub Desktop.
Slot and fill suggestion
const LayoutToolbarButtonsSlot = () => (<>
<Slot id="layout-toolbar-buttons" multi />
<Fill slot="layout-toolbar-buttons" weight={100}>
<ExportButton />
</Fill>
<Fill slot="layout-toolbar-buttons" weight={200}>
<DocumentationButton documentationURL={documentationURL} />
</Fill>
</>);
const FillLayoutToolbarButtonsWithDefaults = () => (
<>
<Fill slot="layout-toolbar-buttons" weight={100}>
<ExportButton />
</Fill>
<Fill slot="layout-toolbar-buttons" weight={200}>
<DocumentationButton documentationURL={documentationURL} />
</Fill>
</>
);
const FillSlotWithDefaults = ({ slotId, fills }) => (
<>
{fills.map(fill => <Fill slot="layout-toolbar-buttons" weight={100}>{fill}</Fill>)}
</>
);
<div><LayoutToolbarButtonsSlot /></div>
<Slot id="layout-toolbar-buttons" multi />
<FillSlotWithDefaults slotId="layout-toolbar-buttons" fills={
<>
<ExportButton />
<DocumentationButton documentationURL={documentationURL} />
</>
} />
<Slot id="layout-toolbar-buttons" multi>
<ExportButton />
<DocumentationButton documentationURL={documentationURL} />
</Slot>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment