mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
fix(segment): working
This commit is contained in:
@ -15,6 +15,9 @@ ion-segment {
|
|||||||
button,
|
button,
|
||||||
[button] {
|
[button] {
|
||||||
|
|
||||||
|
margin-left: 0;
|
||||||
|
margin-right: 0;
|
||||||
|
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: block;
|
display: block;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@ -43,3 +46,40 @@ ion-segment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generate Default Button Colors
|
||||||
|
// --------------------------------------------------
|
||||||
|
|
||||||
|
@each $color, $value in $colors {
|
||||||
|
|
||||||
|
ion-segment[#{$color}] {
|
||||||
|
|
||||||
|
ion-segment-button[button] {
|
||||||
|
$bg-color: $value;
|
||||||
|
$bg-color-activated: darken-or-lighten($bg-color);
|
||||||
|
$text-color: inverse($bg-color);
|
||||||
|
|
||||||
|
background-color: $bg-color;
|
||||||
|
color: $text-color;
|
||||||
|
|
||||||
|
&.activated {
|
||||||
|
background-color: $bg-color-activated;
|
||||||
|
}
|
||||||
|
|
||||||
|
&[outline] {
|
||||||
|
border: 1px solid $bg-color;
|
||||||
|
background: $background-color;
|
||||||
|
color: $bg-color;
|
||||||
|
|
||||||
|
&.activated {
|
||||||
|
opacity: 1;
|
||||||
|
color: $text-color;
|
||||||
|
background-color: $bg-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -17,7 +17,7 @@ import {dom} from 'ionic/util';
|
|||||||
'value'
|
'value'
|
||||||
],
|
],
|
||||||
host: {
|
host: {
|
||||||
'(click)': 'buttonClicked($event)',
|
//'(click)': 'buttonClicked($event)',
|
||||||
'(change)': 'onChange($event)',
|
'(change)': 'onChange($event)',
|
||||||
//'[value]': 'value',
|
//'[value]': 'value',
|
||||||
/*
|
/*
|
||||||
@ -191,7 +191,7 @@ export class SegmentControlValueAccessor {
|
|||||||
],
|
],
|
||||||
host: {
|
host: {
|
||||||
'(click)': 'buttonClicked($event)',
|
'(click)': 'buttonClicked($event)',
|
||||||
'[class.active]': 'isActive'
|
'[class.activated]': 'isActive',
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
export class SegmentButton {
|
export class SegmentButton {
|
||||||
@ -202,10 +202,16 @@ export class SegmentButton {
|
|||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
@Host() segment: Segment,
|
@Host() segment: Segment,
|
||||||
elementRef: ElementRef
|
elementRef: ElementRef,
|
||||||
|
renderer: Renderer
|
||||||
) {
|
) {
|
||||||
this.ele = elementRef.ele
|
|
||||||
this.segment = segment;
|
this.segment = segment;
|
||||||
|
this.renderer = renderer;
|
||||||
|
this.isButton = true;
|
||||||
|
|
||||||
|
// This is a button, and it's outlined
|
||||||
|
this.renderer.setElementAttribute(elementRef, 'button', '');
|
||||||
|
this.renderer.setElementAttribute(elementRef, 'outline', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
onInit() {
|
onInit() {
|
||||||
|
@ -5,12 +5,11 @@ import {App} from 'ionic/ionic';
|
|||||||
|
|
||||||
@App({
|
@App({
|
||||||
templateUrl: 'main.html',
|
templateUrl: 'main.html',
|
||||||
appInjector: [FormBuilder],
|
bindings: [FormBuilder],
|
||||||
directives: [FORM_DIRECTIVES]
|
directives: [FORM_DIRECTIVES]
|
||||||
})
|
})
|
||||||
class IonicApp {
|
class MyApp {
|
||||||
constructor(fb: FormBuilder) {
|
constructor(fb: FormBuilder) {
|
||||||
|
|
||||||
this.myForm = fb.group({
|
this.myForm = fb.group({
|
||||||
mapStyle: ['hybrid', Validators.required]
|
mapStyle: ['hybrid', Validators.required]
|
||||||
});
|
});
|
||||||
@ -18,7 +17,7 @@ class IonicApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
doSubmit(event) {
|
doSubmit(event) {
|
||||||
console.log('Submitting form', this.form.value);
|
console.log('Submitting form', this.myForm.value);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
<ion-content padding>
|
<ion-content padding>
|
||||||
<form (submit)="doSubmit($event)" [ng-form-model]="myForm">
|
<form (submit)="doSubmit($event)" [ng-form-model]="myForm">
|
||||||
<ion-segment ng-control="mapStyle">
|
<ion-segment ng-control="mapStyle" danger>
|
||||||
<ion-segment-button value="standard" button>
|
<ion-segment-button value="standard">
|
||||||
Standard
|
Standard
|
||||||
</ion-segment-button>
|
</ion-segment-button>
|
||||||
<ion-segment-button value="hybrid" button>
|
<ion-segment-button value="hybrid">
|
||||||
Hybrid
|
Hybrid
|
||||||
</ion-segment-button>
|
</ion-segment-button>
|
||||||
<ion-segment-button value="sat" button>
|
<ion-segment-button value="sat">
|
||||||
Satellite
|
Satellite
|
||||||
</ion-segment-button>
|
</ion-segment-button>
|
||||||
</ion-segment>
|
</ion-segment>
|
||||||
|
Reference in New Issue
Block a user