Skip to content

Commit 9a26861

Browse files
committed
Update Transition
Update the icons of the segment modes to use those of chaire-lib-frontend instead. Add a file mapping the modes to their icon files. Also update webpack to copy those icons to the `dist` directory.
1 parent b66cb84 commit 9a26861

File tree

7 files changed

+109
-20
lines changed

7 files changed

+109
-20
lines changed

example/demo_survey/webpack.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ module.exports = (env) => {
165165
new CopyWebpackPlugin(
166166
{
167167
patterns: [
168+
{
169+
context: path.join(__dirname, '..', '..', 'node_modules', 'chaire-lib-frontend', 'lib', 'assets'),
170+
from: "**/*",
171+
to: "",
172+
noErrorOnMissing: true
173+
},
168174
{
169175
context: path.join(__dirname, '..', '..', 'node_modules', 'evolution-frontend', 'lib', 'assets'),
170176
from: "**/*",

packages/evolution-common/src/services/questionnaire/sections/segments/__tests__/widgetSegmentMode.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import * as surveyHelper from '../../../../odSurvey/helpers';
1515
import { modeValues } from '../../../../baseObjects/attributeTypes/SegmentAttributes';
1616
import { modePreToModeMap, modeToModePreMap } from '../../../../odSurvey/types';
1717
import { shouldShowSameAsReverseTripQuestion, getPreviousTripSingleSegment } from '../helpers';
18+
import { modeToIconMapping } from '../modeIconMapping';
1819

1920
jest.mock('../helpers', () => ({
2021
shouldShowSameAsReverseTripQuestion: jest.fn().mockReturnValue(false),
@@ -45,7 +46,7 @@ describe('getModeWidgetConfig', () => {
4546
value: mode,
4647
label: expect.any(Function),
4748
conditional: expect.any(Function),
48-
iconPath: `/dist/images/modes_icons/${mode}.png`
49+
iconPath: modeToIconMapping[mode]
4950
})),
5051
validations: expect.any(Function),
5152
conditional: expect.any(Function)

packages/evolution-common/src/services/questionnaire/sections/segments/__tests__/widgetSegmentModePre.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,42 +43,42 @@ describe('getModePreWidgetConfig', () => {
4343
value: 'carDriver',
4444
label: expect.any(Function),
4545
conditional: expect.any(Function),
46-
iconPath: '/dist/images/modes_icons/carDriver.png'
46+
iconPath: '/dist/icons/modes/car/car_driver_without_passenger.svg'
4747
}),
4848
expect.objectContaining({
4949
value: 'carPassenger',
5050
label: expect.any(Function),
51-
iconPath: '/dist/images/modes_icons/carPassenger.png'
51+
iconPath: '/dist/icons/modes/car/car_passenger.svg'
5252
}),
5353
expect.objectContaining({
5454
value: 'walk',
5555
label: expect.any(Function),
56-
iconPath: '/dist/images/modes_icons/walk.png'
56+
iconPath: '/dist/icons/modes/foot/foot.svg'
5757
}),
5858
expect.objectContaining({
5959
value: 'bicycle',
6060
label: expect.any(Function),
61-
iconPath: '/dist/images/modes_icons/bicycle.png'
61+
iconPath: '/dist/icons/modes/bicycle/bicycle_with_rider.svg'
6262
}),
6363
expect.objectContaining({
6464
value: 'transit',
6565
label: expect.any(Function),
66-
iconPath: '/dist/images/modes_icons/bus.png'
66+
iconPath: '/dist/icons/modes/bus/bus_city.svg'
6767
}),
6868
expect.objectContaining({
6969
value: 'taxi',
7070
label: expect.any(Function),
71-
iconPath: '/dist/images/modes_icons/taxi.png'
71+
iconPath: '/dist/icons/modes/taxi/taxi_no_steering_wheel.svg'
7272
}),
7373
expect.objectContaining({
7474
value: 'other',
7575
label: expect.any(Function),
76-
iconPath: '/dist/images/modes_icons/other.png'
76+
iconPath: '/dist/icons/modes/other/air_balloon.svg'
7777
}),
7878
expect.objectContaining({
7979
value: 'dontKnow',
8080
label: expect.any(Function),
81-
iconPath: '/dist/images/modes_icons/dontKnow.png'
81+
iconPath: '/dist/icons/modes/other/question_mark.svg'
8282
})
8383
]),
8484
validations: expect.any(Function),
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* Copyright 2025, Polytechnique Montreal and contributors
3+
*
4+
* This file is licensed under the MIT License.
5+
* License text available at https://opensource.org/licenses/MIT
6+
*/
7+
8+
import { Mode } from '../../../baseObjects/attributeTypes/SegmentAttributes';
9+
10+
/**
11+
* Maps modes to their corresponding icon paths
12+
* This mapping associates each mode with an appropriate icon in the /dist/icons/modes/ directory
13+
*/
14+
export const modeToIconMapping: Record<Mode, string> = {
15+
// Walking and mobility assistance
16+
walk: '/dist/icons/modes/foot/foot.svg',
17+
wheelchair: '/dist/icons/modes/wheelchair/wheelchair.svg',
18+
mobilityScooter: '/dist/icons/modes/mobility_scooter/mobility_scooter.svg',
19+
20+
// Bicycles and small vehicles
21+
bicycle: '/dist/icons/modes/bicycle/bicycle_with_rider.svg',
22+
// FIXME Confirm this icon
23+
bicyclePassenger: '/dist/icons/modes/bicycle/bicycle_with_rider.svg',
24+
scooterElectric: '/dist/icons/modes/scooter/scooter_electric.svg',
25+
// FIXME Confirm this icon
26+
otherActiveMode: '/dist/icons/modes/kick_scooter/kick_scooter.svg',
27+
motorcycle: '/dist/icons/modes/motorcycle/motorcycle.svg',
28+
29+
// Cars
30+
carDriver: '/dist/icons/modes/car/car_driver_without_passenger.svg',
31+
carPassenger: '/dist/icons/modes/car/car_passenger.svg',
32+
33+
// Transit buses
34+
transitBus: '/dist/icons/modes/bus/bus_city.svg',
35+
transitBRT: '/dist/icons/modes/bus/bus_city.svg',
36+
transitSchoolBus: '/dist/icons/modes/bus/bus_city.svg',
37+
schoolBus: '/dist/icons/modes/bus/bus_school.svg',
38+
intercityBus: '/dist/icons/modes/bus/bus_intercity.svg',
39+
otherBus: '/dist/icons/modes/bus/bus_city.svg',
40+
41+
// Rail transit
42+
transitStreetCar: '/dist/icons/modes/tram/tram.svg',
43+
transitMonorail: '/dist/icons/modes/monorail/monorail.svg',
44+
transitRRT: '/dist/icons/modes/train/subway.svg',
45+
// FIXME Confirm this icon
46+
transitLRT: '/dist/icons/modes/train/train_electric.svg',
47+
// FIXME Confirm this icon
48+
transitLRRT: '/dist/icons/modes/train/train_electric.svg',
49+
transitHSR: '/dist/icons/modes/train/hsr.svg',
50+
transitRegionalRail: '/dist/icons/modes/train/train.svg',
51+
intercityTrain: '/dist/icons/modes/train/train.svg',
52+
53+
// Other transit modes
54+
transitFerry: '/dist/icons/modes/boat/ferry_without_car.svg',
55+
transitGondola: '/dist/icons/modes/gondola/gondola_small.svg',
56+
transitOnDemand: '/dist/icons/modes/minibus/minibus.svg',
57+
transitTaxi: '/dist/icons/modes/taxi/taxi_driver_with_passenger.svg',
58+
59+
// Taxis and paratransit
60+
taxi: '/dist/icons/modes/taxi/taxi_no_steering_wheel.svg',
61+
paratransit: '/dist/icons/modes/minibus/minibus_with_wheelchair.svg',
62+
63+
// Other transportation modes
64+
ferryWithCar: '/dist/icons/modes/boat/ferry_with_car.svg',
65+
plane: '/dist/icons/modes/airplane/airplane.svg',
66+
67+
// Other options
68+
other: '/dist/icons/modes/other/air_balloon.svg',
69+
dontKnow: '/dist/icons/modes/other/question_mark.svg',
70+
preferNotToAnswer: '/dist/icons/modes/other/air_balloon.svg'
71+
};
72+
73+
/**
74+
* Returns the appropriate icon path for a given mode
75+
* @param mode The transportation mode
76+
* @returns The path to the icon for the mode
77+
*/
78+
export const getModeIcon = (mode: Mode): string => {
79+
return modeToIconMapping[mode] || '/dist/icons/modes/other/air_balloon.svg';
80+
};

packages/evolution-common/src/services/questionnaire/sections/segments/widgetSegmentMode.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { getPreviousTripSingleSegment, shouldShowSameAsReverseTripQuestion } fro
1414
import { Mode, modeValues } from '../../../baseObjects/attributeTypes/SegmentAttributes';
1515
import { modePreToModeMap } from '../../../odSurvey/types';
1616
import { ParsingFunction, Person, Segment } from '../../types';
17+
import { getModeIcon } from './modeIconMapping';
1718

1819
// FIXME Move in helpers if required
1920
const conditionalPersonMayHaveDisability = (interview) => {
@@ -47,7 +48,7 @@ const getModeChoices = () =>
4748
const conditional = perModeConditionals[mode];
4849
return conditional ? conditional(interview, path) : true;
4950
},
50-
iconPath: `/dist/images/modes_icons/${mode}.png`
51+
iconPath: getModeIcon(mode)
5152
}));
5253

5354
export const getModeWidgetConfig = (

packages/evolution-common/src/services/questionnaire/sections/segments/widgetSegmentModePre.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import * as odHelpers from '../../../odSurvey/helpers';
1313
import config from 'chaire-lib-common/lib/config/shared/project.config';
1414
import { getPreviousTripSingleSegment, shouldShowSameAsReverseTripQuestion } from './helpers';
1515
import { Person, Segment } from '../../types';
16+
import { getModeIcon } from './modeIconMapping';
1617

1718
/** TODO Get a segment config in parameter to set the sort order and choices */
1819
const getModePreChoices = () => [
@@ -35,12 +36,12 @@ const getModePreChoices = () => [
3536
}
3637
return drivingLicenseOwnership === 'yes';
3738
},
38-
iconPath: '/dist/images/modes_icons/carDriver.png'
39+
iconPath: getModeIcon('carDriver')
3940
},
4041
{
4142
value: 'carPassenger',
4243
label: (t: TFunction) => t(['customSurvey:segments:modePre:CarPassenger', 'segments:modePre:CarPassenger']),
43-
iconPath: '/dist/images/modes_icons/carPassenger.png'
44+
iconPath: getModeIcon('carPassenger')
4445
},
4546
{
4647
value: 'walk',
@@ -51,38 +52,38 @@ const getModePreChoices = () => [
5152
? t(['customSurvey:segments:modePre:WalkOrMobilityHelp', 'segments:modePre:WalkOrMobilityHelp'])
5253
: t(['customSurvey:segments:modePre:Walk', 'segments:modePre:Walk']);
5354
},
54-
iconPath: '/dist/images/modes_icons/walk.png'
55+
iconPath: getModeIcon('walk')
5556
},
5657
{
5758
value: 'bicycle',
5859
label: (t: TFunction) => t(['customSurvey:segments:modePre:Bicycle', 'segments:modePre:Bicycle']),
59-
iconPath: '/dist/images/modes_icons/bicycle.png'
60+
iconPath: getModeIcon('bicycle')
6061
},
6162
{
6263
value: 'transit',
6364
label: (t: TFunction) => t(['customSurvey:segments:modePre:Transit', 'segments:modePre:Transit']),
64-
iconPath: '/dist/images/modes_icons/bus.png'
65+
iconPath: getModeIcon('transitBus')
6566
},
6667
{
6768
value: 'taxi',
6869
label: (t: TFunction) => t(['customSurvey:segments:modePre:Taxi', 'segments:modePre:Taxi']),
69-
iconPath: '/dist/images/modes_icons/taxi.png'
70+
iconPath: getModeIcon('taxi')
7071
},
7172
{
7273
value: 'other',
7374
label: (t: TFunction) => t(['customSurvey:segments:modePre:Other', 'segments:modePre:Other']),
74-
iconPath: '/dist/images/modes_icons/other.png'
75+
iconPath: getModeIcon('other')
7576
},
7677
{
7778
value: 'dontKnow',
7879
label: (t: TFunction) => t(['customSurvey:segments:modePre:DontKnow', 'segments:modePre:DontKnow']),
79-
iconPath: '/dist/images/modes_icons/dontKnow.png'
80+
iconPath: getModeIcon('dontKnow')
8081
},
8182
{
8283
value: 'preferNotToAnswer',
8384
label: (t: TFunction) =>
8485
t(['customSurvey:segments:modePre:PreferNotToAnswer', 'segments:modePre:PreferNotToAnswer']),
85-
iconPath: '/dist/images/modes_icons/preferNotToAnswer.png'
86+
iconPath: getModeIcon('preferNotToAnswer')
8687
}
8788
];
8889

transition

Submodule transition updated 143 files

0 commit comments

Comments
 (0)