├── .gitignore ├── create-react-app-example ├── .gitignore ├── README.md ├── favicon.ico ├── index.html ├── package.json ├── reactcards │ ├── card.js │ └── entry.js ├── src │ ├── App.css │ ├── App.js │ ├── index.css │ ├── index.js │ └── logo.svg └── test │ └── App.js ├── package.json ├── src ├── cards.js ├── components.js └── main.js └── test ├── advanced.js ├── components.js ├── index.js └── simple.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /create-react-app-example/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | node_modules 5 | 6 | # production 7 | build 8 | 9 | # misc 10 | .DS_Store 11 | npm-debug.log 12 | -------------------------------------------------------------------------------- /create-react-app-example/README.md: -------------------------------------------------------------------------------- 1 | Below you will find some information on how to perform common tasks. 2 | You can find the most recent version of this guide [here](https://github.com/facebookincubator/create-react-app/blob/master/template/README.md). 3 | 4 | ## Sending Feedback 5 | 6 | We are always open to [your feedback](https://github.com/facebookincubator/create-react-app/issues). 7 | 8 | ## Folder Structure 9 | 10 | After creation, your project should look like this: 11 | 12 | ``` 13 | my-app/ 14 | README.md 15 | index.html 16 | favicon.ico 17 | node_modules/ 18 | package.json 19 | src/ 20 | App.css 21 | App.js 22 | index.css 23 | index.js 24 | logo.svg 25 | ``` 26 | 27 | For the project to build, **these files must exist with exact filenames**: 28 | 29 | * `index.html` is the page template; 30 | * `favicon.ico` is the icon you see in the browser tab; 31 | * `src/index.js` is the JavaScript entry point. 32 | 33 | You can delete or rename the other files. 34 | 35 | You may create subdirectories inside `src`. For faster rebuilds, only files inside `src` are processed by Webpack. 36 | You need to **put any JS and CSS files inside `src`**, or Webpack won’t see them. 37 | 38 | You can, however, create more top-level directories. 39 | They will not be included in the production build so you can use them for things like documentation. 40 | 41 | >**Known Issue:** 42 | > 43 | >You may encounter an issue where changing a file inside `src` doesn’t trigger a recompilation. Most likely this happens because the path in your filesystem differs in its casing from the path you imported. For example, if a file is called `App.js` but you are importing `app.js`, the watcher might not recognize changes to it. We are [considering](https://github.com/facebookincubator/create-react-app/issues/240) enforcing some checks to prevent this. If this doesn’t help, check out the page on [troubleshooting watching](https://webpack.github.io/docs/troubleshooting.html#watching). 44 | 45 | ## Available Scripts 46 | 47 | In the project directory, you can run: 48 | 49 | ### `npm start` 50 | 51 | Runs the app in the development mode.
52 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 53 | 54 | The page will reload if you make edits.
55 | You will also see any lint errors in the console. 56 | 57 | ### `npm run build` 58 | 59 | Builds the app for production to the `build` folder.
60 | It correctly bundles React in production mode and optimizes the build for the best performance. 61 | 62 | The build is minified and the filenames include the hashes.
63 | Your app is ready to be deployed! 64 | 65 | ### `npm run eject` 66 | 67 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 68 | 69 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 70 | 71 | Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 72 | 73 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 74 | 75 | ## How To... 76 | 77 | ### Install a Dependency 78 | 79 | The generated project includes React and ReactDOM as dependencies. It also includes a set of scripts used by Create React App as a development dependency. You may install other dependencies (for example, React Router) with `npm`: 80 | 81 | ``` 82 | npm install --save 83 | ``` 84 | 85 | ### Import a Component 86 | 87 | This project setup supports ES6 modules thanks to Babel. 88 | While you can still use `require()` and `module.exports`, we encourage you to use [`import` and `export`](http://exploringjs.com/es6/ch_modules.html) instead. 89 | 90 | For example: 91 | 92 | ### `Button.js` 93 | 94 | ```js 95 | import React, { Component } from 'react'; 96 | 97 | class Button extends Component { 98 | render() { 99 | // ... 100 | } 101 | } 102 | 103 | export default Button; // Don’t forget to use export default! 104 | ``` 105 | 106 | ### `DangerButton.js` 107 | 108 | ```js 109 | import React, { Component } from 'react'; 110 | import Button from './Button'; // Import a component from another file 111 | 112 | class DangerButton extends Component { 113 | render() { 114 | return 28 | {props.value} 29 | 30 | 31 | ) 32 | 33 | export class StatefulCounter extends Component { 34 | constructor(props) { 35 | super(props) 36 | this.state = {value: props.value} 37 | } 38 | render() { 39 | return ( 40 | this.setState({value: this.state.value + 1})} 42 | dec={() => this.setState({value: this.state.value - 1})} 43 | value={this.state.value}/> 44 | ) 45 | } 46 | } 47 | 48 | class TodoForm extends Component { 49 | constructor(props) { 50 | super(props) 51 | this.state = {text: ''} 52 | } 53 | submit() { 54 | this.props.onSubmit(this.state.text.trim()) 55 | this.setState({text: ''}) 56 | } 57 | render() { 58 | return ( 59 |
60 | this.setState({text: e.target.value})}/> 63 | 65 |
66 | ) 67 | } 68 | } 69 | 70 | export const TodoList = props => ( 71 |
72 | 73 |
    74 | {props.items.map((item, index) => 75 |
  • 76 | {item.text} 77 |
  • 78 | )} 79 |
80 |
81 | ) 82 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import './cards' 2 | import { run } from 'reactcards' 3 | 4 | if (module.hot) { 5 | module.hot.accept() 6 | } 7 | 8 | run() 9 | -------------------------------------------------------------------------------- /test/advanced.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { assert } from 'chai' 3 | import { shallow } from 'enzyme' 4 | import { Foo, Bar } from '../src/components' 5 | 6 | export function testBarAdvancedComponent() { 7 | describe('Test ', () => { 8 | it('should display a bar. drink up!', () => { 9 | const wrapper = shallow() 10 | assert.equal(wrapper.text(), 'a bar. drink up!') 11 | }) 12 | 13 | it('should contain class bar', () => { 14 | const wrapper = shallow() 15 | assert.equal(wrapper.find('.bar').length, 1) 16 | }) 17 | }) 18 | } 19 | 20 | export function testFooAdvancedComponent() { 21 | describe('Test ', () => { 22 | it('should display Foo says \'testing\'', () => { 23 | const wrapper = shallow() 24 | assert.equal(wrapper.text(), "Foo says 'testing.'") 25 | }) 26 | 27 | it('should contain class foo', () => { 28 | const wrapper = shallow() 29 | assert.equal(wrapper.find('.foo').length, 1) 30 | }) 31 | }) 32 | } 33 | -------------------------------------------------------------------------------- /test/components.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import {assert} from 'chai' 3 | import {shallow} from 'enzyme' 4 | import {Foo, Bar} from '../src/components' 5 | 6 | export function testBarComponent() { 7 | const wrapper = shallow() 8 | assert.equal(wrapper.text(), 'a bar. drink up!') 9 | } 10 | 11 | export function testFooComponent() { 12 | const wrapper = shallow() 13 | assert.equal(wrapper.text(), "Foo says 'testing'") 14 | } 15 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * example for running your reactcards component tests as regular cli tests 4 | * 5 | */ 6 | 7 | import resolveTests from '../../src/utils/resolveTests' 8 | import * as advanced from './advanced' 9 | 10 | resolveTests([advanced]) 11 | -------------------------------------------------------------------------------- /test/simple.js: -------------------------------------------------------------------------------- 1 | import {assert} from 'chai' 2 | 3 | export function testAdd() { 4 | assert.equal(1 + 1, 2) 5 | } 6 | 7 | export function testFail() { 8 | assert.isTrue(false) 9 | } 10 | 11 | export function testFoo() { 12 | assert.equal('foo', 'bar') 13 | } 14 | --------------------------------------------------------------------------------