From 42f50049ff29ccdc484c22f8a5a19cda2dd03a5b Mon Sep 17 00:00:00 2001 From: kibigo! Date: Wed, 3 Jan 2018 12:36:21 -0800 Subject: WIP Refactor; 1000 tiny edits --- .../glitch/features/drawer/search/index.js | 34 ++++++++++++---------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'app/javascript/flavours/glitch/features/drawer/search/index.js') diff --git a/app/javascript/flavours/glitch/features/drawer/search/index.js b/app/javascript/flavours/glitch/features/drawer/search/index.js index ed69f71ed..2d739349c 100644 --- a/app/javascript/flavours/glitch/features/drawer/search/index.js +++ b/app/javascript/flavours/glitch/features/drawer/search/index.js @@ -30,18 +30,18 @@ const messages = defineMessages({ // Handlers. const handlers = { - blur () { + handleBlur () { this.setState({ expanded: false }); }, - change ({ target: { value } }) { + handleChange ({ target: { value } }) { const { onChange } = this.props; if (onChange) { onChange(value); } }, - clear (e) { + handleClear (e) { const { onClear, submitted, @@ -53,7 +53,7 @@ const handlers = { } }, - focus () { + handleFocus () { const { onShow } = this.props; this.setState({ expanded: true }); if (onShow) { @@ -61,7 +61,7 @@ const handlers = { } }, - keyUp (e) { + handleKeyUp (e) { const { onSubmit } = this.props; switch (e.key) { case 'Enter': @@ -78,19 +78,21 @@ const handlers = { // The component. export default class DrawerSearch extends React.PureComponent { + // Constructor. constructor (props) { super(props); assignHandlers(this, handlers); this.state = { expanded: false }; } + // Rendering. render () { const { - blur, - change, - clear, - focus, - keyUp, + handleBlur, + handleChange, + handleClear, + handleFocus, + handleKeyUp, } = this.handlers; const { intl, @@ -110,23 +112,22 @@ export default class DrawerSearch extends React.PureComponent { type='text' placeholder={intl.formatMessage(messages.placeholder)} value={value || ''} - onChange={change} - onKeyUp={keyUp} - onFocus={focus} - onBlur={blur} + onChange={handleChange} + onKeyUp={handleKeyUp} + onFocus={handleFocus} + onBlur={handleBlur} />
-