Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
amy-corson-ibigroup committed Aug 30, 2024
1 parent d6c983d commit 6bee58a
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 31 deletions.
1 change: 1 addition & 0 deletions i18n/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ components:
moreOptions: More options
saveAndReturn: Save and return
saved: Saved
submodeSelectorLabel: Select travel modes and submodes
tripOptions: Trip Options
BatchSettings:
destination: destination
Expand Down
14 changes: 6 additions & 8 deletions lib/components/form/advanced-settings-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ const StyledTransparentButton = styled.button`
margin-bottom: 5px;
`

const AdvancedSettingsButton = ({ onClick }: Props): JSX.Element => {
return (
<StyledTransparentButton onClick={onClick}>
<FormattedMessage id="components.BatchSearchScreen.moreOptions" />
<ArrowRight size={18} />
</StyledTransparentButton>
)
}
const AdvancedSettingsButton = ({ onClick }: Props): JSX.Element => (
<StyledTransparentButton onClick={onClick}>
<FormattedMessage id="components.BatchSearchScreen.moreOptions" />
<ArrowRight size={18} />
</StyledTransparentButton>
)

export default AdvancedSettingsButton
17 changes: 10 additions & 7 deletions lib/components/form/advanced-settings-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ import DateTimeModal from './date-time-modal'
const PanelOverlay = styled.div`
height: 100%;
left: 0;
overflow-y: auto;
padding: 1.5em;
position: absolute;
top: 0;
width: 100%;
z-index: 100;
overflow-y: auto;
`

const GlobalSettingsContainer = styled.div`
Expand All @@ -65,8 +65,8 @@ const CloseButton = styled.button`
const HeaderContainer = styled.div`
align-items: center;
display: flex;
justify-content: space-between;
height: 30px;
justify-content: space-between;
`

