diff --git a/app/javascript/gabsocial/components/navigation_bar/search_navigation_bar_xs.js b/app/javascript/gabsocial/components/navigation_bar/search_navigation_bar_xs.js index 7bb45233..74bb8daf 100644 --- a/app/javascript/gabsocial/components/navigation_bar/search_navigation_bar_xs.js +++ b/app/javascript/gabsocial/components/navigation_bar/search_navigation_bar_xs.js @@ -4,14 +4,28 @@ import Heading from '../heading' import Search from '../search' import Pills from '../pills' import Button from '../button' +import Text from '../text' class SearchNavigationBar extends React.PureComponent { + onClickSearch = (e) => { + e.preventDefault() + const { isSearchFocused } = this.props + if (!isSearchFocused) { + this.props.onToggleSearchExplore(true) + } + } + + onResetSearchFocus = () => { + this.props.onToggleSearchExplore(false) + } + render() { const { children, tabs, value, + isSearchFocused, } = this.props const to = '/home' @@ -20,21 +34,43 @@ class SearchNavigationBar extends React.PureComponent {
-
+
- + }
@@ -53,6 +89,8 @@ class SearchNavigationBar extends React.PureComponent { SearchNavigationBar.propTypes = { tabs: PropTypes.array, value: PropTypes.string, + onToggleSearchExplore: PropTypes.func, + isSearchFocused: PropTypes.bool.isRequired, } export default SearchNavigationBar \ No newline at end of file diff --git a/app/javascript/gabsocial/layouts/search_layout.js b/app/javascript/gabsocial/layouts/search_layout.js index 5e35c845..44f82d03 100644 --- a/app/javascript/gabsocial/layouts/search_layout.js +++ b/app/javascript/gabsocial/layouts/search_layout.js @@ -11,8 +11,6 @@ import Layout from '../layouts/layout' import PageTitle from '../features/ui/util/page_title' import DefaultNavigationBar from '../components/navigation_bar/default_navigation_bar' import FooterBar from '../components/footer_bar' -import ProfileHeader from '../components/profile_header' -import FloatingActionButton from '../components/floating_action_button' import SearchNavigationBar from '../components/navigation_bar/search_navigation_bar_xs' import LoggedOutNavigationBar from '../components/navigation_bar/logged_out_navigation_bar' import Responsive from '../features/ui/util/responsive_component' @@ -24,13 +22,35 @@ import { TrendsPanel, SearchFilterPanel, SignUpPanel, + ExploreTimeline, + HashtagTimeline, + SidebarXS, } from '../features/ui/util/async_components' class SearchLayout extends React.PureComponent { + state = { + isSearchFocused: false, + currentExploreTabIndex: 0, + } + componentWillMount() { const { intl } = this.props + this.exploreTabs = [ + { + title: 'Explore', + onClick: () => this.setState({ currentExploreTabIndex: 0 }), + component: ExploreTimeline, + }, + { + title: '#Election2020', + onClick: () => this.setState({ currentExploreTabIndex: 1 }), + component: HashtagTimeline, + componentParams: { params: { id: 'election2020' } }, + }, + ] + this.searchTabs = [ { title: intl.formatMessage(messages.top), @@ -60,17 +80,30 @@ class SearchLayout extends React.PureComponent { ] } + handleOnToggleSearchExplore = (isSearchFocused) => { + this.setState({ isSearchFocused }) + } + render() { const { intl, children, value, } = this.props + const { + isSearchFocused, + currentExploreTabIndex, + } = this.state - const mainContentClasses = CX({ - d: 1, - w100PC: 1, - z1: 1, + + const activeExploreTab = this.exploreTabs[currentExploreTabIndex]; + const activeTabComponent = activeExploreTab.component + const activeTabComponentParams = activeExploreTab.componentParams || {} + const activeExploreTabs = this.exploreTabs.map((tab, i) => { + return { + ...tab, + active: i === currentExploreTabIndex, + } }) const title = intl.formatMessage(messages.search) @@ -79,16 +112,23 @@ class SearchLayout extends React.PureComponent { return ( + + + { !!me && - + } { !me && } -
+
{ !me && @@ -97,7 +137,20 @@ class SearchLayout extends React.PureComponent {
} - {children} + { + !!isSearchFocused && + children + } + + { + !isSearchFocused && +
+ +
+ }