Skip to content

Conversation

@rosamaggi
Copy link
Contributor

@rosamaggi rosamaggi commented Dec 12, 2023

  • Add input fields stories like: Radiobutton, Text, Numeric, Dropdown list,...
  • Add Responsive tabs, Badge and teaser
  • Active the onChange listener to most of them

@rosamaggi rosamaggi requested a review from domq December 12, 2023 10:23
@domq domq force-pushed the feature/addNewStories branch from 59ddec2 to 5cc5e4a Compare December 12, 2023 13:40
Copy link
Member

@domq domq left a 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.

}

/**
* Primary UI component for user interaction
Copy link
Member

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.
 */

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

icon?: string;
textColor?: ColorValue;
fontWeight: 'normal' | 'bold';
onClickIcon?: () => void;
Copy link
Member

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.

Copy link
Contributor Author

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

border?: 'none' | 'solid' | 'dashed' | 'dotted';
icon?: string;
textColor?: ColorValue;
fontWeight: 'normal' | 'bold';
Copy link
Member

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';
Copy link
Member

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

Copy link
Contributor Author

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>
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


type Item = {
title: string;
tabContent?: React.ReactNode;
Copy link
Member

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.

Copy link
Contributor Author

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":
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done together in call

@rosamaggi rosamaggi force-pushed the feature/addNewStories branch from 0ac0cdb to 1d46de0 Compare December 15, 2023 15:55
@rosamaggi
Copy link
Contributor Author

All changes have been done. Could you verify again please?

Copy link
Member

@domq domq left a 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',
Copy link
Member

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 🤣

<img src={image} className="image"/>
<span style={textStyle}>{title}</span>
<div className="d-flex justify-content-center">
<span className="badge">9</span>
Copy link
Member

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.

onClick,
...props
}: ButtonProps) => {
let mode = primary ? 'storybook-button btn btn-primary' : 'storybook-button btn btn-secondary';
Copy link
Member

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.

margin-right: 10px;
background-color: #eaeaea;
border-radius: 50%;
box-shadow: 0px 4px 4px #00000040;
Copy link
Member

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)

justify-content: center;
}

.card-dashed {
Copy link
Member

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?

flex-direction: row;
}

.clickable-center {
Copy link
Member

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.

cursor: pointer;
}

@media (min-width: 768px) {
Copy link
Member

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) {
Copy link
Member

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).

Copy link
Member

@domq domq left a 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>,
Copy link
Member

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>;
Copy link
Member

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.

Copy link
Contributor Author

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>;
Copy link
Member

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
Copy link
Member

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) => {
Copy link
Member

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) =>
Copy link
Member

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) {
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

“A textarea field”

width: 100%;
vertical-align: top;
display: inline;
} No newline at end of file
Copy link
Member

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.

@domq domq force-pushed the feature/addNewStories branch 2 times, most recently from 9389cf9 to 8b8f1e2 Compare December 19, 2023 11:47
@rosamaggi
Copy link
Contributor Author

Hello,
I added some correction to the branch. Could you verify please?
Thanks
Rosa

@domq domq force-pushed the feature/addNewStories branch 3 times, most recently from 485b342 to 950299c Compare February 28, 2024 10:46
@rosamaggi rosamaggi requested review from domq and williambelle May 2, 2024 12:48
@ponsfrilus ponsfrilus force-pushed the main branch 13 times, most recently from ad81b07 to 0762e04 Compare May 23, 2024 06:31
@ponsfrilus ponsfrilus force-pushed the main branch 2 times, most recently from c271ce5 to 9580d09 Compare May 27, 2024 12:31
rosamaggi and others added 29 commits July 8, 2025 10:18
- 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
@domq domq force-pushed the feature/addNewStories branch from 3da4d7b to fa69d0a Compare July 8, 2025 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants