-
Notifications
You must be signed in to change notification settings - Fork 1
[Feature] Add basic stories #1
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
base: main
Are you sure you want to change the base?
Conversation
59ddec2 to
5cc5e4a
Compare
domq
left a comment
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 is a preliminary review; I'll be more throrough once you have made the nested-element changes, which are a big chunk of work.
src/stories/molecules/Badge.tsx
Outdated
| } | ||
|
|
||
| /** | ||
| * Primary UI component for user interaction |
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 text appears in the UI. Please make it relevant e.g.
/**
* A user badge, where the icon on the right is clickable.
*/
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.
Done
src/stories/molecules/Badge.tsx
Outdated
| icon?: string; | ||
| textColor?: ColorValue; | ||
| fontWeight: 'normal' | 'bold'; | ||
| onClickIcon?: () => void; |
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.
Any particular reason why you want only the icon (on the right) to be sensitive to clicks? I had a hard time figuring it out from the storybook.
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.
Done: the onClick event is now on the div of the Badge
src/stories/molecules/Badge.tsx
Outdated
| border?: 'none' | 'solid' | 'dashed' | 'dotted'; | ||
| icon?: string; | ||
| textColor?: ColorValue; | ||
| fontWeight: 'normal' | 'bold'; |
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.
See above
| } | ||
|
|
||
| interface DropdownProps { | ||
| sizeDropDown?: 'small' | 'medium' | 'large'; |
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.
Please convert to just size
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.
Done
| export const Default: Story = { | ||
| args: { | ||
| items: [ | ||
| { title: "1", content: <div> |
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 not a fan of passing React elements as props (assuming this is permitted at all). Please transform into <ResponsiveTabs.Tabs>, taking Base.TopMenu as an 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.
Done
src/stories/molecules/Tabs.tsx
Outdated
|
|
||
| type Item = { | ||
| title: string; | ||
| tabContent?: React.ReactNode; |
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.
Like above, please refactor using the “chosen child” pattern.
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.
Done
| linkType: hard | ||
|
|
||
| "@vitejs/plugin-react@npm:4.2.1": | ||
| "@vitejs/plugin-react@npm:^4.2.1": |
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.
Please rebase the changes to yarn.lock so that they come with the same commit that caused them (e.g. a change to package.json); and provide the relevant command (e.g. yarn add something) in the commit comment.
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.
Done together in call
0ac0cdb to
1d46de0
Compare
|
All changes have been done. Could you verify again please? |
domq
left a comment
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.
Another batch of work... Sorry need to run for lunch; will do thorough review yet later.
| export const Default: Story = { | ||
| args: { | ||
| title: 'Test default', | ||
| image: 'https://randomuser.me/api/portraits/men/3.jpg', |
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 hate to be that guy, but I think that https://randomuser.me/api/portraits/men/1.jpg is a better choice if we want visitors to focus on the widget rather than the dude 🤣
src/stories/molecules/Badge.tsx
Outdated
| <img src={image} className="image"/> | ||
| <span style={textStyle}>{title}</span> | ||
| <div className="d-flex justify-content-center"> | ||
| <span className="badge">9</span> |
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 9 should probably be a prop.
src/stories/molecules/Button.tsx
Outdated
| onClick, | ||
| ...props | ||
| }: ButtonProps) => { | ||
| let mode = primary ? 'storybook-button btn btn-primary' : 'storybook-button btn btn-secondary'; |
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.
You shouldn't have any references to storybook styles (or in fact, storybook anything: imports, SVG, etc.) in your *.tsx, *.css etc. files intended for production.
src/stories/molecules/badge.css
Outdated
| margin-right: 10px; | ||
| background-color: #eaeaea; | ||
| border-radius: 50%; | ||
| box-shadow: 0px 4px 4px #00000040; |
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.
Same as above (--badge-box-shadow)
src/stories/molecules/badge.css
Outdated
| justify-content: center; | ||
| } | ||
|
|
||
| .card-dashed { |
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 appears to be dead code?
src/stories/molecules/badge.css
Outdated
| flex-direction: row; | ||
| } | ||
|
|
||
| .clickable-center { |
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.
Please split this into two classes, and keep badge in there somewhere. I.e.
.badge-clickable {
cursor: pointer;
}
.badge-center {
align-items: center;
}You can then add both CSS classes to the div.
src/stories/molecules/badge.css
Outdated
| cursor: pointer; | ||
| } | ||
|
|
||
| @media (min-width: 768px) { |
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.
Again, this looks like dead code (from here to end of file).
| } | ||
|
|
||
|
|
||
| @media (min-width: 768px) { |
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.
Please use Bootstrap media queries — For better or worse, Bootstrap is a dependency of elements, and therefore of epfl-elements-react as well; we might as well use it.
Please cherry-pick the two commits of #3 or outright merge the PR (with fast-forward).
domq
left a comment
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.
Aaaaand here comes part deux.
| </Button> | ||
| } | ||
| </svg>, | ||
| <span key="label" style={{ marginLeft: '5px' }}>Primary</span>, |
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 suppose the button text could be made a story parameter here?
|
|
||
| function c_title(children: React.ReactNode) { | ||
| const title = (Children.toArray(children || []).find( | ||
| (child : React.ReactElement) => child.type === Tabs.Tab.Title)) as React.ReactElement<TabTitleProps>; |
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 type after as should have [] at the end, just like on line 14.
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.
Should we have [] even if I used .find that return only one element? In case there are more than one title, I get the first one.
|
|
||
| function c_content(children: React.ReactNode) { | ||
| const content = (Children.toArray(children || []).find( | ||
| (child : React.ReactElement) => child.type === Tabs.Tab.Content)) as React.ReactElement<TabContentProps>; |
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.
Same.
|
|
||
| /** | ||
| * An autocomplete list. | ||
| * If single selection: the selected element is shown directly in the input field. The "itemValue" could be the |
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.
Please skip a line to isolate §.
I don't understand the sentences on lines 23–24. Could you please rewrite it without a conditional (“could”)?
| placeholder = '', | ||
| isReadonly = false, | ||
| onChange | ||
| }: AutocompleteProps & FormControlProps) => { |
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.
You should be able to remove the type either here, or on line 28, and let TypeScript figure it out.
| } | ||
|
|
||
| const handleSelectionChange = (e: React.ChangeEvent<HTMLSelectElement>) => { | ||
| const selectedValues: Item[] = Array.from(e.target.selectedOptions, (option) => |
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 Item[] type is specified twice. You probably want to remove it from here (rather than line 55 below).
|
|
||
| setSelectedOptions(selectedValues); | ||
|
|
||
| if (onChange) { |
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.
Please consider having
if (! onchange) return;as the first line of the function instead (so that the browser doesn't have to compute Array.from() if you are going to end up doing nothing with the result)
| } | ||
|
|
||
| /** | ||
| * An numeric field. |
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.
“A” numeric field
| } | ||
|
|
||
| /** | ||
| * An textarea field. |
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.
“A textarea field”
src/stories/molecules/tabs.css
Outdated
| width: 100%; | ||
| vertical-align: top; | ||
| display: inline; | ||
| } No newline at end of file |
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.
Please (configure your IDE to) make sure all files end with a newline.
9389cf9 to
8b8f1e2
Compare
|
Hello, |
485b342 to
950299c
Compare
ad81b07 to
0762e04
Compare
c271ce5 to
9580d09
Compare
- Use [this named slot trick](https://medium.com/swlh/bring-vue-named-slots-to-react-87684188f18e) to give access to top-level menu, drawer, aside (left-hand) menu, avatar and breadcrumbs - Provide reasonable defaults for (some of) them
- Rename `Base.UserAvatar` to `Base.User`, so that one may decide to put up a login button up there instead - Develop a proper `<Avatar>` component, with a `<Avatar.Image>` named slot that (pretends to) accept either children or a `peopleSciper` prop
3da4d7b to
fa69d0a
Compare
Uh oh!
There was an error while loading. Please reload this page.