From dc8cf35d6091946d45f204b3ad7a0bfb39ff532a Mon Sep 17 00:00:00 2001 From: Robert Messerle Date: Tue, 29 Sep 2015 11:53:16 -0700 Subject: [PATCH] refactor(input): refactors styles to use `display: inline-block` --- docs/config/template/index.template.html | 2 +- src/components/checkbox/checkbox.scss | 13 ++++-- src/components/datepicker/datePicker.scss | 7 +++- .../input/demoBasicUsage/index.html | 11 ++--- src/components/input/demoBasicUsage/style.css | 15 +------ src/components/input/demoErrors/index.html | 14 ++----- src/components/input/demoErrors/style.css | 4 +- src/components/input/demoIcons/index.html | 13 +++--- src/components/input/demoIcons/style.scss | 21 ++-------- src/components/input/input.js | 1 + src/components/input/input.scss | 41 +++++++------------ src/components/radioButton/radio-button.scss | 14 +++++++ .../select/demoValidations/index.html | 2 +- src/components/select/select.js | 2 +- .../switch/demoBasicUsage/index.html | 12 +++--- src/components/switch/switch.scss | 21 ++++++++-- 16 files changed, 94 insertions(+), 99 deletions(-) diff --git a/docs/config/template/index.template.html b/docs/config/template/index.template.html index 77cbdaf488..6fca7d15b2 100644 --- a/docs/config/template/index.template.html +++ b/docs/config/template/index.template.html @@ -69,7 +69,7 @@

