Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change search ux #600

Merged
merged 8 commits into from
Jun 3, 2017
Merged

change search ux #600

merged 8 commits into from
Jun 3, 2017

Conversation

sosukesuzuki
Copy link
Member

Before

2017-05-26 18 06 15
Display the searched note in a popup window.

After

2017-05-26 18 06 38
Display the searched notes in the normal note list.

@huettenhain
Copy link

@sosukesuzuki this looks awesome.

@kazup01
Copy link
Member

kazup01 commented May 26, 2017

Awesome!

@kazup01 kazup01 requested a review from asmsuechan May 26, 2017 09:43
@@ -349,6 +353,71 @@ class NoteList extends React.Component {
})
}

getSearchNotes () {
Copy link
Contributor

@asmsuechan asmsuechan May 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To begin with my review, I'd like you to move this method to a module such as lib/search or something. But it's ok, I'll start my review :) You can move it after my review.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume searchFromNotes() is more appropriate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for commenting! I think so, too. I'll change it.

})
})
} else if (block.match(/^!.+/)) {
let block = block.match(/^!(.+)/)[1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line contains a bug even in production 😨

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can delete this condition too.

return false
})
}
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😎

if (search.trim().length === 0) return []
let searchBlocks = search.split(' ')
searchBlocks.forEach((block) => {
if (block.match(/^!#.+/)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can delete these condition starting from /^!.+/.

})
})
} else if (block.match(/^!.+/)) {
let block = block.match(/^!(.+)/)[1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can delete this condition too.

}
return false
})
} else if (block.match(/^#.+/)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should make a new method named such as findByTag().

return _tag.match(regExp)
})
})
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, you can make a new method such ad findByWord().

} else if (note.type === 'MARKDOWN_NOTE') {
return note.content.match(regExp)
}
return false
Copy link
Contributor

@asmsuechan asmsuechan May 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this below is ideal form.

if (isTag(block)) {
  const tag = block.match(/#(.+)/)[1]
  notes = findByTag(notes, tag)
} else {
  notes = findByWord(notes, block)
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also, we have to contemplate to decide these specifications.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the magic number is not good 🙅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for commenting! That is so simple and so good. I'll change to it.

@@ -349,6 +353,71 @@ class NoteList extends React.Component {
})
}

getSearchNotes () {
let { data } = this.props
let search = document.getElementsByClassName('TopBar__control-search-input___browser-main-TopBar-')[0].childNodes[0].value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class name depends on webpack, so you have to change it. If I were you, I name the element such as searchInput.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for telling it me! I'll add className 'searchInput' to input in Topbar/index.js.

}
})
return notes
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for changing them into the module 😄
And probably, I made a mistake 😨. I assume arranged interface is better (regarding findByTag() and findByWord). So, you should change findByTag(). It's better that to cut out the tag from a block inside the method.

searchBlocks.forEach((block) => {
  if (block.match(/^#.+/)) {
     notes = findByTag(notes, block)
  } else {
     notes = findByWord(notes, block)
  }
})

And also, you can make a method such as findByTagOrWord(block) to combine the methods for finding. (I'm not sure the argument name (block) is better or not 🤒)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for commenting! Certainly it is simple and easy to understand.

Copy link
Contributor

@asmsuechan asmsuechan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

screen shot 2017-06-03 at 16 40 40

@asmsuechan asmsuechan merged commit 66e478a into master Jun 3, 2017
@asmsuechan asmsuechan deleted the feature-change-search-ux branch June 3, 2017 07:41
@kazup01
Copy link
Member

kazup01 commented Jun 3, 2017

🎉🎉🎉🎉🎉🎉🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants