mirror of
https://github.com/HSLdevcom/digitransit-ui
synced 2026-04-25 15:07:53 +02:00
59 lines
1.7 KiB
JavaScript
59 lines
1.7 KiB
JavaScript
import PropTypes from 'prop-types';
|
|
import React from 'react';
|
|
import { FormattedMessage, useIntl } from 'react-intl';
|
|
import Icon from './Icon';
|
|
import { useConfigContext } from '../configurations/ConfigContext';
|
|
|
|
export default function SelectFromMapHeader(props) {
|
|
const { colors } = useConfigContext();
|
|
const intl = useIntl();
|
|
|
|
return (
|
|
<div className="select-from-map-nav-container">
|
|
{!props.hideBackBtn && (
|
|
<button
|
|
type="button"
|
|
className="from-map-modal-nav-button"
|
|
onClick={props.hideBackBtn ? undefined : props.onBackBtnClick}
|
|
aria-label={intl.formatMessage({
|
|
id: 'back-button-title',
|
|
defaultMessage: 'Go back to previous page',
|
|
})}
|
|
>
|
|
<Icon img="icon_arrow-left" color={colors.primary} />
|
|
</button>
|
|
)}
|
|
<div className="select-from-map-nav-title">
|
|
<FormattedMessage id={props.titleId} />
|
|
</div>
|
|
{!props.hideCloseBtn && (
|
|
<button
|
|
type="button"
|
|
className="from-map-modal-nav-button"
|
|
onClick={props.hideCloseBtn ? undefined : props.onCloseBtnClick}
|
|
aria-label={intl.formatMessage({
|
|
id: 'back-button-title',
|
|
defaultMessage: 'Go back to previous page',
|
|
})}
|
|
>
|
|
<Icon img="icon_close" color={colors.primary} />
|
|
</button>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
SelectFromMapHeader.propTypes = {
|
|
titleId: PropTypes.string.isRequired,
|
|
onBackBtnClick: PropTypes.func,
|
|
onCloseBtnClick: PropTypes.func,
|
|
hideBackBtn: PropTypes.bool,
|
|
hideCloseBtn: PropTypes.bool,
|
|
};
|
|
|
|
SelectFromMapHeader.defaultProps = {
|
|
onBackBtnClick: PropTypes.func,
|
|
onCloseBtnClick: PropTypes.func,
|
|
hideBackBtn: false,
|
|
hideCloseBtn: false,
|
|
};
|