-
Notifications
You must be signed in to change notification settings - Fork 367
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: [M3-7542] - TagsInput & TagsPanel Storybook v7 Stories #9963
Changes from all commits
8d20846
900d302
653a060
e957664
baa799f
1b53f6d
f62af1e
ffde327
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Tech Stories | ||
--- | ||
|
||
TagsInput & TagsPanel Storybook v7 Stories ([#9963](https://github.com/linode/manager/pull/9963)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,7 +89,6 @@ const preview: Preview = { | |
<Description /> | ||
<Primary /> | ||
<Controls /> | ||
<Stories /> | ||
</> | ||
), | ||
}, | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { useArgs } from '@storybook/client-api'; | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import React from 'react'; | ||
|
||
import { Box } from 'src/components/Box'; | ||
|
||
import { TagsInput } from './TagsInput'; | ||
|
||
import type { TagsInputProps } from './TagsInput'; | ||
import type { Item } from 'src/components/EnhancedSelect/Select'; | ||
|
||
export const Default: StoryObj<TagsInputProps> = { | ||
args: { | ||
disabled: false, | ||
hideLabel: false, | ||
label: '', | ||
menuPlacement: 'bottom', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we have better support for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also wasn't able to reproduce this - menu placement gets toggled as expected. I did improve the styling of the story so the select sits in the middle of the canvas to help viewing it better tho. |
||
name: '', | ||
tagError: '', | ||
value: [ | ||
{ label: 'tag-1', value: 'tag-1' }, | ||
{ label: 'tag-2', value: 'tag-2' }, | ||
], | ||
}, | ||
render: (args) => { | ||
const TagsInputWrapper = () => { | ||
const [, setTags] = useArgs(); | ||
const handleUpdateTags = (selected: Item[]) => { | ||
return setTags({ value: selected }); | ||
}; | ||
|
||
return ( | ||
<Box sx={{ alignItems: 'center', display: 'flex', height: 300 }}> | ||
<TagsInput | ||
{...args} | ||
onChange={(selected) => handleUpdateTags(selected)} | ||
/> | ||
</Box> | ||
); | ||
}; | ||
|
||
return TagsInputWrapper(); | ||
}, | ||
}; | ||
|
||
const meta: Meta<TagsInputProps> = { | ||
component: TagsInput, | ||
title: 'Components/Tags/Tags Input', | ||
}; | ||
export default meta; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { useArgs } from '@storybook/client-api'; | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import React from 'react'; | ||
|
||
import { Box } from 'src/components/Box'; | ||
|
||
import { TagsPanel } from './TagsPanel'; | ||
|
||
import type { TagsPanelProps } from './TagsPanel'; | ||
|
||
const _tags: string[] = ['tag1', 'tag2', 'tag3', 'tag4', 'tag5']; | ||
|
||
export const Default: StoryObj<TagsPanelProps> = { | ||
render: (args) => { | ||
const TagsInputWrapper = () => { | ||
const [{ tags }, updateArgs] = useArgs(); | ||
const handleUpdateTags = (selected: string[]) => { | ||
return Promise.resolve(updateArgs({ tags: selected })); | ||
}; | ||
|
||
return ( | ||
<Box sx={{ height: 300 }}> | ||
<TagsPanel {...args} tags={tags} updateTags={handleUpdateTags} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we have better support for Currently when it's Changing the selection for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I wasn't able to reproduce this but I remove |
||
</Box> | ||
); | ||
}; | ||
|
||
return TagsInputWrapper(); | ||
}, | ||
}; | ||
|
||
const meta: Meta<TagsPanelProps> = { | ||
args: { | ||
disabled: false, | ||
tags: _tags, | ||
}, | ||
component: TagsPanel, | ||
title: 'Components/Tags/Tags Panel', | ||
}; | ||
export default meta; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Listing all stories in documentation often leads to state issues and it will make things a bit easier to test visual regression by focusing on individual stories.
Documentation is meant to be a playground on the default rendering of the component.
We can always put it back in if people feel it's necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually a bit confused where this is referring to π - is this regarding the Documentation section of each story, like here:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's to show the list of stories in the Documentation page under the args table