Skip to content
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

COM-60: Additional features for Tabs #1392

Closed
wants to merge 34 commits into from

Conversation

jomunker
Copy link
Contributor

@jomunker jomunker commented Nov 13, 2023

This PR adds new Features to the Tabs and RouterTabs Components. (Router-)Tabs can now contain the Divider component as children to separate Tabs. Additionally, one Tab or RouterTab can now show a tab icon, a status with icon and a tooltip.

Acceptance criteria

  • Add changeset

Screenshots

Implementation

Tabs

image

RouterTabs

image

@jomunker jomunker self-assigned this Nov 13, 2023
@lllHuber
Copy link
Contributor

@jomunker, @thomasdax98, @johnnyomair what's the status here? I would like to use this feature in a project and could help out, if something still needs to be done.

@thomasdax98
Copy link
Member

@jomunker Can you please rebase this branch and fix the conflicts?

@jomunker jomunker requested a review from thomasdax98 November 30, 2023 09:49
@johnnyomair
Copy link
Collaborator

This PR has commits from #1351 -> maybe you need a rebase? 🤔

Copy link
Collaborator

@johnnyomair johnnyomair left a comment

Choose a reason for hiding this comment

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

The icons are also added in #1462, right?

"@comet/admin": minor
---

Add new features to `Tabs`. A tab can now have an icon, status and tooltip. A `Divider` component can be added alongside `Tab`/ `RouterTab` components in `Tabs` and `RouterTabs`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

@thomasdax98 is this changeset enough?

Copy link
Member

Choose a reason for hiding this comment

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

@jomunker Please add a code example showing how the Tabs can be configured to the changeset and/or a link to the storybook story showcasing the new functionality

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do it once all discussions are resolved for this PR 👍🏻

Comment on lines +20 to +21
showStatusIcon?: boolean;
statusIcon?: React.FunctionComponentElement<IconProps> | undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Both these props should be controlled via status. Why do you need them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree that we can remove showStatusIcon but the other one is needed imo. If the user wants a custom icon then it's needed. I mean we could use one status prop but as an object with type and icon

Copy link
Member

Choose a reason for hiding this comment

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

There are two versions of the status: with and without icon. We need to support both.

My opinion: Keep showStatusIcon and omit statusIcon. We have three predefined statuses with three predefined colors so we can also have three predefined icons.

Otherwise we have to make the whole component more flexible. But here I'm more pro ease-of-use vs flexibility.

Comment on lines +25 to +28
if (!status && (showStatusIcon || statusIcon)) console.warn("A status (prop: status) has to be provided, if the status icon should show.");

if (status && statusIcon && !showStatusIcon) console.warn("The status icon will only be shown, if the showStatusIcon prop is set to true.");

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we need this warning if we remove showStatusIcon and statusIcon. If we need them, I'd rather throw an error

Comment on lines +30 to +32
showTooltip
tooltipMessage="Tooltip message"
tooltipIcon={<HelpOutline fontSize="large" />}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of these three props, have you thought about <Tab tooltip={<Tooltip><Icon/></Tooltip/>} />? Way more flexible IMO

Copy link
Collaborator

Choose a reason for hiding this comment

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

Status could also be done via <Tab status={<StatusBadge />} />. This would prevent having to prop drill the StatusBadge, Tooltip Props and creating tight coupling between components that have only few things in common (one is the child of another)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. But then the user has to know these two components. Don't know if this is nice UX 🤔

@jomunker
Copy link
Contributor Author

jomunker commented Dec 21, 2023

This PR has commits from #1351 -> maybe you need a rebase? 🤔

Rebase doesn't work since the tab auto scroll PR has been squashed 🤷🏻‍♂️ Should I just leave it like this? Won't change anything I guess and we're squashing here anyways...

@jomunker
Copy link
Contributor Author

The icons are also added in #1462, right?

Nope

@jomunker jomunker requested a review from johnnyomair December 22, 2023 07:39
defaultIndex?: number;
tabsState?: ITabsState;
smallTabText?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

+1 for size


export const Divider: React.FC<DividerProps> = () => null;

