-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
docs: add default stories for IDE components #2398
docs: add default stories for IDE components #2398
Conversation
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.
Excellent work 👍 You've got me thinking about lots of things and I've added many comments with things that we can improve in the future.
The biggest thing is how these components interact with Redux. We have two approaches here to make these stories make sense:
-
Each component exports a connected version which gets the state from Redux and an unconnected version which accepts props. We would use the unconnected version for Storybook. This is easy for the old components which use
connect
. But for the ones that I've rewritten, likeTimer
, I've generally been making it so that the component takes no props and accesses Redux internally. -
We pass the
args
of the story into a Redux provider so that we can specify the correct state. This requires setup and more work on the Storybook side, but no changes to the components which is a pro. But it also requires the story to know the structure of the Redux state, ie. thatprojectSavedTime
should go instate.project.updatedAt
, and that is a con to me because Redux should be a black box.
url: 'https://p5js.org/assets/img/p5js.svg', | ||
name: 'P5 Logo' | ||
} | ||
}; |
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.
We can add stories for audio and video files (can be done later).
|
||
export const Default = { | ||
args: { | ||
totalSize: 123 |
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.
This story shows up with a control for the totalSize
, but changing it doesn't do anything because the default export gets the size from Redux.
Once we get the styles working and once we get this using the args
then it might be cool to have stories for empty vs. full vs. somewhere in the middle.
value: 'an@email.com', | ||
label: 'Example' | ||
} | ||
}; |
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.
We aren't seeing the pencil icon here due to an issue with svgr
. I think it's removing the viewbox
. Just FYI, we can fix that later.
component: NewFileForm | ||
}; | ||
|
||
export const Default = {}; |
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.
The NewFileForm
is only used inside of the NewFileModal
so it might be redundant to have stories for both. (the same for the NerFolderForm
)
TBH we could consider combing the two component files as there's not much left in the NewFileModal
after we made a common Modal
component.
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 like the idea of having fewer Modals and reusing the generic one. I think thats capturing the layout primitives
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've removed NerFolderForm
sketches: [ | ||
{ | ||
id: '1', | ||
name: 'Play Sketch', | ||
createdAt: Date.now().toString(), | ||
updatedAt: Date.now().toString() | ||
} | ||
] |
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 was wondering why these sketches don't show up in the list. Again, it's because the component ignores this prop and gets the actual value from Redux.
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.
Ahhh! I was wondering that myself but was unsure.
…b-editor into docs-add-default-stories
@lindapaiste is there anything here you'd like me to action? I think the comments are follow up items. |
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.
Sorry that this was sitting for so long! I'm going to approve and merge this because it is a huge step forwards. We can continue to workout some of the kinks with future PRs.
Changes:
Adds default stories to IDE components. At least to the ones that make sense. There are a few like Toast, Timer and EditorAccessibility which is either hidden or needs some redux magic set up to trigger output.
There is more that could be done for each story to offer any other variations. But for a first pass I think it's good to get a simple story. I think would ease development for things like file upload or copyable field as they are now surfaced as an isolated story.
I have verified that this pull request:
npm run lint
)npm run test
)develop
branch.Fixes #123