Socket
Socket
Sign inDemoInstall

react-script

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-script

Elegant DSL for React


Version published
Weekly downloads
7.1K
increased by13.29%
Maintainers
1
Weekly downloads
 
Created
Source

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: "#"}
	]

React.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 preceeding. 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"/"area-role" or dataSize/ariaRole or data_size/area_role or data: size: 1.337/aria: role: "button".

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

Install

npm i react-script --save

Run tests

npm test

Similar Projects

Keywords

FAQs

Package last updated on 02 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc