mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 05:58:26 +08:00
chore(build): rename ionic directory to src and update all references in the build process.
This commit is contained in:
168
src/components/segment/segment.ios.scss
Normal file
168
src/components/segment/segment.ios.scss
Normal file
@ -0,0 +1,168 @@
|
||||
@import "../../globals.ios";
|
||||
@import "./segment";
|
||||
|
||||
// iOS Segment
|
||||
// --------------------------------------------------
|
||||
|
||||
$segment-button-ios-background-color: transparent !default;
|
||||
$segment-button-ios-background-color-activated: $toolbar-ios-active-color !default;
|
||||
|
||||
$segment-button-ios-text-color: color-contrast($colors-ios, $segment-button-ios-background-color-activated) !default;
|
||||
$segment-button-ios-transition-activated: 100ms all linear !default;
|
||||
$segment-button-ios-transition-hover: 100ms all linear !default;
|
||||
$segment-button-ios-transition-active: 100ms all linear !default;
|
||||
|
||||
$segment-button-ios-opacity-hover: .1 !default;
|
||||
$segment-button-ios-opacity-active: .16 !default;
|
||||
$segment-button-ios-opacity-activated: 1 !default;
|
||||
$segment-button-ios-opacity-disabled: .3 !default;
|
||||
|
||||
$segment-button-ios-border-width: 1px !default;
|
||||
$segment-button-ios-height: 3.2rem !default;
|
||||
$segment-button-ios-line-height: 3rem !default;
|
||||
$segment-button-ios-font-size: 1.3rem !default;
|
||||
$segment-button-ios-border-radius: 4px !default;
|
||||
$segment-button-ios-icon-size: 2.6rem !default;
|
||||
$segment-button-ios-icon-line-height: 2.8rem !default;
|
||||
|
||||
$segment-button-ios-toolbar-button-max-width: 100px !default;
|
||||
$segment-button-ios-toolbar-button-height: 2.6rem !default;
|
||||
$segment-button-ios-toolbar-line-height: 2.5rem !default;
|
||||
$segment-button-ios-toolbar-font-size: 1.2rem !default;
|
||||
$segment-button-ios-toolbar-icon-size: 2.2rem !default;
|
||||
$segment-button-ios-toolbar-icon-line-height: 2.4rem !default;
|
||||
|
||||
|
||||
.segment-button {
|
||||
flex: 1;
|
||||
|
||||
width: 0;
|
||||
|
||||
height: $segment-button-ios-height;
|
||||
|
||||
border-width: $segment-button-ios-border-width;
|
||||
border-style: solid;
|
||||
border-color: $segment-button-ios-background-color-activated;
|
||||
|
||||
font-size: $segment-button-ios-font-size;
|
||||
line-height: $segment-button-ios-line-height;
|
||||
|
||||
color: $segment-button-ios-background-color-activated;
|
||||
background-color: $segment-button-ios-background-color;
|
||||
|
||||
ion-icon {
|
||||
font-size: $segment-button-ios-icon-size;
|
||||
line-height: $segment-button-ios-icon-line-height;
|
||||
}
|
||||
|
||||
&.segment-activated {
|
||||
color: $segment-button-ios-text-color;
|
||||
background-color: $segment-button-ios-background-color-activated;
|
||||
opacity: $segment-button-ios-opacity-activated;
|
||||
transition: $segment-button-ios-transition-activated;
|
||||
}
|
||||
|
||||
&:hover:not(.segment-activated) {
|
||||
background-color: rgba($segment-button-ios-background-color-activated, $segment-button-ios-opacity-hover);
|
||||
transition: $segment-button-ios-transition-hover;
|
||||
}
|
||||
|
||||
&:active:not(.segment-activated) {
|
||||
background-color: rgba($segment-button-ios-background-color-activated, $segment-button-ios-opacity-active);
|
||||
transition: $segment-button-ios-transition-active;
|
||||
}
|
||||
|
||||
&:first-of-type {
|
||||
margin-right: 0;
|
||||
|
||||
border-radius: $segment-button-ios-border-radius 0 0 $segment-button-ios-border-radius;
|
||||
}
|
||||
|
||||
&:not(:first-of-type) {
|
||||
border-left-width: 0;
|
||||
}
|
||||
|
||||
&:last-of-type {
|
||||
margin-left: 0;
|
||||
|
||||
border-left-width: 0;
|
||||
border-radius: 0 $segment-button-ios-border-radius $segment-button-ios-border-radius 0;
|
||||
}
|
||||
}
|
||||
|
||||
.segment-button-disabled {
|
||||
color: rgba($segment-button-ios-background-color-activated, $segment-button-ios-opacity-disabled);
|
||||
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
|
||||
ion-segment {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.segment-button {
|
||||
max-width: $segment-button-ios-toolbar-button-max-width;
|
||||
height: $segment-button-ios-toolbar-button-height;
|
||||
|
||||
font-size: $segment-button-ios-toolbar-font-size;
|
||||
line-height: $segment-button-ios-toolbar-line-height;
|
||||
|
||||
ion-icon {
|
||||
font-size: $segment-button-ios-toolbar-icon-size;
|
||||
line-height: $segment-button-ios-toolbar-icon-line-height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// iOS Segment Button Mixin
|
||||
// --------------------------------------------------
|
||||
|
||||
@mixin ios-segment-button($color-name, $color-base, $color-contrast) {
|
||||
|
||||
ion-segment[#{$color-name}] {
|
||||
|
||||
.segment-button {
|
||||
border-color: $color-base;
|
||||
color: $color-base;
|
||||
|
||||
&:hover:not(.segment-activated) {
|
||||
background-color: rgba($color-base, $segment-button-ios-opacity-hover);
|
||||
}
|
||||
|
||||
&:active:not(.segment-activated) {
|
||||
background-color: rgba($color-base, $segment-button-ios-opacity-active);
|
||||
}
|
||||
|
||||
&.segment-activated {
|
||||
color: $color-contrast;
|
||||
background-color: $color-base;
|
||||
}
|
||||
}
|
||||
|
||||
.segment-button-disabled {
|
||||
color: rgba($color-base, $segment-button-ios-opacity-disabled);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// iOS Segment Color Generation
|
||||
// --------------------------------------------------
|
||||
|
||||
@each $color-name, $color-base, $color-contrast in get-colors($colors-ios) {
|
||||
|
||||
@include ios-segment-button($color-name, $color-base, $color-contrast);
|
||||
|
||||
.toolbar[#{$color-name}] .segment-button.segment-activated {
|
||||
color: $color-base;
|
||||
}
|
||||
}
|
103
src/components/segment/segment.md.scss
Normal file
103
src/components/segment/segment.md.scss
Normal file
@ -0,0 +1,103 @@
|
||||
@import "../../globals.md";
|
||||
@import "./segment";
|
||||
|
||||
// Material Design Segment
|
||||
// --------------------------------------------------
|
||||
|
||||
$segment-button-md-text-color-activated: $toolbar-md-active-color !default;
|
||||
$segment-button-md-border-color-activated: $toolbar-md-active-color !default;
|
||||
|
||||
$segment-button-md-border-bottom-width: 2px !default;
|
||||
$segment-button-md-border-bottom-color: rgba(#000, .10) !default;
|
||||
|
||||
$segment-button-md-opacity: .7 !default;
|
||||
$segment-button-md-opacity-activated: 1 !default;
|
||||
$segment-button-md-opacity-disabled: .3 !default;
|
||||
|
||||
$segment-button-md-padding: 0 6px !default;
|
||||
$segment-button-md-height: 4.2rem !default;
|
||||
$segment-button-md-line-height: 4rem !default;
|
||||
$segment-button-md-font-size: 1.2rem !default;
|
||||
$segment-button-md-icon-size: 2.6rem !default;
|
||||
$segment-button-md-icon-line-height: $segment-button-md-line-height !default;
|
||||
|
||||
|
||||
.segment-button {
|
||||
flex: 1;
|
||||
|
||||
padding: $segment-button-md-padding;
|
||||
|
||||
width: 0;
|
||||
height: $segment-button-md-height;
|
||||
|
||||
border-bottom-width: $segment-button-md-border-bottom-width;
|
||||
border-bottom-style: solid;
|
||||
border-bottom-color: $segment-button-md-border-bottom-color;
|
||||
|
||||
font-size: $segment-button-md-font-size;
|
||||
font-weight: 500;
|
||||
line-height: $segment-button-md-line-height;
|
||||
text-transform: uppercase;
|
||||
|
||||
color: $segment-button-md-text-color-activated;
|
||||
background-color: transparent;
|
||||
opacity: $segment-button-md-opacity;
|
||||
transition: 100ms all linear;
|
||||
|
||||
ion-icon {
|
||||
font-size: $segment-button-md-icon-size;
|
||||
line-height: $segment-button-md-icon-line-height;
|
||||
}
|
||||
|
||||
&.activated,
|
||||
&.segment-activated {
|
||||
border-color: $segment-button-md-border-color-activated;
|
||||
opacity: $segment-button-md-opacity-activated;
|
||||
}
|
||||
}
|
||||
|
||||
.segment-button-disabled {
|
||||
opacity: $segment-button-md-opacity-disabled;
|
||||
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
|
||||
ion-segment {
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.segment-button.activated,
|
||||
.segment-button.segment-activated {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Material Design Segment Button Mixin
|
||||
// --------------------------------------------------
|
||||
|
||||
@mixin md-segment-button($color-name, $color-base, $color-contrast) {
|
||||
|
||||
ion-segment[#{$color-name}] .segment-button {
|
||||
color: $color-base;
|
||||
|
||||
&.activated,
|
||||
&.segment-activated {
|
||||
border-color: $color-base;
|
||||
color: $color-base;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Material Design Segment Color Generation
|
||||
// --------------------------------------------------
|
||||
|
||||
@each $color-name, $color-base, $color-contrast in get-colors($colors-md) {
|
||||
@include md-segment-button($color-name, $color-base, $color-contrast);
|
||||
}
|
29
src/components/segment/segment.scss
Normal file
29
src/components/segment/segment.scss
Normal file
@ -0,0 +1,29 @@
|
||||
@import "../../globals.core";
|
||||
|
||||
// Segment
|
||||
// --------------------------------------------------
|
||||
|
||||
|
||||
ion-segment {
|
||||
display: flex;
|
||||
|
||||
flex: 1;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.segment-button {
|
||||
position: relative;
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
|
||||
margin-right: 0;
|
||||
margin-left: 0;
|
||||
|
||||
text-align: center;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
}
|
272
src/components/segment/segment.ts
Normal file
272
src/components/segment/segment.ts
Normal file
@ -0,0 +1,272 @@
|
||||
import {Directive, Component, ElementRef, Renderer, Optional, EventEmitter, Input, Output, HostListener, ContentChildren, QueryList, ViewEncapsulation} from '@angular/core';
|
||||
import {NgControl} from '@angular/common';
|
||||
|
||||
import {isTrueProperty, isPresent} from '../../util/util';
|
||||
|
||||
|
||||
/**
|
||||
* @name SegmentButton
|
||||
* @description
|
||||
* The child buttons of the `ion-segment` component. Each `ion-segment-button` must have a value.
|
||||
* @usage
|
||||
* ```html
|
||||
* <ion-segment [(ngModel)]="relationship" primary>
|
||||
* <ion-segment-button value="friends" (select)="selectedFriends()">
|
||||
* Friends
|
||||
* </ion-segment-button>
|
||||
* <ion-segment-button value="enemies" (select)="selectedEnemies()">
|
||||
* Enemies
|
||||
* </ion-segment-button>
|
||||
* </ion-segment>
|
||||
*```
|
||||
*
|
||||
* Or with `FormBuilder`
|
||||
*
|
||||
*```html
|
||||
* <form [ngFormModel]="myForm">
|
||||
* <ion-segment ngControl="mapStyle" danger>
|
||||
* <ion-segment-button value="standard">
|
||||
* Standard
|
||||
* </ion-segment-button>
|
||||
* <ion-segment-button value="hybrid">
|
||||
* Hybrid
|
||||
* </ion-segment-button>
|
||||
* <ion-segment-button value="sat">
|
||||
* Satellite
|
||||
* </ion-segment-button>
|
||||
* </ion-segment>
|
||||
* </form>
|
||||
* ```
|
||||
*
|
||||
*
|
||||
* @demo /docs/v2/demos/segment/
|
||||
* @see {@link /docs/v2/components#segment Segment Component Docs}
|
||||
* @see {@link /docs/v2/api/components/segment/Segment/ Segment API Docs}
|
||||
*/
|
||||
@Component({
|
||||
selector: 'ion-segment-button',
|
||||
template:
|
||||
'<ng-content></ng-content>' +
|
||||
'<ion-button-effect></ion-button-effect>',
|
||||
host: {
|
||||
'tappable': '',
|
||||
'class': 'segment-button',
|
||||
'role': 'button'
|
||||
},
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
})
|
||||
export class SegmentButton {
|
||||
private _disabled: boolean = false;
|
||||
|
||||
/**
|
||||
* @input {string} the value of the segment button. Required.
|
||||
*/
|
||||
@Input() value: string;
|
||||
|
||||
/**
|
||||
* @output {SegmentButton} expression to evaluate when a segment button has been clicked
|
||||
*/
|
||||
@Output() select: EventEmitter<SegmentButton> = new EventEmitter();
|
||||
|
||||
constructor(private _renderer: Renderer, private _elementRef: ElementRef) {}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
@Input()
|
||||
get disabled(): boolean {
|
||||
return this._disabled;
|
||||
}
|
||||
|
||||
set disabled(val: boolean) {
|
||||
this._disabled = isTrueProperty(val);
|
||||
this.setCssClass('segment-button-disabled', this._disabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
setCssClass(cssClass: string, shouldAdd: boolean) {
|
||||
this._renderer.setElementClass(this._elementRef.nativeElement, cssClass, shouldAdd);
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* On click of a SegmentButton
|
||||
*/
|
||||
@HostListener('click', ['$event'])
|
||||
private onClick(ev) {
|
||||
console.debug('SegmentButton, select', this.value);
|
||||
this.select.emit(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
ngOnInit() {
|
||||
if (!isPresent(this.value)) {
|
||||
console.warn('<ion-segment-button> requires a "value" attribute');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
set isActive(isActive) {
|
||||
this._renderer.setElementClass(this._elementRef.nativeElement, 'segment-activated', isActive);
|
||||
this._renderer.setElementAttribute(this._elementRef.nativeElement, 'aria-pressed', isActive);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @name Segment
|
||||
* @description
|
||||
* A Segment is a group of buttons, sometimes known as Segmented Controls, that allow the user to interact with a compact group of a number of controls.
|
||||
* Segments provide functionality similar to tabs, selecting one will unselect all others. You should use a tab bar instead of a segmented control when you want to let the user move back and forth between distinct pages in your app.
|
||||
* You could use Angular 2's `ngModel` or `FormBuilder` API. For an overview on how `FormBuilder` works, checkout [Angular 2 Forms](http://learnangular2.com/forms/), or [Angular FormBuilder](https://angular.io/docs/ts/latest/api/common/FormBuilder-class.html)
|
||||
*
|
||||
*
|
||||
* @usage
|
||||
* ```html
|
||||
* <ion-segment [(ngModel)]="relationship" (change)="onSegmentChanged($event)" danger>
|
||||
* <ion-segment-button value="friends">
|
||||
* Friends
|
||||
* </ion-segment-button>
|
||||
* <ion-segment-button value="enemies">
|
||||
* Enemies
|
||||
* </ion-segment-button>
|
||||
* </ion-segment>
|
||||
*```
|
||||
*
|
||||
* Or with `FormBuilder`
|
||||
*
|
||||
*```html
|
||||
* <form [ngFormModel]="myForm">
|
||||
* <ion-segment ngControl="mapStyle" danger>
|
||||
* <ion-segment-button value="standard">
|
||||
* Standard
|
||||
* </ion-segment-button>
|
||||
* <ion-segment-button value="hybrid">
|
||||
* Hybrid
|
||||
* </ion-segment-button>
|
||||
* <ion-segment-button value="sat">
|
||||
* Satellite
|
||||
* </ion-segment-button>
|
||||
* </ion-segment>
|
||||
* </form>
|
||||
* ```
|
||||
*
|
||||
*
|
||||
* @demo /docs/v2/demos/segment/
|
||||
* @see {@link /docs/v2/components#segment Segment Component Docs}
|
||||
* @see [Angular 2 Forms](http://learnangular2.com/forms/)
|
||||
*/
|
||||
@Directive({
|
||||
selector: 'ion-segment'
|
||||
})
|
||||
export class Segment {
|
||||
private _disabled: boolean = false;
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
value: string;
|
||||
|
||||
|
||||
/**
|
||||
* @output {Any} expression to evaluate when a segment button has been changed
|
||||
*/
|
||||
@Output() change: EventEmitter<SegmentButton> = new EventEmitter();
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
@ContentChildren(SegmentButton) _buttons: QueryList<SegmentButton>;
|
||||
|
||||
constructor(@Optional() ngControl: NgControl) {
|
||||
if (ngControl) {
|
||||
ngControl.valueAccessor = this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
@Input()
|
||||
get disabled(): boolean {
|
||||
return this._disabled;
|
||||
}
|
||||
|
||||
set disabled(val: boolean) {
|
||||
this._disabled = isTrueProperty(val);
|
||||
|
||||
if (this._buttons) {
|
||||
let buttons = this._buttons.toArray();
|
||||
for (let button of buttons) {
|
||||
button.setCssClass('segment-button-disabled', this._disabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Write a new value to the element.
|
||||
*/
|
||||
writeValue(value) {
|
||||
this.value = isPresent(value) ? value : '';
|
||||
if (this._buttons) {
|
||||
let buttons = this._buttons.toArray();
|
||||
for (let button of buttons) {
|
||||
button.isActive = (button.value === this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
ngAfterViewInit() {
|
||||
let buttons = this._buttons.toArray();
|
||||
for (let button of buttons) {
|
||||
button.select.subscribe((selectedButton) => {
|
||||
this.writeValue(selectedButton.value);
|
||||
this.onChange(selectedButton.value);
|
||||
this.change.emit(selectedButton);
|
||||
});
|
||||
|
||||
if (isPresent(this.value)) {
|
||||
button.isActive = (button.value === this.value);
|
||||
}
|
||||
|
||||
if (isTrueProperty(this._disabled)) {
|
||||
button.setCssClass('segment-button-disabled', this._disabled);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
onChange = (_) => {};
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
onTouched = (_) => {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Set the function to be called when the control receives a change event.
|
||||
*/
|
||||
registerOnChange(fn) { this.onChange = fn; }
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Set the function to be called when the control receives a touch event.
|
||||
*/
|
||||
registerOnTouched(fn) { this.onTouched = fn; }
|
||||
|
||||
}
|
92
src/components/segment/segment.wp.scss
Normal file
92
src/components/segment/segment.wp.scss
Normal file
@ -0,0 +1,92 @@
|
||||
@import "../../globals.wp";
|
||||
@import "./segment";
|
||||
|
||||
// Windows Segment
|
||||
// --------------------------------------------------
|
||||
|
||||
$segment-button-wp-text-color-activated: $toolbar-wp-text-color !default;
|
||||
|
||||
$segment-button-wp-padding: 0 6px !default;
|
||||
$segment-button-wp-height: 4rem !default;
|
||||
$segment-button-wp-line-height: 4rem !default;
|
||||
$segment-button-wp-font-size: 1.3rem !default;
|
||||
$segment-button-wp-text-transform: uppercase !default;
|
||||
$segment-button-wp-font-weight: bold !default;
|
||||
$segment-button-wp-icon-size: 2.6rem !default;
|
||||
$segment-button-wp-icon-line-height: $segment-button-wp-line-height !default;
|
||||
$segment-button-wp-background-color: transparent !default;
|
||||
|
||||
$segment-button-wp-opacity: .5 !default;
|
||||
$segment-button-wp-opacity-activated: 1 !default;
|
||||
$segment-button-wp-opacity-disabled: .3 !default;
|
||||
|
||||
$segment-button-wp-buttons-justify-content: flex-start !default;
|
||||
|
||||
ion-segment {
|
||||
justify-content: $segment-button-wp-buttons-justify-content;
|
||||
}
|
||||
|
||||
.segment-button {
|
||||
padding: $segment-button-wp-padding;
|
||||
|
||||
height: $segment-button-wp-height;
|
||||
|
||||
font-size: $segment-button-wp-font-size;
|
||||
font-weight: $segment-button-wp-font-weight;
|
||||
line-height: $segment-button-wp-line-height;
|
||||
|
||||
text-transform: $segment-button-wp-text-transform;
|
||||
|
||||
color: $segment-button-wp-text-color-activated;
|
||||
background-color: $segment-button-wp-background-color;
|
||||
opacity: $segment-button-wp-opacity;
|
||||
|
||||
&.segment-activated {
|
||||
opacity: $segment-button-wp-opacity-activated;
|
||||
}
|
||||
|
||||
ion-icon {
|
||||
font-size: $segment-button-wp-icon-size;
|
||||
line-height: $segment-button-wp-icon-line-height;
|
||||
}
|
||||
}
|
||||
|
||||
.segment-button-disabled {
|
||||
opacity: $segment-button-wp-opacity-disabled;
|
||||
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
|
||||
ion-segment {
|
||||
margin: 0 auto;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Windows Segment Button Mixin
|
||||
// --------------------------------------------------
|
||||
|
||||
@mixin wp-segment-button($color-name, $color-base) {
|
||||
|
||||
ion-segment[#{$color-name}] .segment-button {
|
||||
color: $color-base;
|
||||
|
||||
&.activated,
|
||||
&.segment-activated {
|
||||
border-color: $color-base;
|
||||
color: $color-base;
|
||||
opacity: $segment-button-wp-opacity-activated;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Windows Segment Color Generation
|
||||
// --------------------------------------------------
|
||||
|
||||
@each $color-name, $color-base, $color-contrast in get-colors($colors-wp) {
|
||||
@include wp-segment-button($color-name, $color-base);
|
||||
}
|
10
src/components/segment/test/basic/e2e.ts
Normal file
10
src/components/segment/test/basic/e2e.ts
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
it('friends and standard should be selected', function() {
|
||||
element(by.css('.e2eSegmentFriends')).click();
|
||||
element(by.css('.e2eSegmentStandard')).click();
|
||||
});
|
||||
|
||||
it('model c and top grossing should be selected', function() {
|
||||
element(by.css('.e2eSegmentModelC')).click();
|
||||
element(by.css('.e2eSegmentTopGrossing')).click();
|
||||
});
|
42
src/components/segment/test/basic/index.ts
Normal file
42
src/components/segment/test/basic/index.ts
Normal file
@ -0,0 +1,42 @@
|
||||
import {FORM_DIRECTIVES, FormBuilder, Validators, Control, ControlGroup} from '@angular/common';
|
||||
|
||||
import {App, IonicApp} from '../../../../../ionic';
|
||||
|
||||
|
||||
@App({
|
||||
templateUrl: 'main.html',
|
||||
providers: [FormBuilder],
|
||||
directives: [FORM_DIRECTIVES]
|
||||
})
|
||||
class MyApp {
|
||||
relationship: string = 'enemies';
|
||||
modelStyle: string = 'B';
|
||||
appType: string = 'free';
|
||||
icons: string = 'camera';
|
||||
isDisabled: boolean = true;
|
||||
|
||||
myForm;
|
||||
|
||||
constructor(fb: FormBuilder) {
|
||||
this.myForm = fb.group({
|
||||
mapStyle: ['active', Validators.required]
|
||||
});
|
||||
}
|
||||
|
||||
toggleDisabled() {
|
||||
this.isDisabled = !this.isDisabled;
|
||||
}
|
||||
|
||||
onSegmentChanged(segmentButton) {
|
||||
console.log("Segment changed to", segmentButton.value);
|
||||
}
|
||||
|
||||
onSegmentSelected(segmentButton) {
|
||||
console.log("Segment selected", segmentButton.value);
|
||||
}
|
||||
|
||||
doSubmit(event) {
|
||||
console.log('Submitting form', this.myForm.value);
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
136
src/components/segment/test/basic/main.html
Normal file
136
src/components/segment/test/basic/main.html
Normal file
@ -0,0 +1,136 @@
|
||||
<ion-toolbar>
|
||||
<ion-segment id="segment" [(ngModel)]="relationship" (change)="onSegmentChanged($event)">
|
||||
<ion-segment-button value="friends" (select)="onSegmentSelected($event)" class="e2eSegmentFriends">
|
||||
Friends
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="enemies" (select)="onSegmentSelected($event)">
|
||||
Enemies
|
||||
</ion-segment-button>
|
||||
</ion-segment>
|
||||
</ion-toolbar>
|
||||
|
||||
<ion-toolbar>
|
||||
<ion-buttons end>
|
||||
<button>
|
||||
<ion-icon name="search"></ion-icon>
|
||||
</button>
|
||||
</ion-buttons>
|
||||
<ion-segment [(ngModel)]="icons" secondary>
|
||||
<ion-segment-button value="camera">
|
||||
<ion-icon name="camera"></ion-icon>
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="bookmark">
|
||||
<ion-icon name="bookmark"></ion-icon>
|
||||
</ion-segment-button>
|
||||
</ion-segment>
|
||||
</ion-toolbar>
|
||||
|
||||
<ion-content padding>
|
||||
<div>Are we friends or enemies? <b>{{ relationship }}</b></div>
|
||||
|
||||
<h4>Map mode: NgControl</h4>
|
||||
|
||||
<form (submit)="doSubmit($event)" [ngFormModel]="myForm">
|
||||
<ion-segment ngControl="mapStyle" danger>
|
||||
<ion-segment-button value="active" class="e2eSegmentStandard">
|
||||
Active
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="disabled" [disabled]="isDisabled">
|
||||
Disabled
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="inactive" disabled="false">
|
||||
Inactive
|
||||
</ion-segment-button>
|
||||
</ion-segment>
|
||||
</form>
|
||||
|
||||
<p>
|
||||
Map mode: <b>{{myForm.controls.mapStyle.value}}</b> -
|
||||
|
||||
<span [ngSwitch]="myForm.controls.mapStyle.value">
|
||||
<span *ngSwitchWhen="'standard'">
|
||||
<b>Standard</b>
|
||||
</span>
|
||||
<span *ngSwitchWhen="'hybrid'">
|
||||
<b>Hybrid</b>
|
||||
</span>
|
||||
<span *ngSwitchWhen="'sat'">
|
||||
<b>Satellite</b>
|
||||
</span>
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h4>Model style: NgModel</h4>
|
||||
|
||||
<ion-segment [(ngModel)]="modelStyle" dark>
|
||||
<ion-segment-button value="A">
|
||||
Model A
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="B">
|
||||
Model B
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="C" class="e2eSegmentModelC">
|
||||
Model C
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="D" [disabled]="isDisabled">
|
||||
Model D
|
||||
</ion-segment-button>
|
||||
</ion-segment>
|
||||
|
||||
<p>Model Style: <b>Model {{ modelStyle }}</b></p>
|
||||
|
||||
<ion-segment [(ngModel)]="icons">
|
||||
<ion-segment-button value="camera">
|
||||
<ion-icon name="camera"></ion-icon>
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="bookmark">
|
||||
<ion-icon name="bookmark"></ion-icon>
|
||||
</ion-segment-button>
|
||||
</ion-segment>
|
||||
|
||||
<button block dark (click)="toggleDisabled()">Toggle Disabled</button>
|
||||
</ion-content>
|
||||
|
||||
<ion-toolbar position="bottom" primary>
|
||||
<ion-segment [(ngModel)]="appType" light>
|
||||
<ion-segment-button value="paid">
|
||||
Primary
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="free">
|
||||
Toolbar
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="top" class="e2eSegmentTopGrossing">
|
||||
Light Segment
|
||||
</ion-segment-button>
|
||||
</ion-segment>
|
||||
</ion-toolbar>
|
||||
|
||||
<ion-toolbar position="bottom">
|
||||
<ion-segment [(ngModel)]="appType" danger>
|
||||
<ion-segment-button value="paid">
|
||||
Default
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="free">
|
||||
Toolbar
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="top">
|
||||
Danger Segment
|
||||
</ion-segment-button>
|
||||
</ion-segment>
|
||||
</ion-toolbar>
|
||||
|
||||
<ion-toolbar position="bottom">
|
||||
<ion-segment [(ngModel)]="appType" dark [disabled]="isDisabled">
|
||||
<ion-segment-button value="paid">
|
||||
Default
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="free">
|
||||
Toolbar
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="top">
|
||||
Dark Segment
|
||||
</ion-segment-button>
|
||||
</ion-segment>
|
||||
</ion-toolbar>
|
8
src/components/segment/test/nav/e2e.ts
Normal file
8
src/components/segment/test/nav/e2e.ts
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
it('existing should be selected', function() {
|
||||
element(by.css('.e2eSegmentExistingSegment')).click();
|
||||
});
|
||||
|
||||
it('test should be selected', function() {
|
||||
element(by.css('.e2eSegmentTestButton')).click();
|
||||
});
|
49
src/components/segment/test/nav/index.ts
Normal file
49
src/components/segment/test/nav/index.ts
Normal file
@ -0,0 +1,49 @@
|
||||
import {Validators, Control, ControlGroup} from '@angular/common';
|
||||
import {App, Page, NavController} from '../../../../../ionic';
|
||||
|
||||
|
||||
@Page({
|
||||
templateUrl: 'main.html',
|
||||
})
|
||||
class SegmentPage {
|
||||
constructor(nav: NavController) {
|
||||
this.nav = nav;
|
||||
this.signInType = 'new';
|
||||
}
|
||||
|
||||
goToPage2() {
|
||||
this.nav.push(SegmentPage2);
|
||||
}
|
||||
}
|
||||
|
||||
@Page({
|
||||
template: `
|
||||
<ion-navbar *navbar hideBackButton>
|
||||
<button menuToggle>
|
||||
<ion-icon name="menu"></ion-icon>
|
||||
</button>
|
||||
<ion-title>
|
||||
Second Page
|
||||
</ion-title>
|
||||
</ion-navbar>
|
||||
|
||||
<ion-content>
|
||||
<h1>Page 2</h1>
|
||||
</ion-content>
|
||||
`
|
||||
})
|
||||
class SegmentPage2 {
|
||||
constructor() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@App({
|
||||
pages: [SegmentPage],
|
||||
template: `<ion-nav [root]="root"></ion-nav>`
|
||||
})
|
||||
class MyApp {
|
||||
constructor() {
|
||||
this.root = SegmentPage;
|
||||
}
|
||||
}
|
48
src/components/segment/test/nav/main.html
Normal file
48
src/components/segment/test/nav/main.html
Normal file
@ -0,0 +1,48 @@
|
||||
<ion-navbar *navbar>
|
||||
<ion-title>
|
||||
Segment under Navbar
|
||||
</ion-title>
|
||||
</ion-navbar>
|
||||
<ion-toolbar>
|
||||
<ion-segment [(ngModel)]="signInType">
|
||||
<ion-segment-button value="new">
|
||||
New
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="existing" class="e2eSegmentExistingSegment">
|
||||
Existing
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="test">
|
||||
Test
|
||||
</ion-segment-button>
|
||||
</ion-segment>
|
||||
</ion-toolbar>
|
||||
|
||||
<ion-content padding>
|
||||
|
||||
<ion-row>
|
||||
<ion-col>
|
||||
<button block (click)="signInType='new'">New</button>
|
||||
</ion-col>
|
||||
<ion-col>
|
||||
<button light block (click)="signInType='existing'">Existing</button>
|
||||
</ion-col>
|
||||
<ion-col>
|
||||
<button dark block (click)="signInType='test'" class="e2eSegmentTestButton">Test</button>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
|
||||
<div [ngSwitch]="signInType">
|
||||
<div *ngSwitchWhen="'existing'">
|
||||
Signing up as an <b>Existing User</b>.
|
||||
</div>
|
||||
<div *ngSwitchWhen="'new'">
|
||||
Signing up as a <b>New User</b>.
|
||||
</div>
|
||||
<div *ngSwitchWhen="'test'">
|
||||
Signing up as a <b>Test User</b>.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button block (click)="goToPage2()">Next Page</button>
|
||||
|
||||
</ion-content>
|
57
src/components/segment/test/swipe/index.ts
Normal file
57
src/components/segment/test/swipe/index.ts
Normal file
@ -0,0 +1,57 @@
|
||||
import {Validators, Control, ControlGroup} from '@angular/common';
|
||||
import {Http} from '@angular/http';
|
||||
import {App, Page, IonicApp, NavController} from '../../../../../ionic';
|
||||
|
||||
|
||||
@Page({
|
||||
templateUrl: 'main.html',
|
||||
})
|
||||
class SegmentPage {
|
||||
constructor(app: IonicApp) {
|
||||
this.app = app;
|
||||
|
||||
this.selectedSegment = "first";
|
||||
this.slides = [
|
||||
{
|
||||
id: "first",
|
||||
title: "First Slide"
|
||||
},
|
||||
{
|
||||
id: "second",
|
||||
title: "Second Slide"
|
||||
},
|
||||
{
|
||||
id: "third",
|
||||
title: "Third Slide"
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
onSegmentChanged(segmentButton) {
|
||||
console.log("Segment changed to", segmentButton.value);
|
||||
|
||||
this.sliderComponent = this.app.getComponent('loopSlider');
|
||||
const selectedIndex = this.slides.findIndex((slide) => {
|
||||
return slide.id === segmentButton.value;
|
||||
});
|
||||
this.sliderComponent.slider.slideTo(selectedIndex);
|
||||
}
|
||||
|
||||
onSlideChanged(slider) {
|
||||
console.log('Slide changed', slider);
|
||||
|
||||
const currentSlide = this.slides[slider.activeIndex];
|
||||
this.selectedSegment = currentSlide.id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@App({
|
||||
pages: [SegmentPage],
|
||||
template: `<ion-nav [root]="root"></ion-nav>`
|
||||
})
|
||||
class MyApp {
|
||||
constructor() {
|
||||
this.root = SegmentPage;
|
||||
}
|
||||
}
|
35
src/components/segment/test/swipe/main.html
Normal file
35
src/components/segment/test/swipe/main.html
Normal file
@ -0,0 +1,35 @@
|
||||
<ion-navbar *navbar>
|
||||
<ion-title>
|
||||
Segment Swipeable under Navbar
|
||||
</ion-title>
|
||||
</ion-navbar>
|
||||
<ion-toolbar>
|
||||
<ion-segment [(ngModel)]="selectedSegment" (change)="onSegmentChanged($event)">
|
||||
<ion-segment-button value="first">
|
||||
First
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="second">
|
||||
Second
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="third">
|
||||
Third
|
||||
</ion-segment-button>
|
||||
</ion-segment>
|
||||
</ion-toolbar>
|
||||
|
||||
<ion-content padding>
|
||||
|
||||
<ion-slides (change)="onSlideChanged($event)" id="loopSlider">
|
||||
<ion-slide *ngFor="let slide of slides">
|
||||
<h1>{{ slide.title }}</h1>
|
||||
</ion-slide>
|
||||
</ion-slides>
|
||||
|
||||
</ion-content>
|
||||
|
||||
<style>
|
||||
ion-scroll {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
Reference in New Issue
Block a user