Skip to content

Commit 6462756

Browse files
Merge branch 'master' into update_themr
2 parents 7756ddc + f20128a commit 6462756

File tree

11 files changed

+418
-157
lines changed

11 files changed

+418
-157
lines changed

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ cache:
44
directories:
55
- node_modules
66
node_js:
7-
- "4"
7+
- "node"
88
before_install:
9-
- npm install -g babel-cli
9+
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.9.4
10+
- export PATH="$HOME/.yarn/bin:$PATH"
11+
- yarn global add babel-cli

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}

README.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
1-
[![npm version](https://img.shields.io/npm/v/react-css-themr.svg?style=flat-square)](https://www.npmjs.com/package/react-css-themr)
2-
[![Build Status](http://img.shields.io/travis/javivelasco/react-css-themr/master.svg?style=flat-square)](https://travis-ci.org/javivelasco/react-css-themr)
3-
[![NPM Status](http://img.shields.io/npm/dm/react-css-themr.svg?style=flat-square)](https://www.npmjs.com/package/react-css-themr)
1+
[![npm version](https://img.shields.io/npm/v/@friendsofreactjs/react-css-themr.svg?style=flat-square)](https://www.npmjs.com/package/@friendsofreactjs/react-css-themr)
2+
[![Build Status](http://img.shields.io/travis/FriendsOfReactJS/react-css-themr/master.svg?style=flat-square)](https://travis-ci.org/FriendsOfReactJS/react-css-themr)
3+
[![NPM Status](http://img.shields.io/npm/dm/@friendsofreactjs/react-css-themr.svg?style=flat-square)](https://www.npmjs.com/package/@friendsofreactjs/react-css-themr)
4+
[![Dependency Status](https://david-dm.org/FriendsOfReactJS/react-css-themr.svg)](https://david-dm.org/FriendsOfReactJS/react-css-themr) [![devDependency Status](https://david-dm.org/FriendsOfReactJS/react-css-themr/dev-status.svg)](https://david-dm.org/FriendsOfReactJS/react-css-themr#info=devDependencies&view=table)
5+
[![Twitter](https://img.shields.io/twitter/follow/friendsofreact.svg?style=social)](https://twitter.com/friendsofreact) [![Greenkeeper badge](https://badges.greenkeeper.io/FriendsOfReactJS/react-css-themr.svg)](https://greenkeeper.io/)
46

5-
# React CSS Themr
7+
# Friends of react: React CSS Themr
8+
9+
```
10+
⚛️️️❗️❗️⚛️
11+
This is a fork of React CSS Themr, that is not maintained anymore. We thank Javi Velasco for all his efforts and for
12+
creating such a great package. This package should not be unmaintained - so the friends of react will continue.
13+
14+
Sadly Javi did not responed so we can not continue with the same package name. You find us now on npm with the prefix/scope `@friendsofreactjs`.
15+
```
616

717
Easy theming and composition for CSS Modules.
818

919
```
10-
$ npm install --save react-css-themr
20+
$ npm install --save @friendsofreactjs/react-css-themr
1121
```
1222

1323
**Note: Feedback and contributions on the docs are highly appreciated.**
@@ -22,7 +32,7 @@ Taking ideas from [future-react-ui](https://github.com/nikgraf/future-react-ui)
2232

2333
The most immediate way of providing a classname object is via *props*. In case you want to import a component with a theme already injected, you have to write a higher order component that does the job. This is ok for your own components, but for ui-kits like [React Toolbox](http://www.react-toolbox.com) or [Belle](http://nikgraf.github.io/belle/), you'd have to write a wrapper for every single component you want to use. In this fancy, you can understand the theme as a **set** of related classname objects for different components. It makes sense to group them together in a single object and move it through the component tree using a context. This way, you can provide a theme either via **context**, **hoc** or **props**.
2434

25-
The approach of react-css-themr consists of a *provider* and a *decorator*. The provider sets a context theme. The decorator adds to your components the logic to figure out which theme should be used or how should it be composed, depending on configuration, context and props.
35+
The approach of @friendsofreactjs/react-css-themr consists of a *provider* and a *decorator*. The provider sets a context theme. The decorator adds to your components the logic to figure out which theme should be used or how should it be composed, depending on configuration, context and props.
2636

2737
## Combining CSS modules
2838

@@ -41,7 +51,7 @@ Say you have a `Button` component you want to make themeable. You should pass a
4151
```jsx
4252
// Button.js
4353
import React, { Component } from 'react';
44-
import { themr } from 'react-css-themr';
54+
import { themr } from '@friendsofreactjs/react-css-themr';
4555

4656
@themr('MyThemedButton')
4757
class Button extends Component {
@@ -80,7 +90,7 @@ If you use a component with a base theme, you may want to import the component w
8090
```jsx
8191
// SuccessButton.js
8292
import React, { Component } from 'react';
83-
import { themr } from 'react-css-themr';
93+
import { themr } from '@friendsofreactjs/react-css-themr';
8494
import successTheme from './SuccessButton.css';
8595

8696
@themr('MySuccessButton', successTheme)
@@ -108,7 +118,7 @@ import style from './Section.css';
108118

109119
export default () => (
110120
<section className={style.section}>
111-
<SuccessButton theme={style.button}>Yai!</SuccessButton>
121+
<SuccessButton theme={style}>Yai!</SuccessButton>
112122
</section>
113123
);
114124
```
@@ -129,7 +139,7 @@ Although context theming is not limited to ui-kits, it's very useful to avoid de
129139
```jsx
130140
import React from 'react';
131141
import { render } from 'react-dom';
132-
import { ThemeProvider } from 'react-css-themr';
142+
import { ThemeProvider } from '@friendsofreactjs/react-css-themr';
133143
import App from './app'
134144

135145
const contextTheme = {
@@ -174,4 +184,4 @@ Thanks to [Nik Graf](http://www.twitter.com/nikgraf) and [Mark Dalgleish](http:/
174184
175185
## License
176186
177-
This project is licensed under the terms of the [MIT license](https://github.com/javivelasco/react-css-themr/blob/master/LICENSE).
187+
This project is licensed under the terms of the [MIT license](https://github.com/FriendsOfReactJS/@friendsofreactjs/react-css-themr/blob/master/LICENSE).

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from "react";
22

3-
declare module "react-css-themr" {
3+
declare module "@friendsofreactjs/react-css-themr" {
44
type TReactCSSThemrTheme = {
55
[key: string]: string | TReactCSSThemrTheme
66
}

package.json

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,50 @@
11
{
2-
"name": "react-css-themr",
3-
"description": "React CSS Themr",
4-
"homepage": "https://github.com/javivelasco/react-css-themr#readme",
5-
"version": "2.1.2",
2+
"name": "@friendsofreactjs/react-css-themr",
3+
"description": "Friends of ReactJS: React CSS Themr",
4+
"homepage": "https://github.com/FriendsOfReactJS/react-css-themr#readme",
5+
"version": "3.0.1",
66
"main": "./lib",
7-
"author": {
8-
"email": "javier.velasco86@gmail.com",
9-
"name": "Javi Velasco",
10-
"url": "http://javivelasco.com/"
11-
},
7+
"author": "Javi Velasco <javier.velasco86@gmail.com> (http://javivelasco.com/)",
128
"repository": {
139
"type": "git",
14-
"url": "git+https://github.com/javivelasco/react-css-themr.git"
10+
"url": "git+https://github.com/FriendsOfReactJS/react-css-themr.git"
1511
},
1612
"bugs": {
17-
"url": "https://github.com/javivelasco/react-css-themr/issues"
13+
"url": "https://github.com/FriendsOfReactJS/react-css-themr/issues"
1814
},
1915
"keywords": [
2016
"css-modules",
2117
"customization",
2218
"react",
2319
"react-css-themr",
24-
"theming"
20+
"theming",
21+
"friends of react"
2522
],
2623
"dependencies": {
27-
"hoist-non-react-statics": "^1.2.0",
28-
"invariant": "^2.2.1"
24+
"hoist-non-react-statics": "^3.0.1",
25+
"invariant": "^2.2.4"
2926
},
3027
"devDependencies": {
31-
"@types/react": "^15.0.24",
32-
"babel-cli": "^6.24.1",
33-
"babel-core": "^6.24.1",
28+
"@types/react": "^16.4.7",
29+
"babel-cli": "^6.26.0",
30+
"babel-core": "^6.26.3",
3431
"babel-eslint": "^7.2.3",
35-
"babel-plugin-transform-decorators-legacy": "^1.3.4",
32+
"babel-plugin-transform-decorators-legacy": "^1.3.5",
3633
"babel-preset-es2015": "^6.24.1",
3734
"babel-preset-react": "^6.24.1",
3835
"babel-preset-stage-0": "^6.24.1",
3936
"eslint": "^3.19.0",
4037
"eslint-config-rackt": "^1.1.1",
4138
"eslint-plugin-babel": "^4.1.1",
42-
"eslint-plugin-react": "^7.0.0",
39+
"eslint-plugin-react": "^7.10.0",
4340
"expect": "^1.18.0",
44-
"fbjs": "^0.8.12",
41+
"fbjs": "^0.8.17",
4542
"jsdom": "^9.8.3",
4643
"mocha": "^3.3.0",
47-
"prop-types": "^15.5.9",
48-
"react": "^15.5.4",
49-
"react-dom": "^15.5.4",
50-
"rimraf": "^2.6.1",
44+
"prop-types": "^15.6.2",
45+
"react": "^16.4.2",
46+
"react-dom": "^16.4.2",
47+
"rimraf": "^2.6.2",
5148
"sinon": "^1.17.6"
5249
},
5350
"files": [
@@ -64,7 +61,21 @@
6461
},
6562
"license": "MIT",
6663
"peerDependencies": {
67-
"react": "^0.14.0 || ^15.0.0-0"
64+
"react": "^0.14.0 || ^15.0.0-0 || ^16.0.0"
65+
},
66+
"typings": "./index.d.ts",
67+
"directories": {
68+
"lib": "lib",
69+
"test": "test"
6870
},
69-
"typings": "./index.d.ts"
71+
"greenkeeper": {
72+
"ignore": [
73+
"expect",
74+
"mocha",
75+
"sinon",
76+
"jsdom",
77+
"eslint",
78+
"babel-eslint"
79+
]
80+
}
7081
}

src/components/themr.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,11 @@ export default (componentName, localTheme, options = {}) => (ThemedComponent) =>
9292
getNamespacedTheme(props) {
9393
const { themeNamespace, theme } = props
9494
if (!themeNamespace) return theme
95-
if (themeNamespace && !theme) throw new Error('Invalid themeNamespace use in react-css-themr. ' +
95+
96+
if (themeNamespace && !theme) {
97+
throw new Error('Invalid themeNamespace use in friendsofreactjs/react-css-themr. ' +
9698
'themeNamespace prop should be used only with theme prop.')
99+
}
97100

98101
return Object.keys(theme)
99102
.filter(key => key.startsWith(themeNamespace))
@@ -262,7 +265,7 @@ function merge(original = {}, mixin = {}) {
262265
function validateComposeOption(composeTheme) {
263266
if ([ COMPOSE_DEEPLY, COMPOSE_SOFTLY, DONT_COMPOSE ].indexOf(composeTheme) === -1) {
264267
throw new Error(
265-
`Invalid composeTheme option for react-css-themr. Valid composition options\
268+
`Invalid composeTheme option for friendsofreactjs/react-css-themr. Valid composition options\
266269
are ${COMPOSE_DEEPLY}, ${COMPOSE_SOFTLY} and ${DONT_COMPOSE}. The given\
267270
option was ${composeTheme}`
268271
)

test/components/ThemeProvider.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ import PropTypes from 'prop-types'
44
import TestUtils from 'react-dom/test-utils'
55
import { ThemeProvider } from '../../src/index'
66

7+
8+
before(function () {
9+
/* eslint-disable no-console */
10+
console.error = function () {}
11+
})
12+
13+
after(function () {
14+
delete console.error
15+
})
16+
717
describe('ThemeProvider', () => {
818
class Child extends Component {
919
render() {

test/components/themr.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ describe('Themr decorator function', () => {
351351
<ProviderMock theme={theme}>
352352
<Container themeNamespace="container"/>
353353
</ProviderMock>
354-
)).toThrow(/Invalid themeNamespace use in react-css-themr. themeNamespace prop should be used only with theme prop./)
354+
)).toThrow(/Invalid themeNamespace use in friendsofreactjs\/react-css-themr. themeNamespace prop should be used only with theme prop./)
355355
})
356356

357357
it('when providing a themeNamespace prop composes a theme', () => {

test/setup.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import raf from './tempPolyfills'
12
import { jsdom } from 'jsdom'
23

34
global.document = jsdom('<!doctype html><html><body></body></html>')

test/tempPolyfills.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const raf = global.requestAnimationFrame = (cb) => {
2+
setTimeout(cb, 0)
3+
}
4+
5+
export default raf

0 commit comments

Comments
 (0)