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

Make palette classes immutable records #9004

Open
1 of 2 tasks
danielchalmers opened this issue May 18, 2024 · 0 comments
Open
1 of 2 tasks

Make palette classes immutable records #9004

danielchalmers opened this issue May 18, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@danielchalmers
Copy link
Contributor

Feature request type

Other

Component name

No response

Is your feature request related to a problem?

I don't want to duplicate my palette styles:

MudTheme _theme = new()
{
    PaletteLight = new PaletteLight()
    {
        Primary = "#776be7",
        PrimaryLighten = "#978dec",
        Info = "#776be7",
        AppbarText = "#ffffffe6",
        Background = "#f7f6fb",
        TextDisabled = "#424242",
        HoverOpacity = 0.1,
    },

    PaletteDark = new PaletteDark()
    {
        Primary = "#776be7",
        Info = "#776be7",
        AppbarText = "#ffffffe6",
        TextPrimary = "#ffffffcc",
        TextSecondary = "#ffffff99",
        TextDisabled = "#ffffffb2",
        HoverOpacity = 0.1,
    },
}

With records:

Palette _basePalette = new()
{
    Primary = "#776be7",
    Info = "#776be7",
    AppbarText = "#ffffffe6",
    HoverOpacity = 0.1,
};

MudTheme _theme = new()
{
    PaletteLight = _basePalette with
    {
        PrimaryLighten = "#978dec",
        Background = "#f7f6fb",
        TextDisabled = "#424242",
    },

    PaletteDark = _basePalette with
    {
        TextPrimary = "#ffffffcc",
        TextSecondary = "#ffffff99",
        TextDisabled = "#ffffffb2",
    },
}

Describe the solution you'd like

Make the palettes records, particularly for the with keyword, and ensure they are immutable since they shouldn't be changed during execution as changes won't take effect anyway.

Have you seen this feature anywhere else?

No response

Describe alternatives you've considered

Inheriting the Palette class.

Pull Request

  • I would like to do a Pull Request

Code of Conduct

  • I agree to follow this project's Code of Conduct
@danielchalmers danielchalmers added the enhancement New feature or request label May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Planned for v8
Development

No branches or pull requests

1 participant