cfnz / muirwik

Muirwik - a Material UI React wrapper written in Kotlin
Mozilla Public License 2.0
132 stars 25 forks source link

Question: Is there a way to change the icon size of alert using `mAlert` function #81

Closed EV6999 closed 2 years ago

EV6999 commented 2 years ago

Hello, I want to customize the icon size of alert. But it seems there is no icon attr for mAlert function.

Could you help to answer my question? Thank you.

This is how I use mAlert fuction. mAlert(message= message, severity = MAlertSeverity.warning)

cfnz commented 2 years ago

Looks like you are using an older version (with the mAlert rather than alert), but that is OK because it seems the newer version does not have the icon attribute anyway.

The way to add missing attributes in general is to convert the attributes to dynamic. I tested the following with the new version and it works, I imagine if you replace alert and icon with mAlert and mIcon it should be the same... (didn't test it).

    alert("Alert Title", "This is a big smiley alert") {
        attrs.asDynamic().icon = buildElement {
            icon("sentiment_satisfied") {
                attrs.fontSize = IconFontSize.large
            }
        }
    }
    br {}
    alert("Alert Title", "This is a really big smiley alert") {
        attrs.asDynamic().icon = buildElement {
            icon("sentiment_satisfied") {
                css {
                    fontSize = 16.spacingUnits
                }
            }
        }
    }

I will look at adding the icon attribute properly, but this method should work until then.

EV6999 commented 2 years ago

Thank you so much! It works for me. Have a great day!