Skip to content

Commit

Permalink
fix(ui/input): fix the wrong style of input
Browse files Browse the repository at this point in the history
  • Loading branch information
yuding2019 authored and haoziqaq committed Jul 29, 2021
1 parent fffbb41 commit 0cd5752
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ exports[`test form with input 1`] = `
<div class=\\"var-input var--box\\">
<div class=\\"var-input__controller var-input--disabled\\">
<div class=\\"var-input__icon\\"></div>
<div class=\\"var-input__wrap\\"><input class=\\"var-input__input var-input--disabled\\" autocomplete=\\"off\\" id=\\"var-input-3\\" disabled=\\"\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder\\" for=\\"var-input-3\\"></label></div>
<div class=\\"var-input__wrap\\">
<!--v-if--><input class=\\"var-input__input var-input--disabled\\" autocomplete=\\"new-password\\" id=\\"var-input-3\\" disabled=\\"\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder\\" for=\\"var-input-3\\"></label>
</div>
<div class=\\"var-input__icon\\">
<!--v-if-->
</div>
Expand All @@ -131,7 +133,9 @@ exports[`test form with input 2`] = `
<div class=\\"var-input var--box\\">
<div class=\\"var-input__controller\\">
<div class=\\"var-input__icon\\"></div>
<div class=\\"var-input__wrap\\"><input class=\\"var-input__input\\" autocomplete=\\"off\\" id=\\"var-input-3\\" disabled=\\"\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder\\" for=\\"var-input-3\\"></label></div>
<div class=\\"var-input__wrap\\">
<!--v-if--><input class=\\"var-input__input\\" autocomplete=\\"new-password\\" id=\\"var-input-3\\" disabled=\\"\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder\\" for=\\"var-input-3\\"></label>
</div>
<div class=\\"var-input__icon\\">
<!--v-if-->
</div>
Expand All @@ -151,7 +155,9 @@ exports[`test form with input 3`] = `
<div class=\\"var-input var--box\\">
<div class=\\"var-input__controller var-input--error\\">
<div class=\\"var-input__icon\\"></div>
<div class=\\"var-input__wrap\\"><input class=\\"var-input__input var-input--caret-error\\" autocomplete=\\"off\\" id=\\"var-input-3\\" disabled=\\"\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder\\" for=\\"var-input-3\\"></label></div>
<div class=\\"var-input__wrap\\">
<!--v-if--><input class=\\"var-input__input var-input--caret-error\\" autocomplete=\\"new-password\\" id=\\"var-input-3\\" disabled=\\"\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder\\" for=\\"var-input-3\\"></label>
</div>
<div class=\\"var-input__icon\\">
<!--v-if-->
</div>
Expand All @@ -174,7 +180,9 @@ exports[`test form with input 4`] = `
<div class=\\"var-input var--box\\">
<div class=\\"var-input__controller\\">
<div class=\\"var-input__icon\\"></div>
<div class=\\"var-input__wrap\\"><input class=\\"var-input__input\\" autocomplete=\\"off\\" id=\\"var-input-3\\" disabled=\\"\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder\\" for=\\"var-input-3\\"></label></div>
<div class=\\"var-input__wrap\\">
<!--v-if--><input class=\\"var-input__input\\" autocomplete=\\"new-password\\" id=\\"var-input-3\\" disabled=\\"\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder\\" for=\\"var-input-3\\"></label>
</div>
<div class=\\"var-input__icon\\">
<!--v-if-->
</div>
Expand Down
3 changes: 2 additions & 1 deletion packages/varlet-ui/src/input/Input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
</div>

