JSPM

snabbdom-slot

0.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q21464F
  • License MIT

A shadowDom slot system like for snabbdom stateless components

Package Exports

  • snabbdom-slot

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (snabbdom-slot) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

snabbdom-slot

NPM version NPM downloads

shadowDom slot system like for snabbdom stateless components

Features

    ✓ slot system based on web component / shadowDOM 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.