Browse Source

Switch to flow types; wip

main
tricinel 8 years ago
parent
commit
36beba7a9b
  1. 5
      src/components/Header/Header.js
  2. 8
      src/components/MarkdownHeader/MarkdownHeader.js
  3. 29
      src/components/MarkdownPage/MarkdownPage.js
  4. 10
      src/components/TitleAndMetaTags/TitleAndMetaTags.js
  5. 9
      src/templates/components/ChevronSvg/index.js
  6. 2
      src/templates/components/ExternalLinkSvg/index.js

5
src/components/Header/Header.js

@ -2,6 +2,7 @@
* Copyright (c) 2013-present, Facebook, Inc.
*
* @emails react-core
* @flow
*/
'use strict';
@ -9,7 +10,9 @@
import React from 'react';
import {colors, fonts} from 'theme';
const Header = ({children}) => (
import type {Node} from 'react';
const Header = ({children}: {children: Node}) => (
<h1
css={{
color: colors.dark,

8
src/components/MarkdownHeader/MarkdownHeader.js

@ -2,16 +2,16 @@
* Copyright (c) 2013-present, Facebook, Inc.
*
* @emails react-core
* @flow
*/
'use strict';
import Flex from 'components/Flex';
import PropTypes from 'prop-types';
import React from 'react';
import {colors, fonts, media} from 'theme';
const MarkdownHeader = ({title}) => (
const MarkdownHeader = ({title}: {title: string}) => (
<Flex type="header" halign="space-between" valign="baseline">
<h1
css={{
@ -33,8 +33,4 @@ const MarkdownHeader = ({title}) => (
</Flex>
);
MarkdownHeader.propTypes = {
title: PropTypes.string.isRequired,
};
export default MarkdownHeader;

29
src/components/MarkdownPage/MarkdownPage.js

@ -2,6 +2,7 @@
* Copyright (c) 2013-present, Facebook, Inc.
*
* @emails react-core
* @flow
*/
'use strict';
@ -10,7 +11,6 @@ import Container from 'components/Container';
import Flex from 'components/Flex';
import MarkdownHeader from 'components/MarkdownHeader';
import NavigationFooter from 'templates/components/NavigationFooter';
import PropTypes from 'prop-types';
import React from 'react';
import StickyResponsiveSidebar from 'components/StickyResponsiveSidebar';
import TitleAndMetaTags from 'components/TitleAndMetaTags';
@ -20,7 +20,7 @@ import {sharedStyles} from 'theme';
import createOgUrl from 'utils/createOgUrl';
const MarkdownPage = ({
authors,
authors = [],
createLink,
date,
enableScrollSync,
@ -29,6 +29,16 @@ const MarkdownPage = ({
markdownRemark,
sectionList,
titlePostfix = '',
}: {
authors: Array<string>,
createLink: Function,
date: string,
enableScrollSync: boolean,
ogDescription: string,
location: Object,
markdownRemark: Object,
sectionList: Array<Object>,
titlePostfix: string,
}) => {
const hasAuthors = authors.length > 0;
const titlePrefix = markdownRemark.frontmatter.title || '';
@ -122,19 +132,4 @@ const MarkdownPage = ({
);
};
MarkdownPage.defaultProps = {
authors: [],
};
// TODO Better types
MarkdownPage.propTypes = {
authors: PropTypes.array.isRequired,
createLink: PropTypes.func.isRequired,
date: PropTypes.string,
enableScrollSync: PropTypes.bool,
location: PropTypes.object.isRequired,
markdownRemark: PropTypes.object.isRequired,
sectionList: PropTypes.array.isRequired,
};
export default MarkdownPage;

10
src/components/TitleAndMetaTags/TitleAndMetaTags.js

@ -11,7 +11,15 @@ import React from 'react';
const defaultDescription = 'A JavaScript library for building user interfaces';
const TitleAndMetaTags = ({title, ogDescription, ogUrl}) => {
const TitleAndMetaTags = ({
title,
ogDescription,
ogUrl,
}: {
title: string,
ogDescription: string,
ogUrl: string,
}) => {
return (
<Helmet title={title}>
<meta property="og:title" content={title} />

9
src/templates/components/ChevronSvg/index.js

@ -2,13 +2,20 @@
* Copyright (c) 2013-present, Facebook, Inc.
*
* @emails react-core
* @flow
*/
'use strict';
import React from 'react';
const ChevronSvg = ({size = 10, cssProps = {}}) => (
const ChevronSvg = ({
size = 10,
cssProps = {},
}: {
size: number,
cssProps: Object,
}) => (
<svg
css={cssProps}
viewBox="0 0 926.23699 573.74994"

2
src/templates/components/ExternalLinkSvg/index.js

@ -8,7 +8,7 @@
import React from 'react';
const ExternalLinkSvg = ({cssProps = {}}) => (
const ExternalLinkSvg = ({cssProps = {}}: {cssProps: Object}) => (
<svg
x="0px"
y="0px"

Loading…
Cancel
Save