Skip to content

Commit c71deb4

Browse files
Correct some gotchas
- mm-input size settings - mm-input attr styling - fix FF bug mm-input-mask - don't overwrite color on span mm-icon
1 parent f6a7f06 commit c71deb4

9 files changed

Lines changed: 115 additions & 43 deletions

File tree

src/mm-icon/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
padding: 0;
3838
}
3939

40+
li span {
41+
color:#00ff00;
42+
}
43+
4044
.actions {
4145
color: #FF0000;
4246
}

src/mm-icon/mm-icon.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
._mm_icon {
2020
display: block;
21-
color: inherit;
21+
color: inherit !important;
2222
}
2323

2424
[class^="icon-"], [class*=" icon-"] {

src/mm-input-mask/mm-input-mask.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
on-paste="_handlePaste"
3232
placeholder="{{item.placeholder}}"></input></template><template is="dom-if" if="{{!item.type}}"><span class$="{{ _sepClass(value) }}">{{item.value}}</span></template></template>
3333
</div>
34-
<mm-input icon="{{icon}}" id="input"></mm-input>
34+
<mm-input icon$="{{icon}}" id="input"></mm-input>
3535
<content id="content" select="group,sep"></content>
3636
</template>
3737
</dom-module>

src/mm-input-mask/mm-input-mask.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@
171171
observer: '_placeholderChanged'
172172
},
173173
icon: {
174-
type: String,
175-
value: ""
174+
type: String
176175
},
177176
_arimoLoaded: {
178177
type: Boolean,
@@ -446,11 +445,10 @@
446445
},
447446

