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

Extract booking section from listing page #969

Merged
merged 15 commits into from
Dec 20, 2018
Merged

Conversation

lyyder
Copy link
Contributor

@lyyder lyyder commented Dec 5, 2018

Extract listing page's internal component SectionBooking into it's own component called BookingPanel.

The idea is to handle opening and closing of the mobile modal inside the component and only take submit handler and onManageDisableSrcolling as props.

@lyyder lyyder force-pushed the extract-section-booking branch 3 times, most recently from 3ea3d1f to d40582b Compare December 5, 2018 12:51
@lyyder lyyder force-pushed the extract-section-booking branch 2 times, most recently from d84f14e to b36a367 Compare December 5, 2018 13:05
@lyyder lyyder temporarily deployed to sharetribe-starter-app December 5, 2018 13:49 Inactive
@@ -110,6 +110,10 @@
font-weight: 400;
}

& :global(.DayPicker__withBorder) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this do? Is there possibility that mobile layout or desktop layout breaks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Gnito removes rounding from the corners of the calendar. I guess we might be able to live without this as the border-radius is somehow not applied when there's 312px available for the calendar. Just added this as I wanted to explicitly remove the rounding on the corners and not by accident.

@lyyder lyyder force-pushed the extract-section-booking branch 2 times, most recently from 9ea2c54 to 9b133cd Compare December 11, 2018 06:51
@lyyder lyyder force-pushed the extract-section-booking branch 2 times, most recently from ec2998d to 2b60890 Compare December 17, 2018 20:15
"BookingPanel.closedListingButtonText": "Sorry, this listing has been closed.",
"BookingPanel.ctaButtonMessage": "Request to book",
"BookingPanel.hostedBy": "Hosted by {name}",
"BookingPanel.perUnit": "per night",
Copy link
Contributor

@Gnito Gnito Dec 19, 2018

Choose a reason for hiding this comment

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

@lyyder We have now made bookingTypeUnit changes easier with having translations for all the different unit types:
#970 aka 082707d

@@ -264,6 +229,11 @@ export class ListingPageComponent extends Component {
</span>
);

const bookingTitle = (
<FormattedMessage id="ListingPage.bookingTitle" values={{ title: richTitle }} />
Copy link
Contributor

Choose a reason for hiding this comment

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

It might make sense to

  • remove unnecessary span (<FormattedMessage>) and
  • use intl.formatMessage({ id: 'ListingPage.bookingSubTitle' }, { title: richTitle }); instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Gnito It appears that this requires the FormattedMessage component. Or at least using the intl.formatMessage like that renders the title param as [Object object] if a node is passed there.

isOwnListing: bool,
unitType: propTypes.bookingUnitType,
handleBookingSubmit: func.isRequired,
title: oneOfType([object, string]).isRequired,
Copy link
Contributor

Choose a reason for hiding this comment

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

node is probably better.

https://www.npmjs.com/package/prop-types

  // Anything that can be rendered: numbers, strings, elements or an array
  // (or fragment) containing these types.

import { FormattedMessage } from 'react-intl';
import classNames from 'classnames';
import omit from 'lodash/omit';
import { ModalInMobile, Button } from '../../components';
Copy link
Contributor

@Gnito Gnito Dec 19, 2018

Choose a reason for hiding this comment

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

Import components (incl. forms) as a last thing in imports from outside of this directory.
aka

// import dependency libs
import React from 'react';
// import utils
import { formatMoney } from '../../util/currency';
//  import components
import { ModalInMobile, Button } from '../../components';

// import stuff from this directory
import css from './BookingPanel.css';
  • This makes these imports easier to read and
  • It also makes it less likely to get strange dependency graphs since components might require same utilities than this one.

(I've tried to enforce this structure with everyone.)

Copy link
Contributor

@Gnito Gnito left a comment

Choose a reason for hiding this comment

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

Just a couple of small changes.

@Gnito
Copy link
Contributor

Gnito commented Dec 19, 2018

Since this touches modals: test heavily with mobile phones.

Extract SectionBooking away from ListingPage to a distinct component
called BookingPanel.
Remove isClosed and price from the BookingPanel props as they can be
resolved from the listing.
Rename the prop to title and allow it to be and object or a string. This
way a normal string or a styled html element can be provided.
Use title and sub title provided by a parent component.
Change formatted title and sub title type to node in BookingPanel.
Also remove FormattedText component which renders a redundant span element.
Place components and forms as last imports before the ones from the same
folder.
@lyyder lyyder merged commit f0534bd into master Dec 20, 2018
@lyyder lyyder deleted the extract-section-booking branch December 20, 2018 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants