-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: consolidate input and input group components
- Loading branch information
1 parent
3de1483
commit 74a768e
Showing
34 changed files
with
228 additions
and
547 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,49 @@ | ||
<div> | ||
<TypographyLabel | ||
class="input-label" | ||
v-if="labelText.length" | ||
:text="labelText" | ||
/> | ||
<div | ||
:class="{'search-box': true, 'right-icon': deleteIcon && internalText.length}" | ||
> | ||
<input | ||
v-model="internalText" | ||
class="input" | ||
:class="{invalid : invalid, [`is-${size} is-${type}`]: true}" | ||
:readonly="readonly" | ||
:disabled="disabled" | ||
:type="inputKind" | ||
:placeholder="placeholder" | ||
@input="update" | ||
ref="input" | ||
:maxLength="maxLength" | ||
:minLength="minLength" | ||
@keydown.space="preventLeadingSpace" | ||
@paste="preventEmptyPaste" | ||
@keydown.enter="submitEnter" | ||
@focus="$emit('focus', $event)" | ||
@blur="$emit('blur', $event)" | ||
/> | ||
<div class="input-group"> | ||
<TypographyLabel v-if="label" class="input-label" :text="label" /> | ||
<div class="input-outer"> | ||
<div class="input-inner"> | ||
<input | ||
ref="input" | ||
class="input" | ||
:class="[ | ||
`font-size-${size} is-${color}`, | ||
{ | ||
'show-clear-button': showClear, | ||
'is-danger': error || invalid | ||
} | ||
]" | ||
:value="value" | ||
:type="type" | ||
:readonly="readonly" | ||
:placeholder="placeholder" | ||
:minLength="minLength" | ||
:maxLength="maxLength" | ||
:disabled="disabled" | ||
@keydown.enter="handleSubmit" | ||
@input="handleInput" | ||
data-cy="input-group" | ||
/> | ||
<button | ||
v-if="showClear && !isEmpty" | ||
class="clear-button" | ||
@click="clearInput" | ||
> | ||
<delete-icon size="1x" /> | ||
</button> | ||
</div> | ||
<button | ||
v-if="deleteIcon && internalText.length" | ||
class="search-clear" | ||
@click="clearSearch" | ||
v-if="$slots.default" | ||
class="button" | ||
:class="[`font-size-${size} is-${color}`, {disabled: disabled}]" | ||
@click="handleSubmit" | ||
data-cy="submit-input" | ||
> | ||
<delete-icon size="1x" /> | ||
<UiLoadersSpinner v-if="loading" spinning /> | ||
<slot v-else></slot> | ||
</button> | ||
</div> | ||
<span v-if="showLimit" class="char-limit"> | ||
{{ text.length }}/{{ maxLength }} | ||
</span> | ||
<TypographyError v-if="error" class="error" :text="error" small /> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,69 @@ | ||
.input-label { | ||
text-align: left; | ||
} | ||
.is-full-width { | ||
&:extend(.full-width); | ||
} | ||
.search-box { | ||
&.right-icon { | ||
input { | ||
padding-right: 34px; | ||
.input-group { | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
|
||
.input-outer { | ||
display: flex; | ||
align-items: stretch; | ||
flex-grow: 1; | ||
|
||
.input-inner { | ||
position: relative; | ||
display: flex; | ||
flex-grow: 1; | ||
|
||
.input { | ||
flex-grow: 1; | ||
padding: @light-spacing; | ||
&:extend(.input-bg); | ||
&:extend(.round-corners); | ||
box-shadow: none; | ||
color: @white; | ||
|
||
&.show-clear-button { | ||
padding-right: 2rem; | ||
} | ||
} | ||
|
||
.clear-button { | ||
position: absolute; | ||
inset: 0 0 0 auto; | ||
font-size: @tiny-icon-size; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
padding: @light-spacing; | ||
color: @text-muted; | ||
} | ||
|
||
&:not(:last-child) .input { | ||
border-top-right-radius: 0; | ||
border-bottom-right-radius: 0; | ||
border-right: 0; | ||
} | ||
} | ||
} | ||
.search-clear { | ||
&:extend(.font-primary); | ||
&:focus { | ||
background: @background; | ||
|
||
.button { | ||
border-top-left-radius: 0; | ||
border-bottom-left-radius: 0; | ||
} | ||
position: absolute; | ||
font-size: @tiny-icon-size; | ||
top: 0; | ||
right: 0; | ||
width: 34px; | ||
height: @full; | ||
background: transparent; | ||
border-color: transparent; | ||
cursor: pointer; | ||
&:extend(.first-layer); | ||
} | ||
position: relative; | ||
|
||
.input { | ||
.char-limit { | ||
float: right; | ||
margin-right: @light-spacing; | ||
font-size: @mini-text-size; | ||
font-family: @secondary-font; | ||
&.is-normal { | ||
height: 2.3rem; | ||
} | ||
&:disabled { | ||
&::placeholder { | ||
/* without !important it does not work */ | ||
color: grey !important; | ||
} | ||
} | ||
&.invalid { | ||
border: 1px solid @red; | ||
} | ||
&:extend(.font-muted); | ||
margin-left: auto; | ||
} | ||
|
||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
.error { | ||
margin-top: @light-spacing; | ||
} | ||
|
||
// TODO: remove after removing bulma | ||
.is-primary:not(.is-danger) { | ||
border-color: transparent; | ||
} | ||
} |
Oops, something went wrong.