const Subheader = styled.h2`
Expand Down Expand Up @@ -211,7 +211,9 @@ const AdvancedSettingsPanel = ({
<AdvancedModeSubsettingsContainer
accentColor={accentColor}
fillModeIcons
label="test"
label={intl.formatMessage({
id: 'components.BatchSearchScreen.submodeSelectorLabel'
})}
modeButtons={processedModeButtons}
onSettingsUpdate={onSettingsUpdate(setQueryParam)}
onToggleModeButton={setModeButton(
Expand Down Expand Up @@ -243,10 +245,11 @@ const queryParamConfig = { modeButtons: DelimitedArrayParam }

const mapStateToProps = (state: AppReduxState) => {
const urlSearchParams = new URLSearchParams(state.router.location.search)
const { modes } = state.otp.config
const modeSettingValues = generateModeSettingValues(
urlSearchParams,
state.otp?.modeSettingDefinitions || [],
state.otp.config.modes?.initialState?.modeSettingValues || {}
state.otp.modeSettingDefinitions || [],
modes?.initialState?.modeSettingValues || {}
)
return {
currentQuery: state.otp.currentQuery,
Expand All @@ -255,9 +258,9 @@ const mapStateToProps = (state: AppReduxState) => {
decodeQueryParams(queryParamConfig, {
modeButtons: urlSearchParams.get('modeButtons')
})?.modeButtons?.filter((mb): mb is string => mb !== null) ||
state.otp.config?.modes?.initialState?.enabledModeButtons ||
modes?.initialState?.enabledModeButtons ||
[],
modeButtonOptions: state.otp.config?.modes?.modeButtons || [],
modeButtonOptions: modes?.modeButtons || [],
modeSettingDefinitions: state.otp?.modeSettingDefinitions || [],
modeSettingValues
}
Expand Down
7 changes: 4 additions & 3 deletions lib/components/form/batch-settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ function BatchSettings({
// TODO: Typescript
const mapStateToProps = (state: any) => {
const urlSearchParams = new URLSearchParams(state.router.location.search)
const { modes } = state.otp.config
return {
activeSearch: getActiveSearch(state),
currentQuery: state.otp.currentQuery,
Expand All @@ -141,11 +142,11 @@ const mapStateToProps = (state: any) => {
decodeQueryParams(modesQueryParamConfig, {
modeButtons: urlSearchParams.get('modeButtons')
})?.modeButtons ||
state.otp.config?.modes?.initialState?.enabledModeButtons ||
modes?.initialState?.enabledModeButtons ||
{},
fillModeIcons: state.otp.config.itinerary?.fillModeIcons,
modeButtonOptions: state.otp.config?.modes?.modeButtons || [],
spacedOutModeSelector: state.otp?.config?.modes?.spacedOut
modeButtonOptions: modes?.modeButtons || [],
spacedOutModeSelector: modes?.spacedOut
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/components/form/styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ const transitionMixin = css`
`

const wipeOutMixin = (offset: number) => css`
transform: translateX(${offset}px);
opacity: 0;
transform: translateX(${offset}px);
`
const wipeInMixin = css`
opacity: 1;
Expand Down
16 changes: 8 additions & 8 deletions lib/components/form/util.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export const modesQueryParamConfig = { modeButtons: DelimitedArrayParam }
export const populateSettingWithIcon =
(ModeIcon: React.ComponentType<{ mode?: string; width?: number }>) =>
// eslint-disable-next-line react/display-name
(msd: ModeSetting): ModeSetting => ({
...msd,
icon: <ModeIcon mode={msd.iconName} width={16} />
(modeSetting: ModeSetting): ModeSetting => ({
...modeSetting,
icon: <ModeIcon mode={modeSetting.iconName} width={16} />
})

export const addModeButtonIcon =
Expand All @@ -34,17 +34,17 @@ export const addModeButtonIcon =

export const addCustomSettingLabels =
(intl: IntlShape) =>
(msd: ModeSetting): ModeSetting => {
(modeSetting: ModeSetting): ModeSetting => {
let modeLabel
// If we're using route mode overrides, make sure we're using the custom mode name
if (msd.type === 'SUBMODE') {
modeLabel = msd.overrideMode || msd.addTransportMode.mode
if (modeSetting.type === 'SUBMODE') {
modeLabel = modeSetting.overrideMode || modeSetting.addTransportMode.mode
return {
...msd,
...modeSetting,
label: getFormattedMode(modeLabel, intl)
}
}
return msd
return modeSetting
}

/**
Expand Down
8 changes: 4 additions & 4 deletions lib/components/mobile/batch-search-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ const { SET_FROM_LOCATION, SET_TO_LOCATION } = MobileScreens
const MobileSearchSettings = styled.div<{ advancedPanelOpen: boolean }>`
background: white;
box-shadow: 3px 0px 12px #00000052;
position: fixed;
top: 50px;
height: ${(props) =>
props.advancedPanelOpen ? 'calc(100% - 50px)' : '230px'};
left: 0;
position: fixed;
right: 0;
top: 50px;
transition: all 200ms ease;
height: ${(props) =>
props.advancedPanelOpen ? 'calc(100% - 50px)' : '230px'};
/* Must appear under the 'hamburger' dropdown which has z-index of 1000. */
z-index: 999;
`
Expand Down
29 changes: 29 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2416,6 +2416,24 @@
lodash.isequal "^4.5.0"
qs "^6.9.1"

"@opentripplanner/core-utils@^11.4.1":
version "11.4.4"
resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-11.4.4.tgz#11c1be91a5e90afda4fc265831c761d3e044d933"
integrity sha512-WKhOuG7Q+Yxdm+P5MPmJyXndx+JUtGn44GTeilOnUqDdO8lTLTvqqt0hYeEWjA77jWP0u8tG7fAAsft8IZn2cg==
dependencies:
"@conveyal/lonlat" "^1.4.1"
"@mapbox/polyline" "^1.1.0"
"@opentripplanner/geocoder" "^3.0.2"
"@styled-icons/foundation" "^10.34.0"
"@turf/along" "^6.0.1"
chroma-js "^2.4.2"
date-fns "^2.28.0"
date-fns-tz "^1.2.2"
graphql "^16.6.0"
lodash.clonedeep "^4.5.0"
lodash.isequal "^4.5.0"
qs "^6.9.1"

"@opentripplanner/core-utils@^11.4.3":
version "11.4.3"
resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-11.4.3.tgz#4655f9a3bef1977e53abd81a4a0eae966f977c60"
Expand Down Expand Up @@ -2465,6 +2483,17 @@
isomorphic-mapzen-search "^1.6.1"
lodash.memoize "^4.1.2"

"@opentripplanner/geocoder@^3.0.2":
version "3.0.2"
resolved "https://registry.yarnpkg.com/@opentripplanner/geocoder/-/geocoder-3.0.2.tgz#2c7618947d1d9b082bd39d037327c9cf23282782"
integrity sha512-pl7tCiodex0hXWKLH3WE+I+HzoSgOOWp9kR3xMcuRiE5g6k2JXNneoD/ZfSS1n6Oorxcjv3U2DbMSXT2j/39dQ==
dependencies:
"@conveyal/geocoder-arcgis-geojson" "^0.0.3"
"@conveyal/lonlat" "^1.4.1"
"@leeoniya/ufuzzy" "^1.0.14"
isomorphic-mapzen-search "^1.6.1"
lodash.memoize "^4.1.2"

"@opentripplanner/humanize-distance@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@opentripplanner/humanize-distance/-/humanize-distance-1.2.0.tgz#71cf5d5d1b756adef15300edbba0995ccd4b35ee"
Expand Down

0 comments on commit 6bee58a

Please sign in to comment.