448447
_validateGroup: function(e,target) {
449-
var val;
450-
if(e instanceof KeyboardEvent) val = String.fromCharCode(e.keyCode);
451-
else if(e instanceof ClipboardEvent) val = e.clipboardData.getData('text/plain');
452-
448+
var val = (e instanceof ClipboardEvent) ? e.clipboardData.getData('text/plain') :
449+
String.fromCharCode(e.keyCode);
453450
var group = this._getGroup(target);
451+
454452
// If alphanumeric throw out all modifiers except capital letters
455453
if(group.restrict !== _restrict.all) {
456454
if(e.altKey) return false;
@@ -504,8 +502,11 @@
504502
if(this._isKeyboardShortcut(e)) return;
505503
var max = this._getGroup(e.target).max,
506504
selLength = e.target.selectionEnd - e.target.selectionStart;
507-
if(!this._validateGroup(e,e.target)) e.preventDefault();
508-
else if(e.target.value.length === max && selLength === 0) this._validateGroup(e,this._focusRight(e.target));
505+
if(!this._validateGroup(e,e.target)) {
506+
e.preventDefault();
507+
} else if(e.target.value.length === max && selLength === 0) {
508+
this._validateGroup(e,this._focusRight(e.target));
509+
}
509510
},
510511
_onNum: function(e) {
511512
this._onAlpha(e);

src/mm-input-mask/mm-input-mask.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@
4343
input {
4444
font-family: Arimo, sans-serif !important;
4545
font-size: 13px !important;
46-
line-height: 2.231em !important;
46+
line-height: 29px !important;
4747
&::placeholder {
4848
font-size: 13px !important;
49+
line-height: 29px !important;
4950
font-style: italic;
5051
}
5152
}

src/mm-input/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@
9696
<p><span class="bold">Input:</span> with clear</p>
9797
<mm-input id="ci" placeholder="Clear" clear="true" unresolved></mm-input>
9898
<hr/>
99-
<p><span class="bold">Input:</span> with search</p>
100-
<mm-input placeholder="Search" search="true" unresolved></mm-input>
99+
<p><span class="bold">Input:</span> with search and small</p>
100+
<mm-input placeholder="Search" search="true" size="small" unresolved></mm-input>
101101
<hr/>
102102
<p><span class="bold">Input:</span> with clear and search and fit to parent</p>
103103
<mm-input id="ic" placeholder="Icon and Clear" icon="calendar" clear="true" fitparent unresolved></mm-input>
@@ -123,8 +123,8 @@
123123
<p><span class="bold">Input:</span> validate not empty spaces</p>
124124
<mm-input placeholder="decimal" validation="blank" fitparent="true" unresolved></mm-input>
125125
<hr/>
126-
<p><span class="bold">Input:</span> with clear, search, fit to parent</p>
127-
<mm-input id="searchInput" placeholder="Search, Clear &amp; Fit" search="true" clear="true" fitparent unresolved></mm-input>
126+
<p><span class="bold">Input:</span> with clear, search, fit to parent, large</p>
127+
<mm-input id="searchInput" placeholder="Search, Clear &amp; Fit" search="true" clear="true" size="large" fitparent unresolved></mm-input>
128128
<hr/>
129129
</div>
130130
<div class="vr"></div>

src/mm-input/mm-input.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
maxlength$="{{maxlength}}"
2626
disabled="{{disabled}}"
2727
readonly$="{{readonly}}"
28-
style$="{{ _updateStyle(icon, width, fitparent, clear) }}" />
28+
style$="{{ _updateStyle(width, fitparent) }}" />
2929
<div id="icon" class="icon-holder" style$="{{ _updateIcon(icon, _clearVisible) }}">
30-
<mm-icon type="{{icon}}" width="14" height="14"></mm-icon>
30+
<mm-icon type="{{icon}}" width="{{_iconSize(size)}}" height="{{_iconSize(size)}}"></mm-icon>
3131
</div>
3232
<div id="clearBtn" class="clear-btn" on-tap="clearInput" style$="{{ _updateClear(_clearVisible) }}">
33-
<mm-icon type="fail" width="14" height="14"></mm-icon>
33+
<mm-icon type="fail" width="{{_iconSize(size)}}" height="{{_iconSize(size)}}"></mm-icon>
3434
</div>
3535
</template>
3636
</dom-module>

src/mm-input/mm-input.js

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
},
2424
size: {
2525
type: String,
26-
reflectToAttribute: true
26+
value: 'normal',
27+
reflectToAttribute: true,
28+
notify: true
2729
},
2830
placeholder: {
2931
type: String,
@@ -59,7 +61,8 @@
5961
width: {
6062
type: Number,
6163
value: false,
62-
reflectToAttribute: true
64+
reflectToAttribute: true,
65+
// notify: true
6366
},
6467
maxlength: {
6568
type: Number,
@@ -80,7 +83,8 @@
8083
fitparent: {
8184
type: Boolean,
8285
value: false,
83-
reflectToAttribute: true
86+
reflectToAttribute: true,
87+
// notify: true
8488
},
8589
_layout: {
8690
type: String,
@@ -94,8 +98,6 @@
9498

9599
DIRECTION_TOP: "top",
96100
DIRECTION_BOTTOM: "bottom",
97-
PADDING_RIGHT_ICON: 25,
98-
PADDING_RIGHT_DEFAULT: 10,
99101

100102
_typeChanged: function(newVal, oldVal) {
101103
var types = /(text|password|email|number|tel|search|url)/ig;
@@ -139,16 +141,12 @@
139141
this._clearVisible = false;
140142
},
141143

142-
_updateStyle: function(icon, width, fitparent, clear) {
143-
var p = icon || clear ? this.PADDING_RIGHT_ICON + 'px' : this.PADDING_RIGHT_DEFAULT + 'px',
144-
f = fitparent ? '100%' : false,
144+
_updateStyle: function(width, fitparent) {
145+
var f = fitparent ? '100%' : false,
145146
w = width ? width + 'px' : null,
146147
style = {};
147148

148-
style.paddingRight = p;
149-
// sometimes, we do not want to add width
150149
if(w) style.width = f ? f : w;
151-
152150
return this.styleBlock(style);
153151
},
154152

@@ -159,6 +157,17 @@
159157
o.top = (direction === this.DIRECTION_TOP);
160158
o.bottom = (direction === this.DIRECTION_BOTTOM);
161159
return this.classBlock(o);
160+
},
161+
162+
_iconSize: function(size) {
163+
switch(size) {
164+
case 'large':
165+
return 16;
166+
case 'small':
167+
return 11;
168+
default:
169+
return 14;
170+
}
162171
}
163172

164173
});

src/mm-input/mm-input.scss

Lines changed: 71 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,11 @@
2727

2828
.icon-holder,
2929
.clear-btn {
30-
width: 14px;
31-
height: 14px;
3230
position: absolute;
3331
right: 0;
34-
top: 50%;
35-
margin: -7px 8px 0 0;
3632

3733
mm-icon {
38-
color: $color-A18;
34+
color: $color-A18 !important;
3935
}
4036
}
4137

@@ -47,8 +43,6 @@
4743
.text-input {
4844
box-sizing: border-box;
4945
height: 29px !important;
50-
line-height: 2.231em !important; // line-height equal to height, in em (don't remember the specifics around this choice but there was a case for this)
51-
padding: 0 10px;
5246
}
5347

5448
// layout modes for input
@@ -122,25 +116,88 @@
122116
.text-input {
123117
height: 46px !important;
124118
font-size: 15px !important;
125-
line-height: 2.875em !important;
126-
padding: 0 15px;
119+
line-height: 46px !important;
120+
padding: 0 15px !important;
121+
122+
&::placeholder {
123+
font-size: 15px !important;
124+
line-height: 46px !important;
125+
}
126+
}
127+
}
128+
129+
:host([size='large'][search]),
130+
:host([size='large'][clear]),
131+
:host([size='normal'][icon]){
132+
.text-input {
133+
padding: 0 30px 0 15px !important;
134+
}
135+
136+
.icon-holder,
137+
.clear-btn {
138+
width: 16px;
139+
height: 16px;
140+
top: 15px;
141+
right: 10px;
127142
}
128143
}
129144

130145
:host([size='normal']){
131146
.text-input {
132147
height: 29px !important;
133148
font-size: 13px !important;
134-
line-height: 2.231em !important;
135-
padding: 0 10px;
149+
line-height: 29px !important;
150+
padding: 0 10px !important;
151+
152+
&::placeholder {
153+
font-size: 13px !important;
154+
line-height: 29px !important;
155+
}
156+
}
157+
}
158+
159+
:host([size='normal'][search]),
160+
:host([size='normal'][clear]),
161+
:host([size='normal'][icon]){
162+
.text-input {
163+
padding: 0 25px 0 10px !important;
164+
}
165+
166+
.icon-holder,
167+
.clear-btn {
168+
width: 14px;
169+
height: 14px;
170+
top: 7.5px;
171+
right: 8px;
136172
}
137173
}
138174

139175
:host([size='small']){
140176
.text-input {
141-
height: 20px !important;
177+
height: 26px !important;
142178
font-size: 11px !important;
143-
line-height: 1.250em !important;
144-
padding: 0 7px;
179+
line-height: 26px !important;
180+
padding: 0 8px !important;
181+
182+
&::placeholder {
183+
font-size: 11px !important;
184+
line-height: 26px !important;
185+
}
186+
}
187+
}
188+
189+
:host([size='small'][search]),
190+
:host([size='small'][clear]),
191+
:host([size='normal'][icon]){
192+
.text-input {
193+
padding: 0 22px 0 8px !important;
194+
}
195+
196+
.icon-holder,
197+
.clear-btn {
198+
width: 11px;
199+
height: 11px;
200+
top: 7.5px;
201+
right: 8px;
145202
}
146203
}

0 commit comments

Comments
 (0)