From 9f228334bfaf37b95aa06f7a379905b07cd1b26d Mon Sep 17 00:00:00 2001 From: akameco Date: Tue, 12 Mar 2019 02:53:24 +0900 Subject: [PATCH] refactor(typescript): containers --- app/components/A/tests/index.test.tsx | 1 + app/components/AutoLockScroll/index.tsx | 7 +- app/components/Chip/index.tsx | 11 ++- app/components/ColumnHeaderBookmark/index.tsx | 10 ++- .../{AddColumnModal.js => AddColumnModal.tsx} | 38 ++++----- .../AddColumnModal/{Card.js => Card.tsx} | 7 +- .../{LinkButton.js => LinkButton.tsx} | 7 +- .../AddColumnModal/{index.js => index.tsx} | 19 +++-- .../{Button.js => Button.tsx} | 10 ++- .../{index.js => index.tsx} | 13 ++- app/containers/App/{index.js => index.tsx} | 1 - .../{BookmarkButton.js => BookmarkButton.tsx} | 11 +-- .../BookmarkButton/{index.js => index.tsx} | 14 ++- .../BookmarkButton/{types.js => types.tsx} | 1 - .../BoxContainer/{index.js => index.tsx} | 56 ++++++------ .../ColumnBookmark/{index.js => index.tsx} | 35 ++++---- .../ColumnFollow/{index.js => index.tsx} | 35 ++++---- .../ColumnHistory/{index.js => index.tsx} | 26 +++--- .../ColumnManager/{index.js => index.tsx} | 46 +++++----- .../ColumnRanking/{index.js => index.tsx} | 34 ++++---- .../ColumnRankingR18/{index.js => index.tsx} | 38 ++++----- .../ColumnRecommended/{index.js => index.tsx} | 33 ++++--- .../FilterUsersIn/{index.js => index.tsx} | 10 +-- .../ColumnSearch/{index.js => index.tsx} | 42 ++++----- .../ColumnUserIllust/{index.js => index.tsx} | 33 +++---- .../DrawerManager/{index.js => index.tsx} | 13 ++- .../{FollowButton.js => FollowButton.tsx} | 41 +++++---- .../FollowButton/{index.js => index.tsx} | 14 +-- .../HeaderContainer/{index.js => index.tsx} | 15 ++-- .../{IllustPreview.js => IllustPreview.tsx} | 21 ++--- .../IllustPreview/{LazyImg.js => LazyImg.tsx} | 85 ++++++++++++------- .../IllustPreview/{index.js => index.tsx} | 22 ++--- .../Language/{index.js => index.tsx} | 17 ++-- .../{selectors.test.js => selectors.test.tsx} | 6 +- .../LoginModal/{index.js => index.tsx} | 10 +-- .../{selectors.test.js => selectors.test.tsx} | 20 ++--- .../{MultiPreview.js => MultiPreview.tsx} | 18 ++-- .../MangaPreview/{index.js => index.tsx} | 16 ++-- .../{ModalWrapper.js => ModalWrapper.tsx} | 22 ++--- .../ModalManeger/{index.js => index.tsx} | 18 ++-- .../ModalManeger/{sytles.js => sytles.tsx} | 3 - app/containers/Notify/saga.ts | 2 +- .../{Preview.js => Preview.tsx} | 5 +- .../PreviewFactory/{index.js => index.tsx} | 9 +- app/containers/Root/{index.js => index.tsx} | 9 +- .../SearchField/{Popover.js => Popover.tsx} | 17 ++-- .../{PopoverAuto.js => PopoverAuto.tsx} | 8 +- .../{SearchFiled.js => SearchFiled.tsx} | 50 ++++++----- .../{UsersOver.js => UsersOver.tsx} | 6 +- .../SearchField/{index.js => index.tsx} | 12 +-- .../SettingModal/{Card.js => Card.tsx} | 4 +- .../{LimitSetting.js => LimitSetting.tsx} | 2 - .../{SettingModal.js => SettingModal.tsx} | 48 +++++------ .../SettingModal/{index.js => index.tsx} | 11 ++- app/containers/Table/{Table.js => Table.tsx} | 27 +++--- app/containers/Table/{index.js => index.tsx} | 10 +-- .../{index.js => index.tsx} | 12 +-- .../{index.js => index.tsx} | 23 +++-- package.json | 3 +- tsconfig.json | 10 +-- yarn.lock | 18 +++- 61 files changed, 583 insertions(+), 582 deletions(-) rename app/containers/AddColumnModal/{AddColumnModal.js => AddColumnModal.tsx} (82%) rename app/containers/AddColumnModal/{Card.js => Card.tsx} (92%) rename app/containers/AddColumnModal/{LinkButton.js => LinkButton.tsx} (90%) rename app/containers/AddColumnModal/{index.js => index.tsx} (82%) rename app/containers/AddNewColumnButton/{Button.js => Button.tsx} (77%) rename app/containers/AddNewColumnButton/{index.js => index.tsx} (58%) rename app/containers/App/{index.js => index.tsx} (98%) rename app/containers/BookmarkButton/{BookmarkButton.js => BookmarkButton.tsx} (88%) rename app/containers/BookmarkButton/{index.js => index.tsx} (76%) rename app/containers/BookmarkButton/{types.js => types.tsx} (83%) rename app/containers/BoxContainer/{index.js => index.tsx} (78%) rename app/containers/ColumnBookmark/{index.js => index.tsx} (76%) rename app/containers/ColumnFollow/{index.js => index.tsx} (76%) rename app/containers/ColumnHistory/{index.js => index.tsx} (78%) rename app/containers/ColumnManager/{index.js => index.tsx} (77%) rename app/containers/ColumnRanking/{index.js => index.tsx} (73%) rename app/containers/ColumnRankingR18/{index.js => index.tsx} (71%) rename app/containers/ColumnRecommended/{index.js => index.tsx} (78%) rename app/containers/ColumnSearch/FilterUsersIn/{index.js => index.tsx} (92%) rename app/containers/ColumnSearch/{index.js => index.tsx} (81%) rename app/containers/ColumnUserIllust/{index.js => index.tsx} (79%) rename app/containers/DrawerManager/{index.js => index.tsx} (79%) rename app/containers/FollowButton/{FollowButton.js => FollowButton.tsx} (76%) rename app/containers/FollowButton/{index.js => index.tsx} (59%) rename app/containers/HeaderContainer/{index.js => index.tsx} (83%) rename app/containers/IllustPreview/{IllustPreview.js => IllustPreview.tsx} (87%) rename app/containers/IllustPreview/{LazyImg.js => LazyImg.tsx} (76%) rename app/containers/IllustPreview/{index.js => index.tsx} (81%) rename app/containers/Language/{index.js => index.tsx} (89%) rename app/containers/Language/tests/{selectors.test.js => selectors.test.tsx} (69%) rename app/containers/LoginModal/{index.js => index.tsx} (73%) rename app/containers/LoginModal/tests/{selectors.test.js => selectors.test.tsx} (80%) rename app/containers/MangaPreview/{MultiPreview.js => MultiPreview.tsx} (65%) rename app/containers/MangaPreview/{index.js => index.tsx} (72%) rename app/containers/ModalManeger/{ModalWrapper.js => ModalWrapper.tsx} (82%) rename app/containers/ModalManeger/{index.js => index.tsx} (80%) rename app/containers/ModalManeger/{sytles.js => sytles.tsx} (98%) rename app/containers/PreviewFactory/{Preview.js => Preview.tsx} (86%) rename app/containers/PreviewFactory/{index.js => index.tsx} (65%) rename app/containers/Root/{index.js => index.tsx} (89%) rename app/containers/SearchField/{Popover.js => Popover.tsx} (86%) rename app/containers/SearchField/{PopoverAuto.js => PopoverAuto.tsx} (88%) rename app/containers/SearchField/{SearchFiled.js => SearchFiled.tsx} (80%) rename app/containers/SearchField/{UsersOver.js => UsersOver.tsx} (89%) rename app/containers/SearchField/{index.js => index.tsx} (78%) rename app/containers/SettingModal/{Card.js => Card.tsx} (88%) rename app/containers/SettingModal/{LimitSetting.js => LimitSetting.tsx} (98%) rename app/containers/SettingModal/{SettingModal.js => SettingModal.tsx} (85%) rename app/containers/SettingModal/{index.js => index.tsx} (85%) rename app/containers/Table/{Table.js => Table.tsx} (64%) rename app/containers/Table/{index.js => index.tsx} (68%) rename app/containers/UserDrawerContainer/{index.js => index.tsx} (80%) rename app/containers/UserPopoverContainer/{index.js => index.tsx} (69%) diff --git a/app/components/A/tests/index.test.tsx b/app/components/A/tests/index.test.tsx index a86b93be..ae770513 100644 --- a/app/components/A/tests/index.test.tsx +++ b/app/components/A/tests/index.test.tsx @@ -1,6 +1,7 @@ import * as React from 'react' import { mount } from 'enzyme' // eslint-disable-next-line import/no-unassigned-import +// eslint-disable-next-line import/no-unassigned-import import 'jest-styled-components' import A from '..' diff --git a/app/components/AutoLockScroll/index.tsx b/app/components/AutoLockScroll/index.tsx index 91e89133..8b6219e2 100644 --- a/app/components/AutoLockScroll/index.tsx +++ b/app/components/AutoLockScroll/index.tsx @@ -11,6 +11,8 @@ function getElementBody() { } class AutoLockScroll extends React.Component { + locked: boolean = false + componentDidMount() { if (this.props.lock === true) { this.preventScrolling() @@ -33,8 +35,6 @@ class AutoLockScroll extends React.Component { this.allowScrolling() } - locked: boolean = false - preventScrolling() { if (this.locked) { return @@ -61,8 +61,9 @@ class AutoLockScroll extends React.Component { body.style.overflow = originalBodyOverflow || '' originalBodyOverflow = null } - } // eslint-disable-next-line class-methods-use-this + } + // eslint-disable-next-line class-methods-use-this render() { return null } diff --git a/app/components/Chip/index.tsx b/app/components/Chip/index.tsx index 47fae443..dce81dc4 100644 --- a/app/components/Chip/index.tsx +++ b/app/components/Chip/index.tsx @@ -3,10 +3,11 @@ import styled from 'styled-components' import DeleteIcon from '../Icons/DeleteIcon' export interface Props { - children?: React.Node | null | undefined - onClick?: Function - onRequestDelete?: Function + children?: React.ReactNode + onClick?: any + onRequestDelete?: any } + const StyledChip = styled.div` display: flex; box-sizing: border-box; @@ -22,6 +23,7 @@ const StyledChip = styled.div` vertical-align: baseline; border-radius: 16px; ` + const InnerChip = styled.span` color: rgba(0, 0, 0, 0.87); font-size: 14px; @@ -32,13 +34,14 @@ const InnerChip = styled.span` user-select: none; white-space: nowrap; ` + const icnonStyle = { cursor: 'pointer', margin: '4px 4px 0px -8px', } class Chip extends React.PureComponent { - handleRequestDelete = (e: Event) => { + handleRequestDelete = (e: any) => { e.stopPropagation() if (this.props.onRequestDelete) { diff --git a/app/components/ColumnHeaderBookmark/index.tsx b/app/components/ColumnHeaderBookmark/index.tsx index 5aff385f..18245785 100644 --- a/app/components/ColumnHeaderBookmark/index.tsx +++ b/app/components/ColumnHeaderBookmark/index.tsx @@ -18,22 +18,23 @@ class ColumnHeaderSetting extends React.PureComponent { minBookmarks: 0, } + _sendBookmark = debounce(() => { + this.props.setMinBookmarks(this.state.minBookmarks) + }, 400) + componentWillMount() { this.setState({ minBookmarks: this.props.minBookmarks, }) } - handleSlider = (event: Event, value: number) => { + handleSlider = (event: any, value: number) => { this.setState({ minBookmarks: value, }) this._sendBookmark() } - _sendBookmark = debounce(() => { - this.props.setMinBookmarks(this.state.minBookmarks) - }, 400) render() { const { minBookmarks } = this.state @@ -59,4 +60,5 @@ const Wrap = styled.div` flex-direction: column; color: #eee; ` + export default ColumnHeaderSetting diff --git a/app/containers/AddColumnModal/AddColumnModal.js b/app/containers/AddColumnModal/AddColumnModal.tsx similarity index 82% rename from app/containers/AddColumnModal/AddColumnModal.js rename to app/containers/AddColumnModal/AddColumnModal.tsx index 1479e2ad..78263ed4 100644 --- a/app/containers/AddColumnModal/AddColumnModal.js +++ b/app/containers/AddColumnModal/AddColumnModal.tsx @@ -1,26 +1,24 @@ -// @flow import * as React from 'react' -import { injectIntl, FormattedMessage, type IntlShape } from 'react-intl' -import type { Mode } from 'containers/ColumnRanking/reducer' +import { injectIntl, FormattedMessage, IntlShape } from 'react-intl' +import { Mode } from 'containers/ColumnRanking/reducer' import rankingMessages from 'containers/ColumnRanking/messages' -import type { R18Mode } from 'containers/ColumnRankingR18/reducer' +import { R18Mode } from 'containers/ColumnRankingR18/reducer' import rankingR18Messages from 'containers/ColumnRankingR18/messages' import Card from './Card' import LinkButton from './LinkButton' import messages from './messages' import { Content, Header, Wrap } from './styles' -export type Props = { - addRecommended: () => void, - addBookmark: () => void, - addBookmarkPrivate: () => void, - addFollow: () => void, - addFollowPrivate: () => void, - addHistory: () => void, - addIllustRanking: (mode: Mode) => void, - addIllustR18Ranking: (mode: R18Mode) => void, +export interface Props { + addRecommended: () => undefined + addBookmark: () => undefined + addBookmarkPrivate: () => undefined + addFollow: () => undefined + addFollowPrivate: () => undefined + addHistory: () => undefined + addIllustRanking: (mode: Mode) => undefined + addIllustR18Ranking: (mode: R18Mode) => undefined } - const rankingMode = [ 'day', 'week', @@ -30,7 +28,6 @@ const rankingMode = [ 'week_original', 'week_rookie', ] - const rankingR18Mode = [ 'day_r18', 'week_r18', @@ -39,9 +36,14 @@ const rankingR18Mode = [ 'week_r18g', ] -function SelectColumnModal(props: Props & { intl: IntlShape }) { +function SelectColumnModal( + props: Props & { + intl: IntlShape + } +) { const IllustRankingLinks = rankingMode.map(v => { const handleClick = () => props.addIllustRanking(v) + return ( ) }) - const IllustR18RankingLinks = rankingR18Mode.map(v => { const handleClick = () => props.addIllustR18Ranking(v) + return ( ) }) - const { addBookmark, addBookmarkPrivate, @@ -70,7 +71,6 @@ function SelectColumnModal(props: Props & { intl: IntlShape }) { addHistory, addRecommended, } = props - return (
diff --git a/app/containers/AddColumnModal/Card.js b/app/containers/AddColumnModal/Card.tsx similarity index 92% rename from app/containers/AddColumnModal/Card.js rename to app/containers/AddColumnModal/Card.tsx index 6ac682f1..f59bd0c4 100644 --- a/app/containers/AddColumnModal/Card.js +++ b/app/containers/AddColumnModal/Card.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from 'react' import styled from 'styled-components' @@ -16,7 +15,6 @@ const Wrap = styled.div` background: #fff; overflow-y: auto; ` - const Title = styled.div` font-size: 14px; padding-left: 16px; @@ -26,7 +24,6 @@ const Title = styled.div` box-sizing: border-box; line-height: 40px; ` - const ListWrap = styled.div` padding: 0; margin: 0; @@ -38,8 +35,8 @@ const List = ({ children }: { children?: React.Node }) => ( ) interface Props { - title: string | React.Element; - children?: React.Node; + title: string | React.Element + children?: React.Node } const Card = ({ title, children }: Props) => ( diff --git a/app/containers/AddColumnModal/LinkButton.js b/app/containers/AddColumnModal/LinkButton.tsx similarity index 90% rename from app/containers/AddColumnModal/LinkButton.js rename to app/containers/AddColumnModal/LinkButton.tsx index 107e32b0..4e9077e3 100644 --- a/app/containers/AddColumnModal/LinkButton.js +++ b/app/containers/AddColumnModal/LinkButton.tsx @@ -1,4 +1,3 @@ -// @flow import * as React from 'react' import styled from 'styled-components' @@ -18,14 +17,12 @@ const Wrap = styled.div` background-color: rgba(0, 0, 0, 0.098); } ` - const InnerButton = styled.div` padding: 10px 16px 10px 17px; ` - interface Props { - text: string | React.Element; - onClick: () => void; + text: string | React.Element + onClick: () => undefined } const LinkButton = ({ text, onClick }: Props) => ( diff --git a/app/containers/AddColumnModal/index.js b/app/containers/AddColumnModal/index.tsx similarity index 82% rename from app/containers/AddColumnModal/index.js rename to app/containers/AddColumnModal/index.tsx index 4753f6b5..a1596020 100644 --- a/app/containers/AddColumnModal/index.js +++ b/app/containers/AddColumnModal/index.tsx @@ -1,40 +1,46 @@ -// @flow -import { connect, type Connector } from 'react-redux' -import type { Dispatch } from 'types' +import { connect, Connector } from 'react-redux' +import { Dispatch } from 'types' import { addColumn as addRankingColumn } from 'containers/ColumnRanking/actions' import { addColumn as addRankingR18Column } from 'containers/ColumnRankingR18/actions' import { addColumn as addBookmarkColumn } from 'containers/ColumnBookmark/actions' import { addColumn as addFollowColumn } from 'containers/ColumnFollow/actions' import { addColumn as addRecommendedColumn } from 'containers/ColumnRecommended/actions' import { addColumnHistory } from 'containers/ColumnHistory/actions' -import type { Mode } from 'containers/ColumnRanking/reducer' -import type { R18Mode } from 'containers/ColumnRankingR18/reducer' +import { Mode } from 'containers/ColumnRanking/reducer' +import { R18Mode } from 'containers/ColumnRankingR18/reducer' import Modal from './AddColumnModal' -import type { Props } from './AddColumnModal' +import { Props } from './AddColumnModal' function mapDispatchToProps(dispatch: Dispatch) { return { addRecommended() { dispatch(addRecommendedColumn('recommended')) }, + addHistory() { dispatch(addColumnHistory()) }, + addBookmark() { dispatch(addBookmarkColumn('public')) }, + addBookmarkPrivate() { dispatch(addBookmarkColumn('private')) }, + addFollow() { dispatch(addFollowColumn('public')) }, + addFollowPrivate() { dispatch(addFollowColumn('private')) }, + addIllustRanking(mode: Mode) { dispatch(addRankingColumn(mode)) }, + addIllustR18Ranking(mode: R18Mode) { dispatch(addRankingR18Column(mode)) }, @@ -45,5 +51,4 @@ const connector: Connector<{}, Props> = connect( undefined, mapDispatchToProps ) - export default connector(Modal) diff --git a/app/containers/AddNewColumnButton/Button.js b/app/containers/AddNewColumnButton/Button.tsx similarity index 77% rename from app/containers/AddNewColumnButton/Button.js rename to app/containers/AddNewColumnButton/Button.tsx index b869de10..876d48fb 100644 --- a/app/containers/AddNewColumnButton/Button.js +++ b/app/containers/AddNewColumnButton/Button.tsx @@ -1,15 +1,19 @@ -// @flow import * as React from 'react' import { FormattedMessage } from 'react-intl' import Button from 'components/common/Button' import messages from './messages' export interface Props { - onClick: () => void; + onClick: () => undefined } const AddColumnButton = ({ onClick }: Props) => ( - +