diff --git a/src/components/TopbarDesktop/TopbarDesktop.css b/src/components/TopbarDesktop/TopbarDesktop.css index 38e21f93..cfacbc58 100644 --- a/src/components/TopbarDesktop/TopbarDesktop.css +++ b/src/components/TopbarDesktop/TopbarDesktop.css @@ -10,7 +10,7 @@ display: flex; flex-direction: row; justify-content: space-between; - align-items: baseline; + align-items: flex-start; padding: 0 36px; /* fill */ @@ -32,7 +32,6 @@ /* logo */ .logoLink { - align-self: flex-start; flex-shrink: 0; display: flex; align-items: center; @@ -46,10 +45,8 @@ } /* Search */ -/* TODO This is placeholder, it needs Search component */ .searchLink { - min-width: 220px; - align-self: flex-start; + flex-grow: 1; height: 100%; margin-right: 24px; } @@ -60,15 +57,9 @@ color: var(--matterColor); } -/* Spacer */ -/* Extra space is gathered between search and createListingLink */ -.spacer { - flex-grow: 1; -} - /* Create listing (CTA for providers) */ .createListingLink { - align-self: flex-start; + flex-shrink: 0; height: 100%; margin-right: 24px; } @@ -81,7 +72,6 @@ /* Inbox */ .inboxLink { - align-self: flex-start; height: 100%; margin-right: 24px; } @@ -94,7 +84,6 @@ /* Profile menu */ .profileMenuLabel { - align-self: flex-start; flex-shrink: 0; display: flex; align-items: center; @@ -112,13 +101,13 @@ /* Authentication */ .signupLink { - align-self: flex-start; + flex-shrink: 0; height: 100%; margin-right: 24px; } .loginLink { - align-self: flex-start; + flex-shrink: 0; height: 100%; } diff --git a/src/components/TopbarDesktop/TopbarDesktop.example.js b/src/components/TopbarDesktop/TopbarDesktop.example.js index f6357ec8..5d0c8d16 100644 --- a/src/components/TopbarDesktop/TopbarDesktop.example.js +++ b/src/components/TopbarDesktop/TopbarDesktop.example.js @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ import { fakeIntl } from '../../util/test-data'; import TopbarDesktop from './TopbarDesktop'; @@ -9,6 +10,9 @@ export const AuthenticatedDesktopTopbar = { isAuthenticated: true, currentUserHasListings: true, name: 'John Doe', + onSearchSubmit: values => { + console.log('submit search:', values); + }, intl: fakeIntl, onLogout: noop, }, diff --git a/src/components/TopbarDesktop/TopbarDesktop.js b/src/components/TopbarDesktop/TopbarDesktop.js index 7eacb3d8..fc6edcec 100644 --- a/src/components/TopbarDesktop/TopbarDesktop.js +++ b/src/components/TopbarDesktop/TopbarDesktop.js @@ -1,5 +1,5 @@ import React, { PropTypes } from 'react'; -import { FormattedMessage, intlShape, injectIntl } from 'react-intl'; +import { FormattedMessage, intlShape } from 'react-intl'; import classNames from 'classnames'; import { Avatar, @@ -10,6 +10,7 @@ import { MenuItem, NamedLink, } from '../../components'; +import { TopbarSearchForm } from '../../containers'; import logo from './images/saunatime-logo.png'; import css from './TopbarDesktop.css'; @@ -24,16 +25,20 @@ const TopbarDesktop = props => { intl, isAuthenticated, onLogout, + onSearchSubmit, + initialSearchFormValues, } = props; const rootClass = rootClassName || css.root; const classes = classNames(rootClass, className); - // TODO This is just a placeholder const search = ( -
- Search should be here -
+ ); const inboxLink = isAuthenticated @@ -83,7 +88,6 @@ const TopbarDesktop = props => { /> {search} -
@@ -97,9 +101,15 @@ const TopbarDesktop = props => { ); }; -TopbarDesktop.defaultProps = { className: null, firstName: '', lastName: '', rootClassName: '' }; +const { bool, func, string, object } = PropTypes; -const { bool, func, string } = PropTypes; +TopbarDesktop.defaultProps = { + firstName: '', + lastName: '', + className: null, + rootClassName: null, + initialSearchFormValues: {}, +}; TopbarDesktop.propTypes = { className: string, @@ -109,9 +119,9 @@ TopbarDesktop.propTypes = { firstName: string, lastName: string, rootClassName: string, - - // from injectIntl + onSearchSubmit: func.isRequired, + initialSearchFormValues: object, intl: intlShape.isRequired, }; -export default injectIntl(TopbarDesktop); +export default TopbarDesktop; diff --git a/src/components/TopbarDesktop/TopbarDesktop.test.js b/src/components/TopbarDesktop/TopbarDesktop.test.js index b65a1d04..cbe4653f 100644 --- a/src/components/TopbarDesktop/TopbarDesktop.test.js +++ b/src/components/TopbarDesktop/TopbarDesktop.test.js @@ -10,18 +10,22 @@ const noop = () => null; describe('TopbarDesktop', () => { it('data matches snapshot', () => { + window.google = { maps: {} }; const flattenedRoutes = flattenRoutes(routesConfiguration); + const topbarProps = { + isAuthenticated: true, + currentUserHasListings: true, + name: 'John Doe', + onSearchSubmit: noop, + intl: fakeIntl, + onLogout: noop, + }; const tree = renderDeep( - + ); + delete window.google; expect(tree).toMatchSnapshot(); }); }); diff --git a/src/components/TopbarDesktop/__snapshots__/TopbarDesktop.test.js.snap b/src/components/TopbarDesktop/__snapshots__/TopbarDesktop.test.js.snap index 5d742707..086c0aeb 100644 --- a/src/components/TopbarDesktop/__snapshots__/TopbarDesktop.test.js.snap +++ b/src/components/TopbarDesktop/__snapshots__/TopbarDesktop.test.js.snap @@ -7,19 +7,29 @@ exports[`TopbarDesktop data matches snapshot 1`] = ` onClick={[Function]} style={Object {}}> Logo -
- - Search should be here - -
-
+
+
+ +
+