-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Commuter Rail selectors for future use
- Loading branch information
1 parent
39c00a4
commit 3ab5252
Showing
18 changed files
with
184 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
import { SidebarTabs } from '../../../modules/navigation/SidebarTabs'; | ||
import { TRIP_PAGES, COMMUTER_RAIL_OVERVIEW } from '../../constants/pages'; | ||
import { CommuterRailRouteSelection } from './CommuterRailRouteSelection'; | ||
|
||
interface CommuterRailDropdownProps { | ||
close?: () => void; | ||
} | ||
|
||
export const CommuterRailDropdown: React.FC<CommuterRailDropdownProps> = ({ close }) => { | ||
return ( | ||
<div className="rounded-b-md"> | ||
<CommuterRailRouteSelection /> | ||
<div | ||
className={ | ||
'flex flex-col gap-[2px] rounded-b-md border border-t-0 border-mbta-commuterRail border-opacity-50 bg-neutral-800 px-1 py-[4px]' | ||
} | ||
role={'navigation'} | ||
> | ||
<SidebarTabs tabs={COMMUTER_RAIL_OVERVIEW} close={close} /> | ||
<hr className="h-[1px] w-3/4 self-center border-neutral-500" /> | ||
<SidebarTabs tabs={TRIP_PAGES} close={close} /> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { faCheckCircle } from '@fortawesome/free-solid-svg-icons'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
import { Listbox, Transition } from '@headlessui/react'; | ||
import { ChevronUpDownIcon } from '@heroicons/react/20/solid'; | ||
import { useRouter } from 'next/navigation'; | ||
import React, { Fragment } from 'react'; | ||
import { getCommuterRailRoutes } from '../../constants/stations'; | ||
import { getBusRouteSelectionItemHref, useDelimitatedRoute } from '../../utils/router'; | ||
|
||
// TODO: This is a duplicate of common/components/nav/BusRouteSelection.tsx | ||
export const CommuterRailRouteSelection: React.FC = () => { | ||
const route = useDelimitatedRoute(); | ||
const router = useRouter(); | ||
const crRoutes = getCommuterRailRoutes(); | ||
const selected = route.query.busRoute; | ||
|
||
return ( | ||
<div className="bg-mbta-lightBus"> | ||
<Listbox | ||
value={selected} | ||
onChange={(key) => router.push(getBusRouteSelectionItemHref(key, route))} | ||
> | ||
<div className="relative text-white text-opacity-95"> | ||
<Listbox.Button className="relative w-full cursor-pointer border border-mbta-bus bg-tm-lightGrey py-2 pl-3 pr-10 text-left focus:outline-none focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-white/75 focus-visible:ring-offset-2 focus-visible:ring-offset-orange-300 sm:text-sm"> | ||
<span className="block truncate ">{selected}</span> | ||
<span className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2"> | ||
<ChevronUpDownIcon className="h-5 w-5 " aria-hidden="true" /> | ||
</span> | ||
</Listbox.Button> | ||
<Transition | ||
as={Fragment} | ||
leave="transition ease-in duration-100" | ||
leaveFrom="opacity-100" | ||
leaveTo="opacity-0" | ||
> | ||
<Listbox.Options className="absolute mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black/5 focus:outline-none sm:text-sm"> | ||
{crRoutes.map((crRoute, personIdx) => ( | ||
<Listbox.Option | ||
key={personIdx} | ||
className={({ active }) => | ||
`relative cursor-pointer select-none py-2 pl-10 pr-4 ${ | ||
active ? 'bg-amber-100 text-amber-900' : 'text-gray-900' | ||
}` | ||
} | ||
value={crRoute} | ||
> | ||
{({ selected }) => ( | ||
<> | ||
<span | ||
className={`block truncate ${selected ? 'font-medium' : 'font-normal'}`} | ||
> | ||
{crRoute} | ||
</span> | ||
{selected ? ( | ||
<span className="absolute inset-y-0 left-0 flex items-center pl-3 text-mbta-bus"> | ||
<FontAwesomeIcon | ||
icon={faCheckCircle} | ||
className="h-5 w-5" | ||
aria-hidden="true" | ||
/> | ||
</span> | ||
) : null} | ||
</> | ||
)} | ||
</Listbox.Option> | ||
))} | ||
</Listbox.Options> | ||
</Transition> | ||
</div> | ||
</Listbox> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
import { useDelimitatedRoute } from '../../utils/router'; | ||
import { MenuDropdown } from './MenuDropdown'; | ||
import { CommuterRailDropdown } from './CommuterRailDropdown'; | ||
|
||
interface CommuterRailSectionProps { | ||
close?: () => void; | ||
} | ||
|
||
export const CommuterRailSection: React.FC<CommuterRailSectionProps> = ({ close }) => { | ||
const route = useDelimitatedRoute(); | ||
return ( | ||
<div className="w-full gap-y-2"> | ||
<MenuDropdown line="line-commuter-rail" route={route}> | ||
<CommuterRailDropdown close={close} /> | ||
</MenuDropdown> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.