Skip to content

Commit

Permalink
refactor(item): add the color to the parent item of a radio to style …
Browse files Browse the repository at this point in the history
…the label
  • Loading branch information
brandyscarney committed Aug 19, 2016
1 parent 2debc20 commit 7fba099
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/components/item/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,18 +421,20 @@ export class Item {
/**
* @internal
*/
_updateColor(newColor: string) {
this._setElementColor(this._color, false);
this._setElementColor(newColor, true);
_updateColor(newColor: string, colorClass?: string) {
this._setElementColor(this._color, false, colorClass);
this._setElementColor(newColor, true, colorClass);
this._color = newColor;
}

/**
* @internal
*/
_setElementColor(color: string, isAdd: boolean) {
_setElementColor(color: string, isAdd: boolean, colorClass?: string) {
colorClass = colorClass || 'item'; // item-radio

if (color !== null && color !== '') {
this._renderer.setElementClass(this._elementRef.nativeElement, `item-${color}`, isAdd);
this._renderer.setElementClass(this._elementRef.nativeElement, `${colorClass}-${color}`, isAdd);
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/components/radio/radio-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ export class RadioButton implements OnDestroy, OnInit {
_setElementColor(color: string, isAdd: boolean) {
if (color !== null && color !== '') {
this._renderer.setElementClass(this._elementRef.nativeElement, `radio-${color}`, isAdd);

if (this._item) {
this._item._updateColor(color, 'item-radio');
}
}
}
}
6 changes: 6 additions & 0 deletions src/components/radio/radio.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ ion-radio {

@mixin radio-theme-ios($color-name, $color-base) {

.item-radio-#{$color-name}.item-radio-checked {
ion-label {
color: $color-base;
}
}

.radio-#{$color-name} .radio-checked {
color: $color-base;

Expand Down
6 changes: 6 additions & 0 deletions src/components/radio/radio.md.scss
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ ion-radio {

@mixin radio-theme-md($color-name, $color-base, $color-contrast) {

.item-radio-#{$color-name}.item-radio-checked {
ion-label {
color: $color-base;
}
}

.radio-#{$color-name} {

.radio-checked {
Expand Down

0 comments on commit 7fba099

Please sign in to comment.