-
Notifications
You must be signed in to change notification settings - Fork 942
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
Conversation
3ea3d1f
to
d40582b
Compare
d84f14e
to
b36a367
Compare
@@ -110,6 +110,10 @@ | |||
font-weight: 400; | |||
} | |||
|
|||
& :global(.DayPicker__withBorder) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
d7de7fb
to
34183f0
Compare
9ea2c54
to
9b133cd
Compare
ec2998d
to
2b60890
Compare
src/translations/en.json
Outdated
"BookingPanel.closedListingButtonText": "Sorry, this listing has been closed.", | ||
"BookingPanel.ctaButtonMessage": "Request to book", | ||
"BookingPanel.hostedBy": "Hosted by {name}", | ||
"BookingPanel.perUnit": "per night", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -264,6 +229,11 @@ export class ListingPageComponent extends Component { | |||
</span> | |||
); | |||
|
|||
const bookingTitle = ( | |||
<FormattedMessage id="ListingPage.bookingTitle" values={{ title: richTitle }} /> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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.)
There was a problem hiding this 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.
Since this touches modals: test heavily with mobile phones. |
f7407da
to
299750d
Compare
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.
c4d9e47
to
3d11d73
Compare
Extract listing page's internal component
SectionBooking
into it's own component calledBookingPanel
.The idea is to handle opening and closing of the mobile modal inside the component and only take submit handler and
onManageDisableSrcolling
as props.