Skip to content

Commit 116d4aa

Browse files
committed
refactor(segment): MD fixing the segment colors in toolbars with colors
references #597
1 parent 0a5d1ec commit 116d4aa

File tree

3 files changed

+77
-19
lines changed

3 files changed

+77
-19
lines changed

ionic/components/segment/modes/md.scss

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,34 +39,63 @@ ion-segment {
3939

4040
ion-segment {
4141
margin: 0 auto;
42+
43+
ion-segment-button[button][outline].activated {
44+
background-color: transparent;
45+
}
4246
}
4347

4448
}
4549

46-
// Generate Default Button Colors
50+
// Generate Default Segment Colors
4751
// --------------------------------------------------
4852

49-
@each $color, $value in $colors {
53+
@mixin segment-button($button-color) {
54+
background-color: transparent;
5055

51-
ion-segment[#{$color}] {
52-
53-
ion-segment-button[button] {
54-
$bg-color: $value;
55-
$text-color: inverse($bg-color);
56+
&[outline] {
57+
color: $button-color;
5658

59+
&.activated {
5760
background-color: transparent;
58-
color: $text-color;
61+
color: $button-color;
62+
border-color: $button-color;
63+
opacity: 1;
64+
}
65+
}
66+
}
5967

60-
&[outline] {
61-
color: $bg-color;
68+
// Loop through all of the colors to change the segment colors
69+
// based on the toolbar color or if it isn't in a toolbar then based on
70+
// the segment color value
71+
@each $color-name, $color-value in $colors {
72+
$inverse-color-value: inverse($color-value);
6273

63-
&.activated {
64-
opacity: 1;
65-
color: $bg-color;
66-
border-color: $bg-color;
74+
.toolbar[#{$color-name}] {
75+
76+
ion-segment {
77+
ion-segment-button[button] {
78+
@include segment-button($inverse-color-value);
79+
}
80+
}
81+
82+
// Loop through all of the colors again to change the segment colors
83+
// for each toolbar based on the segment color
84+
// this will take priority over the default toolbar colors
85+
@each $color-name, $color-value in $colors {
86+
ion-segment[#{$color-name}] {
87+
ion-segment-button[button] {
88+
@include segment-button($color-value);
6789
}
6890
}
6991
}
7092

7193
}
94+
95+
ion-segment[#{$color-name}] {
96+
ion-segment-button[button] {
97+
@include segment-button($color-value);
98+
}
99+
100+
}
72101
}

ionic/components/segment/test/basic/main.html

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,44 @@ <h4>Model style: NgModel</h4>
8282
<p>Model Style: <b>Model {{ modelStyle }}</b></p>
8383
</ion-content>
8484

85-
<ion-toolbar position="bottom">
85+
<ion-toolbar position="bottom" primary>
86+
<ion-segment [(ng-model)]="appType">
87+
<ion-segment-button value="paid">
88+
Primary
89+
</ion-segment-button>
90+
<ion-segment-button value="free">
91+
Toolbar
92+
</ion-segment-button>
93+
<ion-segment-button value="top" class="e2eSegmentTopGrossing">
94+
Default Segment
95+
</ion-segment-button>
96+
</ion-segment>
97+
</ion-toolbar>
98+
99+
<ion-toolbar position="bottom" light>
86100
<ion-segment [(ng-model)]="appType" primary>
87101
<ion-segment-button value="paid">
88-
Paid
102+
Light
103+
</ion-segment-button>
104+
<ion-segment-button value="free">
105+
Toolbar
106+
</ion-segment-button>
107+
<ion-segment-button value="top" class="e2eSegmentTopGrossing">
108+
Primary Segment
109+
</ion-segment-button>
110+
</ion-segment>
111+
</ion-toolbar>
112+
113+
<ion-toolbar position="bottom" light>
114+
<ion-segment [(ng-model)]="appType">
115+
<ion-segment-button value="paid">
116+
Light
89117
</ion-segment-button>
90118
<ion-segment-button value="free">
91-
Free
119+
Toolbar
92120
</ion-segment-button>
93121
<ion-segment-button value="top" class="e2eSegmentTopGrossing">
94-
Top Grossing
122+
Default Segment
95123
</ion-segment-button>
96124
</ion-segment>
97125
</ion-toolbar>

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
"!./scripts/**",
1414
"!./dist/**",
1515
"!./tmp/**"
16-
]
16+
],
17+
"compileOnSave" : false
1718
}

0 commit comments

Comments
 (0)