refactor(text-input): flattened css selectors, renamed some, cleaned up styles

references #689
This commit is contained in:
Brandy Carney
2015-12-08 16:58:50 -05:00
parent ce2e4a3e32
commit afaf4d6de4
6 changed files with 109 additions and 64 deletions

View File

@@ -23,7 +23,7 @@ $card-md-thumbnail-size: 8rem !default;
$card-md-background-color: $list-md-background-color !default;
$card-md-box-shadow: 0 2px 2px 0 rgba(0,0,0,.14), 0 3px 1px -2px rgba(0,0,0,.2), 0 1px 5px 0 rgba(0,0,0,.12) !default;
$card-md-border-radius: 2px !default;
$card-md-font-size: 1.4rem !default;
$card-md-font-size: 1.6rem !default;
$card-md-line-height: 1.5 !default;
$card-md-text-color: #222 !default;

View File

@@ -12,7 +12,11 @@ ion-label {
pointer-events: none;
}
[fixed-label] ion-label {
// Stacked & Floating Inputs
// --------------------------------------------------
.fixed-label {
width: 30%;
min-width: 100px;
max-width: 200px;
@@ -22,16 +26,17 @@ ion-label {
[floating-label] {
flex-direction: column;
align-items: flex-start;
ion-label {
align-self: stretch;
margin-bottom: 0;
max-width: 100%;
}
.item-input {
align-self: stretch;
width: auto;
}
}
.stacked-label,
.floating-label {
align-self: stretch;
margin-bottom: 0;
max-width: 100%;
}
.stacked-input,
.floating-input {
align-self: stretch;
width: auto;
}

View File

@@ -9,17 +9,15 @@ $text-input-ios-background-color: $list-ios-background-color !default;
$text-input-ios-label-color: #7f7f7f !default;
// Default Input
// --------------------------------------------------
.item-input {
margin: $item-ios-padding-top ($item-ios-padding-right / 2) $item-ios-padding-bottom 0;
padding: 0;
background-color: $text-input-ios-background-color;
}
ion-input[inset] .item-input {
margin: ($item-ios-padding-top / 2) $item-ios-padding-right ($item-ios-padding-bottom / 2) $item-ios-padding-left;
padding: ($item-ios-padding-top / 2) ($item-ios-padding-right / 2) ($item-ios-padding-bottom / 2) ($item-ios-padding-left / 2);
}
ion-label {
margin: $item-ios-padding-top ($item-ios-padding-right / 2) $item-ios-padding-bottom 0;
color: $text-input-ios-label-color;
@@ -29,30 +27,50 @@ ion-label + .item-input {
margin-left: $item-ios-padding-left;
}
[stacked-label] ion-label {
// Inset Input
// --------------------------------------------------
.inset-input {
margin: ($item-ios-padding-top / 2) $item-ios-padding-right ($item-ios-padding-bottom / 2) $item-ios-padding-left;
padding: ($item-ios-padding-top / 2) ($item-ios-padding-right / 2) ($item-ios-padding-bottom / 2) ($item-ios-padding-left / 2);
}
// Stacked & Floating Inputs
// --------------------------------------------------
.stacked-label {
font-size: 1.2rem;
margin-bottom: 4px;
}
[stacked-label] .item-input,
[floating-label] .item-input {
margin-left: 0;
margin-top: 8px;
margin-bottom: 8px;
}
[floating-label] ion-label {
.floating-label {
margin-bottom: 0;
transform-origin: left top;
transform: translate3d(0, 27px, 0);
transition: transform 150ms ease-in-out;
}
[floating-label].input-focused ion-label,
[floating-label].input-has-value ion-label {
.stacked-input,
.floating-input {
margin-top: 8px;
margin-bottom: 8px;
}
.input-focused .floating-label,
.input-has-value .floating-label {
transform: translate3d(0, 0, 0) scale(0.8);
}
ion-label + .stacked-input,
ion-label + .floating-input {
margin-left: 0;
}
// Generate iOS label colors
// --------------------------------------------------
@each $color-name, $color-value in $colors-ios {
ion-label[#{$color-name}] {

View File

@@ -12,77 +12,97 @@ $text-input-md-hightlight-color-valid: map-get($colors-md, secondary) !defa
$text-input-md-hightlight-color-invalid: map-get($colors-md, danger) !default;
// Default Input
// --------------------------------------------------
.item-input {
margin: $item-md-padding-top ($item-md-padding-right / 2) $item-md-padding-bottom ($item-md-padding-left / 2);
padding: 0;
background-color: $text-input-md-background-color;
}
ion-input[inset] .item-input {
margin: ($item-md-padding-top / 2) $item-md-padding-right ($item-md-padding-bottom / 2) $item-md-padding-left;
padding: ($item-md-padding-top / 2) ($item-md-padding-right / 2) ($item-md-padding-bottom / 2) ($item-md-padding-left / 2);
}
ion-label {
margin: $item-md-padding-top ($item-md-padding-right / 2) $item-md-padding-bottom ($item-md-padding-left / 2);
color: $text-input-md-label-color;
}
// Inset Input
// --------------------------------------------------
.inset-input {
margin: ($item-md-padding-top / 2) $item-md-padding-right ($item-md-padding-bottom / 2) $item-md-padding-left;
padding: ($item-md-padding-top / 2) ($item-md-padding-right / 2) ($item-md-padding-bottom / 2) ($item-md-padding-left / 2);
}
// Highlighted Input
// --------------------------------------------------
ion-input:after {
position: absolute;
bottom: 0;
right: 0;
left: $item-md-padding-left;
border-bottom: 2px solid transparent;
border-bottom-width: 2px;
border-bottom-style: solid;
border-bottom-color: transparent;
content: '';
}
.input-focused:after {
border-bottom: 2px solid $text-input-md-highlight-color;
border-bottom-color: $text-input-md-highlight-color;
}
ion-input.ng-valid.input-has-value:after {
border-bottom: 2px solid $text-input-md-hightlight-color-valid;
border-bottom-color: $text-input-md-hightlight-color-valid;
}
ion-input.ng-invalid.ng-touched:after {
border-bottom: 2px solid $text-input-md-hightlight-color-invalid;
border-bottom-color: $text-input-md-hightlight-color-invalid;
}
[stacked-label] ion-label {
// Stacked & Floating Inputs
// --------------------------------------------------
.stacked-label {
font-size: 1.2rem;
margin-bottom: 0;
}
[stacked-label] ion-label,
[floating-label] ion-label {
margin-left: 0;
}
[stacked-label].input-focused ion-label,
[floating-label].input-focused ion-label {
color: $text-input-md-highlight-color;
}
[stacked-label] .item-input,
[floating-label] .item-input {
margin-bottom: 8px;
margin-top: 8px;
margin-left: 0;
}
[floating-label] ion-label {
margin-bottom: 0;
.floating-label {
transform-origin: left top;
transform: translate3d(0, 27px, 0);
transition: transform 150ms ease-in-out;
}
[floating-label].input-focused ion-label,
[floating-label].input-has-value ion-label {
.stacked-label,
.floating-label {
margin-left: 0;
margin-bottom: 0;
}
.stacked-input,
.floating-input {
margin-left: 0;
margin-top: 8px;
margin-bottom: 8px;
}
.input-focused .stacked-label,
.input-focused .floating-label {
color: $text-input-md-highlight-color;
}
.input-focused .floating-label,
.input-has-value .floating-label {
transform: translate3d(0, 0, 0) scale(0.8);
}
// Generate Material Design label colors
// --------------------------------------------------
@each $color-name, $color-value in $colors-md {
ion-label[#{$color-name}] {
color: $color-value !important;

View File

@@ -24,6 +24,7 @@ $text-input-textarea-resize: none !default;
[scroll-assist] {
width: 1px;
height: 1px;
padding: 0;
background: transparent;
border: 0;
pointer-events: none;

View File

@@ -76,7 +76,8 @@ export class TextInput {
@Optional() navCtrl: NavController,
@Attribute('floating-label') isFloating: string,
@Attribute('stacked-label') isStacked: string,
@Attribute('fixed-label') isFixed: string
@Attribute('fixed-label') isFixed: string,
@Attribute('inset') isInset: string
) {
this.renderer = renderer;
@@ -87,7 +88,7 @@ export class TextInput {
this.lastTouch = 0;
// make more gud with pending @Attributes API
this.displayType = (isFloating === '' ? 'floating' : (isStacked === '' ? 'stacked' : (isFixed === '' ? 'fixed' : null)));
this.displayType = (isFloating === '' ? 'floating' : (isStacked === '' ? 'stacked' : (isFixed === '' ? 'fixed' : (isInset === '' ? 'inset' : null))));
this.app = app;
this.elementRef = elementRef;