【发布时间】:2019-10-31 21:26:33
【问题描述】:
当像这样导入主题时(在 filename.style.ts 中):
import theme from 'common/theme';
我可以访问不同的属性,例如
theme.breakpoints.down('md')
我正在尝试在theme.ts 文件中引用相同的属性,但当然.. 主题。在这里无效,所以我试图找到一种可以重用/引用它的方法。
正如您在 MuiTable 上看到的,我正在尝试访问 breakpoints 和 palette/primary。
theme.ts
import createMuiTheme from '@material-ui/core/styles/createMuiTheme';
export const MuiPaperBackgroundColor = '#f7f8f6';
export default createMuiTheme({
spacing: 8,
breakpoints: {
values: {
xs: 0, sm: 600, md: 960, lg: 1280, xl: 1650,
},
},
palette: {
primary: {
main: '#3f18aa',
extraLight: 'rgb(193, 181, 227)',
noDataColor: '#cccccc',
cardBgColor: '#ECECEC',
chartColors: [
'#E77F42',
'#F3C3A3',
],
},
overrides: {
MuiTable: {
root: {
whiteSpace: 'nowrap',
[theme.breakpoints.down('md')]: {
'& tr': {
'& td:first-child, & th:first-child': {
position: 'sticky',
left: 0,
backgroundColor: theme.palette.header.main,
color: theme.palette.primary.contrastText,
zIndex: 2,
},
},
},
},
},
},
});
【问题讨论】:
-
在这里查看我的答案:stackoverflow.com/questions/56532599/…
-
感谢@RyanCogswell :) 这实际上为我解决了它!.. 谷歌搜索了很多以找到解决方案,但没有找到任何东西..
-
你能把这个作为答案发给我吗?
-
只需对另一个投票,然后我会将其标记为重复,以便交叉引用它(我不能将其标记为不被接受且不被接受的答案的重复)没有任何赞成票)。
-
支持您的评论.. 谢谢 :)
标签: reactjs typescript material-ui