forked from linode/manager
-
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: [M3-8177] - Add
MultipleIPInput
Story (linode#11389)
* feat: [M3-8177] - Add MultipleIPInput Story * Added changeset: MultipleIPInput Story in Storybook * Add functionality to `HelperText` and `Placeholder` * Add functionality to `Placeholder`
- Loading branch information
1 parent
5469160
commit 8ff2562
Showing
3 changed files
with
148 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Added | ||
--- | ||
|
||
MultipleIPInput Story in Storybook ([#11389](https://github.com/linode/manager/pull/11389)) |
75 changes: 75 additions & 0 deletions
75
packages/manager/src/components/MultipleIPInput/MultipleIPInput.stories.tsx
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,75 @@ | ||
import React, { useState } from 'react'; | ||
|
||
import { MultipleIPInput } from './MultipleIPInput'; | ||
|
||
import type { MultipeIPInputProps } from './MultipleIPInput'; | ||
import type { Meta, StoryFn, StoryObj } from '@storybook/react'; | ||
|
||
type Story = StoryObj<typeof MultipleIPInput>; | ||
|
||
const mockTitle = 'IP Address'; | ||
|
||
const defaultArgs = { | ||
buttonText: 'Add An IP', | ||
ips: [{ address: '192.0.2.1/01' }, { address: '192.0.2.1/02' }], | ||
title: mockTitle, | ||
}; | ||
|
||
const meta: Meta<typeof MultipleIPInput> = { | ||
component: MultipleIPInput, | ||
decorators: [ | ||
(Story: StoryFn) => ( | ||
<div style={{ margin: '2em' }}> | ||
<Story /> | ||
</div> | ||
), | ||
], | ||
title: 'Components/MultipleIPInput', | ||
}; | ||
|
||
export default meta; | ||
|
||
const MultipleIPInputWithState = ({ ...args }: MultipeIPInputProps) => { | ||
const [ips, setIps] = useState(args.ips); | ||
|
||
const handleChange = (newIps: typeof ips) => { | ||
setIps(newIps); | ||
}; | ||
|
||
return <MultipleIPInput {...args} ips={ips} onChange={handleChange} />; | ||
}; | ||
|
||
export const Default: Story = { | ||
args: defaultArgs, | ||
render: (args) => { | ||
return <MultipleIPInputWithState {...args} />; | ||
}, | ||
}; | ||
|
||
export const Disabled: Story = { | ||
args: { | ||
...defaultArgs, | ||
disabled: true, | ||
}, | ||
}; | ||
|
||
export const HelperText: Story = { | ||
args: { | ||
...defaultArgs, | ||
helperText: 'helperText', | ||
}, | ||
render: (args) => { | ||
return <MultipleIPInputWithState {...args} />; | ||
}, | ||
}; | ||
|
||
export const Placeholder: Story = { | ||
args: { | ||
ips: [{ address: '' }], | ||
placeholder: 'placeholder', | ||
title: mockTitle, | ||
}, | ||
render: (args) => { | ||
return <MultipleIPInputWithState {...args} />; | ||
}, | ||
}; |
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