-
Notifications
You must be signed in to change notification settings - Fork 8
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
Conversation
…mobile - add flags to tabs component - add disabled styling to TabScrollButton
…mponent with extensions
@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. |
@jomunker Can you please rebase this branch and fix the conflicts? |
This PR has commits from #1351 -> maybe you need a rebase? 🤔 |
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 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`. |
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.
@thomasdax98 is this changeset enough?
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.
@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
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.
Will do it once all discussions are resolved for this PR 👍🏻
showStatusIcon?: boolean; | ||
statusIcon?: React.FunctionComponentElement<IconProps> | undefined; |
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.
Both these props should be controlled via status
. Why do you need them?
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 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
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.
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.
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."); | ||
|
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 don't think we need this warning if we remove showStatusIcon
and statusIcon
. If we need them, I'd rather throw an error
showTooltip | ||
tooltipMessage="Tooltip message" | ||
tooltipIcon={<HelpOutline fontSize="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.
Instead of these three props, have you thought about <Tab tooltip={<Tooltip><Icon/></Tooltip/>} />
? Way more flexible IMO
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.
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)
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.
Good idea. But then the user has to know these two components. Don't know if this is nice UX 🤔
packages/admin/admin-stories/src/docs/components/Tabs/stories/Tabs.stories.tsx
Show resolved
Hide resolved
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... |
Nope |
defaultIndex?: number; | ||
tabsState?: ITabsState; | ||
smallTabText?: boolean; |
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.
+1 for size
|
||
export const Divider: React.FC<DividerProps> = () => null; | ||
|
||
export const CustomDivider: React.FC<DividerProps> = ({ children, ...props }) => { |
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.
+1
|
||
export const Divider: React.FC<DividerProps> = () => null; | ||
|
||
export const CustomDivider: React.FC<DividerProps> = ({ children, ...props }) => { |
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.
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; |
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 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 }) => { |
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.
If we decide to keep this component, I think it should be renamed to TabDivider
.
showStatusIcon?: boolean; | ||
statusIcon?: React.FunctionComponentElement<IconProps> | undefined; |
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.
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>; |
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.
Could this change from MuiTabProps
to TabProps
cause any compatibility problems?
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 only thing would be icon
and tabIcon
I guess. Since @johnnyomair also stated this aswell, I changed it back to icon
.
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; |
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.
Regarding the props, I'd stay with the terms UX uses:

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
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.
Alright. @johnnyomair does this align with your expectations?
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 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.
Co-authored-by: Thomas Dax <thomas.dax@vivid-planet.com>
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. |
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. |
This PR adds new Features to the
Tabs
andRouterTabs
Components.(Router-)Tabs
can now contain theDivider
component as children to separate Tabs. Additionally, oneTab
orRouterTab
can now show a tab icon, a status with icon and a tooltip.Acceptance criteria
Screenshots
Implementation
Tabs
RouterTabs