UNPKG

5.59 kBMarkdownView Raw
1# Topcoder-App-R
2
3This repository houses new Topcoder pages, using React, Redux, and Webpack.
4
5## Installation
6
7We 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
9Install 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 start` and head to `http://localhost:3000/search/challenges`
15- Run tests with `npm test` or use `npm run test:watch` to rerun tests after files change
16- To make sure your code passes linting: `npm run lint`
17- To create the build: `npm run build`
18
19## Contributing
20
21### Pull Requests
22
23To 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.
24
25### Code Style
26
27***Checkout the code and comments in `src/components/ExampleComponent` for an example React component, `.scss` file, and tests.***
28
29React
30 - Most components should be stateless and use the [functional component](https://facebook.github.io/react/blog/2015/10/07/react-v0.14.html#stateless-functional-components) pattern
31 - If you need a stateful component, use [ES6 classes](http://facebook.github.io/react/docs/reusable-components.html#es6-classes)
32 - Always use [PropTypes](http://facebook.github.io/react/docs/reusable-components.html#prop-validation) for all props
33 - Use `classnames` for dynamic classes. See `ExampleComponent` for an example.
34
35JavaScript
36 - Make sure your variable names are easy to understand and descriptive. No acronyms, except for common ones like `i` or `err`.
37 - Use `lodash` and functional JavaScript if it makes the code clearer.
38 - Please use ES2015 syntax whenever possible
39 - Specific rules are enforced via `.eslintrc.json`
40 - Run `npm run lint` to check your code against the linter
41
42SCSS Files
43 - This repository uses flexbox for arranging content
44 - The use of any extra CSS libraries should be discussed with the team
45 - Use SCSS syntax, but do not overly nest
46 - Use 2 spaces for indentation
47 - Use variables, mixins, and classes as much as possible from our [style guide](https://github.com/appirio-tech/styles/tree/master/styles/topcoder)
48 - To include variables from the style guide mentioned above, place `@import 'topcoder/tc-includes;'` at the top of your `.scss` file. Locally, you can look in `./node_modules/appirio-styles/styles/topcoder/_tc-colors.scss` to find many colors already defined (e.g. `#A3A3AE` => `$accent-gray`)
49 - When adding media queries, nest them inside the element, rather than creating a new section
50 ```
51 @import 'topcoder/tc-includes;'
52
53 $my-local-var: 50px;
54
55 .box {
56 height: $my-local-var;
57 width: 50px;
58 color: $medium-gray;
59 @media screen and (min-width: 768px) {
60 height: 100px;
61 width: 100px;
62 color: $dark-gray;
63 }
64
65 .inside-box {
66 font-size: 14px;
67 @media screen and (min-width: 768px) {
68 font-size: 18px;
69 }
70 }
71 }
72 ```
73
74### Writing Tests
75- `npm test` will run the current tests
76- `npm run test:watch` will rerun tests when files change
77- Place your test files in the same directory as the component it's testing
78- Test files should be named `ComponentName.spec.js`
79- Checkout the ExampleComponent directory in `/src/components`
80
81## Recommended Developer Tools
82
83### Syntax highlighting for ES6 and React JSX
84- Install [babel](https://packagecontrol.io/packages/Babel) via the package manager in Sublime Text
85 - **Note:** Sublime Text 3 is required for this plugin
86- Set the plugin as the default syntax for a particular extension
87 - Open a file with the `.js` extension
88 - Select `View` from the menu
89 - Then `Syntax -> Open all with current extension as...`
90 - Then `Babel -> JavaScript (Babel)`
91 - Repeat for any other extensions, e.g. `.jsx`
92
93### Recommended Theme
94- Install [Oceanic Next Color Theme](https://github.com/voronianski/oceanic-next-color-scheme) via the Sublime Text package manager.
95- Add the following to `Sublime Text -> Preferences -> Settings-User` (`⌘ + ,` on Mac)
96```
97{
98 "color_scheme": "Packages/Oceanic Next Color Scheme/Oceanic Next.tmTheme",
99 "theme": "Oceanic Next.sublime-theme"
100}
101```
102
103### Automatic JavaScript linting in Sublime Text
104- Install [SublimeLinter](http://sublimelinter.readthedocs.org/en/latest/installation.html) following the instructions under "Installing via Package Control"
105- Install [SublimeLinter-eslint](https://github.com/roadhump/SublimeLinter-eslint) with the package manager. The package is called `SublimeLinter-contrib-eslint`
106
107### Code expander
108- Examples:
109 - `div.cool-class` becomes `<div className="cool-class"></div>`
110 - `a` becomes `<a href=""></a>`
111- Install [Emmet](https://github.com/sergeche/emmet-sublime) via Sublime Text package manager
112- Configure Emmet to work with React, e.g. classes expand to `className` instead of `class`
113- Follow the instructions under [Get Emmet working](http://www.nitinh.com/2015/02/setting-sublime-text-react-jsx-development/)
114 - **Note:** Add the last snippet of code to `reg_replace.sublime-settings` by navigating to `Sublime Text -> Preferences -> Package Settings -> Reg Replace -> Settings-User`
115
\No newline at end of file