+ style="margin-top: -2px"> {{menu.currentPage | humanizeDoc}} diff --git a/src/components/checkbox/checkbox.scss b/src/components/checkbox/checkbox.scss index 148cb20cf2..87f7313d91 100644 --- a/src/components/checkbox/checkbox.scss +++ b/src/components/checkbox/checkbox.scss @@ -6,16 +6,23 @@ $checkbox-border-width: 2px !default; $checkbox-text-margin: 10px !default; $checkbox-top-left: 12px !default; +.md-inline-form { + md-checkbox { + margin: 19px 0 18px; + } +} + md-checkbox { box-sizing: border-box; - display: block; + display: inline-block; margin: $checkbox-margin; white-space: nowrap; cursor: pointer; outline: none; user-select: none; - @include rtl(padding-left, $checkbox-width, 0); - @include rtl(padding-right, 0, $checkbox-width); + padding: 2px; + @include rtl(padding-left, $checkbox-width, 2px); + @include rtl(padding-right, 2px, $checkbox-width); position: relative; line-height: $checkbox-width + $checkbox-margin; min-width: $checkbox-width; diff --git a/src/components/datepicker/datePicker.scss b/src/components/datepicker/datePicker.scss index 981eb7bfd6..7d29ace241 100644 --- a/src/components/datepicker/datePicker.scss +++ b/src/components/datepicker/datePicker.scss @@ -8,8 +8,13 @@ md-datepicker { white-space: nowrap; } +.md-inline-form { + md-datepicker { + margin-top: 8px; + } +} + // The calendar icon button used to open the calendar pane. -// Need absurd specificty to override md-button.md-icon-button. .md-datepicker-button { display: inline-block; box-sizing: border-box; diff --git a/src/components/input/demoBasicUsage/index.html b/src/components/input/demoBasicUsage/index.html index 48fefcace2..8de4484723 100644 --- a/src/components/input/demoBasicUsage/index.html +++ b/src/components/input/demoBasicUsage/index.html @@ -1,4 +1,4 @@ -
+
@@ -15,7 +15,7 @@
- + @@ -34,11 +34,12 @@
- + - + + @@ -57,7 +58,7 @@
- + diff --git a/src/components/input/demoBasicUsage/style.css b/src/components/input/demoBasicUsage/style.css index 3ed7a4a38c..f831e78451 100644 --- a/src/components/input/demoBasicUsage/style.css +++ b/src/components/input/demoBasicUsage/style.css @@ -1,13 +1,2 @@ -md-datepicker { - margin-top:18px; -} - -.md-datepicker-button { - height: 36px; - width: 36px; - line-height: 36px; -} - -.md-datepicker-input-container { - margin-left: 2px; -} +.md-datepicker-button { width: 36px; } +.md-datepicker-input-container { margin-left: 2px; } \ No newline at end of file diff --git a/src/components/input/demoErrors/index.html b/src/components/input/demoErrors/index.html index 23960846f8..67eb1f1d0e 100644 --- a/src/components/input/demoErrors/index.html +++ b/src/components/input/demoErrors/index.html @@ -1,14 +1,8 @@
- -

- Top Secret Project -

-
- - +
@@ -17,7 +11,7 @@

- +
@@ -25,7 +19,7 @@

- + @@ -37,7 +31,7 @@

- + diff --git a/src/components/input/demoErrors/style.css b/src/components/input/demoErrors/style.css index 2fe0fd6442..6939f113da 100644 --- a/src/components/input/demoErrors/style.css +++ b/src/components/input/demoErrors/style.css @@ -1,3 +1 @@ -.inputErrorsApp { - min-height:48px; -} +.inputErrorsApp { min-height:48px; } diff --git a/src/components/input/demoIcons/index.html b/src/components/input/demoIcons/index.html index 19caf98def..5e382b1609 100644 --- a/src/components/input/demoIcons/index.html +++ b/src/components/input/demoIcons/index.html @@ -1,27 +1,24 @@ -
- -
+
- - + - + - + - + diff --git a/src/components/input/demoIcons/style.scss b/src/components/input/demoIcons/style.scss index e9c4d137cb..f86be30283 100644 --- a/src/components/input/demoIcons/style.scss +++ b/src/components/input/demoIcons/style.scss @@ -1,18 +1,5 @@ -.inputIconDemo { - min-height:48px; -} - - -md-input-container:not(.md-input-invalid) > md-icon.email { - color : green; -} -md-input-container:not(.md-input-invalid) > md-icon.name { - color : dodgerblue; -} - +.inputIconDemo { min-height: 48px; } +md-input-container:not(.md-input-invalid) > md-icon.email { color: green; } +md-input-container:not(.md-input-invalid) > md-icon.name { color: dodgerblue; } md-input-container.md-input-invalid > md-icon.email, -md-input-container.md-input-invalid > md-icon.name, -{ - color : red; -} - +md-input-container.md-input-invalid > md-icon.name { color: red; } diff --git a/src/components/input/input.js b/src/components/input/input.js index 4506226c67..7be53198bf 100644 --- a/src/components/input/input.js +++ b/src/components/input/input.js @@ -56,6 +56,7 @@ function mdInputContainerDirective($mdTheming, $parse) { function postLink(scope, element, attr) { $mdTheming(element); + if (element.find('md-icon').length) element.addClass('md-has-icon'); } function ContainerCtrl($scope, $element, $attrs) { diff --git a/src/components/input/input.scss b/src/components/input/input.scss index 21fd2f3462..285b8df8ce 100644 --- a/src/components/input/input.scss +++ b/src/components/input/input.scss @@ -17,16 +17,21 @@ $input-error-height: 24px !default; $icon-offset : 36px !default; -$icon-float-top: -16px !default; $icon-float-focused-top: -8px !default; md-input-container { - display: flex; + display: inline-block; position: relative; - flex-direction: column; - padding: $input-container-padding; - padding-bottom: $input-container-padding + $input-error-height; + margin: 18px 0; + + &.md-block { + display: block; + } + + &.md-has-icon { + padding-left: $icon-offset; + } // When we have ng-messages, remove the input error height from our bottom padding, since the // ng-messages wrapper has a min-height of 1 error (so we don't adjust height as often; see below) @@ -39,7 +44,6 @@ md-input-container { top: 5px; left: 2px; + input { - margin-left: $icon-offset; } } @@ -80,8 +84,8 @@ md-input-container { } label { - position: relative; - top: -2px; + position: absolute; + bottom: 100%; } @@ -103,9 +107,6 @@ md-input-container { opacity: 0; transition-property: opacity, transform; transform: translate3d(0, $input-placeholder-offset + $baseline-grid * 0.75, 0); - &.md-static { - position: static; - } } &.md-input-focused .md-placeholder { opacity: 1; @@ -150,7 +151,8 @@ md-input-container { border-radius: 0; // Fix number inputs in Firefox to be full-width - width: auto; + width: 100%; + box-sizing: border-box; &:focus { outline: none; @@ -270,35 +272,22 @@ md-input-container { md-input-container.md-icon-float { - margin-top : $icon-float-top; transition : margin-top 0.5s $swift-ease-out-timing-function ; > label { pointer-events:none; position:absolute; - margin-left: $icon-offset; } > md-icon { - top: 26px; + top: 2px; left: 2px; - + input, - + textarea { - margin-left: $icon-offset; - } - } - - > input, - > textarea { - padding-top : $input-line-height - $input-container-padding; } &.md-input-focused, &.md-input-has-value { - margin-top: $icon-float-focused-top; - label { transform: translate3d(0,$input-label-float-offset,0) scale($input-label-float-scale); transition: transform $swift-ease-out-timing-function 0.5s; diff --git a/src/components/radioButton/radio-button.scss b/src/components/radioButton/radio-button.scss index 1e3e12db1f..680b8b3cc9 100644 --- a/src/components/radioButton/radio-button.scss +++ b/src/components/radioButton/radio-button.scss @@ -112,6 +112,20 @@ md-radio-group { } } +.md-inline-form { + md-radio-group { + margin: 18px 0 19px; + md-radio-button { + display: inline-block; + height: 30px; + padding: 2px; + box-sizing: border-box; + margin-top: 0; + margin-bottom: 0; + } + } +} + @media screen and (-ms-high-contrast: active) { md-radio-button.md-default-theme .md-on { background-color: #fff; diff --git a/src/components/select/demoValidations/index.html b/src/components/select/demoValidations/index.html index bad68479d6..a3a9fe756d 100755 --- a/src/components/select/demoValidations/index.html +++ b/src/components/select/demoValidations/index.html @@ -1,7 +1,7 @@

Note that invalid styling only applies if invalid and dirty

- + One diff --git a/src/components/select/select.js b/src/components/select/select.js index 1e9e0d9fba..71271b37d0 100755 --- a/src/components/select/select.js +++ b/src/components/select/select.js @@ -212,7 +212,7 @@ function SelectDirective($mdSelect, $mdUtil, $mdTheming, $mdAria, $compile, $par if (isPlaceholder) { valueEl.addClass('md-select-placeholder'); if (containerCtrl && containerCtrl.label) { - containerCtrl.label.addClass('md-placeholder md-static'); + containerCtrl.label.addClass('md-placeholder'); } } else { valueEl.removeClass('md-select-placeholder'); diff --git a/src/components/switch/demoBasicUsage/index.html b/src/components/switch/demoBasicUsage/index.html index 74d83c2f0f..3a8075f44b 100644 --- a/src/components/switch/demoBasicUsage/index.html +++ b/src/components/switch/demoBasicUsage/index.html @@ -1,25 +1,25 @@
- + Switch 1: {{ data.cb1 }} - + Switch 2 (md-warn): {{ data.cb2 }} - + Switch (Disabled) - + Switch (Disabled, Active) - + Switch (md-primary): No Ink - + Switch 6 message: {{ message }}
diff --git a/src/components/switch/switch.scss b/src/components/switch/switch.scss index 1476050013..039457b212 100644 --- a/src/components/switch/switch.scss +++ b/src/components/switch/switch.scss @@ -3,16 +3,26 @@ $switch-height: $baseline-grid * 3 !default; $switch-bar-height: 14px !default; $switch-thumb-size: 20px !default; -md-switch { - - display: flex; - align-items: center; +.md-inline-form { + md-switch { + margin-top: 18px; + margin-bottom: 19px; + } +} +md-switch { + display: inline-block; margin: 15px; white-space: nowrap; cursor: pointer; outline: none; user-select: none; + height: 30px; + line-height: 28px; + + &.md-block { + display: block; + } .md-container { cursor: grab; @@ -21,6 +31,8 @@ md-switch { position: relative; user-select: none; margin-right: 8px; + margin-top: (30 - $switch-height) / 2; + float: left; } // If the user moves his mouse off the switch, stil display grabbing cursor @@ -49,6 +61,7 @@ md-switch { .md-label { border-color: transparent; border-width: 0; + float: left; } .md-bar {