Skip to content

Commit

Permalink
feat(storybook): Add storybook story for RoutePropertiesCard (#2609)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshlarson authored May 20, 2024
1 parent a46dd31 commit f569ca6
Showing 1 changed file with 97 additions and 0 deletions.
97 changes: 97 additions & 0 deletions assets/stories/skate-components/routePropertiesCard.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import type { Meta, StoryObj } from "@storybook/react"
import React from "react"

import RoutePropertiesCard from "../../src/components/mapPage/routePropertiesCard"
import { routePatternFactory } from "../../tests/factories/routePattern"
import routeFactory from "../../tests/factories/route"
import { RoutesProvider } from "../../src/contexts/routesContext"
import stopFactory from "../../tests/factories/stop"
import shapeFactory from "../../tests/factories/shape"

const outboundStops = [
stopFactory.build({ name: "Watertown Square" }),
stopFactory.build({ name: "Centre St @ Beacon St" }),
stopFactory.build({ name: "Charles River Loop" }),
stopFactory.build({ name: "Dedham Mall" }),
]

const routePattern0 = routePatternFactory.build({
directionId: 0,
headsign: "Dedham Mall",
id: "52-5-0",
name: "Watertown - Dedham Mall via Meadowbrook Rd",
routeId: "52",
shape: shapeFactory.build({ stops: outboundStops }),
})
const routePattern1 = routePatternFactory.build({
directionId: 0,
headsign: "Charles River Loop",
id: "52-4-0",
name: "Watertown - Charles River Loop via Meadowbrook Rd",
routeId: "52",
shape: shapeFactory.build({ stops: outboundStops }),
})
const routePattern2 = routePatternFactory.build({
directionId: 1,
headsign: "Watertown Yard",
id: "52-5-1",
name: "Dedham Mall - Watertown via Meadowbrook Rd",
routeId: "52",
shape: shapeFactory.build({ stops: outboundStops.reverse() }),
})
const routePattern3 = routePatternFactory.build({
directionId: 1,
headsign: "Watertown Yard",
id: "52-4-1",
name: "Charles River Loop - Watertown via Meadowbrook Rd",
routeId: "52",
shape: shapeFactory.build({ stops: outboundStops.reverse() }),
})
const routePattern4 = routePatternFactory.build({
directionId: 1,
headsign: "Watertown Yard via Dedham St",
id: "52-6-1",
name: "Charles River Loop - Watertown via Dedham St",
routeId: "52",
shape: shapeFactory.build({ stops: outboundStops.reverse() }),
})
const routePatterns = {
[routePattern0.id]: routePattern0,
[routePattern1.id]: routePattern1,
[routePattern2.id]: routePattern2,
[routePattern3.id]: routePattern3,
[routePattern4.id]: routePattern4,
}

const route = routeFactory.build({ id: "52" })

const meta = {
component: RoutePropertiesCard,
args: {
routePatterns: routePatterns,
selectedRoutePatternId: routePattern0.id,
},
argTypes: {
routePatterns: { table: { disable: true } },
selectedRoutePatternId: { table: { disable: true } },
selectRoutePattern: { table: { disable: true } },
onClose: { table: { disable: true } },
},
decorators: [
(StoryFn) => (
<RoutesProvider routes={[route]}>
<StoryFn />
</RoutesProvider>
),
],
} satisfies Meta<typeof RoutePropertiesCard>
export default meta

type Story = StoryObj<typeof RoutePropertiesCard>

export const Default: Story = {}
export const WithInboundSelected: Story = {
args: {
selectedRoutePatternId: routePattern3.id,
},
}

0 comments on commit f569ca6

Please sign in to comment.