feat: add search input type with icon support and update styles

This commit is contained in:
2026-06-26 09:56:09 -03:00
parent a0c35c76a7
commit 455b7c8506
5 changed files with 27 additions and 1 deletions

View File

@@ -46,6 +46,7 @@
<div class="input-grid"> <div class="input-grid">
<app-input <app-input
type="search"
placeholder="Buscar producto" placeholder="Buscar producto"
[value]="textValue" [value]="textValue"
[maxlength]="24" [maxlength]="24"

View File

@@ -32,6 +32,12 @@
[attr.accept]="type() === 'file' ? accept() : null" [attr.accept]="type() === 'file' ? accept() : null"
/> />
@if (type() === 'search') {
<span class="input-search-icon" aria-hidden="true">
<i class="fa-solid fa-magnifying-glass"></i>
</span>
}
@if (type() === 'file') { @if (type() === 'file') {
<span class="input-file-name" [class.input-file-name-empty]="!resolvedFileName()"> <span class="input-file-name" [class.input-file-name-empty]="!resolvedFileName()">
{{ resolvedFileName() || 'Sin archivo...' }} {{ resolvedFileName() || 'Sin archivo...' }}

View File

@@ -14,6 +14,16 @@
position: relative; position: relative;
} }
.input-search-icon {
position: absolute;
right: 1rem;
top: 50%;
z-index: 1;
color: #495057;
transform: translateY(-50%);
pointer-events: none;
}
.form-control { .form-control {
min-height: 40px; min-height: 40px;
padding: 0.625rem 1rem; padding: 0.625rem 1rem;
@@ -29,6 +39,10 @@
} }
} }
.input-with-search-icon {
padding-right: 2.5rem;
}
input[type='file'].form-control { input[type='file'].form-control {
padding-right: 1rem; padding-right: 1rem;
color: transparent; color: transparent;

View File

@@ -13,6 +13,7 @@ import {
import { NgClass } from '@angular/common'; import { NgClass } from '@angular/common';
export type AppInputType = export type AppInputType =
| 'search'
| 'text' | 'text'
| 'number' | 'number'
| 'email' | 'email'
@@ -26,6 +27,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',
'text', 'text',
'number', 'number',
'email', 'email',
@@ -81,7 +83,7 @@ export class InputComponent {
protected readonly inputType = computed(() => { protected readonly inputType = computed(() => {
const type = this.type(); const type = this.type();
if (type === 'currency' || type === 'percent' || type === 'editable') { if (type === 'search' || type === 'currency' || type === 'percent' || type === 'editable') {
return 'text'; return 'text';
} }
@@ -95,6 +97,7 @@ export class InputComponent {
protected readonly inputClasses = computed(() => ({ protected readonly inputClasses = computed(() => ({
'form-control': true, 'form-control': true,
'is-invalid': this.invalid(), 'is-invalid': this.invalid(),
'input-with-search-icon': this.type() === 'search',
'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'

View File

@@ -1,6 +1,8 @@
@use "./fonts"; @use "./fonts";
@import "@fortawesome/fontawesome-free/css/all.min.css";
@import "./theme"; @import "./theme";
@import "../node_modules/bootstrap/scss/bootstrap"; @import "../node_modules/bootstrap/scss/bootstrap";