Skip to content
This repository was archived by the owner on Apr 11, 2019. It is now read-only.

Commit aa53612

Browse files
authored
Merge pull request #66 from RyanCCollins/feat_rc_flow_configuration
Feat rc flow configuration
2 parents 9f07dc5 + ac81ecf commit aa53612

File tree

112 files changed

+26758
-9683
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+26758
-9683
lines changed

.eslintrc.js

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ module.exports = {
88
"node": true,
99
"jest": true
1010
},
11+
"settings": {
12+
"import/resolver": {
13+
"webpack": {
14+
"config": "webpack.config.babel.js"
15+
}
16+
}
17+
},
1118
"rules": {
1219
"func-names": 0,
1320
"eol-last": 0,

.flowconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[ignore]
2+
.*/node_modules/.*
3+
4+
[include]
5+
6+
[libs]
7+
config/flow-typed/npm
8+
9+
[options]
10+
suppress_comment=.*\\$FlowFixMe
11+
suppress_comment=.*\\$FlowInvalidInputTest
12+
module.name_mapper='\(react-redux\)' -> '<PROJECT_ROOT>/config/flow-typed/GeneralStub.js'
13+
module.name_mapper='\(react\)' -> '<PROJECT_ROOT>/config/flow-typed/GeneralStub.js'
14+
module.name_mapper='\(redux\)' -> '<PROJECT_ROOT>/config/flow-typed/GeneralStub.js'
15+
module.name_mapper='.*\(.scss\|.png\)' -> '<PROJECT_ROOT>/config/flow-typed/GeneralStub.js'

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ The setup includes the ability to generate the boilerplate to create GraphQL / A
5252

5353
Take a look at the [Example Apps](https://github.com/RyanCCollins/scalable-react-boilerplate#example-apps) section to see examples of GraphQL configuration in practice.
5454

55+
### Flow
56+
Static types are all the rage in Front End JavaScript land right now.
57+
58+
We feel that the use of Static types is paramount in the evolution of JavaScript and as such have integrated the Flow static type-checking library.
59+
60+
The nice thing about Flow is that you can gradually introduce it into your app, much like we have done with the example code of this boilerplate. You can see a couple of examples of Flow in use in the project in the components directory. If this is not a feature you desire, then do not add the `// @flow` comment in any files.
61+
62+
We have provided library definitions within the [`config/flow-typed`](https://github.com/RyanCCollins/scalable-react-boilerplate/tree/master/config/flow-typed) folder and have also provided some useful configuration within the `.flowconfig` file.
63+
5564
# Documentation
5665

5766
## Getting Started
+26-31
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,34 @@
1-
import React, { PropTypes } from 'react';
1+
// @flow
2+
import React from 'react';
23
import cssModules from 'react-css-modules';
34
import Spinning from 'grommet-udacity/components/icons/Spinning';
45
import Box from 'grommet-udacity/components/Box';
56
import Heading from 'grommet-udacity/components/Heading';
67
import styles from './index.module.scss';
78

8-
const LoadingIndicator = ({
9-
isLoading,
10-
message,
11-
}) => (
12-
<Box
13-
align="center"
14-
justify="center"
15-
className={styles.loadingIndicator}
16-
>
17-
{isLoading &&
18-
<Box
19-
align="center"
20-
justify="center"
21-
>
22-
<Spinning />
23-
<Heading tag="h3" align="center">{message}</Heading>
24-
</Box>
25-
}
26-
</Box>
27-
);
28-
29-
LoadingIndicator.propTypes = {
30-
isLoading: PropTypes.bool.isRequired,
31-
message: PropTypes.string.isRequired,
32-
};
33-
34-
LoadingIndicator.defaultProps = {
35-
isLoading: true,
36-
message: 'Loading',
37-
};
9+
function LoadingIndicator(props: {
10+
isLoading: boolean,
11+
message: string
12+
}) {
13+
const { message, isLoading } = props;
14+
const title = message || 'Loading';
15+
return (
16+
<Box
17+
align="center"
18+
justify="center"
19+
className={styles.loadingIndicator}
20+
>
21+
{isLoading &&
22+
<Box
23+
align="center"
24+
justify="center"
25+
>
26+
<Spinning />
27+
<Heading tag="h3" align="center">{title}</Heading>
28+
</Box>
29+
}
30+
</Box>
31+
);
32+
}
3833

3934
export default cssModules(LoadingIndicator, styles);

app/src/components/Navbar/index.js

+29-31
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
1-
import React, { PropTypes } from 'react';
1+
// @flow
2+
import React from 'react';
23
import Header from 'grommet-udacity/components/Header';
34
import Title from 'grommet-udacity/components/Title';
45
import Anchor from 'grommet-udacity/components/Anchor';
56
import Search from 'grommet-udacity/components/Search';
67
import LogoImage from './logo.png';
78
import { StyledMenu, StyledLogo, LogoPlaceholder } from './styles';
89

9-
const Navbar = ({
10-
pathname,
11-
}) => (
12-
<div>
13-
<Header justify="between">
14-
<Title>
15-
{typeof window !== 'undefined' ?
16-
<StyledLogo src={LogoImage} alt="logo" />
17-
:
18-
<LogoPlaceholder />
19-
}
20-
</Title>
21-
<StyledMenu inline direction="row" align="center" responsive={false}>
22-
<Anchor href="/" className={pathname === '/' ? 'active' : ''}>
23-
Home
24-
</Anchor>
25-
<Anchor href="/about" className={pathname === '/about' ? 'active' : ''}>
26-
About
27-
</Anchor>
28-
<Search dropAlign={{ right: 'right' }} />
29-
</StyledMenu>
30-
</Header>
31-
</div>
32-
);
33-
34-
Navbar.propTypes = {
35-
pathname: PropTypes.string.isRequired,
36-
};
37-
38-
export default Navbar;
10+
export default function Navbar(props: {
11+
pathname: string
12+
}) {
13+
const { pathname } = props;
14+
return (
15+
<div>
16+
<Header justify="between">
17+
<Title>
18+
{typeof window !== 'undefined' ?
19+
<StyledLogo src={LogoImage} alt="logo" />
20+
:
21+
<LogoPlaceholder />
22+
}
23+
</Title>
24+
<StyledMenu inline direction="row" align="center" responsive={false}>
25+
<Anchor href="/" className={pathname === '/' ? 'active' : ''}>
26+
Home
27+
</Anchor>
28+
<Anchor href="/about" className={pathname === '/about' ? 'active' : ''}>
29+
About
30+
</Anchor>
31+
<Search dropAlign={{ right: 'right' }} />
32+
</StyledMenu>
33+
</Header>
34+
</div>
35+
);
36+
}

app/src/containers/AboutContainer/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
22
import Box from 'grommet-udacity/components/Box';
33
import Section from 'grommet-udacity/components/Section';
44
import Headline from 'grommet-udacity/components/Headline';
5-
import { Divider, About } from 'components';
5+
import { Divider, About } from 'components'; // eslint-disable-line
66
import links from './data';
77

88
class AboutContainer extends Component { // eslint-disable-line react/prefer-stateless-function

app/src/containers/AppContainer/actions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as types from './constants';
1+
import types from './constants';
22

33
// appContainerdefaultAction :: None -> {Action}
44
export const appContainerDefaultAction = () => ({ // eslint-disable-line
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
export const APPCONTAINER_DEFAULT_ACTION = 'APPCONTAINER_DEFAULT_ACTION';
1+
const APPCONTAINER_DEFAULT_ACTION = 'APPCONTAINER_DEFAULT_ACTION';
2+
export default APPCONTAINER_DEFAULT_ACTION;

app/src/containers/AppContainer/reducer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as types from './constants';
1+
import types from './constants';
22

33
export const initialState = {
44
isMobile: false,

app/src/utils/functors.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// @flow
2+
export default class Functors {
3+
static Identity = x => ({
4+
map: f => Functors.Identity(f(x)),
5+
fold: f => f(x),
6+
inspect: () => `Functors.Identity(${x})`,
7+
});
8+
static Right = x => ({
9+
map: f => Functors.Right(f(x)),
10+
fold: (_, g) => g(x),
11+
inspect: () => `Functors.Right(${x})`,
12+
});
13+
static Left = x => ({
14+
map: () => Functors.Left(x),
15+
fold: f => f(x),
16+
inspect: () => `Functors.Left(${x})`,
17+
});
18+
static Sum = x => ({
19+
x,
20+
concat: ({ x: y }) =>
21+
Functors.Sum(x + y),
22+
inspect: () => `Functors.Sum(${x})`,
23+
});
24+
static All = x => ({
25+
x,
26+
concat: ({ x: y }) =>
27+
Functors.All(x && y),
28+
inspect: () => `Functors.All(${x})`,
29+
});
30+
static First = x => ({
31+
x,
32+
concat: () =>
33+
Functors.First(x),
34+
inspect: () => `Functors.First(${x})`,
35+
});
36+
}

app/src/utils/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export Functors from './functors';

config/flow-typed/GeneralStub.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default {};

0 commit comments

Comments
 (0)