-
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
Theming for widget variants #847
Comments
5 tasks
5 tasks
This was referenced Nov 29, 2019
5 tasks
5 tasks
This was referenced Dec 3, 2019
This was referenced Dec 4, 2019
This was referenced Dec 6, 2019
7 tasks
7 tasks
7 tasks
7 tasks
7 tasks
This was referenced Apr 9, 2021
This was referenced Apr 12, 2021
This was referenced Apr 12, 2021
This was referenced Apr 13, 2021
7 tasks
7 tasks
This was referenced May 3, 2021
This was referenced May 24, 2021
This was referenced Jun 10, 2021
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We need to develop a way to theme widget variants.
For example, it should be possible for a user to target the
raised-button
or theemail-input
directly and theme is differently to the standardbutton
/input
.Current code (wrong)
Currently we are going some way to achieving this using
classes
along withthis.theme
, as seen here in theraised-button
render function.The problem with this approach is that
classes
is an additive function whereastheme
is designed to replace the existing styling. This means that the raised button, when themed, will receive the theme styles for bothbutton
andraised-button
.eg. given the following code and the current approach, the raised button will have a green background and italic purple text. This is not correct as the
raisedButtonCss
root class should override thebuttonCss
root class.In order to achieve the correct result, where we only get the styles from the
raisedButtonCss
and see purple italics without the green background we need to do something cleverer withthis.theme
and the object that gets passed to thebutton
.Class based solution (better)
To fix this issue correctly and allow widget variants (ie.
raised-button
) to be fully themeable we need to compose together the themed classes for bothbutton
andraised-button
and then pass this object astheme
to the underlying widget.This proposed solution to be adopted by all widget variants appears to work and in the previous example, the
raised-button
gets only the appropriate theme styles applied to it.Function based widget approach (best +++)
The proposed solution for this theming issue when using function based widgets and the
theme
middleware is the simplest approach by far.For this reason, I believe that all widget variants should be created using the function based approach.
Downsides of this approach
It is a known issue that changing the
theme
object that is passed down will mean that any child widgets will receive the adjustedtheme
. However, as it is highly unlikely that a button will contain another button, or an input etc, I do not believe this will be an issue and cannot think of any realistic scenarios in which this would be problematic.The text was updated successfully, but these errors were encountered: