Skip to content

Commit 866aa76

Browse files
committed
Merge pull request #2 from appirio-tech/dev
Updated dev
2 parents d4f958c + c358164 commit 866aa76

19 files changed

+437
-83
lines changed

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["es2015", "react", "stage-2"]
3+
}

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false
14+
15+
[*.jade]
16+
trim_trailing_whitespace = false

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/*

.eslintrc.json

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"rules": {
3+
"indent": [2, 2],
4+
"quotes": [2, "single"],
5+
"linebreak-style": [2, "unix"],
6+
"semi": [2, "never"],
7+
"no-console": 0,
8+
"prefer-const": 2,
9+
"no-const-assign": 2,
10+
"no-var": 2,
11+
"object-shorthand": 2,
12+
"quote-props": [2, "as-needed", { "keywords": true }],
13+
"prefer-arrow-callback": 2,
14+
"arrow-spacing": 2,
15+
"camelcase": 2,
16+
"new-cap": 2,
17+
"one-var": [2, "never"],
18+
"eqeqeq": 2,
19+
"comma-style": 2,
20+
"no-nested-ternary": 2,
21+
"no-unneeded-ternary": 2,
22+
"react/jsx-uses-vars": 2,
23+
"react/jsx-no-bind": 2,
24+
"react/prefer-es6-class": [2, "always"],
25+
"react/jsx-pascal-case": 2,
26+
"react/jsx-closing-bracket-location": 2,
27+
"jsx-quotes": [2, "prefer-double"],
28+
"react/jsx-boolean-value": 2,
29+
"react/wrap-multilines": 2,
30+
"react/self-closing-comp": 2,
31+
"react/no-is-mounted": 2
32+
},
33+
"globals": {
34+
"React": true,
35+
"_": true
36+
},
37+
"env": {
38+
"es6": true,
39+
"browser": true,
40+
"node": true,
41+
"mocha": true,
42+
"jquery": true
43+
},
44+
"parserOptions": {
45+
"ecmaVersion": 6,
46+
"sourceType": "module",
47+
"ecmaFeatures": {
48+
"jsx": true,
49+
"experimentalObjectRestSpread": true,
50+
"blockBindings": true
51+
}
52+
},
53+
"extends": "eslint:recommended",
54+
"plugins": [
55+
"react"
56+
]
57+
}

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
language: node_js
22
node_js:
33
- 5.2.0
4-
before_install:
4+
install:
55
- npm install
6+
script:
7+
- npm run lint
68
sudo: false
79
before_deploy:
810
- npm-prepublish --verbose

README.md

Lines changed: 93 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,100 @@
1-
# Appirio File Uploader
1+
# React Components
22

3-
## Using the repo in your app
3+
This repository is used to distribute reusable React components.
44

5-
## Install
5+
## Installation
66

7-
```shell
8-
npm install appirio-tech-react-components
7+
We use node 5.x and npm 3.x, so you may need to download a new version of node. The easiest way is to download [nvm](https://github.com/creationix/nvm). We have a `.nvmrc` file in the root of the project, so you can just run `nvm use` to switch to the correct version of node.
8+
9+
Install dependencies by running the following in the root of the project:
10+
- `npm i`
11+
- **Note:** You must use npm 3. Type `npm -v` to ensure you have a 3.x version.
12+
13+
## NPM Commands
14+
- To run locally, run `npm run dev` and head to `localhost:8080`
15+
- To create the build: `npm run build`
16+
- To run the test runner: `TODO: need to update`
17+
- To make sure your code passes linting: `npm run lint`
18+
19+
## Recommended Developer Tools
20+
21+
Syntax highlighting for ES6 and React JSX
22+
- Install [babel](https://packagecontrol.io/packages/Babel) via the package manager in Sublime Text
23+
- **Note:** Sublime Text 3 is required for this plugin
24+
- Set the plugin as the default syntax for a particular extension
25+
- Open a file with the `.js` extension
26+
- Select `View` from the menu
27+
- Then `Syntax -> Open all with current extension as...`
28+
- Then `Babel -> JavaScript (Babel)`
29+
- Repeat for any other extensions, e.g. `.jsx`
30+
31+
Recommended Theme
32+
- Install [Oceanic Next Color Theme](https://github.com/voronianski/oceanic-next-color-scheme) via the Sublime Text package manager.
33+
- Add the following to `Sublime Text -> Preferences -> Settings-User` (`⌘ + ,` on Mac)
34+
```
35+
{
36+
"color_scheme": "Packages/Oceanic Next Color Scheme/Oceanic Next.tmTheme",
37+
"theme": "Oceanic Next.sublime-theme"
38+
}
939
```
1040

11-
## Developing
41+
Code expander
42+
- Examples:
43+
- `div.cool-class` becomes `<div className="cool-class"></div>`
44+
- `a` becomes `<a href=""></a>`
45+
- Install [Emmet](https://github.com/sergeche/emmet-sublime) via Sublime Text package manager
46+
- Configure Emmet to work with React, e.g. classes expand to `className` instead of `class`
47+
- Follow the instructions under [Get Emmet working](http://www.nitinh.com/2015/02/setting-sublime-text-react-jsx-development/)
48+
- **Note:** Add the last snippet of code to `reg_replace.sublime-settings` by navigating to `Sublime Text -> Preferences -> Package Settings -> Reg Replace -> Settings-User`
49+
50+
JavaScript linting
51+
- `npm run lint` will lint your files for you. Please make sure all `.jsx` and `.js` code passes linting, otherwise the Travis build will fail.
52+
53+
Automatic JavaScript linting in Sublime Text
54+
- Install [SublimeLinter](http://sublimelinter.readthedocs.org/en/latest/installation.html) following the instructions under "Installing via Package Control"
55+
- Install [SublimeLinter-eslint](https://github.com/roadhump/SublimeLinter-eslint) with the package manager. The package is called `SublimeLinter-contrib-eslint`
56+
57+
## Contributing
1258

13-
```shell
14-
nvm use
15-
npm install
16-
npm run example
59+
### Pull Requests
60+
61+
To contribute to the repository, please create a feature branch off of the dev branch. Once you're finished working on the feature, make a pull request to merge it into dev. Please make sure that every pull request has passed the build checks, which appear just before the "Merge pull request" button in github.
62+
63+
### Code Style
64+
65+
JavaScript
66+
- Please use ES2015 syntax whenever possible
67+
- Specific rules are enforced via `.eslintrc.json`
68+
- Run `npm run lint` to check your code against the linter
69+
70+
SCSS Files
71+
- This repository uses flexbox for arranging content
72+
- The use of any extra CSS libraries should be discussed with the team
73+
- Use SCSS syntax, but do not overly nest
74+
- Use variables, mixins, and classes as much as possible from our [style guide](https://github.com/appirio-tech/styles)
75+
- When adding media queries, nest them inside the element, rather than creating a new section
76+
```
77+
.box {
78+
height: 50px;
79+
width: 50px;
80+
@media screen and (min-width: 768px) {
81+
height: 100px;
82+
width: 100px;
83+
}
84+
85+
.inside-box {
86+
font-size: 14px;
87+
@media screen and (min-width: 768px) {
88+
font-size: 18px;
89+
}
90+
}
91+
}
92+
```
93+
94+
## Using the react-components repository in your app
95+
96+
## Install
97+
98+
```
99+
npm install appirio-tech-react-components
17100
```

components/ExampleNav/ExampleNavContainer.coffee

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ navs =
1515
'ImageViewerHeaderExamples'
1616
'ImageViewerExamples'
1717
'LoaderExamples',
18-
'PanelExamples'
18+
'PanelExamples',
19+
'StandardListItemExamples'
1920
]
2021
ManageSteps: [
2122
'ManageStepsExamples'
@@ -46,4 +47,4 @@ container =
4647
else
4748
createElement ExampleNav, { links, onBack }
4849

49-
module.exports = createClass(container)
50+
module.exports = createClass(container)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export default function ExampleTest(props) {
2+
const row = (value, index) =>
3+
<li key={index}>{value}</li>
4+
5+
return (
6+
<ul>
7+
{ props.values.map(row) }
8+
</ul>
9+
)
10+
}
11+
12+
ExampleTest.propTypes = {
13+
}
14+
15+
module.exports = ExampleTest
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import chai from 'chai'
2+
import cheerio from 'cheerio'
3+
import { createElement } from 'react'
4+
import { renderToStaticMarkup as render } from 'react/lib/ReactDOMServer'
5+
6+
import ExampleTest from './ExampleTest.jsx'
7+
8+
chai.should()
9+
10+
describe('Manage Steps View', () => {
11+
describe('Savings label', () => {
12+
it('displays as savings when savings exist', () => {
13+
const props = {
14+
values: ['hello', 'world']
15+
}
16+
17+
const html = render(createElement(ExampleTest, props))
18+
const $ = cheerio.load(html)
19+
const items = $('li')
20+
21+
items.length.should.equal(2)
22+
items.html().should.equal('hello')
23+
})
24+
})
25+
})

components/Panel/Panel.jsx

Lines changed: 46 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,57 @@
1+
import { PropTypes, Component } from 'react'
2+
13
require('./Panel.scss')
2-
var React = require('react')
34

4-
var Panel = {
5-
getInitialState: function() {
6-
return {expanded: true};
7-
},
8-
handleClick: function(event) {
5+
class Panel extends Component {
6+
constructor(props) {
7+
super(props)
8+
9+
this.state = { expanded: true }
10+
11+
this.handleClick = this.handleClick.bind(this)
12+
}
13+
14+
handleClick(event) {
915
if (this.props.expandTrigger && event.target.className.indexOf(this.props.expandTrigger) !== -1) {
10-
this.setState({expanded: !this.state.expanded});
16+
this.setState({expanded: !this.state.expanded})
1117
}
12-
},
13-
render: function() {
14-
var header = <div className="panel-header" onClick={this.handleClick}>
15-
{
16-
React.Children.map(this.props.children, function(child) {
18+
}
19+
20+
render() {
21+
const header = (
22+
<div className="panel-header" onClick={this.handleClick}>
23+
{this.props.children.map(child => {
1724
if (child.props.className === 'panel-header')
18-
return child.props.children;
19-
20-
})
21-
}
22-
</div>
23-
var body = <div className="panel-body">
24-
{
25-
React.Children.map(this.props.children, function(child) {
25+
return child.props.children
26+
})}
27+
</div>
28+
)
29+
30+
let body = (
31+
<div className="panel-body">
32+
{this.props.children.map((child) => {
2633
if (child.props.className === 'panel-body')
27-
return child.props.children;
34+
return child.props.children
35+
})}
36+
</div>
37+
)
2838

29-
})
30-
}
31-
</div>
32-
if(this.state.expanded === false) {
33-
body = null;
39+
if (!this.state.expanded) {
40+
body = null
3441
}
35-
var dom = <div className="panel">
36-
{header}
37-
{body}
38-
</div>
39-
return dom;
42+
43+
return (
44+
<div className="panel">
45+
{header}
46+
{body}
47+
</div>
48+
)
4049
}
4150
}
4251

43-
module.exports = React.createClass(Panel)
52+
Panel.propTypes = {
53+
children : PropTypes.array.isRequired,
54+
expandTrigger: PropTypes.string
55+
}
56+
57+
export default Panel

0 commit comments

Comments
 (0)