<div class="var-input__wrap" :class="[!hint ? 'var-input--non-hint' : null]">
<input class="var-input__autocomplete" v-if="type === 'password'" />
<component
class="var-input__input"
ref="el"
autocomplete="off"
autocomplete="new-password"
:is="textarea ? 'textarea' : 'input'"
:id="id"
:disabled="formDisabled || disabled || formReadonly || readonly"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ exports[`test input clear 1`] = `
"<div class=\\"var-input var--box\\">
<div class=\\"var-input__controller\\">
<div class=\\"var-input__icon\\"></div>
<div class=\\"var-input__wrap\\"><input class=\\"var-input__input\\" autocomplete=\\"off\\" id=\\"var-input-58\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder var-input--placeholder-hint\\" for=\\"var-input-58\\"></label></div>
<div class=\\"var-input__wrap\\">
<!--v-if--><input class=\\"var-input__input\\" autocomplete=\\"new-password\\" id=\\"var-input-58\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder var-input--placeholder-hint\\" for=\\"var-input-58\\"></label>
</div>
<div class=\\"var-input__icon\\"><i class=\\"var-icon var-icon--set var-icon-close-circle var-input__clear-icon\\" style=\\"transition: all 0ms; font-size: 14px;\\" var-input-cover=\\"\\"></i></div>
</div>
<div class=\\"var-input__line\\">
Expand All @@ -21,7 +23,9 @@ exports[`test input example 1`] = `
<div class=\\"var-input var--box\\">
<div class=\\"var-input__controller\\">
<div class=\\"var-input__icon\\"></div>
<div class=\\"var-input__wrap\\"><input class=\\"var-input__input\\" autocomplete=\\"off\\" id=\\"var-input-3\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder\\" for=\\"var-input-3\\">请输入文本</label></div>
<div class=\\"var-input__wrap\\">
<!--v-if--><input class=\\"var-input__input\\" autocomplete=\\"new-password\\" id=\\"var-input-3\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder\\" for=\\"var-input-3\\">请输入文本</label>
</div>
<div class=\\"var-input__icon\\">
<!--v-if-->
</div>
Expand All @@ -37,7 +41,9 @@ exports[`test input example 1`] = `
<div class=\\"var-input var--box\\">
<div class=\\"var-input__controller\\">
<div class=\\"var-input__icon var-input--non-hint\\"></div>
<div class=\\"var-input__wrap var-input--non-hint\\"><input class=\\"var-input__input\\" autocomplete=\\"off\\" id=\\"var-input-7\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder var-input--placeholder-non-hint\\" for=\\"var-input-7\\">请输入文本</label></div>
<div class=\\"var-input__wrap var-input--non-hint\\">
<!--v-if--><input class=\\"var-input__input\\" autocomplete=\\"new-password\\" id=\\"var-input-7\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder var-input--placeholder-non-hint\\" for=\\"var-input-7\\">请输入文本</label>
</div>
<div class=\\"var-input__icon var-input--non-hint\\">
<!--v-if-->
</div>
Expand All @@ -51,7 +57,9 @@ exports[`test input example 1`] = `
<div class=\\"var-input var--box\\">
<div class=\\"var-input__controller\\">
<div class=\\"var-input__icon\\"></div>
<div class=\\"var-input__wrap\\"><textarea class=\\"var-input__input var-input--textarea\\" autocomplete=\\"off\\" id=\\"var-input-11\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"></textarea><label class=\\"var-input__textarea-placeholder\\" for=\\"var-input-11\\">请输入文本</label></div>
<div class=\\"var-input__wrap\\">
<!--v-if--><textarea class=\\"var-input__input var-input--textarea\\" autocomplete=\\"new-password\\" id=\\"var-input-11\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"></textarea><label class=\\"var-input__textarea-placeholder\\" for=\\"var-input-11\\">请输入文本</label>
</div>
<div class=\\"var-input__icon\\">
<!--v-if-->
</div>
Expand All @@ -67,7 +75,9 @@ exports[`test input example 1`] = `
<div class=\\"var-input var--box\\">
<div class=\\"var-input__controller\\">
<div class=\\"var-input__icon\\"></div>
<div class=\\"var-input__wrap\\"><input class=\\"var-input__input\\" autocomplete=\\"off\\" id=\\"var-input-15\\" type=\\"text\\" maxlength=\\"10\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder\\" for=\\"var-input-15\\">请输入文本</label></div>
<div class=\\"var-input__wrap\\">
<!--v-if--><input class=\\"var-input__input\\" autocomplete=\\"new-password\\" id=\\"var-input-15\\" type=\\"text\\" maxlength=\\"10\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder\\" for=\\"var-input-15\\">请输入文本</label>
</div>
<div class=\\"var-input__icon\\">
<!--v-if-->
</div>
Expand All @@ -86,7 +96,9 @@ exports[`test input example 1`] = `
<div class=\\"var-input var--box var-input--disabled\\">
<div class=\\"var-input__controller var-input--disabled\\">
<div class=\\"var-input__icon\\"></div>
<div class=\\"var-input__wrap\\"><input class=\\"var-input__input var-input--disabled\\" autocomplete=\\"off\\" id=\\"var-input-19\\" disabled=\\"\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder\\" for=\\"var-input-19\\">请输入文本</label></div>
<div class=\\"var-input__wrap\\">
<!--v-if--><input class=\\"var-input__input var-input--disabled\\" autocomplete=\\"new-password\\" id=\\"var-input-19\\" disabled=\\"\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder\\" for=\\"var-input-19\\">请输入文本</label>
</div>
<div class=\\"var-input__icon\\">
<!--v-if-->
</div>
Expand All @@ -102,7 +114,9 @@ exports[`test input example 1`] = `
<div class=\\"var-input var--box\\">
<div class=\\"var-input__controller\\">
<div class=\\"var-input__icon\\"></div>
<div class=\\"var-input__wrap\\"><input class=\\"var-input__input\\" autocomplete=\\"off\\" id=\\"var-input-23\\" disabled=\\"\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder\\" for=\\"var-input-23\\">请输入文本</label></div>
<div class=\\"var-input__wrap\\">
<!--v-if--><input class=\\"var-input__input\\" autocomplete=\\"new-password\\" id=\\"var-input-23\\" disabled=\\"\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder\\" for=\\"var-input-23\\">请输入文本</label>
</div>
<div class=\\"var-input__icon\\">
<!--v-if-->
</div>
Expand All @@ -118,7 +132,9 @@ exports[`test input example 1`] = `
<div class=\\"var-input var--box\\">
<div class=\\"var-input__controller\\">
<div class=\\"var-input__icon\\"></div>
<div class=\\"var-input__wrap\\"><input class=\\"var-input__input\\" autocomplete=\\"off\\" id=\\"var-input-27\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder var-input--placeholder-hint\\" for=\\"var-input-27\\">请输入文本</label></div>
<div class=\\"var-input__wrap\\">
<!--v-if--><input class=\\"var-input__input\\" autocomplete=\\"new-password\\" id=\\"var-input-27\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder var-input--placeholder-hint\\" for=\\"var-input-27\\">请输入文本</label>
</div>
<div class=\\"var-input__icon\\"><i class=\\"var-icon var-icon--set var-icon-close-circle var-input__clear-icon\\" style=\\"transition: all 0ms; font-size: 14px;\\" var-input-cover=\\"\\"></i></div>
</div>
<div class=\\"var-input__line\\">
Expand All @@ -132,7 +148,9 @@ exports[`test input example 1`] = `
<div class=\\"var-input var--box\\">
<div class=\\"var-input__controller\\">
<div class=\\"var-input__icon\\"><i class=\\"var-icon var-icon--set var-icon-plus prepend-icon\\" style=\\"transition: all 0ms;\\"></i></div>
<div class=\\"var-input__wrap\\"><input class=\\"var-input__input\\" autocomplete=\\"off\\" id=\\"var-input-32\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder\\" for=\\"var-input-32\\">请输入文本</label></div>
<div class=\\"var-input__wrap\\">
<!--v-if--><input class=\\"var-input__input\\" autocomplete=\\"new-password\\" id=\\"var-input-32\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder\\" for=\\"var-input-32\\">请输入文本</label>
</div>
<div class=\\"var-input__icon\\"><i class=\\"var-icon var-icon--set var-icon-minus append-icon\\" style=\\"transition: all 0ms;\\"></i></div>
</div>
<div class=\\"var-input__line\\">
Expand All @@ -146,7 +164,9 @@ exports[`test input example 1`] = `
<div class=\\"var-input var--box\\">
<div class=\\"var-input__controller\\">
<div class=\\"var-input__icon\\"></div>
<div class=\\"var-input__wrap\\"><input class=\\"var-input__input\\" autocomplete=\\"off\\" id=\\"var-input-38\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder\\" for=\\"var-input-38\\">请输入文本</label></div>
<div class=\\"var-input__wrap\\">
<!--v-if--><input class=\\"var-input__input\\" autocomplete=\\"new-password\\" id=\\"var-input-38\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder\\" for=\\"var-input-38\\">请输入文本</label>
</div>
<div class=\\"var-input__icon\\">
<!--v-if-->
</div>
Expand All @@ -165,7 +185,9 @@ exports[`test input focus & blur 1`] = `
"<div class=\\"var-input var--box\\">
<div class=\\"var-input__controller var-input--focus\\">
<div class=\\"var-input__icon\\"></div>
<div class=\\"var-input__wrap\\"><input class=\\"var-input__input\\" autocomplete=\\"off\\" id=\\"var-input-42\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder var-input--placeholder-hint\\" for=\\"var-input-42\\"></label></div>
<div class=\\"var-input__wrap\\">
<!--v-if--><input class=\\"var-input__input\\" autocomplete=\\"new-password\\" id=\\"var-input-42\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder var-input--placeholder-hint\\" for=\\"var-input-42\\"></label>
</div>
<div class=\\"var-input__icon\\">
<!--v-if-->
</div>
Expand All @@ -183,7 +205,9 @@ exports[`test input focus & blur 2`] = `
"<div class=\\"var-input var--box\\">
<div class=\\"var-input__controller\\">
<div class=\\"var-input__icon\\"></div>
<div class=\\"var-input__wrap\\"><input class=\\"var-input__input\\" autocomplete=\\"off\\" id=\\"var-input-42\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder\\" for=\\"var-input-42\\"></label></div>
<div class=\\"var-input__wrap\\">
<!--v-if--><input class=\\"var-input__input\\" autocomplete=\\"new-password\\" id=\\"var-input-42\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder\\" for=\\"var-input-42\\"></label>
</div>
<div class=\\"var-input__icon\\">
<!--v-if-->
</div>
Expand All @@ -201,7 +225,9 @@ exports[`test input hint to be false 1`] = `
"<div class=\\"var-input var--box\\">
<div class=\\"var-input__controller\\">
<div class=\\"var-input__icon var-input--non-hint\\"></div>
<div class=\\"var-input__wrap var-input--non-hint\\"><input class=\\"var-input__input\\" autocomplete=\\"off\\" id=\\"var-input-54\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder var-input--placeholder-hidden var-input--placeholder-non-hint\\" for=\\"var-input-54\\"></label></div>
<div class=\\"var-input__wrap var-input--non-hint\\">
<!--v-if--><input class=\\"var-input__input\\" autocomplete=\\"new-password\\" id=\\"var-input-54\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder var-input--placeholder-hidden var-input--placeholder-non-hint\\" for=\\"var-input-54\\"></label>
</div>
<div class=\\"var-input__icon var-input--non-hint\\">
<!--v-if-->
</div>
Expand All @@ -219,7 +245,9 @@ exports[`test input maxlength 1`] = `
"<div class=\\"var-input var--box\\">
<div class=\\"var-input__controller\\">
<div class=\\"var-input__icon\\"></div>
<div class=\\"var-input__wrap\\"><input class=\\"var-input__input\\" autocomplete=\\"off\\" id=\\"var-input-50\\" type=\\"text\\" maxlength=\\"100\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder var-input--placeholder-hint\\" for=\\"var-input-50\\"></label></div>
<div class=\\"var-input__wrap\\">
<!--v-if--><input class=\\"var-input__input\\" autocomplete=\\"new-password\\" id=\\"var-input-50\\" type=\\"text\\" maxlength=\\"100\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder var-input--placeholder-hint\\" for=\\"var-input-50\\"></label>
</div>
<div class=\\"var-input__icon\\">
<!--v-if-->
</div>
Expand All @@ -240,7 +268,9 @@ exports[`test input validation 1`] = `
"<div class=\\"var-input var--box\\">
<div class=\\"var-input__controller var-input--error\\">
<div class=\\"var-input__icon\\"></div>
<div class=\\"var-input__wrap\\"><input class=\\"var-input__input var-input--caret-error\\" autocomplete=\\"off\\" id=\\"var-input-73\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder var-input--placeholder-hint\\" for=\\"var-input-73\\"></label></div>
<div class=\\"var-input__wrap\\">
<!--v-if--><input class=\\"var-input__input var-input--caret-error\\" autocomplete=\\"new-password\\" id=\\"var-input-73\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder var-input--placeholder-hint\\" for=\\"var-input-73\\"></label>
</div>
<div class=\\"var-input__icon\\">
<!--v-if-->
</div>
Expand All @@ -261,7 +291,9 @@ exports[`test input validation 2`] = `
"<div class=\\"var-input var--box\\">
<div class=\\"var-input__controller\\">
<div class=\\"var-input__icon\\"></div>
<div class=\\"var-input__wrap\\"><input class=\\"var-input__input\\" autocomplete=\\"off\\" id=\\"var-input-73\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder\\" for=\\"var-input-73\\"></label></div>
<div class=\\"var-input__wrap\\">
<!--v-if--><input class=\\"var-input__input\\" autocomplete=\\"new-password\\" id=\\"var-input-73\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder\\" for=\\"var-input-73\\"></label>
</div>
<div class=\\"var-input__icon\\">
<!--v-if-->
</div>
Expand All @@ -279,7 +311,9 @@ exports[`test input validation 3`] = `
"<div class=\\"var-input var--box\\">
<div class=\\"var-input__controller\\">
<div class=\\"var-input__icon\\"></div>
<div class=\\"var-input__wrap\\"><input class=\\"var-input__input\\" autocomplete=\\"off\\" id=\\"var-input-73\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder var-input--placeholder-hint\\" for=\\"var-input-73\\"></label></div>
<div class=\\"var-input__wrap\\">
<!--v-if--><input class=\\"var-input__input\\" autocomplete=\\"new-password\\" id=\\"var-input-73\\" type=\\"text\\" rows=\\"8\\" style=\\"resize: none;\\"><label class=\\"var-input__placeholder var-input--placeholder-hint\\" for=\\"var-input-73\\"></label>
</div>
<div class=\\"var-input__icon\\">
<!--v-if-->
</div>
Expand Down
9 changes: 9 additions & 0 deletions packages/varlet-ui/src/input/input.less
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@
font-size: var(--input-placeholder-size);
}

&__autocomplete {
width: 0;
height: 0;
padding: 0;
border: none;
outline: none;
font-size: 0;
}

&__input {
width: 100%;
height: 32px;
Expand Down

0 comments on commit 0cd5752

Please sign in to comment.