From 2dee1e00c9f2f549121e5573e6c8275984795806 Mon Sep 17 00:00:00 2001 From: Josh Larson Date: Thu, 5 Sep 2024 15:05:06 -0400 Subject: [PATCH] feat: Add new nav icon for the detours page (#2771) Co-authored-by: Kayla Firestack --- assets/src/helpers/navIcons.tsx | 27 ++++++++++++++ .../src/{navLinkData.ts => navLinkData.tsx} | 26 +++++++------ .../icons/detourNavIcon.stories.tsx | 37 +++++++++++++++++++ 3 files changed, 79 insertions(+), 11 deletions(-) create mode 100644 assets/src/helpers/navIcons.tsx rename assets/src/{navLinkData.ts => navLinkData.tsx} (61%) create mode 100644 assets/stories/skate-components/icons/detourNavIcon.stories.tsx diff --git a/assets/src/helpers/navIcons.tsx b/assets/src/helpers/navIcons.tsx new file mode 100644 index 000000000..1a17d8d65 --- /dev/null +++ b/assets/src/helpers/navIcons.tsx @@ -0,0 +1,27 @@ +import React, { ComponentPropsWithoutRef } from "react" + +export type NavIconProps = ComponentPropsWithoutRef<"svg"> + +export const DetourNavIcon = (props: NavIconProps) => ( + + + + +) diff --git a/assets/src/navLinkData.ts b/assets/src/navLinkData.tsx similarity index 61% rename from assets/src/navLinkData.ts rename to assets/src/navLinkData.tsx index 3af137a78..70a0f59d9 100644 --- a/assets/src/navLinkData.ts +++ b/assets/src/navLinkData.tsx @@ -1,19 +1,17 @@ -import React from "react" +import React, { ComponentProps } from "react" import { fullStoryEvent } from "./helpers/fullStory" -import { - DiamondTurnRightIcon, - LadderIcon, - MapIcon, - SearchMapIcon, -} from "./helpers/icon" +import { LadderIcon, MapIcon, SearchMapIcon } from "./helpers/icon" import inTestGroup, { TestGroups } from "./userInTestGroup" +import { DetourNavIcon, NavIconProps } from "./helpers/navIcons" type HTMLElementProps = React.PropsWithoutRef> export interface LinkData { title: string path: string - navIcon: React.JSXElementConstructor + navIcon: + | React.JSXElementConstructor + | ((props: NavIconProps) => React.JSX.Element) onClick?: () => void hideOnMobile?: boolean } @@ -24,12 +22,16 @@ export const getNavLinkData: () => LinkData[] = () => { { title: "Detours", path: "/detours", - navIcon: DiamondTurnRightIcon, + navIcon: (props: ComponentProps<"span">) => ( + + + + ), }, ] : [] - return [ + const alwaysPresentItems: LinkData[] = [ { title: "Route Ladders", path: "/", @@ -46,5 +48,7 @@ export const getNavLinkData: () => LinkData[] = () => { navIcon: SearchMapIcon, onClick: () => fullStoryEvent("Search Map nav entry clicked", {}), }, - ].concat(maybeDetours) + ] + + return alwaysPresentItems.concat(maybeDetours) } diff --git a/assets/stories/skate-components/icons/detourNavIcon.stories.tsx b/assets/stories/skate-components/icons/detourNavIcon.stories.tsx new file mode 100644 index 000000000..9d13bf687 --- /dev/null +++ b/assets/stories/skate-components/icons/detourNavIcon.stories.tsx @@ -0,0 +1,37 @@ +import React from "react" + +import type { Meta, StoryObj } from "@storybook/react" +import { DetourNavIcon } from "../../../src/helpers/navIcons" + +const meta = { + component: DetourNavIcon, + parameters: { + layout: "centered", + stretch: false, + }, +} satisfies Meta + +export default meta +type Story = StoryObj + +export const Default: Story = {} + +export const UnselectedInContext: Story = { + decorators: [ + (StoryFn) => ( +
+ +
+ ), + ], +} + +export const SelectedInContext: Story = { + decorators: [ + (StoryFn) => ( +
+ +
+ ), + ], +}