Skip to content

Commit 876bdd3

Browse files
committed
Made PrintableItinerary use a headingAs
1 parent e373287 commit 876bdd3

File tree

11 files changed

+15243
-15174
lines changed

11 files changed

+15243
-15174
lines changed

packages/itinerary-body/src/defaults/access-leg-description.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import Distance from "./default-distance";
1010

1111
const { ensureAtLeastOneMinute, toHoursMinutesSeconds } = coreUtils.time;
1212

13-
interface Props extends HTMLAttributes<HTMLSpanElement> {
13+
interface Props extends HTMLAttributes<HTMLElement> {
1414
config: Config;
1515
leg: Leg;
16+
headingAs?: React.ElementType;
1617
}
1718

1819
/**
@@ -75,7 +76,8 @@ export default function AccessLegDescription({
7576
className,
7677
config,
7778
leg,
78-
style
79+
style,
80+
headingAs
7981
}: Props): ReactElement {
8082
const intl = useIntl();
8183
const { companies, formatDuration, units } = config;
@@ -98,10 +100,15 @@ export default function AccessLegDescription({
98100
// TODO: is this causing issues with TNC legs? Do walk legs leading to a TNC
99101
// trip really have the same `to.stopId` as `from.stopId`?
100102
const isTransferLeg = to.stopId === from.stopId;
103+
101104
return (
102105
// Return an HTML element which is passed a className (and style props)
103106
// for styled-components support.
104-
<span className={className} style={style}>
107+
<S.AccessLegDescriptionHeading
108+
as={headingAs ?? "span"}
109+
className={className}
110+
style={style}
111+
>
105112
{distance > 0 ? (
106113
<FormattedMessage
107114
defaultMessage="{mode} {distance} to {place}"
@@ -147,6 +154,6 @@ export default function AccessLegDescription({
147154
}}
148155
/>
149156
)}
150-
</span>
157+
</S.AccessLegDescriptionHeading>
151158
);
152159
}

packages/itinerary-body/src/stories/__snapshots__/OtpRrItineraryBody.story.tsx.snap

Lines changed: 6751 additions & 6751 deletions
Large diffs are not rendered by default.

packages/itinerary-body/src/stories/__snapshots__/OtpUiItineraryBody.story.tsx.snap

Lines changed: 7567 additions & 7567 deletions
Large diffs are not rendered by default.

packages/itinerary-body/src/styled.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,10 @@ export const ItineraryBody = styled.ol`
280280
padding: 0;
281281
`;
282282

283+
export const AccessLegDescriptionHeading = styled.span`
284+
margin: 0;
285+
`;
286+
283287
export const LegBody = styled.div`
284288
color: #676767;
285289
font-size: 13px;

0 commit comments

Comments
 (0)