Skip to content

Commit b3814c6

Browse files
committed
formatting
1 parent df27873 commit b3814c6

File tree

4 files changed

+110
-105
lines changed

4 files changed

+110
-105
lines changed

src/custom.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ declare module 'custom-model-editor/src/index'
77
declare module 'config' {
88
import ol from 'ol/dist/ol'
99
import array = ol.array
10-
import {ProfileGroup, ProfileGroupMap} from "@/stores/QueryStore";
10+
import { ProfileGroup, ProfileGroupMap } from '@/stores/QueryStore'
1111
const routingApi: string
1212
const geocodingApi: string
1313
const defaultTiles: string

src/sidebar/SettingsBox.tsx

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,54 @@
1-
import {SetVehicleProfile, UpdateSettings} from '@/actions/Actions'
1+
import { SetVehicleProfile, UpdateSettings } from '@/actions/Actions'
22
import Dispatcher from '@/stores/Dispatcher'
33
import styles from '@/sidebar/SettingsBox.module.css'
4-
import {tr} from '@/translation/Translation'
4+
import { tr } from '@/translation/Translation'
55
import PlainButton from '@/PlainButton'
66
import OnIcon from '@/sidebar/toggle_on.svg'
77
import OffIcon from '@/sidebar/toggle_off.svg'
8-
import {useContext} from 'react'
9-
import {SettingsContext} from '@/contexts/SettingsContext'
10-
import {RoutingProfile} from '@/api/graphhopper'
11-
import {ProfileGroupMap} from "@/stores/QueryStore";
12-
import * as config from "config";
8+
import { useContext } from 'react'
9+
import { SettingsContext } from '@/contexts/SettingsContext'
10+
import { RoutingProfile } from '@/api/graphhopper'
11+
import { ProfileGroupMap } from '@/stores/QueryStore'
12+
import * as config from 'config'
1313

14-
export default function SettingsBox({profile}: { profile: RoutingProfile }) {
14+
export default function SettingsBox({ profile }: { profile: RoutingProfile }) {
1515
const settings = useContext(SettingsContext)
1616

1717
function setProfile(n: string) {
18-
Dispatcher.dispatch(new SetVehicleProfile({name: profile.name === n ? 'car' : n}))
18+
Dispatcher.dispatch(new SetVehicleProfile({ name: profile.name === n ? 'car' : n }))
1919
}
2020

2121
const groupName = ProfileGroupMap.create(config.profile_group_mapping)[profile.name]
2222
const group = config.profile_group_mapping[groupName]
2323
return (
2424
<div className={styles.parent}>
25-
{groupName && <span className={styles.groupProfileOptionsHeader}>
26-
{tr(groupName + "_settings")}
27-
</span>}
28-
{groupName && <div className={styles.settingsTable}>
29-
<div className={styles.groupProfileOptions}>
30-
{group.options.map((option) => (
31-
<div key={option.profile}>
32-
<input checked={profile.name === option.profile} type="radio" id={option.profile}
33-
name={groupName} value={option.profile}
34-
onClick={() => setProfile(option.profile)}/>
35-
<label htmlFor={option.profile}>
36-
{tr(groupName + '_settings_' + option.profile)}
37-
</label>
38-
</div>
39-
))}
25+
{groupName && <span className={styles.groupProfileOptionsHeader}>{tr(groupName + '_settings')}</span>}
26+
{groupName && (
27+
<div className={styles.settingsTable}>
28+
<div className={styles.groupProfileOptions}>
29+
{group.options.map(option => (
30+
<div key={option.profile}>
31+
<input
32+
checked={profile.name === option.profile}
33+
type="radio"
34+
id={option.profile}
35+
name={groupName}
36+
value={option.profile}
37+
onClick={() => setProfile(option.profile)}
38+
/>
39+
<label htmlFor={option.profile}>{tr(groupName + '_settings_' + option.profile)}</label>
40+
</div>
41+
))}
42+
</div>
4043
</div>
41-
</div>}
44+
)}
4245
<div className={styles.title}>{tr('settings')}</div>
4346
<div className={styles.settingsTable}>
4447
<SettingsToggle
4548
title={tr('distance_unit', [tr(settings.showDistanceInMiles ? 'mi' : 'km')])}
4649
enabled={settings.showDistanceInMiles}
4750
onClick={() =>
48-
Dispatcher.dispatch(new UpdateSettings({showDistanceInMiles: !settings.showDistanceInMiles}))
51+
Dispatcher.dispatch(new UpdateSettings({ showDistanceInMiles: !settings.showDistanceInMiles }))
4952
}
5053
/>
5154
</div>
@@ -56,23 +59,23 @@ export default function SettingsBox({profile}: { profile: RoutingProfile }) {
5659
title={tr('settings_gpx_export_trk')}
5760
enabled={settings.gpxExportTrk}
5861
onClick={() =>
59-
Dispatcher.dispatch(new UpdateSettings({gpxExportTrk: !settings.gpxExportTrk}))
62+
Dispatcher.dispatch(new UpdateSettings({ gpxExportTrk: !settings.gpxExportTrk }))
6063
}
6164
/>
6265

6366
<SettingsCheckbox
6467
title={tr('settings_gpx_export_rte')}
6568
enabled={settings.gpxExportRte}
6669
onClick={() =>
67-
Dispatcher.dispatch(new UpdateSettings({gpxExportRte: !settings.gpxExportRte}))
70+
Dispatcher.dispatch(new UpdateSettings({ gpxExportRte: !settings.gpxExportRte }))
6871
}
6972
/>
7073

7174
<SettingsCheckbox
7275
title={tr('settings_gpx_export_wpt')}
7376
enabled={settings.gpxExportWpt}
7477
onClick={() =>
75-
Dispatcher.dispatch(new UpdateSettings({gpxExportWpt: !settings.gpxExportWpt}))
78+
Dispatcher.dispatch(new UpdateSettings({ gpxExportWpt: !settings.gpxExportWpt }))
7679
}
7780
/>
7881
</div>
@@ -88,23 +91,22 @@ export default function SettingsBox({profile}: { profile: RoutingProfile }) {
8891
)
8992
}
9093

91-
function SettingsToggle({title, enabled, onClick}: { title: string; enabled: boolean; onClick: () => void }) {
94+
function SettingsToggle({ title, enabled, onClick }: { title: string; enabled: boolean; onClick: () => void }) {
9295
return (
9396
<div className={styles.settingsToggle} onClick={onClick}>
94-
<PlainButton style={{color: enabled ? '' : 'lightgray'}} className={styles.toggleButton}>
95-
{enabled ? <OnIcon/> : <OffIcon/>}
97+
<PlainButton style={{ color: enabled ? '' : 'lightgray' }} className={styles.toggleButton}>
98+
{enabled ? <OnIcon /> : <OffIcon />}
9699
</PlainButton>
97-
<div style={{color: enabled ? '#5b616a' : 'gray'}}>{title}</div>
100+
<div style={{ color: enabled ? '#5b616a' : 'gray' }}>{title}</div>
98101
</div>
99102
)
100103
}
101104

102-
function SettingsCheckbox({title, enabled, onClick}: { title: string; enabled: boolean; onClick: () => void }) {
105+
function SettingsCheckbox({ title, enabled, onClick }: { title: string; enabled: boolean; onClick: () => void }) {
103106
return (
104107
<div className={styles.settingsCheckbox} onClick={onClick}>
105-
<input type="checkbox" checked={enabled} onChange={ignore => {
106-
}}></input>
107-
<label style={{color: enabled ? '#5b616a' : 'gray'}}>{title}</label>
108+
<input type="checkbox" checked={enabled} onChange={ignore => {}}></input>
109+
<label style={{ color: enabled ? '#5b616a' : 'gray' }}>{title}</label>
108110
</div>
109111
)
110112
}

src/sidebar/search/routingProfiles/RoutingProfiles.tsx

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
import React, {useEffect, useState} from 'react'
1+
import React, { useEffect, useState } from 'react'
22
import styles from './RoutingProfiles.module.css'
33
import Dispatcher from '@/stores/Dispatcher'
4-
import {SetVehicleProfile} from '@/actions/Actions'
5-
import {RoutingProfile} from '@/api/graphhopper'
4+
import { SetVehicleProfile } from '@/actions/Actions'
5+
import { RoutingProfile } from '@/api/graphhopper'
66
import PlainButton from '@/PlainButton'
77
import Chevron from './chevron.svg'
8-
import {tr} from '@/translation/Translation'
8+
import { tr } from '@/translation/Translation'
99
import CustomModelBoxSVG from '@/sidebar/open_custom_model.svg'
10-
import {icons} from '@/sidebar/search/routingProfiles/profileIcons'
11-
import {ProfileGroup, ProfileGroupMap} from "@/stores/QueryStore";
10+
import { icons } from '@/sidebar/search/routingProfiles/profileIcons'
11+
import { ProfileGroup, ProfileGroupMap } from '@/stores/QueryStore'
1212

1313
export default function ({
14-
routingProfiles,
15-
profileGroupMapping,
16-
selectedProfile,
17-
showCustomModelBox,
18-
toggleCustomModelBox,
19-
customModelBoxEnabled,
20-
}: {
14+
routingProfiles,
15+
profileGroupMapping,
16+
selectedProfile,
17+
showCustomModelBox,
18+
toggleCustomModelBox,
19+
customModelBoxEnabled,
20+
}: {
2121
routingProfiles: RoutingProfile[]
2222
profileGroupMapping: Record<string, ProfileGroup>
2323
selectedProfile: RoutingProfile
@@ -91,7 +91,7 @@ export default function ({
9191
className={showCustomModelBox ? styles.enabledCMBox : styles.cmBox}
9292
onClick={toggleCustomModelBox}
9393
>
94-
<CustomModelBoxSVG/>
94+
<CustomModelBoxSVG />
9595
</PlainButton>
9696
<div className={styles.carousel}>
9797
<PlainButton
@@ -100,38 +100,43 @@ export default function ({
100100
onClick={() => move(false)}
101101
disabled={profileScroll <= 0}
102102
>
103-
<Chevron/>
103+
<Chevron />
104104
</PlainButton>
105105
<ul className={styles.profiles} id="profiles_carousel_items" onScroll={onScroll}>
106-
{routingProfiles.filter(profile => !profileToGroup[profile.name] || profile.name == profileToGroup[profile.name]).map(profile => {
107-
const isProfileSelected =
108-
profile.name === selectedProfile.name || profile.name == profileToGroup[selectedProfile.name]
109-
const className = isProfileSelected
110-
? styles.selectedProfile + ' ' + styles.profileBtn
111-
: styles.profileBtn
112-
return (
113-
<li key={profile.name}>
114-
<PlainButton
115-
title={tr(profile.name)}
116-
onClick={() => Dispatcher.dispatch(new SetVehicleProfile(profile))}
117-
className={className}
118-
>
119-
{customModelBoxEnabled && profile.name === selectedProfile.name && (
120-
<CustomModelBoxSVG className={styles.asIndicator}/>
121-
)}
122-
{getIcon(profile.name, customProfiles)}
123-
</PlainButton>
124-
</li>
106+
{routingProfiles
107+
.filter(
108+
profile => !profileToGroup[profile.name] || profile.name == profileToGroup[profile.name]
125109
)
126-
})}
110+
.map(profile => {
111+
const isProfileSelected =
112+
profile.name === selectedProfile.name ||
113+
profile.name == profileToGroup[selectedProfile.name]
114+
const className = isProfileSelected
115+
? styles.selectedProfile + ' ' + styles.profileBtn
116+
: styles.profileBtn
117+
return (
118+
<li key={profile.name}>
119+
<PlainButton
120+
title={tr(profile.name)}
121+
onClick={() => Dispatcher.dispatch(new SetVehicleProfile(profile))}
122+
className={className}
123+
>
124+
{customModelBoxEnabled && profile.name === selectedProfile.name && (
125+
<CustomModelBoxSVG className={styles.asIndicator} />
126+
)}
127+
{getIcon(profile.name, customProfiles)}
128+
</PlainButton>
129+
</li>
130+
)
131+
})}
127132
</ul>
128133
<PlainButton
129134
className={styles.chevron + ' ' + styles.flip}
130135
title={tr('next')}
131136
onClick={() => move()}
132137
disabled={profileScroll >= profileWidth}
133138
>
134-
<Chevron/>
139+
<Chevron />
135140
</PlainButton>
136141
</div>
137142
</div>
@@ -148,25 +153,25 @@ function getIcon(profileName: string, customProfiles: Record<string, Array<strin
148153
if (index >= 1) {
149154
let icon = icons[key.slice(0, -1)] // slice to remove underscore from key
150155
if (!icon) icon = icons.question_mark
151-
return key === '_' ? <NumberIcon number={index}/> : <IconWithBatchNumber baseIcon={icon} number={index}/>
156+
return key === '_' ? <NumberIcon number={index} /> : <IconWithBatchNumber baseIcon={icon} number={index} />
152157
}
153158
}
154159

155160
// this is the very last fallback, should never be reached
156161
return React.createElement(icons.question_mark)
157162
}
158163

159-
function IconWithBatchNumber({baseIcon, number}: { baseIcon: any; number: number }) {
164+
function IconWithBatchNumber({ baseIcon, number }: { baseIcon: any; number: number }) {
160165
return (
161166
<div className={styles.iconContainer}>
162167
{React.createElement(baseIcon)}
163168
<div className={styles.batchNumber}>
164-
<NumberIcon number={number}/>
169+
<NumberIcon number={number} />
165170
</div>
166171
</div>
167172
)
168173
}
169174

170-
function NumberIcon({number}: { number: number }) {
175+
function NumberIcon({ number }: { number: number }) {
171176
return <span>{number}</span>
172177
}

0 commit comments

Comments
 (0)