0.0.1 • Published 8 years ago
neutrine-utils v0.0.1
neutrine-utils
Utility components and hepers for React.
NOTE: this package is on development.
Installation
Use npm to install this package:
$ npm install --save neutrine-utilsAPI
classNames(...values)
A small utility to join classNames. The classNames function takes any number of arguments, that should be a string or an array of strings. Other values will be ignored.
import {classNames} from "neutrine-utils";
classNames("foo", "bar"); // --> "foo bar"
classNames(["foo", "bar"]); // --> "foo bar"
classNames(["foo"], ["bar", null]); // --> "foo bar"
classNames("foo", null, "bar"); // --> "foo bar"hyperscript(component, props, ..children)
A parser for React.createElement. Returns a React element.
component: a React component or a HTML tagstring.props: anobjectwith the properties of the element.children: astring, a React element or anarrayof React elements or strings.
import React from "react";
import {hyperscript as h} from "neutrine-utils";
export default class Example extends React.Component {
render() {
let children = [
h("div", {}, "Div element"),
h("span", {className: "text-red"}, "Red text"),
h("div", {className: "h1"}, "Heading 1")
];
return h("div", {id: "example"}, children);
}
}ready(fn)
Executes the provided function fn when the DOM becomes ready. This utility is similar to jQuery's ready method.
import {ready} from "neutrine-utils";
//Execute this function when the DOM is ready
ready(function () {
console.log("DOM is ready");
});License
Released under the MIT LICENSE.
0.0.1
8 years ago