From 167d08643a9872d35f1fcee971025d6988ba8925 Mon Sep 17 00:00:00 2001 From: Simo Partinen Date: Tue, 31 Dec 2024 12:16:18 +0200 Subject: [PATCH 1/4] feat: ticketsaleless Navigator bottom sheet --- .../itinerary/navigator/NaviBottom.js | 61 +++++++++++-------- .../itinerary/navigator/navigator.scss | 6 +- 2 files changed, 42 insertions(+), 25 deletions(-) diff --git a/app/component/itinerary/navigator/NaviBottom.js b/app/component/itinerary/navigator/NaviBottom.js index 9d6507b155..40c070cad0 100644 --- a/app/component/itinerary/navigator/NaviBottom.js +++ b/app/component/itinerary/navigator/NaviBottom.js @@ -1,3 +1,4 @@ +import cx from 'classnames'; import PropTypes from 'prop-types'; import React from 'react'; import { FormattedMessage } from 'react-intl'; @@ -8,35 +9,47 @@ export default function NaviBottom( { setNavigation, arrival, time }, { config }, ) { + const handleClose = () => setNavigation(false); + const handleTicketButtonClick = e => e.stopPropagation(); + + const isTicketSaleActive = !!config?.ticketLink; const remainingDuration = Math.ceil((arrival - time) / 60000); // ms to minutes + + const controlsClasses = cx('navi-bottom-controls', { + 'ticket-link': isTicketSaleActive, + }); + + const closeButton = ( + + ); + + const durationDiv = remainingDuration >= 0 && ( +
+ + + + {epochToTime(arrival, config)} +
+ ); + + const [FirstElement, SecondElement] = isTicketSaleActive + ? [closeButton, durationDiv] + : [durationDiv, closeButton]; + return (
-
- - - {remainingDuration >= 0 && ( -
- - - - {epochToTime(arrival, config)} -
- )} - {config.ticketLink && ( +
+ {FirstElement} + {SecondElement} + {isTicketSaleActive && ( - )} -
+
+ {FirstElement} + {SecondElement} + {isTicketSaleActive && ( + + )}
); } diff --git a/app/component/itinerary/navigator/navigator.scss b/app/component/itinerary/navigator/navigator.scss index 84b07d618d..aa92bafea9 100644 --- a/app/component/itinerary/navigator/navigator.scss +++ b/app/component/itinerary/navigator/navigator.scss @@ -540,62 +540,58 @@ $fixed-width-padding: 16px; } .navi-bottom-sheet { - .divider { - width: 100%; - height: 1px; - border-top: 1px solid #ddd; - margin-top: 10px; - } + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-between; + font-size: $font-size-normal; + text-align: center; + margin: var(--space-m) var(--space-l); - .navi-bottom-controls { - display: flex; - flex-direction: row; - align-items: center; - justify-content: space-between; - font-size: $font-size-normal; - text-align: center; - margin: var(--space-m) var(--space-l); + &.ticket-link { + margin: var(--space-l) var(--space-m); - &.ticket-link { - margin: var(--space-l) var(--space-m); + .navi-time { + align-items: inherit; } + } - .navi-close-button { - border-style: solid; - border-width: 1px; - border-radius: 20px; - width: 100px; - height: 40px; - text-align: center; - background-color: white; - border-color: $cancelation-red; - color: $cancelation-red; - } + .navi-close-button { + border-style: solid; + border-width: 1px; + border-radius: 20px; + width: 100px; + height: 40px; + text-align: center; + background-color: white; + border-color: $cancelation-red; + color: $cancelation-red; + } - .navi-time { - display: flex; - flex-direction: column; - color: $black; + .navi-time { + display: flex; + flex-direction: column; + align-items: flex-start; + color: $black; - .navi-daytime { - font-size: $font-size-xsmall; - font-weight: $font-weight-book; - } + .navi-daytime { + font-size: $font-size-xsmall; + font-weight: $font-weight-book; } + } - .navi-ticket-button { - border-radius: 20px; - width: 100px; - height: 40px; - text-align: center; - margin-left: 16px; - background-color: $primary-color; - color: white; + .navi-ticket-button { + border-radius: 20px; + width: 100px; + height: 40px; + text-align: center; + margin-left: 16px; + background-color: $primary-color; + color: white; - a { - color: white; - text-decoration: none; - } + a { + color: white; + text-decoration: none; } } } From 07c23ba5d1bb86fa51ce39df9e34313802ead71d Mon Sep 17 00:00:00 2001 From: Simo Partinen Date: Tue, 31 Dec 2024 16:05:43 +0200 Subject: [PATCH 4/4] chore: useCallbacked functions --- app/component/itinerary/navigator/NaviBottom.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/component/itinerary/navigator/NaviBottom.js b/app/component/itinerary/navigator/NaviBottom.js index d87cbef12b..d4b9140b40 100644 --- a/app/component/itinerary/navigator/NaviBottom.js +++ b/app/component/itinerary/navigator/NaviBottom.js @@ -1,6 +1,6 @@ import cx from 'classnames'; import PropTypes from 'prop-types'; -import React from 'react'; +import React, { useCallback } from 'react'; import { FormattedMessage } from 'react-intl'; import { configShape } from '../../../util/shapes'; import { epochToTime } from '../../../util/timeUtils'; @@ -9,8 +9,8 @@ export default function NaviBottom( { setNavigation, arrival, time }, { config }, ) { - const handleClose = () => setNavigation(false); - const handleTicketButtonClick = e => e.stopPropagation(); + const handleClose = useCallback(() => setNavigation(false), [setNavigation]); + const handleTicketButtonClick = useCallback(e => e.stopPropagation(), []); const isTicketSaleActive = !!config?.ticketLink; const remainingDuration = Math.ceil((arrival - time) / 60000); // ms to minutes