Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced Trip Form #1249

Merged
merged 96 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
12692f9
Create advanced settings panel
amy-corson-ibigroup Jun 10, 2024
3374486
Merge branch 'dev' into advanced-trip-form-panel
amy-corson-ibigroup Jun 10, 2024
6bfcf27
refactor(advanced-settings-panel): clean up css, add focus trap, add …
amy-corson-ibigroup Jun 10, 2024
9a5f4af
Fix animation timing
amy-corson-ibigroup Jun 10, 2024
88b3038
Close advanced panel on page change
amy-corson-ibigroup Jun 10, 2024
e5c0192
create PANEL_ANIMATION_TIMING variable
amy-corson-ibigroup Jun 10, 2024
c80a8ba
Smooth animation
amy-corson-ibigroup Jun 10, 2024
8fbabd2
revert example.css changes
amy-corson-ibigroup Jun 10, 2024
5f4268c
Add AdvancedModePanel to mobile search
amy-corson-ibigroup Jun 10, 2024
f2462aa
fix(batch-routing-panel): Remove itins and user settings if advanced …
amy-corson-ibigroup Jun 10, 2024
ab198f1
Clean up animation + add prefersReducedMotion util
amy-corson-ibigroup Jun 10, 2024
3690005
Clean up comments, tweak css
amy-corson-ibigroup Jun 10, 2024
31520af
Sort css
amy-corson-ibigroup Jun 10, 2024
a6ca364
update animation from homepage to advanced settings
amy-corson-ibigroup Jun 11, 2024
75f8a7f
messy first pass of bringing in advanced settings from otp ui
daniel-heppner-ibigroup Jun 14, 2024
fc07097
add react-transition-group to advanced panel
amy-corson-ibigroup Jun 14, 2024
e7f34c4
Merge branch 'advanced-trip-form-panel' of https://github.com/opentri…
amy-corson-ibigroup Jun 14, 2024
9af5feb
Fix innerRef
amy-corson-ibigroup Jun 14, 2024
55a26dc
cleanup and address PR feedback
amy-corson-ibigroup Jun 14, 2024
5eef8ff
Add react-transition-group for mobile screens
amy-corson-ibigroup Jun 14, 2024
96e4bc8
fix bad merge
amy-corson-ibigroup Jun 14, 2024
5eb6f41
upgrade trip-form downgrade animate height
daniel-heppner-ibigroup Jun 15, 2024
5551187
finish wiring up advanced settings pane
daniel-heppner-ibigroup Jun 15, 2024
58e1258
tweak styling and remove focustrapwrapper
amy-corson-ibigroup Jun 17, 2024
e4ee080
Update accentColor for AdvancedModeSubsettingsContainer and update al…
amy-corson-ibigroup Jun 18, 2024
ac1020e
Turn h2 into subheader component
amy-corson-ibigroup Jun 18, 2024
5a359ff
Create toggle and global settings
amy-corson-ibigroup Jun 19, 2024
96555b8
fix passing accent color to AdvancedModeSubsettingsContainer
amy-corson-ibigroup Jun 19, 2024
35b0062
fix passing accent color to AdvancedModeSubsettingsContainer
amy-corson-ibigroup Jun 19, 2024
623b5ca
remove unnecessary classname from subheader
amy-corson-ibigroup Jun 19, 2024
cb142d0
update otp-ui and animation durations
amy-corson-ibigroup Jun 21, 2024
c7d2b92
remove unecessary closepanel function
amy-corson-ibigroup Jun 21, 2024
046bc16
Merge pull request #1230 from opentripplanner/advanced-trip-form-panel
amy-corson-ibigroup Jun 21, 2024
8a65b46
Merge branch 'master-trip-form-update' into connected-toggle-checkboxes
amy-corson-ibigroup Jun 21, 2024
4f3ccf0
remove unnecessary comment
amy-corson-ibigroup Jun 21, 2024
13edd96
fix: overflow bug on itinerary results
amy-corson-ibigroup Jun 25, 2024
8d75fb9
Make subheaders invisible and address feedback
amy-corson-ibigroup Jul 1, 2024
077876d
adjust form for if there are no processedGlobalSettings
amy-corson-ibigroup Jul 1, 2024
71128ac
Add Plan trip and back buttons to advanced trip form
amy-corson-ibigroup Jul 2, 2024
69d70c6
Merge pull request #1240 from opentripplanner/connected-toggle-checkb…
amy-corson-ibigroup Jul 3, 2024
176145f
address PR comments
daniel-heppner-ibigroup Jul 9, 2024
590ab8d
Merge branch 'master-trip-form-update' into plan-trip-button-advanced…
daniel-heppner-ibigroup Jul 9, 2024
f96bd54
fix issue with base color race condition
daniel-heppner-ibigroup Jul 9, 2024
d390bb7
refactor(AdvancedSettingsPanel): sort imports
josh-willis-arcadis Jul 10, 2024
52906bc
fix when toast announces changes saved
amy-corson-ibigroup Jul 10, 2024
ee9e579
fix width on advanced-panel buttons
amy-corson-ibigroup Jul 10, 2024
b2f8647
fix height container bug AGAIN
amy-corson-ibigroup Jul 10, 2024
be55193
use variables in toggle checkboxes
amy-corson-ibigroup Jul 10, 2024
1c49549
remove unnecessary toast from mobile
amy-corson-ibigroup Jul 10, 2024
5ed48dc
Merge pull request #1244 from opentripplanner/plan-trip-button-advanc…
amy-corson-ibigroup Jul 10, 2024
0440176
Change mobile container height on advanced panel open
amy-corson-ibigroup Jul 10, 2024
74a0a75
Merge pull request #1247 from opentripplanner/mobile-styling-advanced…
amy-corson-ibigroup Jul 11, 2024
c895829
update trip-from alpha
amy-corson-ibigroup Jul 11, 2024
7edd335
add classname for custom styling
amy-corson-ibigroup Jul 11, 2024
248924a
fix react-transition-group d/t bug
amy-corson-ibigroup Jul 11, 2024
58a0668
import dt selector to the advanced settings panel
amy-corson-ibigroup Jul 11, 2024
6baf3f1
remove unneccesary hover + subsettings states in batch settings
amy-corson-ibigroup Jul 11, 2024
d4215c5
fix button padding d/t selector
amy-corson-ibigroup Jul 12, 2024
09c5c06
Merge pull request #1248 from opentripplanner/dt-hover-cleanup
amy-corson-ibigroup Jul 12, 2024
ca2e057
Merge branch 'dev' into master-trip-form-update
amy-corson-ibigroup Jul 12, 2024
433f236
Merge branch 'dev' into master-trip-form-update
amy-corson-ibigroup Jul 26, 2024
c5b1974
remove styling on d/t selector, revert checkboxes, move to one button
amy-corson-ibigroup Aug 6, 2024
e417ac3
add save feedback in save button and close button
amy-corson-ibigroup Aug 7, 2024
62ef9a3
some scroll + padding cleanup
amy-corson-ibigroup Aug 7, 2024
0ae71aa
update yarn.lock
amy-corson-ibigroup Aug 7, 2024
35a9ae3
Merge branch 'dev' into master-trip-form-update
amy-corson-ibigroup Aug 9, 2024
9d90771
add button classname for styling
amy-corson-ibigroup Aug 9, 2024
fc2a0fe
update packages
amy-corson-ibigroup Aug 9, 2024
0b27c31
inline state change function
amy-corson-ibigroup Aug 13, 2024
af8fff5
keep animation delay even with prefersReducedMotion
amy-corson-ibigroup Aug 13, 2024
8496d37
Switch animation timing to ease-in-out
amy-corson-ibigroup Aug 14, 2024
8c0b494
Merge branch 'dev' into master-trip-form-update
amy-corson-ibigroup Aug 15, 2024
fa2cf01
Merge branch 'dev' into master-trip-form-update
amy-corson-ibigroup Aug 26, 2024
d6c983d
Merge branch 'dev' into master-trip-form-update
amy-corson-ibigroup Aug 27, 2024
6bee58a
Code cleanup
amy-corson-ibigroup Aug 30, 2024
3177acf
Merge branch 'dev' into master-trip-form-update
amy-corson-ibigroup Sep 9, 2024
50299ab
fix(advanced-settings-panel): Replace close button with back button, …
amy-corson-ibigroup Sep 9, 2024
7bdc7a2
fix: update advanced settings props for mobile
amy-corson-ibigroup Sep 9, 2024
84a5a58
Merge branch 'dev' into master-trip-form-update
amy-corson-ibigroup Sep 16, 2024
ddda7fb
attempt to clean up event type
daniel-heppner-ibigroup Sep 18, 2024
f389d34
Revert unnecessary example.css change
amy-corson-ibigroup Sep 18, 2024
c9606d9
Merge branch 'master-trip-form-update' of https://github.com/opentrip…
amy-corson-ibigroup Sep 18, 2024
a4c8058
Merge branch 'dev' into master-trip-form-update
amy-corson-ibigroup Sep 18, 2024
c5e6671
chore(i18n): Add FR strings
binh-dam-ibigroup Sep 19, 2024
8017627
Code cleanup
amy-corson-ibigroup Sep 19, 2024
0778c58
turn inline functions into class methods
amy-corson-ibigroup Sep 20, 2024
5b0a5b7
Merge branch 'dev' into master-trip-form-update
amy-corson-ibigroup Sep 20, 2024
cf8e322
Fix mobile transition timing
amy-corson-ibigroup Sep 23, 2024
64d7d9b
Update snapshots
amy-corson-ibigroup Sep 23, 2024
26cbc16
Update percy tests
amy-corson-ibigroup Sep 23, 2024
45e47e5
update otp-ui packages
amy-corson-ibigroup Sep 24, 2024
df10d08
fix unit tests
amy-corson-ibigroup Sep 25, 2024
b2d92b6
Merge branch 'dev' into master-trip-form-update
amy-corson-ibigroup Sep 25, 2024
5835e92
Update percy tests
amy-corson-ibigroup Sep 25, 2024
d57f58e
Merge branch 'master-trip-form-update' of https://github.com/opentrip…
amy-corson-ibigroup Sep 25, 2024
a3343d4
fix percy tests
amy-corson-ibigroup Sep 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,154 changes: 577 additions & 577 deletions __tests__/components/viewers/__snapshots__/nearby-view.js.snap

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ exports[`components > viewers > stop viewer should render with initial stop id a
>
<Styled(styled.span)>
<span
className="sc-jifHHV sc-hkwmXC frJUIW gWGcte"
className="sc-hkwmXC sc-bSFUlv eFsrhn gAUjbw"
>
<ArrowLeft>
<StyledIconBase
Expand Down Expand Up @@ -267,11 +267,11 @@ exports[`components > viewers > stop viewer should render with initial stop id a
</div>
<styled.div>
<div
className="sc-hJxDiT dbjOgr"
className="sc-liccgK jihWTk"
>
<styled.div>
<div
className="sc-jlIlqL sdJoA"
className="sc-iWRHom bUIXtU"
>
<h1>
<FormattedMessage
Expand Down
3 changes: 3 additions & 0 deletions example-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,9 @@ itinerary:
# - 'DEPARTURETIME'
# In the batch itinerary UI, this setting will always show both departure/arrival times
alwaysShowBothTimes: false
advancedSettingsPanel:
# Show button in advanced panel that allows users to save and return
saveAndReturnButton: true

# The transitOperators key is a list of transit operators that can be used to
# order transit agencies when sorting by route. Also, this can optionally
Expand Down
7 changes: 7 additions & 0 deletions i18n/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,15 @@ components:
BatchRoutingPanel:
shortTitle: Plan Trip
BatchSearchScreen:
advancedHeader: Advanced Preferences
header: Plan Your Trip
modeOptions: Mode Options
modeSelectorLabel: Select a travel mode
moreOptions: More options
saveAndReturn: Save and return
saved: Saved
submodeSelectorLabel: Select travel modes and submodes
tripOptions: Trip Options
BatchSettings:
destination: destination
invalidModeSelection: >-
Expand Down
7 changes: 7 additions & 0 deletions i18n/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,15 @@ components:
BatchRoutingPanel:
shortTitle: Planifier un trajet
BatchSearchScreen:
advancedHeader: Préférences avancées
header: Votre trajet
modeOptions: Choix du mode
modeSelectorLabel: Sélectionnez un mode de déplacement
moreOptions: Plus d'options
saveAndReturn: Enregistrer et fermer
saved: Enregistré
submodeSelectorLabel: Sélectionnez vos modes et sous-modes de déplacement
tripOptions: Options concernant le trajet
BatchSettings:
destination: destination
invalidModeSelection: >-
Expand Down
206 changes: 158 additions & 48 deletions lib/components/app/batch-routing-panel.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { connect } from 'react-redux'
import { CSSTransition, TransitionGroup } from 'react-transition-group'
import { FormattedMessage, injectIntl, IntlShape } from 'react-intl'
import React, { Component, FormEvent } from 'react'

import {
advancedPanelClassName,
mainPanelClassName,
transitionDuration,
TransitionStyles
} from '../form/styled'
import { getActiveSearch, getShowUserSettings } from '../../util/state'
import { getPersistenceMode } from '../../util/user'
import AdvancedSettingsPanel from '../form/advanced-settings-panel'
import BatchSettings from '../form/batch-settings'
import InvisibleA11yLabel from '../util/invisible-a11y-label'
import LocationField from '../form/connected-location-field'
Expand All @@ -15,6 +23,7 @@ import ViewerContainer from '../viewers/viewer-container'
interface Props {
activeSearch: any
intl: IntlShape
mainPanelContent: number
mobile?: boolean
showUserSettings: boolean
}
Expand All @@ -24,7 +33,43 @@ interface Props {
*/
class BatchRoutingPanel extends Component<Props> {
state = {
planTripClicked: false
closeAdvancedSettingsWithDelay: false,
planTripClicked: false,
showAdvancedModeSettings: false
}

_advancedSettingRef = React.createRef<HTMLDivElement>()
_mainPanelContentRef = React.createRef<HTMLDivElement>()
_itinerariesAndUserRef = React.createRef<HTMLDivElement>()

componentDidUpdate(prevProps: Readonly<Props>): void {
// Close the advanced mode settings if we navigate to another page
if (
prevProps.mainPanelContent === null &&
this.props.mainPanelContent !== null &&
this.state.showAdvancedModeSettings
) {
this.setState({
showAdvancedModeSettings: false
})
}
}

openAdvancedSettings = () => {
this.setState({
closeAdvancedSettingsWithDelay: false,
showAdvancedModeSettings: true
})
}

closeAdvancedSettings = () => {
this.setState({ showAdvancedModeSettings: false })
}

setCloseAdvancedSettingsWithDelay = () => {
this.setState({
closeAdvancedSettingsWithDelay: true
})
}

handleSubmit = (e: FormEvent) => e.preventDefault()
Expand All @@ -44,6 +89,11 @@ class BatchRoutingPanel extends Component<Props> {
id: 'common.searchForms.click'
})

/* If there is a save button in advanced preferences, add a transition delay to allow
the saved state to be displayed to users */
const transitionDelay = this.state.closeAdvancedSettingsWithDelay ? 300 : 0
const transitionDurationWithDelay = transitionDuration + transitionDelay

return (
<ViewerContainer
className="batch-routing-panel"
Expand All @@ -53,55 +103,112 @@ class BatchRoutingPanel extends Component<Props> {
height: '100%'
}}
>
<InvisibleA11yLabel>
<h1>
<FormattedMessage id="components.BatchSearchScreen.header" />
</h1>
</InvisibleA11yLabel>
<form
className="form"
onSubmit={this.handleSubmit}
style={{ padding: '10px' }}
>
<span className="batch-routing-panel-location-fields">
<LocationField
inputPlaceholder={intl.formatMessage(
{ id: 'common.searchForms.enterStartLocation' },
{ mapAction }
<TransitionStyles transitionDelay={transitionDelay}>
{!this.state.showAdvancedModeSettings && (
<InvisibleA11yLabel>
<h1>
miles-grant-ibigroup marked this conversation as resolved.
Show resolved Hide resolved
<FormattedMessage id="components.BatchSearchScreen.header" />
</h1>
</InvisibleA11yLabel>
)}
<form
className="form"
onSubmit={this.handleSubmit}
style={{ padding: '10px' }}
>
<TransitionGroup style={{ display: 'content' }}>
{this.state.showAdvancedModeSettings && (
amy-corson-ibigroup marked this conversation as resolved.
Show resolved Hide resolved
<CSSTransition
classNames={advancedPanelClassName}
nodeRef={this._advancedSettingRef}
timeout={{
enter: transitionDuration,
exit: transitionDurationWithDelay
}}
>
<AdvancedSettingsPanel
closeAdvancedSettings={this.closeAdvancedSettings}
innerRef={this._advancedSettingRef}
setCloseAdvancedSettingsWithDelay={
this.setCloseAdvancedSettingsWithDelay
}
/>
</CSSTransition>
)}
isRequired
locationType="from"
selfValidate={planTripClicked}
showClearButton={!mobile}
/>
<LocationField
inputPlaceholder={intl.formatMessage(
{ id: 'common.searchForms.enterDestination' },
{ mapAction }

{!this.state.showAdvancedModeSettings && (
<CSSTransition
classNames={mainPanelClassName}
nodeRef={this._mainPanelContentRef}
onExit={this.openAdvancedSettings}
timeout={transitionDurationWithDelay}
>
<div ref={this._mainPanelContentRef}>
<span className="batch-routing-panel-location-fields">
<LocationField
inputPlaceholder={intl.formatMessage(
{ id: 'common.searchForms.enterStartLocation' },
{ mapAction }
)}
isRequired
locationType="from"
selfValidate={planTripClicked}
showClearButton={!mobile}
/>
<LocationField
inputPlaceholder={intl.formatMessage(
{ id: 'common.searchForms.enterDestination' },
{ mapAction }
)}
isRequired
locationType="to"
selfValidate={planTripClicked}
showClearButton={!mobile}
/>
<div className="switch-button-container">
<SwitchButton />
</div>
</span>
<BatchSettings
onPlanTripClick={this.handlePlanTripClick}
openAdvancedSettings={this.openAdvancedSettings}
/>
</div>
</CSSTransition>
)}
isRequired
locationType="to"
selfValidate={planTripClicked}
showClearButton={!mobile}
/>
<div className="switch-button-container">
<SwitchButton />
</div>
</span>
<BatchSettings onPlanTripClick={this.handlePlanTripClick} />
</form>
{!activeSearch && showUserSettings && (
<UserSettings style={{ margin: '0 10px', overflowY: 'auto' }} />
)}
<div
className="desktop-narrative-container"
style={{
flexGrow: 1,
overflowY: 'hidden'
}}
>
<NarrativeItineraries />
</div>
</TransitionGroup>
</form>
<TransitionGroup style={{ display: 'contents' }}>
{!this.state.showAdvancedModeSettings && (
<CSSTransition
classNames={mainPanelClassName}
nodeRef={this._itinerariesAndUserRef}
timeout={transitionDurationWithDelay}
>
<div
ref={this._itinerariesAndUserRef}
style={{ height: '100%', overflowY: 'auto' }}
>
{!activeSearch && showUserSettings && (
<UserSettings
style={{ margin: '0 10px', overflowY: 'auto' }}
/>
)}
<div
className="desktop-narrative-container"
style={{
flexGrow: 1,
height: activeSearch ? '100%' : 'auto',
overflowY: 'hidden'
}}
>
<NarrativeItineraries />
</div>
</div>
</CSSTransition>
)}
</TransitionGroup>
</TransitionStyles>
</ViewerContainer>
)
}
Expand All @@ -115,8 +222,11 @@ const mapStateToProps = (state: any) => {
getShowUserSettings(state) &&
(state.user.loggedInUser?.hasConsentedToTerms ||
getPersistenceMode(state.otp.config.persistence).isLocalStorage)
const { mainPanelContent } = state.otp.ui

return {
activeSearch: getActiveSearch(state),
mainPanelContent,
showUserSettings
}
}
Expand Down
29 changes: 29 additions & 0 deletions lib/components/form/advanced-settings-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { ArrowRight } from '@styled-icons/fa-solid'
import { FormattedMessage } from 'react-intl'

import { grey } from '../util/colors'
import React from 'react'
import styled from 'styled-components'

interface Props {
onClick: () => void
}

const StyledTransparentButton = styled.button`
align-items: center;
background: transparent;
border: none;
color: ${grey[800]};
display: flex;
gap: 7px;
margin-bottom: 5px;
`

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

export default AdvancedSettingsButton
Loading
Loading