Skip to content

Commit 1d79d97

Browse files
committed
refactor(itinerary): use button instead of a tag
1 parent 9f41b49 commit 1d79d97

File tree

5 files changed

+22
-29
lines changed

5 files changed

+22
-29
lines changed

Diff for: dist/index.css.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: example.css

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
padding: 0px;
2020
}
2121

22-
a.header, a.step, .intermediate-stops a {
22+
button.header, button.step, .intermediate-stops button {
23+
background: inherit;
2324
color: inherit;
25+
border: 0;
26+
text-align: inherit;
2427
text-decoration: none;
25-
}
26-
27-
.step {
2828
width: 100%;
2929
}

Diff for: lib/components/narrative/access-leg.js

+11-15
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default class AccessLeg extends Component {
1313
setActiveStep: PropTypes.func
1414
}
1515

16-
_onLegClick (e) {
16+
_onLegClick = (e) => {
1717
const {active, leg, index, setActiveLeg} = this.props
1818
if (active) {
1919
setActiveLeg(null)
@@ -36,35 +36,31 @@ export default class AccessLeg extends Component {
3636
<div
3737
key={index}
3838
className={`leg${active ? ' active' : ''}`}>
39-
<a
39+
<button
4040
className='header'
4141
onClick={this._onLegClick}
42-
tabIndex='0'
4342
>
4443
<span><Icon type={`caret-${active ? 'down' : 'right'}`} /></span>
4544
<span><b>{leg.mode}</b></span>
4645
{' '}
4746
<span className='leg-duration'>{formatDuration(leg.duration)}</span>
4847
{' '}
4948
<span className='leg-distance'>({distanceString(leg.distance)})</span>
50-
</a>
49+
</button>
5150
{active &&
5251
<div className='step-by-step'>
5352
<div className='access-leg'>
5453
{leg.steps.map((step, stepIndex) => {
5554
const stepIsActive = activeStep === stepIndex
5655
return (
57-
<div>
58-
<a
59-
key={stepIndex}
60-
className={`step ${stepIsActive ? 'active' : ''}`}
61-
onClick={(e) => this._onStepClick(e, step, stepIndex)}
62-
tabIndex='0'
63-
>
64-
<span className='step-distance'>{distanceString(step.distance)}</span>
65-
<span className='step-text'>{getStepInstructions(step)}</span>
66-
</a>
67-
</div>
56+
<button
57+
key={stepIndex}
58+
className={`step ${stepIsActive ? 'active' : ''}`}
59+
onClick={(e) => this._onStepClick(e, step, stepIndex)}
60+
>
61+
<span className='step-distance'>{distanceString(step.distance)}</span>
62+
<span className='step-text'>{getStepInstructions(step)}</span>
63+
</button>
6864
)
6965
})}
7066
</div>

Diff for: lib/components/narrative/narrative-itinerary.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,15 @@ export default class NarrativeItinerary extends Component {
3737
} = this.props
3838
return (
3939
<div className={`option itinerary${active ? ' active' : ''}`}>
40-
<a
40+
<button
4141
className='header'
4242
onClick={this._onHeaderClick}
43-
tabIndex='0'
4443
>
4544
<span className='title'>Itinerary {index + 1}</span>{' '}
4645
<span className='duration pull-right'>{formatDuration(itinerary.duration)}</span>{' '}
4746
<span className='arrivalTime'>{formatTime(itinerary.startTime)}{formatTime(itinerary.endTime)}</span>
4847
<ItinerarySummary itinerary={itinerary} />
49-
</a>
48+
</button>
5049
{active &&
5150
<div className='body'>
5251
<ItineraryDetails

Diff for: lib/components/narrative/transit-leg.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,13 @@ export default class TransitLeg extends Component {
3636
return (
3737
<div
3838
className={`leg${active ? ' active' : ''}`}>
39-
<a
39+
<button
4040
className={`header`}
4141
onClick={(e) => this._onLegClick(e, leg, index)}
42-
tabIndex='0'
4342
>
4443
{leg.realTime ? <Icon type='rss' /> : null}
4544
<span><Label>{leg.routeShortName}</Label> <b>{leg.routeLongName}</b> {leg.headsign}</span>
46-
</a>
45+
</button>
4746
<div className='step-by-step'>
4847
<div className='transit-leg'>
4948
<div className='from-stop'>
@@ -54,15 +53,14 @@ export default class TransitLeg extends Component {
5453
className='stop-count'
5554
style={{borderLeft: `3px solid ${getMapColor(leg.mode)}`}}
5655
>
57-
<a
56+
<button
5857
onClick={this._onClick}
59-
tabIndex='0'
6058
>
6159
<Icon type={`caret-${expanded ? 'down' : 'right'}`} />
6260
<span className='transit-duration'>{formatDuration(leg.duration)}</span>
6361
{' '}
6462
({numStops ? `${numStops} stops` : 'non-stop'})
65-
</a>
63+
</button>
6664
{leg.alerts &&
6765
<div>
6866
<div className='item'><Icon type='exclamation-circle' /> Information</div>

0 commit comments

Comments
 (0)