-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
[Tabs] Simplify override #14638
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
[Tabs] Simplify override #14638
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,3 @@ | ||
import React from 'react'; | ||
import clsx from 'clsx'; | ||
import MuiTab from '@material-ui/core/Tab'; | ||
import { TAB } from '../../theme/core'; | ||
|
||
const Tab = ({ className, inverted, ...props }) => ( | ||
<MuiTab | ||
className={clsx(TAB.root, className)} | ||
classes={{ label: TAB.label, selected: TAB.selected }} | ||
{...props} | ||
/> | ||
); | ||
|
||
export default Tab; | ||
export default MuiTab; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,3 @@ | ||
import React from 'react'; | ||
import clsx from 'clsx'; | ||
import MuiTabs from '@material-ui/core/Tabs'; | ||
import { TABS } from '../../theme/core'; | ||
|
||
const Tabs = ({ className, inverted, ...props }) => ( | ||
<MuiTabs | ||
className={clsx(TABS.root, className, inverted && TABS.inverted)} | ||
classes={{ indicator: TABS.indicator }} | ||
{...props} | ||
/> | ||
); | ||
|
||
export default Tabs; | ||
export default MuiTabs; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export default ({ attach, theme, nest, ICON, TAB }) => ({ | ||
export default ({ theme }) => ({ | ||
MuiTabs: { | ||
root: { | ||
borderTop: '1px solid #efefef', | ||
|
@@ -15,52 +15,30 @@ export default ({ attach, theme, nest, ICON, TAB }) => ({ | |
}, | ||
MuiTab: { | ||
root: { | ||
lineHeight: 'inherit', | ||
minHeight: 54, | ||
fontWeight: 600, | ||
minWidth: 0, | ||
marginRight: theme.spacing(1), | ||
marginLeft: theme.spacing(1), | ||
[theme.breakpoints.up('md')]: { | ||
minWidth: 0, | ||
marginRight: 30, | ||
marginLeft: 30, | ||
}, | ||
[attach(TAB.selected)]: { | ||
[nest(TAB.label)]: { | ||
fontWeight: 600, | ||
}, | ||
'& *': { | ||
color: '#262626 !important', | ||
}, | ||
}, | ||
}, | ||
labelIcon: { | ||
minHeight: 53, | ||
paddingTop: 0, | ||
'& .MuiTab-wrapper': { | ||
flexDirection: 'row', | ||
}, | ||
[nest(ICON.root)]: { | ||
minHeight: null, | ||
paddingTop: null, | ||
'& $wrapper :first-child': { | ||
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. Oh this rule applies to all first-childs in the tree. This messes things up, if you are using icons and labels.
I think you want to omit the space here:
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. In my case I am using Tabs with Labels, Icons and Badges. The above rule is applied to all of them. 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. Are you using this custom theme? Yeah, I'm happy to try the change. 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. Oh actually not. I added this comment to the wrong part of the code 😬. Nevertheless the issue stays the same. You might want look at this, too. 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. Here is an example: https://codesandbox.io/s/53o696672p 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. What about? '& $wrapper > *:first-child': { 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. testes locally & lgtm! 😍 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. Awesome! Do you want to submit a pull request? :) 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. Happy to! 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. Done #14844 |
||
fontSize: 16, | ||
marginBottom: 0, | ||
marginRight: 6, | ||
}, | ||
}, | ||
wrapper: { | ||
flexDirection: 'row', | ||
'& *': { | ||
color: '#999', | ||
textColorInherit: { | ||
color: '#999', | ||
'&$selected': { | ||
color: '#262626', | ||
}, | ||
}, | ||
labelContainer: { | ||
padding: 0, | ||
[theme.breakpoints.up('md')]: { | ||
padding: 0, | ||
paddingLeft: 0, | ||
paddingRight: 0, | ||
}, | ||
}, | ||
label: { | ||
letterSpacing: 1, | ||
textTransform: 'uppercase', | ||
wrapper: { | ||
flexDirection: 'row', | ||
}, | ||
}, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,3 @@ | ||
import React from 'react'; | ||
import clsx from 'clsx'; | ||
import MuiTabs from '@material-ui/core/Tabs'; | ||
import { TABS } from '../../theme/core'; | ||
|
||
const Tabs = ({ className, underline, inverted, ...props }) => ( | ||
<MuiTabs | ||
className={clsx(TABS.root, className, inverted && TABS.inverted, underline && TABS.underline)} | ||
classes={{ indicator: TABS.indicator }} | ||
{...props} | ||
/> | ||
); | ||
|
||
export default Tabs; | ||
export default MuiTabs; |
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.
Hi @siriwatknp, If you have some time, I think that it would be great that we take the time to find the best possible theme implementation. We have different theme demos, the approach isn't consistent. I think that we should try to unify 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.
Hi @oliviertassinari, should we open a discussion topic about mui-theming?