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

feat(itinerary-body): add and use showAlertEffectiveDateTimeText to alert components #799

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports[`Building-Blocks/Alert BasicAlert smoke-test 1`] = `
focusable="false"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
class="StyledIconBase-sc-ea9ulj-0 kcHuPT"
class="StyledIconBase-ea9ulj-0 hPhvO"
>
<path d="M8 16a2 2 0 0 0 2-2H6a2 2 0 0 0 2 2zM8 1.918l-.797.161A4.002 4.002 0 0 0 4 6c0 .628-.134 2.197-.459 3.742-.16.767-.376 1.566-.663 2.258h10.244c-.287-.692-.502-1.49-.663-2.258C12.134 8.197 12 6.628 12 6a4.002 4.002 0 0 0-3.203-3.92L8 1.917zM14.22 12c.223.447.481.801.78 1H1c.299-.199.557-.553.78-1C2.68 10.2 3 6.88 3 6c0-2.42 1.72-4.44 4.005-4.901a1 1 0 1 1 1.99 0A5.002 5.002 0 0 1 13 6c0 .88.32 4.2 1.22 6z">
</path>
Expand Down Expand Up @@ -46,7 +46,7 @@ exports[`Building-Blocks/Alert CollapsibleAlertWithTransitAlerts smoke-test 1`]
focusable="false"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
class="StyledIconBase-sc-ea9ulj-0 kcHuPT"
class="StyledIconBase-ea9ulj-0 hPhvO"
>
<path d="M7.938 2.016A.13.13 0 0 1 8.002 2a.13.13 0 0 1 .063.016.146.146 0 0 1 .054.057l6.857 11.667c.036.06.035.124.002.183a.163.163 0 0 1-.054.06.116.116 0 0 1-.066.017H1.146a.115.115 0 0 1-.066-.017.163.163 0 0 1-.054-.06.176.176 0 0 1 .002-.183L7.884 2.073a.147.147 0 0 1 .054-.057zm1.044-.45a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566z">
</path>
Expand All @@ -68,7 +68,7 @@ exports[`Building-Blocks/Alert CollapsibleAlertWithTransitAlerts smoke-test 1`]
focusable="false"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
class="StyledIconBase-sc-ea9ulj-0 kcHuPT"
class="StyledIconBase-ea9ulj-0 hPhvO"
>
<path fill-rule="evenodd"
d="M7.646 4.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1-.708.708L8 5.707l-5.646 5.647a.5.5 0 0 1-.708-.708l6-6z"
Expand Down
4 changes: 3 additions & 1 deletion packages/itinerary-body/src/ItineraryBody/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ const ItineraryBody = ({
setActiveLeg,
setLegDiagram,
setViewedTrip,
showApproximateAccessLegTravelTimes,
showAgencyInfo,
showAlertEffectiveDateTimeText,
showApproximateAccessLegTravelTimes,
showElevationProfile,
showLegIcon,
showMapButtonColumn = true,
Expand Down Expand Up @@ -87,6 +88,7 @@ const ItineraryBody = ({
showApproximateAccessLegTravelTimes
}
showAgencyInfo={showAgencyInfo}
showAlertEffectiveDateTimeText={showAlertEffectiveDateTimeText}
showElevationProfile={showElevationProfile}
showLegIcon={showLegIcon}
showMapButtonColumn={showMapButtonColumn}
Expand Down
2 changes: 2 additions & 0 deletions packages/itinerary-body/src/ItineraryBody/place-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default function PlaceRow({
setLegDiagram,
setViewedTrip,
showAgencyInfo,
showAlertEffectiveDateTimeText,
showApproximateAccessLegTravelTimes,
showElevationProfile,
showLegIcon,
Expand Down Expand Up @@ -158,6 +159,7 @@ export default function PlaceRow({
setActiveLeg={setActiveLeg}
setViewedTrip={setViewedTrip}
showAgencyInfo={showAgencyInfo}
showAlertEffectiveDateTimeText={showAlertEffectiveDateTimeText}
showViewTripButton={showViewTripButton}
timeZone={config.homeTimezone}
TransitLegSubheader={TransitLegSubheader}
Expand Down
59 changes: 31 additions & 28 deletions packages/itinerary-body/src/TransitLegBody/alerts-body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface Props {
agencyName?: string;
alerts: Alert[];
AlertIcon?: FunctionComponent;
showAlertEffectiveDateTimeText?: boolean;
timeZone?: string;
}

Expand Down Expand Up @@ -67,6 +68,7 @@ export default function AlertsBody({
agencyName,
alerts,
AlertIcon = S.DefaultAlertBodyIcon,
showAlertEffectiveDateTimeText = true,
timeZone = getUserTimezone()
}: Props): ReactElement {
if (typeof alerts !== "object") return null;
Expand Down Expand Up @@ -106,34 +108,35 @@ export default function AlertsBody({
)}
<S.TransitAlertBody>{description}</S.TransitAlertBody>
<S.TransitAlertEffectiveDate>
{Math.abs(dayDiff) <= 1 ? (
<FormattedMessage
defaultMessage={
defaultMessages[
"otpUi.TransitLegBody.AlertsBody.effectiveTimeAndDate"
]
}
description="Text with the time and date an alert takes effect"
id="otpUi.TransitLegBody.AlertsBody.effectiveTimeAndDate"
values={{
dateTime: effectiveStartDate * 1000,
day: <AlertDay dayDiff={dayDiff} />
}}
/>
) : (
<FormattedMessage
defaultMessage={
defaultMessages[
"otpUi.TransitLegBody.AlertsBody.effectiveDate"
]
}
description="Text with the date an alert takes effect"
id="otpUi.TransitLegBody.AlertsBody.effectiveDate"
values={{
dateTime: effectiveStartDate * 1000
}}
/>
)}
{showAlertEffectiveDateTimeText &&
(Math.abs(dayDiff) <= 1 ? (
josh-willis-arcadis marked this conversation as resolved.
Show resolved Hide resolved
<FormattedMessage
defaultMessage={
defaultMessages[
"otpUi.TransitLegBody.AlertsBody.effectiveTimeAndDate"
]
}
description="Text with the time and date an alert takes effect"
id="otpUi.TransitLegBody.AlertsBody.effectiveTimeAndDate"
values={{
dateTime: effectiveStartDate * 1000,
day: <AlertDay dayDiff={dayDiff} />
}}
/>
) : (
<FormattedMessage
defaultMessage={
defaultMessages[
"otpUi.TransitLegBody.AlertsBody.effectiveDate"
]
}
description="Text with the date an alert takes effect"
id="otpUi.TransitLegBody.AlertsBody.effectiveDate"
values={{
dateTime: effectiveStartDate * 1000
}}
/>
))}
{alertUrl?.trim() && (
<S.TransitAlertExternalLink href={alertUrl} target="_blank">
<ExternalLinkAlt height={10} />
Expand Down
3 changes: 3 additions & 0 deletions packages/itinerary-body/src/TransitLegBody/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ interface Props {
setActiveLeg: SetActiveLegFunction;
setViewedTrip: SetViewedTripFunction;
showAgencyInfo: boolean;
showAlertEffectiveDateTimeText?: boolean;
showViewTripButton: boolean;
timeZone: string;
TransitLegSubheader?: FunctionComponent<TransitLegSubheaderProps>;
Expand Down Expand Up @@ -140,6 +141,7 @@ class TransitLegBody extends Component<Props, State> {
RouteDescriptionFooter,
setViewedTrip,
showAgencyInfo,
showAlertEffectiveDateTimeText,
showViewTripButton,
timeZone,
TransitLegSubheader,
Expand Down Expand Up @@ -332,6 +334,7 @@ class TransitLegBody extends Component<Props, State> {
agencyName={agencyName}
alerts={leg.alerts}
AlertIcon={AlertBodyIcon}
showAlertEffectiveDateTimeText={showAlertEffectiveDateTimeText}
timeZone={timeZone}
/>
</AnimateHeight>
Expand Down
10 changes: 10 additions & 0 deletions packages/itinerary-body/src/stories/OtpRrItineraryBody.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ interface StoryWrapperProps {
defaultFareSelector?: FareProductSelector;
hideDrivingDirections?: boolean;
itinerary: Itinerary;
showAlertEffectiveDateTimeText?: boolean;
showApproximateAccessLegTravelTimes?: boolean;
TimeColumnContent?: FunctionComponent<TimeColumnContentProps>;
}
Expand All @@ -70,6 +71,7 @@ function OtpRRItineraryBodyWrapper({
defaultFareSelector,
hideDrivingDirections = false,
itinerary,
showAlertEffectiveDateTimeText = true,
showApproximateAccessLegTravelTimes = false,
TimeColumnContent
}: StoryWrapperProps): ReactElement {
Expand All @@ -84,6 +86,7 @@ function OtpRRItineraryBodyWrapper({
PlaceName={OtpRRPlaceName}
RouteDescription={OtpRRRouteDescription}
showAgencyInfo
showAlertEffectiveDateTimeText={showAlertEffectiveDateTimeText}
showApproximateAccessLegTravelTimes={showApproximateAccessLegTravelTimes}
showLegIcon
showMapButtonColumn={false}
Expand Down Expand Up @@ -263,3 +266,10 @@ export const ApproximatePrefixItinerary = (): ReactElement => (
export const TransferLegItinerary = (): ReactElement => (
<OtpRRItineraryBodyWrapper itinerary={transferLegItinerary} />
);

export const AlertNoEffectiveAsOfItinerary = (): ReactElement => (
<OtpRRItineraryBodyWrapper
itinerary={walkTransitWalkItinerary}
showAlertEffectiveDateTimeText={false}
/>
);
Loading
Loading