From 7ceda630d41c885b2ccf5fc6b536bc5a7e5d81f3 Mon Sep 17 00:00:00 2001 From: gerard Date: Thu, 21 Jun 2018 09:12:35 +0200 Subject: [PATCH] Revert Texfield --- .../core/src/components/textfield/style.scss | 131 +++++------------- .../src/components/textfield/textfield.html | 64 ++++----- .../src/components/textfield/textfield.js | 54 +++----- .../components/textfield/textfield.spec.js | 2 +- 4 files changed, 81 insertions(+), 170 deletions(-) diff --git a/client/core/src/components/textfield/style.scss b/client/core/src/components/textfield/style.scss index ae614b1b7..5ff112e31 100644 --- a/client/core/src/components/textfield/style.scss +++ b/client/core/src/components/textfield/style.scss @@ -1,111 +1,46 @@ -@import "colors"; vn-textfield { - margin: 20px 0!important; - display: block; - - .leftIcons, .rightIcons, .suffix{ - display: inline-flex; - color: $secondary-font-color; - & .material-icons{ - font-size: 20px!important - } + .mdl-chip__action { + position: absolute; + width: auto; + top: 0px; + right: -6px; + margin: 21px 0px; + background: white; + opacity: 1; + z-index: 1; + color: #aaa; } - .leftIcons{ - margin-right: 3px; - } - .container{ + .mdl-textfield { width: 100%; - position: relative; - padding-bottom: 2px; } - .textField{ - width: 100%; - display: inline-flex; - position: relative; - padding: 4px 0; - } - .infix { - position: relative; - display: block; - flex: auto; - width: 100%; - min-width: 0; - } - i.pointer { - visibility: hidden - } - i.visible { + .mdl-textfield__error { visibility: visible; - } - label { - position: absolute; - bottom: 2px; - pointer-events: none; - color: $secondary-font-color; - transition-duration: .2s; - transition-timing-function: cubic-bezier(.4,0,.2,1); - } - input { - - outline: none; - border: none; - font-family: "Helvetica","Arial",sans-serif; - display: block; - font-size: 16px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; width: 100%; - background: 0 0; - color: inherit; - - &[type=number]{ - -moz-appearance: textfield; - &::-webkit-outer-spin-button, - &::-webkit-inner-spin-button{ - -webkit-appearance: none; - margin: 0; - } + } + .mdl-textfield.invalid { + .mdl-textfield__input { + border-color: #d50000; + box-shadow: none; + } + .mdl-textfield__label::after { + background-color: #d50000; } } - - .underline{ - position: absolute; - bottom: 0; - height: 1px; - content: ' '; - pointer-events: none; - width: 100%; - background-color: rgba(0,0,0,.12); + .mdl-textfield--floating-label.invalid .mdl-textfield__label { + color: #d50000; + font-size: 12px; + top: 4px; } - - .selected.underline{ - background-color: rgb(255,152,0); - height: 2px; - left: 50%; - width: 0px!important; - transition-duration: 0.2s; - transition-timing-function: cubic-bezier(.4,0,.2,1); + .material-icons { + font-size: 18px; + float: right; + margin-right: 5px; } - - &.not-empty{ - & label { - bottom: 24px; - color: $main-01; - font-size: 12px; - } - } - - div.selected{ - &.container{ - border-bottom: 0px; - } - & label { - bottom: 24px; - color: $main-01; - font-size: 12px; - } - & .selected.underline{ - left: 0; - width: 100%!important; - } + .material-icons:hover { + color: rgba(0,0,0, .87); } & > div.container > div.textField > div.infix.invalid{ diff --git a/client/core/src/components/textfield/textfield.html b/client/core/src/components/textfield/textfield.html index 0b019b545..fe69149a3 100644 --- a/client/core/src/components/textfield/textfield.html +++ b/client/core/src/components/textfield/textfield.html @@ -1,41 +1,29 @@ -
-
-
-
- -
- - - -
-
-
-
- - clear - - - info_outline - -
-
+ ng-mouseleave="$ctrl.hasMouseIn = false"> + +
+ + info_outline + + + clear +
+
diff --git a/client/core/src/components/textfield/textfield.js b/client/core/src/components/textfield/textfield.js index 83be9f400..b566b45b4 100644 --- a/client/core/src/components/textfield/textfield.js +++ b/client/core/src/components/textfield/textfield.js @@ -3,7 +3,7 @@ import Input from '../../lib/input'; import './style.scss'; export default class Textfield extends Input { - constructor($element, $scope, $attrs, vnTemplate, $transclude) { + constructor($element, $scope, $attrs, vnTemplate) { super($element, $scope); vnTemplate.normalizeInputAttrs($attrs); this._value = null; @@ -13,53 +13,41 @@ export default class Textfield extends Input { this.info = $attrs.info || null; this.hasFocus = false; this.hasMouseIn = false; - - if ($transclude) { - $transclude($scope.$parent, tClone => { - this.leftIcons = tClone[0]; - }, null, 'leftIcons'); - $transclude($scope.$parent, tClone => { - this.rightIcons = tClone[0]; - }, null, 'rightIcons'); - } - } - set leftIcons(value) { - for (let i = 0; i < value.children.length; i++) { - this.element.querySelector('.leftIcons').appendChild(value); - } - } - set rightIcons(value) { - for (let i = 0; i < value.children.length; i++) { - this.element.querySelector('.rightIcons').appendChild(value.children[i]); - } - } - set value(value) { - this._value = (value === undefined || value === '') ? null : value; - this.input.value = this._value; - this.hasValue = this._value !== null; - if (this.hasValue) this.element.classList.add('not-empty'); - else this.element.classList.remove('not-empty'); - this.mdlUpdate(); + componentHandler.upgradeElement($element[0].firstChild); } get value() { return this._value; } + set value(value) { + this._value = (value === undefined || value === '') ? null : value; + this.input.value = this._value; +<<<<<<< HEAD + this.hasValue = this._value !== null; + if (this.hasValue) this.element.classList.add('not-empty'); + else this.element.classList.remove('not-empty'); +======= + this.hasValue = Boolean(this._value); +>>>>>>> parent of 97c994b... Bug #137 RefactorizaciĆ³n Textfield + this.mdlUpdate(); + } + set vnTabIndex(value) { this.input.tabindex = value; } + clear() { this.value = null; this.input.focus(); } + mdlUpdate() { + let mdlElement = this.element.firstChild.MaterialTextfield; + if (mdlElement) mdlElement.updateClasses_(); + } } -Textfield.$inject = ['$element', '$scope', '$attrs', 'vnTemplate', '$transclude']; +Textfield.$inject = ['$element', '$scope', '$attrs', 'vnTemplate']; ngModule.component('vnTextfield', { template: require('./textfield.html'), - transclude: { - leftIcons: '?tLeftIcons', - rightIcons: '?tRightIcons' - }, controller: Textfield, bindings: { value: '=model', diff --git a/client/core/src/components/textfield/textfield.spec.js b/client/core/src/components/textfield/textfield.spec.js index 73d2ee7de..9eea12b0c 100644 --- a/client/core/src/components/textfield/textfield.spec.js +++ b/client/core/src/components/textfield/textfield.spec.js @@ -18,7 +18,7 @@ describe('Component vnTextfield', () => { $attrs = {}; $timeout = _$timeout_; $element = angular.element('
'); - controller = $componentController('vnTextfield', {$scope, $element, $attrs, $timeout, $transclude: null}); + controller = $componentController('vnTextfield', {$scope, $element, $attrs, $timeout}); })); describe('value() setter', () => {