├── .eslintignore ├── .flowconfig ├── .gitignore ├── .npmignore ├── .travis.yml ├── LICENSE ├── Makefile ├── README.md ├── component.js ├── css.js ├── package.json ├── src ├── CSS.js ├── DOMStylesheet.js ├── StyleableDOMComponent.js ├── __tests__ │ ├── DOMStylesheet-test.js │ ├── StyleableDOMComponent-test.js │ ├── index-test.js │ └── setup.js ├── component.js ├── getComponentDisplayName.js ├── index.js └── index.js.flow └── test_flow ├── .flowconfig ├── index.js └── package.json /.eslintignore: -------------------------------------------------------------------------------- 1 | src/**/__tests__/*.js 2 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | /node_modules/fbjs/.*.flow 3 | /node_modules/fbjs/.*.js 4 | /node_modules/.store/fbjs@.*/.*.flow 5 | /node_modules/.store/fbjs@.*/.*.js 6 | /test_flow/node_modules/fbjs/.*.flow 7 | /test_flow/node_modules/fbjs/.*.js 8 | /test_flow/node_modules/.store/fbjs@.*/.*.flow 9 | /test_flow/node_modules/.store/fbjs@.*/.*.js 10 | 11 | [include] 12 | 13 | [libs] 14 | 15 | [options] 16 | suppress_comment=\\(.\\|\\n\\)*\\$ExpectError 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | example/bundle.js 3 | lib/ 4 | coverage/ 5 | .nyc_output/ 6 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | src/ 2 | npm-debug.log 3 | coverage/ 4 | .nyc_output/ 5 | test_flow/ 6 | Makefile 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 4 4 | - 6 5 | - stable 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Prometheus Research 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .DELETE_ON_ERROR: 2 | 3 | BIN = ./node_modules/.bin 4 | TESTS = $(shell find src -path '*/__tests__/*-test.js') 5 | SRC = $(filter-out $(TESTS), $(shell find src -name '*.js')) $(wildcard src/*.js.flow) 6 | LIB = $(SRC:src/%.js=lib/%.js) $(SRC:src/%.js.flow=lib/%.js.flow) lib/CSS.js.flow 7 | NODE = $(BIN)/babel-node $(BABEL_OPTIONS) 8 | MOCHA_OPTIONS = --require ./src/__tests__/setup.js 9 | MOCHA = $(BIN)/_mocha $(MOCHA_OPTIONS) 10 | NYC_OPTIONS = --all --require babel-core/register 11 | NYC = $(BIN)/nyc $(NYC_OPTIONS) 12 | 13 | build: 14 | @$(MAKE) -j 8 $(LIB) 15 | 16 | lint: 17 | @$(BIN)/eslint src 18 | 19 | test:: 20 | @NODE_ENV=test $(BIN)/babel-node $(MOCHA) -- $(TESTS) 21 | 22 | ci: 23 | @NODE_ENV=test $(BIN)/babel-node $(MOCHA) --watch -- $(TESTS) 24 | 25 | test-cov:: 26 | @NODE_ENV=test $(NYC) --check-coverage $(MOCHA) -- $(TESTS) 27 | 28 | test-flow:: 29 | @(cd test_flow/ && npm install && $(BIN)/flow check) 30 | 31 | report-cov:: 32 | @$(BIN)/nyc report --reporter html 33 | 34 | report-cov-coveralls:: 35 | @$(BIN)/nyc report --reporter=text-lcov | $(BIN)/coveralls 36 | 37 | version-major version-minor version-patch: lint test 38 | @npm version $(@:version-%=%) 39 | 40 | publish: build test lint 41 | @npm publish 42 | @git push --tags origin HEAD:master 43 | 44 | clean: 45 | @rm -rf lib/ 46 | 47 | lib/%.js: src/%.js 48 | @echo "Building $<" 49 | @mkdir -p $(@D) 50 | @$(BIN)/babel $(BABEL_OPTIONS) -o $@ $< 51 | 52 | lib/%.js.flow: src/%.js.flow 53 | @echo "Building $<" 54 | @mkdir -p $(@D) 55 | @cp $< $@ 56 | 57 | lib/CSS.js.flow: src/CSS.js 58 | @echo "Building $<" 59 | @mkdir -p $(@D) 60 | @cp $< $@ 61 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # React DOM Stylesheet 2 | 3 | A simple yet powerful way to define styled React DOM components. 4 | 5 | ## Installation 6 | 7 | ``` 8 | % npm install react-dom-stylesheet 9 | ``` 10 | 11 | ## Usage 12 | 13 | Basic usage: 14 | 15 | ``` 16 | import {style} from 'react-dom-stylesheet' 17 | 18 | let Label = style('span', { 19 | fontWeight: 'bold', 20 | fontSize: '12pt', 21 | }) 22 | ``` 23 | 24 | Now `Label` is a regular React component styled with `fontWeight` and 25 | `fontSize`. You can render into DOM and use as a part of React element tree: 26 | 27 | ``` 28 |