From 52956c3587b1982601c6877c514ee41fbd6be2e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Sat, 24 Oct 2020 10:35:12 +0200 Subject: [PATCH] Moving the title from board/table into an independent component --- webapp/src/components/boardComponent.tsx | 49 +--------- webapp/src/components/tableComponent.tsx | 78 +--------------- webapp/src/components/viewTitle.tsx | 114 +++++++++++++++++++++++ 3 files changed, 119 insertions(+), 122 deletions(-) create mode 100644 webapp/src/components/viewTitle.tsx diff --git a/webapp/src/components/boardComponent.tsx b/webapp/src/components/boardComponent.tsx index d30143ec4..fcc448223 100644 --- a/webapp/src/components/boardComponent.tsx +++ b/webapp/src/components/boardComponent.tsx @@ -21,6 +21,7 @@ import {CardDialog} from './cardDialog' import {Editable} from './editable' import RootPortal from './rootPortal' import ViewHeader from './viewHeader' +import ViewTitle from './viewTitle' type Props = { boardTree?: BoardTree @@ -32,7 +33,6 @@ type State = { isSearching: boolean shownCard?: Card viewMenu: boolean - isHoverOnCover: boolean selectedCards: Card[] showFilter: boolean } @@ -67,7 +67,6 @@ class BoardComponent extends React.Component { constructor(props: Props) { super(props) this.state = { - isHoverOnCover: false, isSearching: Boolean(this.props.boardTree?.getSearchText()), viewMenu: false, selectedCards: [], @@ -120,51 +119,7 @@ class BoardComponent extends React.Component { }
-
{ - this.setState({...this.state, isHoverOnCover: true}) - }} - onMouseLeave={() => { - this.setState({...this.state, isHoverOnCover: false}) - }} - > - -
- -
- {board.icon ? - -
{board.icon}
- - mutator.changeIcon(board, BlockIcons.shared.randomIcon())} - /> - mutator.changeIcon(board, undefined, 'remove icon')} - /> - -
: - undefined} - { - mutator.changeTitle(board, text) - }} - /> -
+
{ constructor(props: Props) { super(props) - this.state = {isHoverOnCover: false, isSearching: Boolean(this.props.boardTree?.getSearchText()), viewMenu: false, showFilter: false} + this.state = {isSearching: Boolean(this.props.boardTree?.getSearchText()), viewMenu: false, showFilter: false} } shouldComponentUpdate(): boolean { @@ -84,76 +81,7 @@ class TableComponent extends React.Component { /> }
-
{ - this.setState({...this.state, isHoverOnCover: true}) - }} - onMouseLeave={() => { - this.setState({...this.state, isHoverOnCover: false}) - }} - > - -
- -
- {board.icon && - -
{board.icon}
- - - {(text: string) => ( - mutator.changeIcon(board, BlockIcons.shared.randomIcon())} - /> - )} - - - {(text: string) => ( - mutator.changeIcon(board, undefined, 'remove icon')} - /> - )} - - -
} - - {(placeholder: string) => ( - { - mutator.changeTitle(board, text) - }} - /> - )} - -
+
{ + shouldComponentUpdate(): boolean { + return true + } + + constructor(props: Props) { + super(props) + this.state = {isHoverOnCover: false} + } + + render(): JSX.Element { + const {board} = this.props + + return ( + <> +
{ + this.setState({isHoverOnCover: true}) + }} + onMouseLeave={() => { + this.setState({isHoverOnCover: false}) + }} + > + +
+ +
+ {board.icon && + +
{board.icon}
+ + + {(text: string) => ( + mutator.changeIcon(board, BlockIcons.shared.randomIcon())} + /> + )} + + + {(text: string) => ( + mutator.changeIcon(board, undefined, 'remove icon')} + /> + )} + + +
} + + {(placeholder: string) => ( + { + mutator.changeTitle(board, text) + }} + /> + )} + +
+ + ) + } +} + +export default injectIntl(ViewTitle)