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

Commit cb33cad

Browse files
committed
Feat: update flow configuration and add a few flow components
1 parent 86406d8 commit cb33cad

File tree

11 files changed

+147
-839
lines changed

11 files changed

+147
-839
lines changed

.flowconfig

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
[include]
55

66
[libs]
7-
config/flow-typed
7+
config/flow-typed/npm
88

99
[options]
1010
suppress_comment=.*\\$FlowFixMe
1111
suppress_comment=.*\\$FlowInvalidInputTest
12-
module.name_mapper='\(react-redux\)' -> '<PROJECT_ROOT>/config/flow/GeneralStub.js'
13-
module.name_mapper='\(react\)' -> '<PROJECT_ROOT>/config/flow/GeneralStub.js'
14-
module.name_mapper='\(redux\)' -> '<PROJECT_ROOT>/config/flow/GeneralStub.js'
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'
Lines changed: 26 additions & 31 deletions
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

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @flow
12
import React, { PropTypes } from 'react';
23
import Header from 'grommet-udacity/components/Header';
34
import Title from 'grommet-udacity/components/Title';
@@ -6,33 +7,30 @@ 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

Lines changed: 1 addition & 1 deletion
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/utils/functors.js

Lines changed: 36 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export Functors from './functors';

config/flow-typed/npm/actions_vx.x.x.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

config/flow-typed/npm/components_vx.x.x.js

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)