1.1.4 • Published 8 years ago

sun v1.1.4

Weekly downloads
66
License
-
Repository
github
Last release
8 years ago

sun

Simple little virtual DOM node builder for Preact.

Example

let render = require('preact-render-to-string')
let { div, span, strong } = require('sun')

const App = ({ name }) => (
  div.class('App')(
    span('hello'),
    strong(name)
  )
)

render(App({ name: 'matt' }))
// <div class="App"><span>hello</span><strong>matt</strong></div>

Features

  • Functions for all valid HTML elements
  • Functions for all valid HTML attributes on each element
  • Supports custom attributes (e.g. span({ custom: 'attribute' })('hi there!'))
  • Proudly built for Preact

Installation

npm install sun

High-Order Components

High-Order Components are a powerful technique for modifying children on the fly. Here's how you can do it with sun.

let render = require('preact-render-to-string')
let { component } = require('sun')

let styling = component(function ({ class: cls, children }) {
  assert.equal(cls, 'whatever')
  return children[0]
})

let app = styling.class('whatever')(
  div.class('wahtever')(
    strong('hi')
  )
)

assert.equal(render(app), '<div class="wahtever"><strong>hi</strong></div>')

Where you can Help

  • Performance tuning
  • React support

Test

npm install
make test

License

MIT

1.1.4

8 years ago

1.1.3

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.0.1

9 years ago

0.1.0

12 years ago