-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add dropdown when right-clicking on a vehicle marker (#2373)
* feat: Add dropdown when right-clicking on a vehicle marker * refactor: Extract <DropdownMenu /> to its own file * feat(storybook): Add Storybook story for <DropdownMenu /> * feat(test-groups): Gate "Start Detour" dropdown behind a test group * feat: Only allow the dropdown on desktop and tablet * refactor: Make the popup a children property of the <VehicleMarker /> * refactor: Make shouldShowPopup state that's passed into a <VehicleMarker /> * feat: Close popup when its menu item is clicked * test: Move the dropdown tests so that they test the right use case * test: Assert using getByRole and queryByRole rather than looking for CSS classes
- Loading branch information
1 parent
f160f3f
commit c071338
Showing
10 changed files
with
307 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.c-dropdown-popup-wrapper { | ||
visibility: hidden; | ||
} | ||
|
||
.c-dropdown-popup-menu { | ||
position: static; | ||
visibility: visible; | ||
} |
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,17 @@ | ||
import React, { PropsWithChildren } from "react" | ||
import { Dropdown } from "react-bootstrap" | ||
|
||
interface DropdownMenuProps extends PropsWithChildren {} | ||
|
||
export const DropdownMenu = ({ children }: DropdownMenuProps) => { | ||
return ( | ||
<Dropdown.Menu | ||
className="c-dropdown-popup-menu border-box inherit-box" | ||
show | ||
> | ||
{children} | ||
</Dropdown.Menu> | ||
) | ||
} | ||
|
||
export const DropdownItem = Dropdown.Item |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import type { Meta, StoryObj } from "@storybook/react" | ||
|
||
import React from "react" | ||
import { | ||
DropdownItem, | ||
DropdownMenu, | ||
} from "../../../src/components/map/dropdown" | ||
|
||
const meta = { | ||
component: DropdownMenu, | ||
args: { | ||
children: ["Start a detour on route 66"], | ||
}, | ||
parameters: { | ||
layout: "centered", | ||
}, | ||
decorators: [ | ||
(StoryFn, ctx) => { | ||
const children = ctx.args["children"] as Array<string> | ||
|
||
ctx.args["children"] = children.map((child) => ( | ||
<DropdownItem key={child}>{child}</DropdownItem> | ||
)) | ||
|
||
return <StoryFn /> | ||
}, | ||
], | ||
} satisfies Meta<typeof DropdownMenu> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof meta> | ||
|
||
export const Default: Story = {} | ||
|
||
export const WithMoreEntries: Story = { | ||
args: { | ||
children: [ | ||
"Start a detour on route 66", | ||
"Hold this bus for 10 minutes", | ||
"View old detours for this route", | ||
], | ||
}, | ||
} |
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.