npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-script

v2.0.5

Published

Elegant DSL for React

Downloads

95,737

Readme

ReactScript

An elegant, flexible DSL for React for use with CoffeeScript (and maybe other languages)

With CoffeeScript:

# Alias it as whatever you want (maybe _ or $?)
E = ReactScript or require "react-script"

class Message extends React.Component
	render: ->
		E ".message", class: (if @props.author is you then "from-you"),
			E ".info",
				style: float: "right"
				"From "
				E "span.author", @props.author
				" at "
				E "span.time", @props.time
			E "p.body",
				@props.text
				if @props.fileTransfers
					E ".transfers",
						"Sent files:"
						E "ul.files",
							for transfer in @props.fileTransfers
								E "li", E "a",
									href: transfer.downloadLink
									download: transfer.fileName
									transfer.fileName

message = E Message,
	author: "John"
	time: "5:47 PM"
	text: "Hello world!"
	fileTransfers: [
		{fileName:  "virus.exe", downloadLink: "#"}
	]

ReactDOM.render message, document.body

By simply supporting arrays and ignoring nully values, it works with all forms of conditionals and comprehensions.

All the functionality of classnames is built in. Just provide any class, classes, className, classNames or classList. All those properties are treated the same and can be a single class name, a single string with multiple class names, an object where the keys are the class names and the values are whether they should be present, or an array of any of the preceding. Nully values are ignored, allowing for conditionals.

The whole library tries to be pretty flexible.

You can specify data-* and aria-* properties either as e.g. "data-size"/"aria-pressed" or dataSize/ariaPressed or data_size/aria_pressed or data: size: 1.337/aria: pressed: true. (ARIA's role attribute is just role.)

Check out the specs for more details.

If you find something that doesn't work as you'd hope, feel free to open an issue.

Installation

npm i react-script --save

Usage

You can use ReactScript through a bundler like browserify or webpack, or you can include it as a script:

<script src="node_modules/react-script/lib/react-script.js"></script>`

Then alias ReactScript as something short such as E to use as a DSL.

var E = ReactScript; // or require("react-script");

Run tests

npm test

Similar Projects