1.0.7 • Published 7 years ago

pylo v1.0.7

Weekly downloads
1
License
MIT
Repository
-
Last release
7 years ago

Pylo

styled-jsx alternative for preact. supports nested <style> tags.

Example

<header>
  my red header

  <header>
    my blue header inside my red header
    <style type="jsx">{`
    header {
      background: blue;
    }
    `}</style>
  </header>

  <style type="jsx">{`
  header {
    background: red;
  }
  `}</style>
</header>

Design

  • babel not needed
  • runtime is 650 bytes
  • nested <style> tag support
  • <style jsx global> tag support
  • zero dependencies in browser
  • server-side rendering required
  • dynamic styles possible, but not implemented

Install

npm install pylo

Setup

Server

const Stringify = require('preact-render-to-string')
const Server = require('pylo/server').default
const { options } = require('preact')

const flush = Server(options)
const html = Stringify(<Simple />) // component's html
const styles = flush() // list of preact vnodes you can stringify

Client

const Client = require('pylo/client').default
const { options, render } = require('preact')

const cleanup = Client(options)
const html = render(<Simple />, document.body)
cleanup() // detaches the render hook

Test

npm install --dev pylo
npm run test

License

MIT

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago