-
Notifications
You must be signed in to change notification settings - Fork 0
Fix handling of style property in Tabs component
#139
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
Changes from 4 commits
45d7761
2aee8e3
e25e6ba
87c9a41
725fe23
fde84a7
d7f1896
594979e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,10 +9,11 @@ import { Box } from "@/plugins/mui/Box"; | |
| import { isString } from "@/utils/isString"; | ||
| import { isComponentState } from "@/types/state/component"; | ||
|
|
||
| interface TabState { | ||
| interface TabState extends ComponentState { | ||
| type: "Tab"; | ||
| label?: string; | ||
| icon?: string; | ||
| iconPosition?: "bottom" | "end" | "start" | "top" | undefined; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we have
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, |
||
| disabled?: boolean; | ||
| children?: ComponentProps[]; | ||
| } | ||
|
|
@@ -44,21 +45,23 @@ export function Tabs({ | |
| } | ||
| }; | ||
| return ( | ||
| <MuiBox sx={{ width: "100%" }}> | ||
| <MuiBox sx={{ width: "100%" }} style={style}> | ||
| <MuiBox sx={{ borderBottom: 1, borderColor: "divider" }}> | ||
| <MuiTabs id={id} style={style} value={value} onChange={handleChange}> | ||
| <MuiTabs id={id} value={value} onChange={handleChange}> | ||
| {tabItems?.map((tab, index) => { | ||
| const tabState = isComponentState(tab) | ||
| ? (tab as TabState) | ||
| : undefined; | ||
| return ( | ||
| <MuiTab | ||
| key={index} | ||
| style={tabState?.style} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we apply the same style to both the Tab button and body, was this a design decision? or does it needs discussion?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct, this enables a user to apply styling to the entire Tab component (Button in the header + body). Before this change it was only possible to change the styling of the button and the user had no styling control over the content (body) of the Tab (see #135). However, this desicion was not discussed.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @b-yogesh is right, using the same style for both cannot be right.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I applied your change requests. Now, the style of the Tab component gets applied only to the Tab button, the styling of the Tab content needs to be managed by the children of the Tab component.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you share a screenshot of this new demo looks like with the style-specific children in Tab content? |
||
| label={tabState ? tabState.label : isString(tab) ? tab : ""} | ||
| icon={ | ||
| tabState && | ||
| tabState.icon && <MuiIcon>{tabState.icon}</MuiIcon> | ||
| } | ||
| iconPosition={tabState?.iconPosition} | ||
| disabled={disabled || (tabState && tabState.disabled)} | ||
| /> | ||
| ); | ||
|
|
@@ -70,10 +73,11 @@ export function Tabs({ | |
| return ( | ||
| value === index && ( | ||
| <Box | ||
| style={tabState?.style} | ||
| key={index} | ||
| type={type} | ||
| onChange={onChange} | ||
| children={tabState?.children ?? undefined} | ||
| children={tabState?.children} | ||
| /> | ||
| ) | ||
| ); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.