Skip to content

Commit cce9ef7

Browse files
committed
Add flow types to components; realted to reactjs#24
1 parent bea8fa0 commit cce9ef7

File tree

10 files changed

+95
-12
lines changed

10 files changed

+95
-12
lines changed

flow-typed/glamor.js

+10
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,13 @@ declare module 'glamor' {
55
},
66
};
77
}
8+
9+
declare module 'glamor/react' {
10+
declare module.exports: {
11+
createElement: any,
12+
dom: any,
13+
vars: any,
14+
makeTheme: any,
15+
propMerge: Function,
16+
};
17+
}

src/components/Flex/Flex.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,27 @@
22
* Copyright (c) 2013-present, Facebook, Inc.
33
*
44
* @emails react-core
5+
* @flow
56
*/
67

78
'use strict';
89

910
import {createElement} from 'glamor/react';
1011

12+
import type {Node} from 'react';
13+
14+
type Props = {
15+
basis: string,
16+
children: Node,
17+
direction: string,
18+
grow: number,
19+
halign: string,
20+
shrink: number,
21+
type: string,
22+
valign: string,
23+
rest: Array<any>,
24+
};
25+
1126
/**
1227
* Convenience component for declaring a flexbox layout.
1328
*/
@@ -21,7 +36,7 @@ const Flex = ({
2136
type = 'div',
2237
valign = 'flex-start',
2338
...rest
24-
}) =>
39+
}: Props) =>
2540
createElement(
2641
type,
2742
{

src/components/LayoutFooter/ExternalFooterLink.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (c) 2013-present, Facebook, Inc.
33
*
44
* @emails react-core
5+
* @flow
56
*/
67

78
'use strict';
@@ -10,7 +11,16 @@ import React from 'react';
1011
import {colors} from 'theme';
1112
import ExternalLinkSvg from 'templates/components/ExternalLinkSvg';
1213

13-
const ExternalFooterLink = ({children, href, target, rel}) => (
14+
import type {Node} from 'react';
15+
16+
type Props = {
17+
children: Node,
18+
href: string,
19+
target?: string,
20+
rel?: string,
21+
};
22+
23+
const ExternalFooterLink = ({children, href, target, rel}: Props) => (
1424
<a
1525
css={{
1626
lineHeight: 2,

src/components/LayoutFooter/Footer.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (c) 2013-present, Facebook, Inc.
33
*
44
* @emails react-core
5+
* @flow
56
*/
67

78
'use strict';
@@ -16,7 +17,7 @@ import {colors, media} from 'theme';
1617

1718
import ossLogoPng from 'images/oss_logo.png';
1819

19-
const Footer = ({layoutHasSidebar = false}) => (
20+
const Footer = ({layoutHasSidebar = false}: {layoutHasSidebar: boolean}) => (
2021
<footer
2122
css={{
2223
backgroundColor: colors.darker,

src/components/LayoutFooter/FooterLink.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (c) 2013-present, Facebook, Inc.
33
*
44
* @emails react-core
5+
* @flow
56
*/
67

78
'use strict';
@@ -10,7 +11,15 @@ import Link from 'gatsby-link';
1011
import React from 'react';
1112
import {colors} from 'theme';
1213

13-
const FooterLink = ({children, target, to}) => (
14+
import type {Node} from 'react';
15+
16+
type Props = {
17+
children: Node,
18+
target?: string,
19+
to: string,
20+
};
21+
22+
const FooterLink = ({children, target, to}: Props) => (
1423
<Link
1524
css={{
1625
lineHeight: 2,

src/components/LayoutFooter/FooterNav.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,23 @@
22
* Copyright (c) 2013-present, Facebook, Inc.
33
*
44
* @emails react-core
5+
* @flow
56
*/
67

78
'use strict';
89

910
import React from 'react';
1011
import {media} from 'theme';
1112

12-
const FooterNav = ({children, title, layoutHasSidebar = false}) => (
13+
import type {Node} from 'react';
14+
15+
type Props = {
16+
children: Node,
17+
title?: string,
18+
layoutHasSidebar: boolean,
19+
};
20+
21+
const FooterNav = ({children, title, layoutHasSidebar = false}: Props) => (
1322
<div
1423
css={{
1524
display: 'flex',

src/components/LayoutHeader/DocSearch.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22
* Copyright (c) 2013-present, Facebook, Inc.
33
*
44
* @emails react-core
5+
* @flow
56
*/
67

78
import React, {Component} from 'react';
89
import {colors, media} from 'theme';
910

10-
class DocSearch extends Component {
11+
type State = {
12+
enabled: boolean,
13+
};
14+
15+
class DocSearch extends Component<{}, State> {
1116
state = {
1217
enabled: true,
1318
};

src/components/LayoutHeader/Header.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (c) 2013-present, Facebook, Inc.
33
*
44
* @emails react-core
5+
* @flow
56
*/
67

78
'use strict';
@@ -17,7 +18,7 @@ import DocSearch from './DocSearch';
1718

1819
import logoSvg from 'icons/logo.svg';
1920

20-
const Header = ({location}) => (
21+
const Header = ({location}: {location: Location}) => (
2122
<header
2223
css={{
2324
backgroundColor: colors.darker,

src/components/LayoutHeader/HeaderLink.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (c) 2013-present, Facebook, Inc.
33
*
44
* @emails react-core
5+
* @flow
56
*/
67

78
'use strict';
@@ -10,7 +11,13 @@ import Link from 'gatsby-link';
1011
import React from 'react';
1112
import {colors, media} from 'theme';
1213

13-
const HeaderLink = ({isActive, title, to}) => (
14+
type Props = {
15+
isActive: boolean,
16+
title: string,
17+
to: string,
18+
};
19+
20+
const HeaderLink = ({isActive, title, to}: Props) => (
1421
<Link css={[style, isActive && activeStyle]} to={to}>
1522
{title}
1623
{isActive && <span css={activeAfterStyle} />}

src/components/StickyResponsiveSidebar/StickyResponsiveSidebar.js

+20-4
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,32 @@
22
* Copyright (c) 2013-present, Facebook, Inc.
33
*
44
* @emails react-core
5+
* @flow
56
*/
67

78
'use strict';
89

910
import Container from 'components/Container';
10-
import {Component, React} from 'react';
11+
import React, {Component} from 'react';
1112
import Sidebar from 'templates/components/Sidebar';
1213
import {colors, media} from 'theme';
1314
import ChevronSvg from 'templates/components/ChevronSvg';
1415

15-
class StickyResponsiveSidebar extends Component {
16-
constructor(props, context) {
17-
super(props, context);
16+
type State = {
17+
open: boolean,
18+
};
19+
20+
type Props = {
21+
enableScrollSync?: boolean,
22+
createLink: Function, // TODO: Add better flow type once we Flow-type createLink
23+
defaultActiveSection: string,
24+
location: Location,
25+
sectionList: Array<Object>, // TODO: Add better flow type once we have the Section component
26+
};
27+
28+
class StickyResponsiveSidebar extends Component<Props, State> {
29+
constructor(props: Props) {
30+
super(props);
1831

1932
this.state = {
2033
open: false,
@@ -23,6 +36,9 @@ class StickyResponsiveSidebar extends Component {
2336
this._closeNavMenu = this._closeNavMenu.bind(this);
2437
}
2538

39+
_openNavMenu: Function;
40+
_closeNavMenu: Function;
41+
2642
_openNavMenu() {
2743
this.setState({open: !this.state.open});
2844
}

0 commit comments

Comments
 (0)