Skip to content

Commit 040ae9d

Browse files
committed
highlight hints via orange/red; red if hike_rating>=5
1 parent a023c81 commit 040ae9d

File tree

3 files changed

+252
-169
lines changed

3 files changed

+252
-169
lines changed

src/sidebar/RoutingResult.module.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@
183183
color: black;
184184
}
185185

186+
.redButton {
187+
color: red !important;
188+
}
189+
190+
.orangeButton {
191+
color: orange !important;
192+
}
193+
186194
.routeHintButton,
187195
.routeHintButton span {
188196
color: gray;

src/sidebar/RoutingResults.tsx

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,17 @@ function RoutingResult({
7676
)
7777
const ferryInfo = getInfoFor(path.points, path.details.road_environment, s => s === 'ferry')
7878
const accessCondInfo = getInfoFor(path.points, path.details.access_conditional, s => s != null && s.length > 0)
79+
7980
const footAccessCondInfo = !ApiImpl.isFootLike(profile)
8081
? new RouteInfo()
8182
: getInfoFor(path.points, path.details.foot_conditional, s => s != null && s.length > 0)
83+
8284
const hikeRatingInfo = !ApiImpl.isFootLike(profile)
8385
? new RouteInfo()
84-
: getInfoFor(path.points, path.details.hike_rating, s => s > 1)
86+
: getInfoFor(path.points, path.details.hike_rating, s => s > 1 && s < 5)
87+
const dangerousHikeRatingInfo = !ApiImpl.isFootLike(profile)
88+
? new RouteInfo()
89+
: getInfoFor(path.points, path.details.hike_rating, s => s >= 5)
8590

8691
const bikeAccessCondInfo = !ApiImpl.isBikeLike(profile)
8792
? new RouteInfo()
@@ -137,6 +142,7 @@ function RoutingResult({
137142
getOffBikeInfo.distance > 0 ||
138143
mtbRatingInfo.distance > 0 ||
139144
hikeRatingInfo.distance > 0 ||
145+
dangerousHikeRatingInfo.distance > 0 ||
140146
steepInfo.distance > 0
141147

142148
return (
@@ -194,6 +200,7 @@ function RoutingResult({
194200
selected={selectedRH}
195201
segments={fordInfo.segments}
196202
values={[]}
203+
addClassName={styles.orangeButton}
197204
/>
198205
<RHButton
199206
setDescription={b => setDescriptionRH(b)}
@@ -299,7 +306,7 @@ function RoutingResult({
299306
/>
300307
<RHButton
301308
setDescription={b => setDescriptionRH(b)}
302-
description={tr('way_contains', [tr('challenging_sections')])}
309+
description={tr('challenging_sections')}
303310
setType={t => setSelectedRH(t)}
304311
type={'mtb_rating'}
305312
child={<DangerousIcon />}
@@ -310,10 +317,11 @@ function RoutingResult({
310317
selected={selectedRH}
311318
segments={mtbRatingInfo.segments}
312319
values={mtbRatingInfo.values}
320+
addClassName={styles.orangeButton}
313321
/>
314322
<RHButton
315323
setDescription={b => setDescriptionRH(b)}
316-
description={tr('way_contains', [tr('challenging_sections')])}
324+
description={tr('challenging_sections')}
317325
setType={t => setSelectedRH(t)}
318326
type={'hike_rating'}
319327
child={<DangerousIcon />}
@@ -324,6 +332,22 @@ function RoutingResult({
324332
selected={selectedRH}
325333
segments={hikeRatingInfo.segments}
326334
values={hikeRatingInfo.values}
335+
addClassName={styles.orangeButton}
336+
/>
337+
<RHButton
338+
setDescription={b => setDescriptionRH(b)}
339+
description={tr('dangerous_sections')}
340+
setType={t => setSelectedRH(t)}
341+
type={'hike_rating'}
342+
child={<DangerousIcon />}
343+
value={
344+
dangerousHikeRatingInfo.distance > 0 &&
345+
metersToShortText(dangerousHikeRatingInfo.distance, showDistanceInMiles)
346+
}
347+
selected={selectedRH}
348+
segments={dangerousHikeRatingInfo.segments}
349+
values={dangerousHikeRatingInfo.values}
350+
addClassName={styles.redButton}
327351
/>
328352
<RHButton
329353
setDescription={b => setDescriptionRH(b)}
@@ -360,6 +384,7 @@ function RoutingResult({
360384
selected={selectedRH}
361385
segments={trunkInfo.segments}
362386
values={[]}
387+
addClassName={styles.orangeButton}
363388
/>
364389
<RHButton
365390
setDescription={b => setDescriptionRH(b)}
@@ -412,12 +437,13 @@ function RHButton(p: {
412437
selected: string
413438
segments: Coordinate[][]
414439
values: string[]
440+
addClassName?: string
415441
}) {
416442
let [index, setIndex] = useState(0)
417443
if (p.value === false) return null
418444
return (
419445
<PlainButton
420-
className={p.selected == p.type ? styles.selectedRouteHintButton : styles.routeHintButton}
446+
className={(p.addClassName || "") + " " + (p.selected == p.type ? styles.selectedRouteHintButton : styles.routeHintButton)}
421447
onClick={() => {
422448
p.setType(p.type)
423449

0 commit comments

Comments
 (0)