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

Provide "setThemeVariants" for HasThemeVariant #6887

Open
stefanuebe opened this issue Dec 5, 2024 · 0 comments
Open

Provide "setThemeVariants" for HasThemeVariant #6887

stefanuebe opened this issue Dec 5, 2024 · 0 comments
Labels
DX Developer experience issue enhancement New feature or request good first issue Good for newcomers

Comments

@stefanuebe
Copy link
Contributor

Describe your motivation

This is a pure dx improvement / core readability request.

  1. To override the current theme variants, it is necessary to remove them manually first and then add a new one (if one wants to use theme variants):
button.removeThemeNames(button.getThemeNames().toArray(String[]::new))
button.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
  1. To apply/remove a theme variant to/from a component depending on a boolean, it is necessary to create an if-else like
if (someCondition) {              
    button.removeThemeVariants(ButtonVariant.LUMO_PRIMARY);
} else {
    button.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
}

Both use cases add unnecessary overhead and at least the 1 case is not really intuitive.

Describe the solution you'd like

Please provide a setThemeVariants method similar to the setThemeName(String, boolean) variant,

something like setThemeVariants(Variants...) (use case 1) and setThemeVariants(boolean , Variants...) (use case 2).

Describe alternatives you've considered

See the snippets.

Additional context

No response

@web-padawan web-padawan added the enhancement New feature or request label Dec 5, 2024
@yuriy-fix yuriy-fix added DX Developer experience issue good first issue Good for newcomers labels Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX Developer experience issue enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants