-
Notifications
You must be signed in to change notification settings - Fork 65
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
Creating a new Widget and Styles #273
Comments
The most basic way to answer this is just that all VNodes should get passed a className in this.classes() even if they receive no styles in the current theme, and all WNodes should get passed the There are a couple other patterns that will make the experience of theming a widget a little nicer: fixed classes, and making it easy to extend the widget and add to state classes (although the second may be more a widget extension pattern than a theming one). First, fixed classes: any styles that are necessary for the basic function of the widget should be split out into fixed classes so widget authors don’t need to worry about breaking functionality while trying to modify visual style. A good example of this is the Slider widget, which relies on an invisible native slider input overlaid on the styled interface. There are a number of styles necessary to correctly make the native input invisible and correctly positioned, all of which would be a pain to re-create every time an author wished to thumb size, for example. The second point, isolating and returning “state”-type classes in their own overridable method is something we don’t do yet in any existing widgets. For example: a Button already has classes for export interface CustomButtonProperties extends ButtonProperties {
loading: boolean;
}
@theme(css)
export class CustomButton extends Button<CustomButtonProperties> {
getStateClasses() {
const { disabled, popup, pressed, loading } = this.properties;
return this.classes(
disabled ? css.disabled : null,
popup ? css.popup : null,
pressed ? css.pressed : null,
loading ? css.loading : null
);
}
} Summary
|
@smhigley summarized this pretty perfectly. #316 covers returning “state”-type classes in their own method and our current theme tutorial covers the other three points listed. Action items:
|
User Story
As a developer, when I create a new class of widget, I want it to be easily themeable. What considerations and conventions should I include in the styles for the widget to ensure it is themeable downstream?
The text was updated successfully, but these errors were encountered: