-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
Color attribute: add color as an attribute to our components #7467
Comments
For 'dynamic theming' (at runtime) it would be nice to be able to write
or when theming is realized with normal classes:
|
@szerner Yes that is how this attribute would work. :) Updated issue to show a better example. |
@brandyscarney what about |
I would appreciate the possibility to set the colors of the But this might be non trivial, since the color seems to be "hard coded" into the icons SVG definition. |
Thanks for the recommendation @joekukish. We are going to stick with Hi @szerner, could you open a separate issue for this and I can look into it? Right now I am adding the |
|
@brandyscarney I opened a new issue #7826 for my suggestion. |
…ibutes clean up tests with colors references #7467
…ly adding the color to the component BREAKING CHANGES: Colors should be passed in the `color` input on components, not added individually as an attribute on the component. For example: ``` <ion-tabs primary> ``` Becomes ``` <ion-tabs color=”primary”> ``` Or to bind an expression to color: ``` <ion-navbar [color]="barColor"> ... </ion-navbar> ``` ```ts @component({ templateUrl: 'build/pages/about/about.html' }) export class AboutPage { barColor: string; constructor(private nav: NavController, platform: Platform) { this.barColor = platform.is('android') ? 'primary' : 'light'; } } ``` Reason for this change: It was difficult to dynamically add colors to components, especially if the name of the color attribute was unknown in the template. This change keeps the css flat since we aren’t chaining color attributes on components and instead we assign a class to the component which includes the color’s name. This allows you to easily toggle a component between multiple colors. Speeds up performance because we are no longer reading through all of the attributes to grab the color ones. references #7467 closes #7087 closes #7401 closes #7523
I think that might be useful to have |
|
@albrecht-jun-zhang You can use property binding for
See: https://angular.io/docs/ts/latest/guide/template-syntax.html#!#property-binding |
@brandyscarney One question please. |
@akkii922 A good solution to that would be to have an injectable class for the state of the theming variables. You then inject the state in the constructor of each controller and reference the state object properties on each page using things like [color]. |
Hello,
|
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
This makes dynamically changing attributes easier for the user, and it will be easier to manage internally. For example:
<button primary>Button</button>
will become
<button color="primary">Button</button>
Edit: I realized button is probably a bad example since it already has this attribute, but this will benefit components like
ion-navbar
as well:or
Edit: Components that will have the color input:
The text was updated successfully, but these errors were encountered: