0.0.4 • Published 2 years ago

d3activated v0.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

d3activated

npm.io npm version

Small javascript library for transpiling JSX to DOM Elements and optionally wrapping the element in d3-selection.

Installation

npm i -D d3activated

d3activated provides functions for use with bundlers to transpile JSX to plain DOM elements.

Usage

The following JSX

<div />

transpiles to HTMLDIVElement.

Add classes, ids, & common attributes

<ul className={styles.list} />

<img src={imgSrc} />

The eventListener attribute takes an array that contains exactly 2 elements: the event type and the function.

<span eventListener={['click', e => {
    console.log(e)
}]} />

Use a function as an element type to create functional components with custom attributes.

const Component = ({ attributes: { items }}) => (
    <ul>
        {items.map(item => <li>{item.name}</li>)}
    </ul>
)

const items = ['foo' 'bar']

<Component items={items} />

Pass children to any element

const Component = ({ children }) => (
    <div>
    { children }
    </div>
)

<Component>
    <div></div>
    Hey! These divs aren't going to nest themselves!
</Component>
0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago