Skip to content
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

DEBATE: get rid of all the ''individual color enums'' #767

Open
Lucasharskamp opened this issue Jun 20, 2024 · 0 comments
Open

DEBATE: get rid of all the ''individual color enums'' #767

Lucasharskamp opened this issue Jun 20, 2024 · 0 comments

Comments

@Lucasharskamp
Copy link
Contributor

Lucasharskamp commented Jun 20, 2024

There might be something I'm missing here @gvreddy04 , so I want your input on this: but why does this library have so many ''Color'' enums? BackgroundColor, ToastType, all the ones in the Enums -> Color folder, etc.

Most of them contain the following colors: None, Default, Primary, Secondary, Success, Danger, Warning, Info, Light and Dark. Some also contain Transparent.

Problem 1: it isn't up to the library to determine how the components are used.

ToastType for example doesn't contain an option for Transparent or None. Why not? Maybe the programmer in this case wants to have the contents of the Toast be a div.container with gutters where only specific sections get a background. it isn't up to Blazor.Bootstrap to decide what is and isn't allowed.

Same goes for Callout: Callout only gets Default, Danger, Warning, Info and Success. But I don't care, really! I want a Light or Dark or Transparent callout if those are the needs of the UI.

Problem 2: unclear naming

Primary, Secondary, Success, etc are clear. The problem lies with these 3: None, Default and Transparent.

What does None mean in this context? Does it mean we have no background (transparent) or that we revert to the default background? Or are we using the CSS inherit functionality?

Proposed solution:

Proposed solution: just have 1 enum for Colors for everything in the library, even for text. If the user wants text to be transparent, than we must trust them to have a good reason for it. The library exists to help create business solutions, but not infringe on what those business solutions are. It also removes some needless transformation methods that turn an enum of, say, AlertColor to TextColor or anything like that.

public enum BsColor
{
    Default = 0,
    Primary,
    Secondary,
    Success,
    Danger,
    Warning,
    Info,
    Light,
    Dark,
   Body, // grab from --bs-body, useful for backgrounds but others as well. 
    White, // refers to --bs-white
    Black, // refers to --bs-black
    Transparent,
    Muted,
    Link
}

It's called BsColor as a reference as how Bootstrap has its variables beginning with --bs-, for the sake of readability in code and differentiate it from System.Drawing.Color.

A gradient can be handled by simply providing an extra bool parameter signifying the gradient, that if true will add the .bg-gradient class to the component. The only problem may be for Muted/Link colors, but then again, one can also just ignore it, create a custom css for it for the user to fill in or use NotImplementedExceptions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant