项目作者: blikblum

项目描述 :
slot system for snabbdom stateless components
高级语言: JavaScript
项目地址: git://github.com/blikblum/snabbdom-slot.git
创建时间: 2018-01-14T23:34:12Z
项目社区:https://github.com/blikblum/snabbdom-slot

开源协议:MIT License

下载


snabbdom-slot

NPM version
NPM downloads

slot system for snabbdom stateless components based on Shadow DOM API

Features

  1. slot system based on web component / [Shadow DOM spec](https://developers.google.com/web/fundamentals/web-components/shadowdom)<br>
  2. works with JSX or hyperscript<br>

Usage

````jsx harmony
import { withSlot } from ‘snabbdom-slot’
import Snabbdom from ‘snabbdom-pragma’

const Component = withSlot((props) => {
return (


My {props.name || ‘nice’} component

Default Header
Default body
Default footer

)
})

const tree = (

Custom title

All rights reserved

Main content

More content


)

//render tree with snabbdom

  1. Output
  2. ```html
  3. <div>
  4. <div>My great component</div>
  5. <slot name="header">
  6. <div slot="header">Custom title</div>
  7. </slot>
  8. <slot>
  9. <div>Main content</div>
  10. <div>More content</div>
  11. </slot>
  12. <slot name="footer">
  13. <div slot="footer">All rights reserved</div>
  14. </slot>
  15. </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.