-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: navigation menu + wordmark (#117)
- Loading branch information
Showing
23 changed files
with
415 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,32 @@ | ||
import { paths } from "../paths"; | ||
import { className } from "../util/dom"; | ||
import { Link, useLocation } from "react-router-dom"; | ||
|
||
export const Header = () => { | ||
const currentLocation = useLocation(); | ||
const menuSelected = | ||
currentLocation.pathname === paths.menu || | ||
currentLocation.pathname === paths.help; | ||
|
||
return ( | ||
<div className="w-full bg-gray-200 p-2 flex justify-between"> | ||
<img src="/images/logo.svg" alt="MBTA" className="w-8" /> | ||
<a href="/logout" className="underline p-1"> | ||
Log out | ||
</a> | ||
<Link to={paths.root}> | ||
<img src="/images/logo.svg" alt="MBTA" className="w-44" /> | ||
</Link> | ||
<Link to={paths.menu}> | ||
<button | ||
className={className([ | ||
"border border-black bg-gray-200 rounded w-8 h-8", | ||
menuSelected && "invert border-white", | ||
])} | ||
> | ||
<img | ||
src="/images/menu.svg" | ||
alt="Menu" | ||
className="w-full h-full text-black" | ||
/> | ||
</button> | ||
</Link> | ||
</div> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
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,124 @@ | ||
import { IconName } from "../icons"; | ||
import { paths } from "../paths"; | ||
import { className } from "../util/dom"; | ||
import { getMetaContent } from "../util/metadata"; | ||
import { ReactElement } from "react"; | ||
import { Link } from "react-router-dom"; | ||
|
||
const MenuLink = ({ | ||
to, | ||
icon, | ||
iconExtraClassName, | ||
reload, | ||
newTab, | ||
children, | ||
}: { | ||
to: string; | ||
icon?: IconName; | ||
iconExtraClassName?: string; | ||
reload?: boolean; | ||
newTab?: boolean; | ||
children: string; | ||
}): ReactElement => ( | ||
<Link | ||
to={to} | ||
reloadDocument={reload} | ||
target={newTab ? "_blank" : undefined} | ||
rel={newTab ? "noopener noreferrer" : undefined} | ||
> | ||
<button className="block font-semibold mx-auto w-full rounded border border-gray-300 bg-none hover:bg-gray-200 p-1 mb-6"> | ||
{icon && ( | ||
<img | ||
src={`/images/${icon}.svg`} | ||
// Per MDN re: alt text: | ||
// > If the image doesn't require a fallback (such as for an image which is decorative or an advisory icon | ||
// of minimal importance), you may specify an empty string ("") | ||
alt={""} | ||
className={className(["inline", iconExtraClassName])} | ||
/> | ||
)} | ||
{children} | ||
</button> | ||
</Link> | ||
); | ||
|
||
export const Menu = (): ReactElement => { | ||
const name = getMetaContent("userName"); | ||
const email = getMetaContent("userEmail"); | ||
|
||
return ( | ||
<main className="w-5/6 mx-auto mt-4 max-w-[400px]"> | ||
<h2 className="text-2xl mb-6">Hi, {name ?? email}</h2> | ||
|
||
<MenuLink icon="help" iconExtraClassName="h-7 w-7" to={paths.help}> | ||
Help | ||
</MenuLink> | ||
<MenuLink | ||
icon="feedback" | ||
iconExtraClassName="h-7 w-7" | ||
newTab={true} | ||
to="https://form.asana.com/?k=NS0FKd0bBpHpURLbD3jmeg&d=15492006741476" | ||
> | ||
Send Feedback | ||
</MenuLink> | ||
<hr className="mx-auto my-8 w-full" /> | ||
<MenuLink | ||
icon={"sign-out"} | ||
iconExtraClassName="h-5 w-5 mr-1" | ||
to={paths.logout} | ||
reload={true} | ||
> | ||
Logout | ||
</MenuLink> | ||
</main> | ||
); | ||
}; | ||
|
||
export const HelpMenu = (): ReactElement => { | ||
return ( | ||
<main className="w-5/6 mx-auto mt-4 max-w-[400px]"> | ||
<Link | ||
className="mb-6 tracking-widest h-full w-16 text-sm font-semibold uppercase no-underline" | ||
to={paths.menu} | ||
> | ||
<img | ||
src={`/images/back.svg`} | ||
alt={"Back"} | ||
className="w-5 inline -translate-y-0.5" | ||
/> | ||
Back | ||
</Link> | ||
|
||
<h2 className="text-2xl my-8">How can we help?</h2> | ||
|
||
<MenuLink | ||
icon="info" | ||
iconExtraClassName="w-4 mr-2" | ||
newTab={true} | ||
to="https://www.mbta.com/orbit-user-guide" | ||
> | ||
User Guide | ||
</MenuLink> | ||
<MenuLink | ||
icon="clipboard" | ||
iconExtraClassName="w-3 mr-2" | ||
newTab={true} | ||
to="https://www.mbta.com/orbit-training" | ||
> | ||
Training Materials | ||
</MenuLink> | ||
<hr className="mx-auto my-8 w-full" /> | ||
<div> | ||
For more support, contact{" "} | ||
<Link className="underline" to={"mailto:[email protected]"}> | ||
[email protected] | ||
</Link>{" "} | ||
or{" "} | ||
<Link className="underline" to={"tel:+1-617-222-5761"}> | ||
617-222-5761 | ||
</Link>{" "} | ||
and mention that you are having an issue with Orbit. | ||
</div> | ||
</main> | ||
); | ||
}; |
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,10 @@ | ||
export type IconName = | ||
| "back" | ||
| "clipboard" | ||
| "feedback" | ||
| "help" | ||
| "info" | ||
| "logo" | ||
| "menu" | ||
| "shield" | ||
| "sign-out"; |
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,6 @@ | ||
export const paths = { | ||
root: "/", | ||
menu: "/menu", | ||
help: "/help", | ||
logout: "/logout", | ||
} as const; |
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,36 @@ | ||
import { HelpMenu, Menu } from "../../components/menus"; | ||
import { render } from "@testing-library/react"; | ||
import { MemoryRouter } from "react-router-dom"; | ||
|
||
describe("menu", () => { | ||
test("has links", () => { | ||
const view = render( | ||
<MemoryRouter> | ||
<Menu /> | ||
</MemoryRouter>, | ||
); | ||
expect(view.getAllByRole("button")).toHaveLength(3); | ||
expect(view.getByRole("button", { name: "Help" })).toBeInTheDocument(); | ||
expect( | ||
view.getByRole("button", { name: "Send Feedback" }), | ||
).toBeInTheDocument(); | ||
expect(view.getByRole("button", { name: "Logout" })).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
describe("help menu", () => { | ||
test("has links", () => { | ||
const view = render( | ||
<MemoryRouter> | ||
<HelpMenu /> | ||
</MemoryRouter>, | ||
); | ||
expect(view.getAllByRole("button")).toHaveLength(2); | ||
expect( | ||
view.getByRole("button", { name: "User Guide" }), | ||
).toBeInTheDocument(); | ||
expect( | ||
view.getByRole("button", { name: "Training Materials" }), | ||
).toBeInTheDocument(); | ||
}); | ||
}); |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.