virtex-element
A slightly opinionated, higher-level JSX element creator for virtex
Last updated 4 years ago by ashaffer88 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install virtex-element 
SYNC missed versions from official npm registry.

virtex-element

js-standard-style

A slightly opinionated, higher-level JSX element creator for 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.

Event handler registration

Adds ev-store delegated events via onXxx property names - where Xxx is an event name (e.g. onClick). Use a library like delegant to process them. E.g.

delegant(rootNode, store.dispatch)

When your app is bootstrapped. If you are using 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.

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. E.g.

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 © 2015, Weo.io <info@weo.io>

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.

Current Tags

  • 0.4.2                                ...           latest (4 years ago)

20 Versions

  • 0.4.2                                ...           4 years ago
  • 0.4.1                                ...           4 years ago
  • 0.4.0                                ...           4 years ago
  • 0.3.6                                ...           4 years ago
  • 0.3.5                                ...           5 years ago
  • 0.3.4                                ...           5 years ago
  • 0.3.3                                ...           5 years ago
  • 0.3.2                                ...           5 years ago
  • 0.3.1                                ...           5 years ago
  • 0.3.0                                ...           5 years ago
  • 0.2.3                                ...           5 years ago
  • 0.2.2                                ...           5 years ago
  • 0.2.1                                ...           5 years ago
  • 0.2.0                                ...           5 years ago
  • 0.1.5                                ...           5 years ago
  • 0.1.4                                ...           5 years ago
  • 0.1.3                                ...           5 years ago
  • 0.1.2                                ...           5 years ago
  • 0.1.1                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (8)
Dev Dependencies (6)

Copyright 2014 - 2016 © taobao.org |