0.1.2 • Published 8 years ago

@sliversniper/react-atr v0.1.2

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

React-atr

Motivation

Jsx can get ugly very fast.

use a clojure like way to represent react element

<div className="a b c">hello world</div>
['div.a.b.c', 'hello world'] // attr is optional

let onClick = (e) => alert('clicked')
<div onClick={_onClick} />
['div', {onClick}]

or more generally

let wrapAttr = {onClick: () => ''}
let headAttr = {style: {color: 'red'}}
['div', wrapAttr, [
    ['h1', headAttr, 'text'],
    ['section', 'lorem']
]]

API

import {ATR, ATRS, CX} from 'react-atr'

ATR(['div', 'hello world'])

let atr = ATRS({ca: 'a...', cb: 'b...'})
atr(['div.wrapper', 'use for css modules'])

let el = CX('div')({ca: true, cb: false}) // ==> 'div.ca'

atr(el)
0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago