From cb7387d491598ce365ad915d6bb4cf18e10464e0 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Fri, 7 Aug 2015 14:13:16 -0500 Subject: [PATCH] change label to ion-label --- ionic/components.ts | 1 - ionic/components/form/form.ts | 1 - ionic/components/form/input.scss | 40 +++------------ ionic/components/form/input.ts | 4 +- ionic/components/form/label.scss | 27 ++-------- ionic/components/form/label.ts | 15 +++--- ionic/components/form/tap-input.ts | 49 ------------------- .../form/test/fixed-inline-labels/main.html | 48 +++++++++--------- .../form/test/inline-labels/main.html | 24 ++++----- .../form/test/stacked-labels/main.html | 40 +++++++-------- ionic/components/form/text-input.ts | 2 +- .../show-hide-when/test/basic/e2e.ts | 4 -- ionic/config/annotations.ts | 3 +- 13 files changed, 77 insertions(+), 181 deletions(-) delete mode 100644 ionic/components/form/tap-input.ts diff --git a/ionic/components.ts b/ionic/components.ts index a37b3540ad..184e230a1f 100644 --- a/ionic/components.ts +++ b/ionic/components.ts @@ -11,7 +11,6 @@ export * from 'ionic/components/item/item' export * from 'ionic/components/item/item-group' export * from 'ionic/components/form/input' export * from 'ionic/components/form/text-input' -export * from 'ionic/components/form/tap-input' export * from 'ionic/components/form/label' export * from 'ionic/components/list/list' export * from 'ionic/components/show-hide-when/show-hide-when' diff --git a/ionic/components/form/form.ts b/ionic/components/form/form.ts index a8a9597fb7..cc38c1ac3d 100644 --- a/ionic/components/form/form.ts +++ b/ionic/components/form/form.ts @@ -1,4 +1,3 @@ export * from './focus-holder' export * from './input' -export * from './tap-input' export * from './text-input' diff --git a/ionic/components/form/input.scss b/ionic/components/form/input.scss index f6b1dd3332..06c3ab73ca 100644 --- a/ionic/components/form/input.scss +++ b/ionic/components/form/input.scss @@ -1,4 +1,7 @@ -$item-input-padding: 6px 0 5px 0px; + +// Input +// -------------------------------------------------- + ion-input { display: block; @@ -20,8 +23,7 @@ focus-holder input { align-items: flex-start; } -.item.input input, -.item.input textarea { +.item.input .text-input { flex: 1; } @@ -29,37 +31,7 @@ focus-holder input { padding-top: 9px; } -.item .item-content label.input-label { +.item .item-content .input-label { margin: 0; padding: 0; } - -/*ion-input { - display: block; - - - position: relative; - overflow: hidden; - - display: flex; - align-items: center; - - .item-label { - padding: $item-input-padding; - } - - input, textarea { - width: 100%; - //font-size: 1.6rem; - - border-radius: 0; - - flex: 1 220px; - @include appearance(none); - - margin: 0; - padding-right: 24px; - background-color: transparent; - } -} -*/ diff --git a/ionic/components/form/input.ts b/ionic/components/form/input.ts index 4e3d01bf16..04a4894c00 100644 --- a/ionic/components/form/input.ts +++ b/ionic/components/form/input.ts @@ -111,8 +111,8 @@ export class IonInputItem extends Ion { onInit() { super.onInit(); if (this.input && this.label) { - this.input.id = (this.input.id || 'input-' + this.id); - this.label.labelFor = this.input.id; + this.label.id = (this.label.id || 'label-' + this.id); + this.input.labelledBy = this.label.id; } } diff --git a/ionic/components/form/label.scss b/ionic/components/form/label.scss index 01fb3c600f..fd825e049e 100644 --- a/ionic/components/form/label.scss +++ b/ionic/components/form/label.scss @@ -13,7 +13,7 @@ $input-label-color: #888 !default; white-space: nowrap; } -.fixed-inline-label { +[fixed-label] .input-label { display: block; max-width: 200px; width: 30%; @@ -23,36 +23,17 @@ $input-label-color: #888 !default; white-space: nowrap; } -.item-stacked-label { +.item-input[stacked-label] { flex-direction: column; align-items: flex-start; .input-label { - width: auto; + align-self: stretch; max-width: 100%; } .input-label + .input { margin-top: 0; - } -} - -.item-floating-label { - display: block; - background-color: transparent; - box-shadow: none; - - .input-label { - position: relative; - padding: 5px 0 0 0; - opacity: 0; - top: 10px; - transition: opacity .15s ease-in, top .2s linear; - - &.has-input { - opacity: 1; - top: 0; - transition: opacity .15s ease-in, top .2s linear; - } + padding-left: 16px; } } diff --git a/ionic/components/form/label.ts b/ionic/components/form/label.ts index a23653d7ee..bac76ee3db 100644 --- a/ionic/components/form/label.ts +++ b/ionic/components/form/label.ts @@ -9,9 +9,12 @@ import {Switch} from '../switch/switch'; @Directive({ - selector: 'label', + selector: 'ion-label', + properties: [ + 'id' + ], host: { - '[attr.for]': 'labelFor', + '[attr.id]': 'id', '[class.input-label]': 'inputLabel', '(touchstart)': 'pointerStart($event)', '(touchend)': 'pointerEnd($event)', @@ -22,12 +25,9 @@ import {Switch} from '../switch/switch'; export class Label { constructor( @Optional() @Host() textContainer: Input, - @Optional() @Host() checkboxContainer: Checkbox, - @Optional() @Host() radioContainer: RadioButton, - @Optional() @Host() switchContainer: Switch, config: IonicConfig ) { - this.container = textContainer || checkboxContainer || radioContainer || switchContainer; + this.container = textContainer; if (this.container) { this.container.registerLabel(this); @@ -54,8 +54,7 @@ export class Label { if (!dom.hasPointerMoved(20, this.startCoord, endCoord)) { ev.preventDefault(); ev.stopPropagation(); - - this.container instanceof Input ? this.container.focus() : this.container.toggle(); + this.container.focus(); } this.startCoord = null; diff --git a/ionic/components/form/tap-input.ts b/ionic/components/form/tap-input.ts deleted file mode 100644 index 229f370101..0000000000 --- a/ionic/components/form/tap-input.ts +++ /dev/null @@ -1,49 +0,0 @@ -import {Host, Optional, ElementRef, Attribute, Directive} from 'angular2/angular2'; - -import {IonInput} from './input'; -import {IonicApp} from '../app/app'; -import {IonicConfig} from '../../config/config'; -import {Content} from '../content/content'; -import {Checkbox} from '../checkbox/checkbox'; -import {RadioButton} from '../radio/radio'; - - -@Directive({ - selector: 'input[type=checkbox],input[type=radio]', - properties: [ - 'checked', - 'name', - 'value' - ], - host: { - '[checked]': 'checked', - '[value]': 'value', - '[attr.name]': 'name', - 'class': 'tap-input input' - } -}) -export class TapInput extends IonInput { - constructor( - @Optional() @Host() checkboxContainer: Checkbox, - @Optional() @Host() radioContainer: RadioButton, - @Optional() @Host() scrollView: Content, - @Attribute('type') type: string, - elementRef: ElementRef, - app: IonicApp, - config: IonicConfig - ) { - super(elementRef, app, config, scrollView); - - let container = checkboxContainer || radioContainer; - - if (container) { - container.registerInput(this); - this.container = container; - } - - this.type = type; - this.elementRef = elementRef; - this.tabIndex = this.tabIndex || ''; - } - -} diff --git a/ionic/components/form/test/fixed-inline-labels/main.html b/ionic/components/form/test/fixed-inline-labels/main.html index 9755bcce34..bc37398872 100644 --- a/ionic/components/form/test/fixed-inline-labels/main.html +++ b/ionic/components/form/test/fixed-inline-labels/main.html @@ -6,70 +6,70 @@ - - + + To - - + + CC - - + + From - - + + Comments - + - + Website - + - + Email - + - + Feedback - - + + More Info - - + + Score - - + + First Name - - + + Last Name - - + + Message diff --git a/ionic/components/form/test/inline-labels/main.html b/ionic/components/form/test/inline-labels/main.html index 2f1ebfa8bf..6dce4fcf3f 100644 --- a/ionic/components/form/test/inline-labels/main.html +++ b/ionic/components/form/test/inline-labels/main.html @@ -7,17 +7,17 @@ - + To: - + CC: - + From: - + First Name: - + Last Name: - + Message: diff --git a/ionic/components/form/test/stacked-labels/main.html b/ionic/components/form/test/stacked-labels/main.html index d9a2a3adff..fa63df3df4 100644 --- a/ionic/components/form/test/stacked-labels/main.html +++ b/ionic/components/form/test/stacked-labels/main.html @@ -6,53 +6,53 @@ - - + + Label 1 - - + + Label 2 - - + + Label 3 - - + + Label 4 - - + + Label 5 - - + + Label 6 - - + + Label 7 - - + + Label 8 - - + + Label 9 - - + + Label 10 diff --git a/ionic/components/form/text-input.ts b/ionic/components/form/text-input.ts index 8afd0b7475..7ddeae938a 100644 --- a/ionic/components/form/text-input.ts +++ b/ionic/components/form/text-input.ts @@ -45,7 +45,7 @@ export class Input extends IonInputItem { '(touchend)': 'pointerEnd($event)', '(mousedown)': 'pointerStart($event)', '(mouseup)': 'pointerEnd($event)', - '[attr.id]': 'id', + '[attr.aria-labelledby]': 'labelledBy', 'class': 'text-input input' } }) diff --git a/ionic/components/show-hide-when/test/basic/e2e.ts b/ionic/components/show-hide-when/test/basic/e2e.ts index 3e340014f6..e69de29bb2 100644 --- a/ionic/components/show-hide-when/test/basic/e2e.ts +++ b/ionic/components/show-hide-when/test/basic/e2e.ts @@ -1,4 +0,0 @@ - -it('should toggle checkbox state with label click', function() { - element(by.css('#appleLabel')).click(); -}); diff --git a/ionic/config/annotations.ts b/ionic/config/annotations.ts index de9daac2e8..fadfc45c09 100644 --- a/ionic/config/annotations.ts +++ b/ionic/config/annotations.ts @@ -12,7 +12,7 @@ import { Toolbar, Icon, IconDirective, - Checkbox, TapInput, Switch, + Checkbox, Switch, Input, TextInput, Label, Segment, SegmentButton, SegmentControlValueAccessor, RadioGroup, RadioButton, SearchBar, @@ -73,7 +73,6 @@ export const IonicDirectives = [ // Input forwardRef(() => Input), forwardRef(() => TextInput), - forwardRef(() => TapInput), forwardRef(() => Label), // Nav