feat: add user input type with icon support in input component
This commit is contained in:
@@ -73,6 +73,15 @@
|
|||||||
Email
|
Email
|
||||||
</app-input>
|
</app-input>
|
||||||
|
|
||||||
|
<app-input
|
||||||
|
type="user"
|
||||||
|
placeholder="Nombre de usuario"
|
||||||
|
[value]="user"
|
||||||
|
(valueChange)="user = $event"
|
||||||
|
>
|
||||||
|
Usuario
|
||||||
|
</app-input>
|
||||||
|
|
||||||
<app-input
|
<app-input
|
||||||
type="password-toggle"
|
type="password-toggle"
|
||||||
placeholder="********"
|
placeholder="********"
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export class ReutilizablesTestPageComponent {
|
|||||||
protected textValue = 'Auriculares';
|
protected textValue = 'Auriculares';
|
||||||
protected numberValue = '24';
|
protected numberValue = '24';
|
||||||
protected email = 'usuario@empresa.com';
|
protected email = 'usuario@empresa.com';
|
||||||
|
protected user = 'Juan Perez';
|
||||||
protected password = '12345678';
|
protected password = '12345678';
|
||||||
protected date = '2026-06-24';
|
protected date = '2026-06-24';
|
||||||
protected amount = '125000';
|
protected amount = '125000';
|
||||||
|
|||||||
@@ -39,6 +39,12 @@
|
|||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@if (type() === 'user') {
|
||||||
|
<span class="input-user-icon" aria-hidden="true">
|
||||||
|
<i class="fa-solid fa-user"></i>
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
|
||||||
@if (type() === 'password-toggle') {
|
@if (type() === 'password-toggle') {
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
@@ -14,7 +14,8 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.input-search-icon {
|
.input-search-icon,
|
||||||
|
.input-user-icon {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 1rem;
|
right: 1rem;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { NgClass } from '@angular/common';
|
|||||||
|
|
||||||
export type AppInputType =
|
export type AppInputType =
|
||||||
| 'search'
|
| 'search'
|
||||||
|
| 'user'
|
||||||
| 'text'
|
| 'text'
|
||||||
| 'number'
|
| 'number'
|
||||||
| 'email'
|
| 'email'
|
||||||
@@ -29,6 +30,7 @@ export type AppInputType =
|
|||||||
const DEFAULT_TYPE: AppInputType = 'text';
|
const DEFAULT_TYPE: AppInputType = 'text';
|
||||||
const INPUT_TYPES = new Set<AppInputType>([
|
const INPUT_TYPES = new Set<AppInputType>([
|
||||||
'search',
|
'search',
|
||||||
|
'user',
|
||||||
'text',
|
'text',
|
||||||
'number',
|
'number',
|
||||||
'email',
|
'email',
|
||||||
@@ -92,7 +94,13 @@ export class InputComponent {
|
|||||||
return this.isPasswordVisible() ? 'text' : 'password';
|
return this.isPasswordVisible() ? 'text' : 'password';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'search' || type === 'currency' || type === 'percent' || type === 'editable') {
|
if (
|
||||||
|
type === 'search' ||
|
||||||
|
type === 'user' ||
|
||||||
|
type === 'currency' ||
|
||||||
|
type === 'percent' ||
|
||||||
|
type === 'editable'
|
||||||
|
) {
|
||||||
return 'text';
|
return 'text';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,10 +115,10 @@ export class InputComponent {
|
|||||||
'form-control': true,
|
'form-control': true,
|
||||||
'is-invalid': this.invalid(),
|
'is-invalid': this.invalid(),
|
||||||
'input-with-search-icon': this.type() === 'search',
|
'input-with-search-icon': this.type() === 'search',
|
||||||
|
'input-with-action-icon': this.type() === 'user' || this.type() === 'password-toggle',
|
||||||
'input-with-prefix': this.type() === 'currency',
|
'input-with-prefix': this.type() === 'currency',
|
||||||
'input-with-suffix': this.type() === 'percent',
|
'input-with-suffix': this.type() === 'percent',
|
||||||
'input-with-icon': this.type() === 'editable',
|
'input-with-icon': this.type() === 'editable'
|
||||||
'input-with-action-icon': this.type() === 'password-toggle'
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
protected readonly isInputDisabled = computed(() =>
|
protected readonly isInputDisabled = computed(() =>
|
||||||
|
|||||||
Reference in New Issue
Block a user