New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow hex colors in place of Color enum #8783
base: dev
Are you sure you want to change the base?
Conversation
How do I hook it up to the Theme Provider when MudColor doesn't accept CSS variables? Do we need a separate class that can handle MudColor, Color enum, and CSS strings? |
I find this switch very hard to read, especially if it will have more cases. public static MudColor FromColor(Color color)
{
var hex = color switch
{
Color.Primary => "#594AE2",
Color.Secondary => Colors.Pink.Accent3,
Color.Tertiary => "#1EC8A5",
_ => "#594AE2"
};
return new MudColor(hex);
}
public static implicit operator MudColor(Color color) => FromColor(color); Like why we want a constructor for |
Not sure I'm understanding the problem. Can you describe the problem in more detail with examples? |
@ScarletKuro the disgusting switch was just for quick demonstration :)
You can define colors through the ThemeProvider and components will use them via CSS variables like |
Oh, now i get it. Yeah, that's pain |
Off topic: If we will use |
Actually, implementing this change isn't as straightforward as solving 2 + 2 (like I thought at first) |
Description
Adds a backwards-compatible way of using hex colors in places that accept the
MudBlazor.Color
enum by making it implicit withMudColor
.#470
How Has This Been Tested?
Type of Changes
Compare the visuals to the code in the screenshot:
Checklist
dev
).