# virtex-element

> A slightly opinionated, higher-level JSX element creator for virtex

Latest version **0.4.2** (published 2016-12-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install virtex-element
pnpm add virtex-element
yarn add virtex-element
bun add virtex-element
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.2 |
| Published | 2016-12-08 |
| First published | 2015-10-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Maintainers | ashaffer88 |

## Links

- npm: https://www.npmjs.com/package/virtex-element
- Repository: https://github.com/ashaffer/virtex-element
- Homepage: https://github.com/ashaffer/virtex-element#readme
- Issues: https://github.com/ashaffer/virtex-element/issues
- npm.io page: https://npm.io/package/virtex-element

## Dependencies (8)

- [virtex](https://npm.io/package/virtex.md) ^0.3.6
- [ev-store](https://npm.io/package/ev-store.md) ^7.0.0
- [classnames](https://npm.io/package/classnames.md) ^2.2.3
- [@f/keychord](https://npm.io/package/@f/keychord.md) ^1.1.1
- [@f/is-object](https://npm.io/package/@f/is-object.md) ^1.1.1
- [@f/capitalize](https://npm.io/package/@f/capitalize.md) ^1.0.0
- [@f/dom-events](https://npm.io/package/@f/dom-events.md) ^1.0.3
- [@f/event-handler](https://npm.io/package/@f/event-handler.md) ^1.0.3

## Recent versions

- 0.4.2 (latest) — 2016-12-08
- 0.4.1 — 2016-11-10
- 0.4.0 — 2016-11-09
- 0.3.6 — 2016-06-06
- 0.3.5 — 2016-05-03
- 0.3.4 — 2016-05-03
- 0.3.3 — 2016-04-29
- 0.3.2 — 2016-02-25
- 0.3.1 — 2016-02-08
- 0.3.0 — 2016-01-29
- 0.2.3 — 2016-01-16
- 0.2.2 — 2016-01-10
- 0.2.1 — 2016-01-10
- 0.2.0 — 2016-01-02
- 0.1.5 — 2015-12-08
- … 5 more at https://npm.io/package/virtex-element/versions

## README

# virtex-element

[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)

A slightly opinionated, higher-level JSX element creator for [virtex](https://github.com/ashaffer/virtex) that wraps it's native `element`.

## Installation

    $ npm install virtex-element

## Features

This library provides a number of little bits of syntactic sugar to make your life easier when working with [virtex](https://github.com/ashaffer/virtex).

### Event handler registration

Adds [ev-store](https://github.com/Raynos/ev-store) delegated events via `onXxx` property names - where `Xxx` is an event name (e.g. `onClick`).  Use a library like [delegant](https://github.com/ashaffer/delegant) to process them. E.g.

```javascript
delegant(rootNode, store.dispatch)
```

When your app is bootstrapped. If you are using [vdux](https://github.com/ashaffer/vdux), this will be done for you.

### Class sugar

Object/array syntax for classnames.

`class={['nav', 'featured']}` -> `class="nav featured"`

`class={{nav: true, featured: true, small: false}}` -> `class="nav featured"`

### Style objects

Passing an object as the `style` prop to an element will cause that object to be stringified and each camel cased property will get dashed. E.g.

```javascript
import colors from 'lib/colors'

function render ({props, children}) {
  return <button style={{backgroundColor: props.primary ? colors.primary : colors.accent}}>{children}</button>
  // style = 'background-color:#fff'
}
```

### Event sugar

All event handlers accept arrays, which will execute all of the handlers in the array. The `keyup/keydown/keypress` events have additional special syntax for selecting on keys or key combinations using [keychord](https://github.com/micro-js/keychord). E.g.

```javascript
function render () {
  return <input onKeyPress={{enter: submitEntry, esc: cancelEdit}} onInput={setText} />
}
```

The available events and their mappings are:

```
onBlur: 'blur',
onChange: 'change',
onClick: 'click',
onContextMenu: 'contextmenu',
onCopy: 'copy',
onCut: 'cut',
onDoubleClick: 'dblclick',
onDblClick: 'dblclick',
onDrag: 'drag',
onDragEnd: 'dragend',
onDragEnter: 'dragenter',
onDragExit: 'dragexit',
onDragLeave: 'dragleave',
onDragOver: 'dragover',
onDragStart: 'dragstart',
onDrop: 'drop',
onError: 'error',
onFocus: 'focus',
onInput: 'input',
onInvalid: 'invalid',
onKeyDown: 'keydown',
onKeyPress: 'keypress',
onKeyUp: 'keyup',
onMouseDown: 'mousedown',
onMouseEnter: 'mouseenter',
onMouseLeave: 'mouseleave',
onMouseMove: 'mousemove',
onMouseOut: 'mouseout',
onMouseOver: 'mouseover',
onMouseUp: 'mouseup',
onPaste: 'paste',
onReset: 'reset',
onScroll: 'scroll',
onSubmit: 'submit',
onTouchCancel: 'touchcancel',
onTouchEnd: 'touchend',
onTouchMove: 'touchmove',
onTouchStart: 'touchstart',
onWheel: 'wheel'
```

If you'd like to see something else added here, feel free to submit a pull request.



## License

The MIT License

Copyright &copy; 2015, Weo.io &lt;info@weo.io&gt;

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---
_Source: https://npm.io/package/virtex-element · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
