Skip to content

Commit 27fb231

Browse files
committed
fix: navi ticket button's clickable area
1 parent dedcf83 commit 27fb231

2 files changed

Lines changed: 26 additions & 43 deletions

File tree

app/component/itinerary/navigator/NaviBottom.js

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
import cx from 'classnames';
22
import PropTypes from 'prop-types';
3-
import React, { useCallback } from 'react';
3+
import React from 'react';
44
import { FormattedMessage, useIntl } from 'react-intl';
5-
import connectToStores from 'fluxible-addons-react/connectToStores';
65
import { addAnalyticsEvent } from '../../../util/analyticsUtils';
7-
import { configShape, legShape } from '../../../util/shapes';
6+
import { legShape } from '../../../util/shapes';
87
import { epochToTime, durationToString } from '../../../util/timeUtils';
98
import { getFaresFromLegs, shouldShowFareInfo } from '../../../util/fareUtils';
109
import localizedUrl from '../../../util/urlUtils';
10+
import { useConfigContext } from '../../../configurations/ConfigContext';
1111

12-
function NaviBottom(
13-
{ setNavigation, arrival, time, legs, currentLanguage },
14-
{ config },
15-
) {
16-
const handleClose = useCallback(() => {
12+
export default function NaviBottom({ setNavigation, arrival, time, legs }) {
13+
const intl = useIntl();
14+
const config = useConfigContext();
15+
const currentLanguage = config.language;
16+
17+
const handleClose = () => {
1718
addAnalyticsEvent({
1819
category: 'Itinerary',
1920
event: 'navigator',
2021
action: 'cancel_navigation',
2122
});
2223
setNavigation(false);
23-
}, [setNavigation]);
24-
const handleTicketButtonClick = useCallback(e => e.stopPropagation(), []);
25-
const intl = useIntl();
24+
};
25+
26+
const handleTicketButtonClick = e => {
27+
e.stopPropagation();
28+
};
2629

2730
const isTicketSaleActive =
2831
config.navigatorTicketLink &&
@@ -70,19 +73,16 @@ function NaviBottom(
7073
{FirstElement}
7174
{SecondElement}
7275
{isTicketSaleActive && (
73-
/* TODO HSL hack, make link below configurable */ <button
74-
type="button"
76+
/* TODO HSL hack, make link below configurable */
77+
<a
7578
className="navi-ticket-button"
79+
href={localizedUrl(config.navigatorTicketLink, currentLanguage)}
80+
onClick={handleTicketButtonClick}
81+
target="_blank"
82+
rel="noopener noreferrer"
7683
>
77-
<a
78-
onClick={handleTicketButtonClick}
79-
href={localizedUrl(config.navigatorTicketLink, currentLanguage)}
80-
target="_blank"
81-
rel="noopener noreferrer"
82-
>
83-
<FormattedMessage id="navigation-ticket" />
84-
</a>
85-
</button>
84+
<FormattedMessage id="navigation-ticket" />
85+
</a>
8686
)}
8787
</div>
8888
);
@@ -93,19 +93,4 @@ NaviBottom.propTypes = {
9393
arrival: PropTypes.number.isRequired,
9494
time: PropTypes.number.isRequired,
9595
legs: PropTypes.arrayOf(legShape).isRequired,
96-
currentLanguage: PropTypes.string.isRequired,
9796
};
98-
99-
NaviBottom.contextTypes = {
100-
config: configShape.isRequired,
101-
};
102-
103-
const connectedComponent = connectToStores(
104-
NaviBottom,
105-
['PreferencesStore'],
106-
context => ({
107-
currentLanguage: context.getStore('PreferencesStore').getLanguage(),
108-
}),
109-
);
110-
111-
export { connectedComponent as default, NaviBottom as Component };

app/component/itinerary/navigator/navigator.scss

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -888,17 +888,15 @@
888888
}
889889

890890
.navi-ticket-button {
891+
display: inline-flex;
892+
align-items: center;
893+
justify-content: center;
891894
border-radius: 20px;
892895
width: 100px;
893896
height: 40px;
894-
text-align: center;
895897
margin-left: 16px;
896898
background-color: $theme-primary-color;
897899
color: white;
898-
899-
a {
900-
color: white;
901-
text-decoration: none;
902-
}
900+
text-decoration: none;
903901
}
904902
}

0 commit comments

Comments
 (0)