Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(components): refactor location icon stories #14896

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 22 additions & 28 deletions components/src/molecules/LocationIcon/LocationIcon.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import * as React from 'react'

import { Flex, SPACING } from '@opentrons/components'

import { Flex } from '../../primitives'
import { SPACING } from '../../ui-style-constants'
import { GlobalStyle } from '../../../../app/src/atoms/GlobalStyle'
import { customViewports } from '../../../../.storybook/preview'
import { LocationIcon } from '.'

import type { Story, Meta } from '@storybook/react'
import { ICON_DATA_BY_NAME } from '../../icons'
import { LocationIcon } from '.'
import type { Meta, StoryObj } from '@storybook/react'

const slots = [
'A1',
Expand All @@ -28,26 +26,23 @@ const slots = [
'D4',
]

export default {
title: 'ODD/Molecules/LocationIcon',
const meta: Meta<typeof LocationIcon> = {
title: 'Library/Molecules/LocationIcon',
argTypes: {
iconName: {
control: {
type: 'select',
options: Object.keys(ICON_DATA_BY_NAME),
},
defaultValue: undefined,
options: Object.keys(ICON_DATA_BY_NAME),
},
slotName: {
control: {
type: 'select',
options: slots,
},
defaultValue: undefined,
options: slots,
},
},
component: LocationIcon,
// Note (kk:08/29/2023) this component is located in components so avoid importing const from app
parameters: {
viewport: {
viewports: customViewports,
Expand All @@ -56,26 +51,25 @@ export default {
},
decorators: [
Story => (
<>
<Flex padding={SPACING.spacing16} width="15rem" height="5rem">
<GlobalStyle isOnDevice />
<Story />
</>
</Flex>
),
],
} as Meta

const Template: Story<React.ComponentProps<typeof LocationIcon>> = args => (
<Flex marginTop={SPACING.spacing16} width="15rem" height="5rem">
<LocationIcon {...args} />
</Flex>
)
}
export default meta
type Story = StoryObj<typeof LocationIcon>

export const DisplaySlot = Template.bind({})
DisplaySlot.args = {
slotName: 'A1',
export const DisplaySlot: Story = {
args: {
slotName: 'A1',
iconName: undefined,
},
}

export const DisplayIcon = Template.bind({})
DisplayIcon.args = {
iconName: 'ot-temperature-v2',
export const DisplayIcon: Story = {
args: {
iconName: 'ot-temperature-v2',
},
}
Loading