kLabz / haxe-material-ui

Haxe externs and tools for material-ui
MIT License
9 stars 5 forks source link

makeStyles #9

Open kevinresol opened 4 years ago

kevinresol commented 4 years ago

The macro helps typing the said function correctly.

kLabz commented 4 years ago

I have a variant here that should be more complete (usage with or without theme), and also allows using css.Properties enum values like Styles.jss(...) does for withStyles.

Example usage:

import mui.core.styles.MuiTheme;
import mui.core.styles.Styles;

private typedef TClasses = Classes<[fullHeight]>;

// ...

var styles:TClasses = Styles.makeStyles({
    fullHeight: {
        display: "flex",
        position: Relative,
        height: "100%",
        "@media print": {
            borderRadius: 0,
            boxShadow: "none"
        }
    }
})();

console.dir(styles);
trace(styles.fullHeight);

var styles:TClasses = Styles.makeStyles(
    (theme:DefaultTheme) -> Styles.jss({
        fullHeight: {
            color: theme.palette.text.primary
        }
    })
)(theme);

console.dir(styles);
trace(styles.fullHeight);
kLabz commented 4 years ago

Does this work for your use case?