From 47d519927a66c9e8e39b81f6f0f22f992648cdee Mon Sep 17 00:00:00 2001 From: hmhealey Date: Thu, 22 Oct 2015 12:15:21 -0400 Subject: Added help popover to search box --- web/react/components/search_bar.jsx | 33 +++++++++++++++++++++++++++++- web/sass-files/sass/partials/_popover.scss | 19 +++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) (limited to 'web') diff --git a/web/react/components/search_bar.jsx b/web/react/components/search_bar.jsx index 2e9764bd9..bf12ca160 100644 --- a/web/react/components/search_bar.jsx +++ b/web/react/components/search_bar.jsx @@ -8,6 +8,7 @@ var AppDispatcher = require('../dispatcher/app_dispatcher.jsx'); var utils = require('../utils/utils.jsx'); var Constants = require('../utils/constants.jsx'); var ActionTypes = Constants.ActionTypes; +var Tooltip = ReactBootstrap.Tooltip; export default class SearchBar extends React.Component { constructor() { @@ -16,10 +17,14 @@ export default class SearchBar extends React.Component { this.onListenerChange = this.onListenerChange.bind(this); this.handleUserInput = this.handleUserInput.bind(this); + this.handleUserFocus = this.handleUserFocus.bind(this); + this.handleUserBlur = this.handleUserBlur.bind(this); this.performSearch = this.performSearch.bind(this); this.handleSubmit = this.handleSubmit.bind(this); - this.state = this.getSearchTermStateFromStores(); + const state = this.getSearchTermStateFromStores(); + state.focused = false; + this.state = state; } getSearchTermStateFromStores() { var term = PostStore.getSearchTerm() || ''; @@ -78,9 +83,14 @@ export default class SearchBar extends React.Component { handleMouseInput(e) { e.preventDefault(); } + handleUserBlur() { + this.setState({focused: false}); + } handleUserFocus(e) { e.target.select(); $('.search-bar__container').addClass('focused'); + + this.setState({focused: true}); } performSearch(terms, isMentionSearch) { if (terms.length) { @@ -115,6 +125,12 @@ export default class SearchBar extends React.Component { if (this.state.isSearching) { isSearching = ; } + + let helpClass = 'search-help-popover'; + if (!this.state.searchTerm && this.state.focused) { + helpClass += ' visible'; + } + return (
{isSearching} + +

{'Search Options'}

+
    +
  • + {'Use '}{'"quotation marks"'}{' to search for phrases'} +
  • +
  • + {'Use '}{'from:'}{' to find posts from specific users and '}{'in:'}{' to find posts in specific channels'} +
  • +
+
); diff --git a/web/sass-files/sass/partials/_popover.scss b/web/sass-files/sass/partials/_popover.scss index 126d239ec..c389ddf7d 100644 --- a/web/sass-files/sass/partials/_popover.scss +++ b/web/sass-files/sass/partials/_popover.scss @@ -20,3 +20,22 @@ display: block; } +.search-help-popover { + transition: opacity 0.3s; + + h4 { + text-align: left; + } + ul { + padding-left: 2em; + text-align: left; + } + .tooltip-inner { + max-width: 100%; + } +} + +.search-help-popover.visible { + opacity: 100; + transition: opacity 0.3s; +} -- cgit v1.2.3-1-g7c22