0.3.0-alpha.5 • Published 1 year ago
rgjs-preact-slots v0.3.0-alpha.5
rgjs-preact-slots
Getting started
npm install rgjs-preact-slots
Usage
Reusable components
Toolbar.js:
import { SlotProvider, Slot, SlotContent } from 'rgjs-preact-slots';
const Toolbar = ({ children }) => (
<div class="toolbar">
<SlotProvider>
<div class="icon"><Slot name="icon" /></div>
<div class="title"><Slot name="title" /></div>
{children}
</SlotProvider>
</div>
);
Toolbar.Slot = SlotContent;
export Toolbar;
Page.js
import { Toolbar } from './Toolbar.js';
const Page = () => (
<>
<Toolbar>
<Toolbar.Slot slot="icon"><img src="path/to/image.jpg" /></Toolbar.Slot>
<Toolbar.Slot slot="title">Title</Toolbar.Slot>
</Toolbar>
<div>Lorem ispum</div>
</>
);
Output:
<div class="toolbar">
<div class="icon"><img src="path/to/image.jpg" /></div>
<div class="title">Title</div>
</div>
<div>Lorem ispum</div>
Good to know
Default slot
Create a Slot
element without a name to create a default slot:
<Slot name="with-name" />
<Slot />
Any SlotContent
elements that do not target a specific slot will end up there:
<SlontContent slot="with-name">Targets the 'with-name' slot</SlontContent>
<SlontContent>This will end up in the default slot</SlontContent>
Contribute
File a bug and I'll try to help.
License
MIT © REJH Gadellaa
Heavily inspired by the preact-slots library.
0.3.0-alpha.5
1 year ago
0.3.0-alpha.2
1 year ago
0.3.0-alpha.3
1 year ago
0.3.0-alpha.4
1 year ago
0.3.0-alpha.1
1 year ago
0.2.22
2 years ago
0.2.22-alpha.2
2 years ago
0.2.22-alpha.1
2 years ago
0.2.22-alpha.3
2 years ago
0.2.21
2 years ago
0.2.20
2 years ago
0.2.19
3 years ago
0.2.18
3 years ago
0.2.17
3 years ago
0.2.16
3 years ago
0.2.15
3 years ago
0.2.14
3 years ago
0.2.13
3 years ago
0.2.12
3 years ago
0.2.11
3 years ago
0.2.10
3 years ago
0.2.9
3 years ago
0.2.8
3 years ago
0.2.7
3 years ago
0.2.6
4 years ago
0.2.5
4 years ago
0.2.4
4 years ago
0.2.3
4 years ago
0.2.2
4 years ago
0.2.1
4 years ago
0.2.0
4 years ago
0.1.6
4 years ago
0.1.5
4 years ago
0.1.4
4 years ago
0.1.2
4 years ago
0.1.1
4 years ago
0.1.0
4 years ago
0.0.7
4 years ago
0.0.6
4 years ago
0.0.5
4 years ago
0.0.3
4 years ago
0.0.2
4 years ago
0.0.1
4 years ago