export const CustomDivider: React.FC<DividerProps> = ({ children, ...props }) => {
Copy link
Member

Choose a reason for hiding this comment

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

+1


export const Divider: React.FC<DividerProps> = () => null;

export const CustomDivider: React.FC<DividerProps> = ({ children, ...props }) => {
Copy link
Member

Choose a reason for hiding this comment

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

Although I think this was originally @jamesricky's suggestion. Maybe he can elaborate on that?


export type DividerProps = Omit<MuiDividerProps, "orientation" | "variant">;

export const Divider: React.FC<DividerProps> = () => null;
Copy link
Member

Choose a reason for hiding this comment

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

This is the same pattern we also use for Tab and RouterTab. But it isn't necessary for the Divider since we don't enhance it with more information later. So you could use CustomDivider directly in the application.


export const Divider: React.FC<DividerProps> = () => null;

export const CustomDivider: React.FC<DividerProps> = ({ children, ...props }) => {
Copy link
Member

Choose a reason for hiding this comment

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

If we decide to keep this component, I think it should be renamed to TabDivider.

Comment on lines +20 to +21
showStatusIcon?: boolean;
statusIcon?: React.FunctionComponentElement<IconProps> | undefined;
Copy link
Member

Choose a reason for hiding this comment

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

There are two versions of the status: with and without icon. We need to support both.

My opinion: Keep showStatusIcon and omit statusIcon. We have three predefined statuses with three predefined colors so we can also have three predefined icons.

Otherwise we have to make the whole component more flexible. But here I'm more pro ease-of-use vs flexibility.

children: Array<React.ReactElement<TabProps> | boolean | null | undefined> | React.ReactElement<TabProps>;
tabComponent?: React.ComponentType<MuiTabProps>;
children: Array<React.ReactElement<TabProps | DividerProps> | boolean | null | undefined>;
tabComponent?: React.ComponentType<TabProps>;
Copy link
Member

Choose a reason for hiding this comment

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

Could this change from MuiTabProps to TabProps cause any compatibility problems?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only thing would be icon and tabIcon I guess. Since @johnnyomair also stated this aswell, I changed it back to icon.

Comment on lines 15 to 23
tabIcon?: React.FunctionComponentElement<IconProps>;
status?: Status;
showStatusIcon?: boolean;
statusIcon?: React.FunctionComponentElement<IconProps>;
showTooltip?: boolean;
tooltipMessage?: string;
tooltipIcon?: React.FunctionComponentElement<IconProps>;
tooltipPlacement?: TooltipProps["placement"];
smallTabText?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

Regarding the props, I'd stay with the terms UX uses:

Bildschirmfoto 2023-12-27 um 11 00 03

So
tabIcon -> icon
tooltipIcon -> helperIcon

I'd further:
remove showTooltip (should be controlled by helperIcon)
omit tooltipMessage and tooltipPlacement in favor of passing a Tooltip via helperIcon (Alternative: only pass helperText. Omit helperIcon, always show the Info icon instead)
rename smallTabText to 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.

Alright. @johnnyomair does this align with your expectations?

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 size be a number then or an enum value or what? Because at the moment it's a boolean and the name of a boolean variable (or prop in this case) should indicate that it is a boolean.

@vivid-planet vivid-planet deleted a comment from netlify bot Jan 10, 2024
@vivid-planet vivid-planet deleted a comment from netlify bot Jan 10, 2024
@johnnyomair
Copy link
Collaborator

We discussed this in today's meeting: There will be some UX changes (for instance, no tooltip), which need to be addressed in this PR before merging. Marking as draft for now.

@johnnyomair johnnyomair marked this pull request as draft January 10, 2024 15:53
@johnnyomair johnnyomair removed their request for review January 10, 2024 15:53
@johnnyomair
Copy link
Collaborator

This PR hasn't been updated in over a year, so I'm closing it for now. If it's still relevant, feel free to update and re-open.

@johnnyomair johnnyomair deleted the COM-60-tab-additional-features branch January 21, 2025 10:37
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.

6 participants