Skip to content

Commit

Permalink
Merge pull request #25 from negativetwelve/mark/react-x/render
Browse files Browse the repository at this point in the history
[react-x] Add Render component to main react-x export
  • Loading branch information
negativetwelve committed Sep 3, 2017
2 parents dd5d045 + 6565962 commit 145e1d1
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ before_install:
- export PATH="$HOME/.yarn/bin:$PATH"

script:
- yarn install --force
- yarn run clean
- yarn run build
- yarn lint:cached
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ module.exports = {

Component | Version | Description
----------|---------|------------
[`react-x-render`](/packages/react-x-render) | [![npm](https://img.shields.io/npm/v/react-x-render.svg)][npm-render] | Conditional rendering based on if/unless conditions.
[`react-x-switch`](/packages/react-x-switch) | [![npm](https://img.shields.io/npm/v/react-x-switch.svg)][npm-switch] | Switch component for toggling on/off.

[npm-render]: https://www.npmjs.com/package/react-x-render
[npm-switch]: https://www.npmjs.com/package/react-x-switch

## Contributing
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ environment:
install:
- ps: Install-Product node $env:nodejs_version
- choco install yarn --ignore-dependencies
- yarn
- yarn install --force
- yarn run clean
- yarn run build

Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies:
cache_directories:
- ~/.cache/yarn
override:
- yarn
- yarn install --force
- yarn run clean
- yarn run build

Expand Down
3 changes: 3 additions & 0 deletions packages/react-x-render/src/Render.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const Render = ({if: ifCondition, unless, children}) => {
}
};

// --------------------------------------------------
// Props
// --------------------------------------------------
Render.propTypes = {
if: PropTypes.bool,
unless: PropTypes.bool,
Expand Down
1 change: 1 addition & 0 deletions packages/react-x/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"build"
],
"dependencies": {
"react-x-render": "^0.2.4",
"react-x-switch": "^0.2.4"
},
"peerDependencies": {
Expand Down
13 changes: 10 additions & 3 deletions packages/react-x/src/__tests__/react-x.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@ import ReactX from '../react-x';

/* eslint-disable no-undef */
describe('ReactX', () => {
describe('Switch', () => {
const components = [
'Render',
'Switch',
];

forEach({component: components}, () => {
it('should exist', () => {
expect(ReactX.Switch).toBeDefined();
expect(ReactX[component]).toBeDefined();
});

// TODO(mark): Create generic matcher to support stateless and class-based
// components.
it('should be a component', () => {
expect(ReactX.Switch).toBeInstanceOf(Function);
expect(ReactX[component]).toBeInstanceOf(Function);
});
});
});
1 change: 1 addition & 0 deletions packages/react-x/src/react-x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable brace-style */
const ReactX = {
get Render() { return require('react-x-render').default; },
get Switch() { return require('react-x-switch').default; },
};

Expand Down

0 comments on commit 145e1d1

Please sign in to comment.