Skip to content

slot system for snabbdom stateless components

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt
Notifications You must be signed in to change notification settings

blikblum/snabbdom-slot

Repository files navigation

snabbdom-slot

NPM version NPM downloads

slot system for snabbdom stateless components based on Shadow DOM API

Features

    ✓ slot system based on web component / Shadow DOM spec
    ✓ works with JSX or hyperscript

Usage

import { withSlot } from 'snabbdom-slot'
import Snabbdom from 'snabbdom-pragma'

const Component = withSlot((props) => {
  return (
   <div>
     <div>My {props.name || 'nice'} component</div>
     <slot name="header">Default Header</slot>
     <slot>Default body</slot>
     <slot name="footer">Default footer</slot>
   </div> 
  )  
})

const tree = (
  <Component name="great">
    <div slot="header">Custom title</div>
    <div slot="footer">All rights reserved</div>
    <div>Main content</div>
    <div>More content</div>
  </Component>
)

//render tree with snabbdom

Output

   <div>
     <div>My great component</div>
     <slot name="header">
       <div slot="header">Custom title</div>
     </slot>
     <slot>
       <div>Main content</div>
       <div>More content</div>
     </slot>
     <slot name="footer">
       <div slot="footer">All rights reserved</div>
     </slot>
   </div> 

Check this for more info about slot element behavior

License

Copyright © 2015-2016 Luiz Américo Pereira Câmara. This source code is licensed under the MIT license found in the LICENSE.txt file. The documentation to the project is licensed under the CC BY-SA 4.0 license.

About

slot system for snabbdom stateless components

Topics

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published