Skip to content

Commit 0a3940f

Browse files
kojiCarlos-fernandez
authored andcommitted
fix(app): update Inputfield stories (#15084)
* fix(app): update Inputfield stories
1 parent 74f4069 commit 0a3940f

File tree

1 file changed

+46
-13
lines changed

1 file changed

+46
-13
lines changed

app/src/atoms/InputField/InputField.stories.tsx

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,61 @@
11
import * as React from 'react'
2-
import { InputField } from './index'
3-
import type { Story, Meta } from '@storybook/react'
2+
import { Flex, SPACING, VIEWPORT } from '@opentrons/components'
3+
import { InputField as InputFieldComponent } from './index'
4+
import type { Meta, StoryObj } from '@storybook/react'
45

5-
export default {
6+
const meta: Meta<typeof InputFieldComponent> = {
7+
// ToDo (kk05/02/2024) this should be in Library but at this moment there is the same name component in components
8+
// The unification for this component will be done when the old component is retired completely.
69
title: 'App/Atoms/InputField',
7-
component: InputField,
8-
} as Meta
10+
component: InputFieldComponent,
11+
parameters: VIEWPORT.touchScreenViewport,
12+
}
13+
14+
export default meta
15+
type Story = StoryObj<typeof InputFieldComponent>
916

10-
const Template: Story<React.ComponentProps<typeof InputField>> = args => (
11-
<InputField {...args} />
12-
)
17+
export const InputField: Story = args => {
18+
const [value, setValue] = React.useState(args.value)
19+
return (
20+
<Flex padding={SPACING.spacing16} width="100%">
21+
<InputFieldComponent
22+
{...args}
23+
value={value}
24+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
25+
setValue(e.target.value)
26+
}}
27+
units={args.type !== 'number' ? undefined : args.units}
28+
/>
29+
</Flex>
30+
)
31+
}
1332

14-
export const Primary = Template.bind({})
15-
Primary.args = {
33+
InputField.args = {
1634
value: 200,
1735
units: 'rpm',
1836
type: 'number',
1937
caption: 'example caption',
2038
max: 200,
21-
min: 200,
39+
min: 10,
40+
}
41+
42+
export const InputFieldWithError: Story = args => {
43+
const [value, setValue] = React.useState(args.value)
44+
return (
45+
<Flex padding={SPACING.spacing16} width="100%">
46+
<InputFieldComponent
47+
{...args}
48+
value={value}
49+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
50+
setValue(e.target.value)
51+
}}
52+
units={args.type !== 'number' ? undefined : args.units}
53+
/>
54+
</Flex>
55+
)
2256
}
2357

24-
export const ErrorMessage = Template.bind({})
25-
ErrorMessage.args = {
58+
InputFieldWithError.args = {
2659
units: 'C',
2760
type: 'number',
2861
caption: 'example caption',

0 commit comments

Comments
 (0)