【发布时间】:2019-08-05 20:04:53
【问题描述】:
我是样式化组件的新手,我希望能够正确输入样式化组件,这样当我传递“vs code”道具时,我可以自动检测我拥有的所有道具,而不仅仅是主题中的那个或者我可以用接口放置的那些。
我在其他answer 中看到的那样,如果不使用 HOC,有什么办法吗?是否有可能获得一个通用的道具来使用,而不必像示例中那样在样式的每个属性中定义?
app.theme.ts
export const theme = {
palette: {
primaryColor: '#FF5018',
secondaryColor: '#252729',
tertiaryColor: '#1A1C1E',
textColor: 'white',
},
};
export type Theme = typeof theme;
navigation-bar.styled.component.ts
export const NavigationBarStyled = styled.div`
grid-area: navigation-bar-item;
padding-left: 2rem;
display: flex;
align-items: center;
color: ${({ theme }) => theme.palette.primaryColor};
background-color: ${({ theme }) => theme.palette.primaryColor};
`;
提前致谢, 最好的
【问题讨论】:
标签: reactjs typescript styled-components