Skip to content

Commit 761c810

Browse files
committed
compact comments
1 parent d7c30a1 commit 761c810

8 files changed

Lines changed: 20 additions & 46 deletions

File tree

src/pages/components/map-related/MapLayers/MapIndexLayer.stories.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ const meta = {
1010
title: 'Map/Layers/MapIndexLayer',
1111
component: MapIndexLayer,
1212
parameters: { layout: 'centered' },
13-
// Every legend rule in map.scss is nested under `.map-info` — the wrapper MapShell puts round
14-
// a map page — and the box chrome comes from the `.map-legend` slot inside it. Mounted bare,
15-
// the legend gets none of it: the grid never applies and the glyphs render at their intrinsic
16-
// size rather than 20px. So the decorator reproduces MapShell's two levels, and the wrapper is
17-
// given a map-sized box because `.map-legend` is absolutely positioned within it.
13+
// Every legend rule in map.scss is nested under `.map-info` and its `.map-legend` slot, so
14+
// mounted bare the legend gets no grid and glyphs at their intrinsic size. Reproduce MapShell's
15+
// two levels; the wrapper needs a size because `.map-legend` is absolutely positioned in it.
1816
decorators: [
1917
(Story) => (
2018
<div className="map-info" style={{ width: 340, height: 210 }}>

src/pages/components/map-related/MapSpeedIndex.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ import {
99

1010
/**
1111
* Key to the ping markers' speed ramp: the compass badge for a bus reported standing, then an
12-
* arrow per band, growing as it goes faster.
13-
*
14-
* Size carries the ramp rung by rung, but it can only run one way — the pings a rider cares
15-
* about, the slow ones, come out the smallest marks on the map. So colour splits the ramp in
16-
* half against the grain: red on the slow bands and on the standing badge's rim, the app's
17-
* colour for a bad result, leaving the fast half in plain ink to recede.
12+
* arrow per band, growing as it goes faster and red across the slow half.
1813
*/
1914
export function MapSpeedIndex() {
2015
const { t } = useTranslation()

src/pages/components/map-related/map-types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { SiriVehicleLocationWithRelatedPydanticModel } from '@hasadna/open-bus-api-client'
22
import { BusStop } from 'src/model/busStop'
33

4-
/** One per concurrent ride on the map, cycled. Deliberately no red: red is the ping speed ramp's
5-
* (`.ping-arrow--slow`), and red arrows over a red line read as neither. */
4+
/** One per concurrent ride on the map, cycled. Deliberately no red — that belongs to the ping
5+
* speed ramp (`.ping-arrow--slow`), and red arrows over a red line read as neither. */
66
export const ROUTE_COLORS = ['#f97316', '#3b82f6', '#22c55e', '#a855f7', '#0891b2']
77

88
export interface Point {

src/pages/components/map-related/mapMarkers.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ describe('vehicleBearingMarker', () => {
3535

3636
expect(scale(5)).toBeLessThan(scale(25))
3737
expect(scale(25)).toBeLessThan(scale(FAST))
38-
// colour says it a second way, and the only way that does not shrink with the arrow
3938
expect(html(0, 5)).toContain('ping-arrow--slow')
4039
expect(html(0, FAST)).not.toContain('ping-arrow--slow')
4140
})

src/pages/components/map-related/mapMarkers.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
/**
22
* Every Leaflet icon and line colour the map draws with, and nothing that renders.
33
*
4-
* They live here rather than in `MapContent` because the layers `MapContent` renders need them
5-
* too: with the definitions in `MapContent`, `MapContent → MapLayers/* → MapContent` was an
6-
* import cycle (two of them, which `madge --circular` fails CI on). A module of leaf values that
7-
* imports no component breaks it — the layers and `MapContent` both depend on this, and it
8-
* depends on neither.
4+
* Apart from `MapContent` because the layers it renders need these too, which made
5+
* `MapContent → MapLayers/* → MapContent` an import cycle — `madge --circular` fails CI on it.
6+
* Keep this module free of component imports.
97
*/
108
import { DivIcon, Icon, IconOptions } from 'leaflet'
119
import {

src/pages/components/map-related/vehicleBearingGlyph.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ describe('arrowSvgMarkup', () => {
7676
expect(arrowSvgMarkup(0, TOP)).not.toContain('ping-arrow--slow')
7777
})
7878

79-
// The regression this ramp's floor exists to prevent: the slowest band is both the smallest
80-
// arrow and the one worth finding, and below ~0.6 it is a speck between its neighbours.
8179
it('keeps the slowest arrow big enough to find, not merely big enough to draw', () => {
8280
const scale = Number(/scale\(([\d.]+)\)/.exec(arrowSvgMarkup(0, 0))![1])
8381

@@ -96,7 +94,6 @@ describe('standingSvgMarkup', () => {
9694
expect(standingSvgMarkup(undefined)).toContain('ping-badge')
9795
})
9896

99-
// A parked bus is a speed reading and joins the red family; the end of a ride is not.
10097
it('rims the parked bus in the slow ramp colour, which the ride-end badge must not take', () => {
10198
expect(standingSvgMarkup(0)).toContain('ping-badge--standing')
10299
expect(rideEndSvgMarkup()).not.toContain('ping-badge--standing')

src/pages/components/map-related/vehicleBearingGlyph.tsx

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
*
66
* The two badges take the ride-start marker's shape (`.bus-icon-circle`: a white disc in a
77
* coloured rim, the same in both themes), so the things that bookend or interrupt a ride read as
8-
* one family and the arrows stay the only bare shapes on the map. Only the rim colour separates
9-
* them: the ride-end badge keeps the primary rim, while the standing badge takes the slow arrows'
10-
* red, because a parked bus is a speed reading and the end of a ride is not.
8+
* one family. Only the rim colour separates them — the standing badge takes the slow arrows' red,
9+
* the ride-end badge keeps the primary rim.
1110
*
1211
* They live apart from `MapContent` so the legend can render them without pulling Leaflet in,
1312
* and so both renderings — Leaflet's HTML string and the legend's element — come off one set of
@@ -61,23 +60,17 @@ export const STANDING_LABEL = '0'
6160
/** How the arrow grows across the bands, as a factor of the glyph: evenly spaced, so adding a
6261
* band re-spaces the ramp instead of squeezing it in at one end. The top of the range keeps the
6362
* fastest arrow inside the viewBox's inscribed circle, so no bearing clips a corner off it. The
64-
* bottom is a legibility floor rather than a ramp choice: the ramp would happily start lower,
65-
* but at 0.46 the slowest arrow came out ~8px across and was lost among the pings either side. */
63+
* bottom is a legibility floor, not a ramp choice: at 0.46 the slowest arrow was ~8px across and
64+
* lost among the pings either side of it. */
6665
const BAND_SCALE_MIN = 0.62
6766
const BAND_SCALE_MAX = 0.96
6867
const bandScale = (band: number) =>
6968
BAND_SCALE_MIN + ((BAND_SCALE_MAX - BAND_SCALE_MIN) * band) / (SPEED_BANDS.length - 1)
7069

7170
/**
7271
* Size alone can't carry six bands at ~14px, so colour splits the ramp in two and the size then
73-
* places an arrow within its half. The slow half is red — what a bad result is painted
74-
* everywhere else in the app — and the fast half stays the map's default ink.
75-
*
76-
* Colour rather than fill, because size runs against the point of the map here: a bus stuck in
77-
* traffic is the ping worth finding and also the one drawn smallest, and stacking it on top
78-
* ({@link bearingZIndex}) only stops it being covered, it does not make it easier to spot.
79-
* Colour is the one channel that doesn't shrink with the arrow.
80-
*
72+
* places an arrow within its half. Colour rather than fill because it is the one channel that
73+
* doesn't shrink with the arrow, and the slow half — the pings worth finding — is the small end.
8174
* The colours live in `map.scss`; the markup carries geometry alone.
8275
*/
8376
const bandClass = (band: number) =>
@@ -123,10 +116,8 @@ export const arrowSvgMarkup = (deg: number, band: number) =>
123116
`<path class="${bandClass(band)}" d="${ARROW_PATH}" transform="${bandTransform(deg, band)}"/>` +
124117
`</svg>`
125118

126-
/** The standing badge's rim wears the slow ramp's red, so a parked bus reads as part of the same
127-
* family as the crawling arrows. The ride-end badge keeps the plain rim — it bookends the ride
128-
* rather than reporting a speed — which is why this is a modifier and not a change to
129-
* `.ping-badge`. Named here so the legend's element and Leaflet's markup can't drift apart. */
119+
/** A modifier rather than a change to `.ping-badge`, which the ride-end badge shares. Named so
120+
* the legend's element and Leaflet's markup can't drift apart. */
130121
const STANDING_DISC_CLASS = 'ping-badge ping-badge--standing'
131122

132123
const discMarkup = (

src/resources/map.scss

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
// theme from a stylesheet, so it comes from here.
44
$primary: #1976d2;
55

6-
// The speed ramp's red, worn by the slow arrows and by the standing badge's rim. Red is what the
7-
// app paints a bad result everywhere else ($terrible-result, the far end of GpsCoverageStrip's
8-
// gap ramp), and ROUTE_COLORS deliberately holds none, so it can't be read as a ride's own line.
6+
// The speed ramp's red, worn by the slow arrows and the standing badge's rim. ROUTE_COLORS
7+
// deliberately holds no red, so it can't be read as a ride's own line colour.
98
$slow-ping: #c1121f;
109

1110
// Shared translucency for map overlay controls so they read consistently across
@@ -334,8 +333,7 @@ pre {
334333
stroke: $primary;
335334
stroke-width: 1.8;
336335

337-
// A parked bus is the slowest reading on the ramp, so its rim joins the slow arrows' red. The
338-
// ride-end badge keeps the primary rim: it bookends the ride rather than reporting a speed.
336+
// Only the standing badge: the ride-end badge shares `.ping-badge` and keeps the primary rim.
339337
&--standing {
340338
stroke: $slow-ping;
341339
}
@@ -359,8 +357,6 @@ pre {
359357
// arrows exactly where they are already hardest to see.
360358
vector-effect: non-scaling-stroke;
361359

362-
// Every arrow is solid; only the fill colour changes across the ramp, so the slow half is the
363-
// one that catches the eye and the fast half recedes into the same ink as the map's own labels.
364360
&--slow {
365361
fill: $slow-ping;
366362
}

0 commit comments

Comments
 (0)