There is this project, someone wrote components with custom css in it.
There is this thing I saw in it This is a wrapper component similar to Container in Material ui, or just a div wrapper which just apply css.
export const Container = styled.div`
position: relative;
margin: 0 auto;
margin-top: ${p => p.marginTop ? p.theme.spacing[p.marginTop] : 0};
width: 100%;
max-width: ${p => (p.maxWidth && p.theme.screen[p.maxWidth])};
padding: ${p => p.padding ? `0 ${p.theme.spacing[p.padding]}` : `0 ${p.theme.spacing.sm}`};
z-index: ${p => p.zIndex && p.theme.zIndex[p.zIndex]};
background-color: ${p => p.color && p.theme.colors[p.color]};
border-radius: ${p => p.radius && p.theme.radius[p.radius]};
`;
but i don't understand the p.marginTop, p.theme, and all others
but now i want to just convert the thing to simple div wrapper and give it style property the material ui way.
some thing like this
const useStyles = makeStyles((theme) => ({
container: {
position: 'relative',
margin: '0 auto',
// margin-top: ${p => p.marginTop ? p.theme.spacing[p.marginTop] : 0},
width: '100%',
// max-width: ${p => (p.maxWidth && p.theme.screen[p.maxWidth])},
// padding: ${p => p.padding ? `0 ${p.theme.spacing[p.padding]}` : `0 ${p.theme.spacing.sm}`},
padding: themeIntance.spacing.sm,
// z-index: ${p => p.zIndex && p.theme.zIndex[p.zIndex]},
// background-color: ${p => p.color && p.theme.colors[p.color]},
// border-radius: ${p => p.radius && p.theme.radius[p.radius]},
}
}))
but all the commented lined in it, were showing errors, saying it doesn't recognizance p.
(previously those p.theme things, I found a work around, there was a had a theme.js file, from where i could import all the p.theme.spacing.sm, but I don't understand what p.padding or p.maxWidth are)
Please help me understanding this.