Compare commits
3 Commits
394a1dde0d
...
8a6ed763df
| Author | SHA1 | Date | |
|---|---|---|---|
| 8a6ed763df | |||
| 0a7a9d91c7 | |||
| 202205c038 |
@@ -63,6 +63,57 @@
|
||||
|
||||
<hr class="section-divider" />
|
||||
|
||||
<div class="icon-button-showcase">
|
||||
<h2>Icon Buttons</h2>
|
||||
<p class="text-muted mb-4">
|
||||
Botones de ícono pequeños con color base <code>#666666</code>, deshabilitados con <code>#A0A0A0</code> y estados hover/active con color de marca (a excepción de trash que usa danger).
|
||||
</p>
|
||||
|
||||
<div class="icon-button-showcase__grid">
|
||||
<!-- Disabled Row -->
|
||||
<div class="icon-button-showcase__row">
|
||||
<span class="icon-button-showcase__label">Disabled</span>
|
||||
<div class="icon-button-showcase__items">
|
||||
<app-icon-button variant="user" [disabled]="true" />
|
||||
<app-icon-button variant="trash" [disabled]="true" />
|
||||
<app-icon-button variant="angle-left" [disabled]="true" />
|
||||
<app-icon-button variant="angle-right" [disabled]="true" />
|
||||
<app-icon-button variant="angle-up" [disabled]="true" />
|
||||
<app-icon-button variant="angle-down" [disabled]="true" />
|
||||
<app-icon-button variant="copy" [disabled]="true" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Normal Row -->
|
||||
<div class="icon-button-showcase__row">
|
||||
<span class="icon-button-showcase__label">Normal</span>
|
||||
<div class="icon-button-showcase__items">
|
||||
<app-icon-button variant="user" />
|
||||
<app-icon-button variant="trash" />
|
||||
<app-icon-button variant="angle-left" />
|
||||
<app-icon-button variant="angle-right" />
|
||||
<app-icon-button variant="angle-up" />
|
||||
<app-icon-button variant="angle-down" />
|
||||
<app-icon-button variant="copy" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Hover/Active Row -->
|
||||
<div class="icon-button-showcase__row">
|
||||
<span class="icon-button-showcase__label">Active / Hover</span>
|
||||
<div class="icon-button-showcase__items">
|
||||
<app-icon-button variant="user" class="hover-preview" />
|
||||
<app-icon-button variant="trash" class="hover-preview" />
|
||||
<app-icon-button variant="angle-left" class="hover-preview" />
|
||||
<app-icon-button variant="angle-right" class="hover-preview" />
|
||||
<app-icon-button variant="angle-up" class="hover-preview" />
|
||||
<app-icon-button variant="angle-down" class="hover-preview" />
|
||||
<app-icon-button variant="copy" class="hover-preview" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input-grid">
|
||||
<div class="input-field">
|
||||
<label for="search-input">Texto</label>
|
||||
|
||||
@@ -244,3 +244,44 @@ h1 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.icon-button-showcase {
|
||||
display: grid;
|
||||
gap: 1.5rem;
|
||||
|
||||
&__grid {
|
||||
display: grid;
|
||||
gap: 1.5rem;
|
||||
background-color: #eaeaea;
|
||||
padding: 1.5rem;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #dee2e6;
|
||||
}
|
||||
|
||||
&__row {
|
||||
display: grid;
|
||||
grid-template-columns: 160px 1fr;
|
||||
align-items: center;
|
||||
gap: 1.5rem;
|
||||
|
||||
@media (max-width: 575.98px) {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
&__label {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
color: #495057;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
|
||||
&__items {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,12 +5,21 @@ import { InputComponent } from '../../../../shared/components/input/input.compon
|
||||
import { PaginatorComponent } from '../../../../shared/components/paginator/paginator.component';
|
||||
import { ProductCardComponent } from '../../../../shared/components/product-card/product-card.component';
|
||||
import { StoreSectionComponent } from '../../../../shared/components/store-section/store-section.component';
|
||||
import { IconButtonComponent } from '../../../../shared/components/icon-button/icon-button.component';
|
||||
import { TenantService } from '../../../../core/services/tenant.service';
|
||||
import { ToastService } from '../../../../core/services/toast.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-reutilizables-test-page',
|
||||
imports: [ButtonComponent, CartComponent, InputComponent, PaginatorComponent, ProductCardComponent, StoreSectionComponent],
|
||||
imports: [
|
||||
ButtonComponent,
|
||||
CartComponent,
|
||||
InputComponent,
|
||||
PaginatorComponent,
|
||||
ProductCardComponent,
|
||||
StoreSectionComponent,
|
||||
IconButtonComponent
|
||||
],
|
||||
templateUrl: './reutilizables-test-page.component.html',
|
||||
styleUrl: './reutilizables-test-page.component.scss'
|
||||
})
|
||||
|
||||
@@ -54,11 +54,8 @@
|
||||
<section class="product-detail__section">
|
||||
<div class="product-detail__purchase">
|
||||
<app-quantity-selector
|
||||
[quantity]="quantity()"
|
||||
[(quantity)]="quantity"
|
||||
[max]="selectedVariant()?.stock ?? 1"
|
||||
(increase)="increaseQuantity()"
|
||||
(decrease)="decreaseQuantity()"
|
||||
(quantityChange)="quantity.set($event)"
|
||||
/>
|
||||
|
||||
<div class="product-detail__actions">
|
||||
|
||||
@@ -215,14 +215,7 @@ export class ProductDetailPageComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
protected increaseQuantity(): void {
|
||||
const currentStock = this.selectedVariant()?.stock ?? 1;
|
||||
this.quantity.update((current) => current < currentStock ? current + 1 : current);
|
||||
}
|
||||
|
||||
protected decreaseQuantity(): void {
|
||||
this.quantity.update((current) => Math.max(1, current - 1));
|
||||
}
|
||||
|
||||
protected addToCart(): void {
|
||||
const variant = this.selectedVariant();
|
||||
|
||||
@@ -33,13 +33,19 @@
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-end align-items-center mt-auto cart-item-actions" aria-hidden="true">
|
||||
<button class="border d-inline-flex align-items-center justify-content-center bg-white rounded-0 cart-item-qty-btn" type="button">-</button>
|
||||
<span class="border d-inline-flex align-items-center justify-content-center bg-white rounded-0 cart-item-qty-value" >{{ quantity() }}</span>
|
||||
<button class="border d-inline-flex align-items-center justify-content-center bg-white rounded-0 cart-item-qty-btn" type="button">+</button>
|
||||
<button class="border-0 bg-transparent d-inline-flex align-items-center justify-content-center cart-item-remove-btn" type="button">
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
</button>
|
||||
<div class="d-flex justify-content-end align-items-center mt-auto cart-item-actions">
|
||||
<app-quantity-selector
|
||||
size="small"
|
||||
[quantity]="quantity()"
|
||||
(quantityChange)="onQuantityChange($event)"
|
||||
(increase)="onIncrease()"
|
||||
(decrease)="onDecrease()"
|
||||
/>
|
||||
<app-icon-button
|
||||
variant="trash"
|
||||
class="cart-item-remove-btn"
|
||||
(click)="onRemove()"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
@@ -92,25 +92,9 @@
|
||||
gap: 0.125rem;
|
||||
}
|
||||
|
||||
.cart-item-qty-btn,
|
||||
.cart-item-qty-value {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border-color: #cfcfcf !important;
|
||||
color: #666666;
|
||||
font-size: 10px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.cart-item-qty-btn {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
.cart-item-remove-btn {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
margin-left: 0.35rem;
|
||||
padding: 0;
|
||||
color: #b3b3b3;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, computed, input, output } from '@angular/core';
|
||||
import { QuantitySelectorComponent } from '../quantity-selector/quantity-selector.component';
|
||||
import { IconButtonComponent } from '../icon-button/icon-button.component';
|
||||
|
||||
export interface CartItemAttribute {
|
||||
label: string;
|
||||
@@ -8,6 +10,7 @@ export interface CartItemAttribute {
|
||||
@Component({
|
||||
selector: 'app-cart-item',
|
||||
standalone: true,
|
||||
imports: [QuantitySelectorComponent, IconButtonComponent],
|
||||
templateUrl: './cart-item.component.html',
|
||||
styleUrl: './cart-item.component.scss',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
@@ -21,6 +24,27 @@ export class CartItemComponent {
|
||||
readonly attributes = input<CartItemAttribute[]>([]);
|
||||
readonly quantity = input<number>(1);
|
||||
|
||||
readonly quantityChange = output<number>();
|
||||
readonly remove = output<void>();
|
||||
readonly increase = output<void>();
|
||||
readonly decrease = output<void>();
|
||||
|
||||
protected onQuantityChange(newQuantity: number): void {
|
||||
this.quantityChange.emit(newQuantity);
|
||||
}
|
||||
|
||||
protected onRemove(): void {
|
||||
this.remove.emit();
|
||||
}
|
||||
|
||||
protected onIncrease(): void {
|
||||
this.increase.emit();
|
||||
}
|
||||
|
||||
protected onDecrease(): void {
|
||||
this.decrease.emit();
|
||||
}
|
||||
|
||||
protected readonly formattedOriginalPrice = computed(() => {
|
||||
const price = this.originalPrice();
|
||||
return price === null ? null : this.formatCurrency(price);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<button
|
||||
type="button"
|
||||
[disabled]="disabled()"
|
||||
[ngClass]="buttonClasses()"
|
||||
[attr.aria-label]="ariaLabel() || variant()"
|
||||
>
|
||||
<i [ngClass]="iconClass()"></i>
|
||||
</button>
|
||||
@@ -0,0 +1,76 @@
|
||||
:host {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.icon-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: transparent;
|
||||
border: none;
|
||||
padding: 4px;
|
||||
margin: 0;
|
||||
color: #666666;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
transition: color 0.15s ease-in-out, transform 0.1s ease-in-out;
|
||||
border-radius: 4px;
|
||||
|
||||
i {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
font-size: 13px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
// Active state subtle scale down
|
||||
&:active:not(:disabled) {
|
||||
transform: scale(0.92);
|
||||
}
|
||||
|
||||
// Focus ring for accessibility
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--tenant-primary);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
// Disabled state
|
||||
&:disabled {
|
||||
color: #A0A0A0;
|
||||
cursor: not-allowed;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
// Hover/Active/Focus colors (non-disabled)
|
||||
.icon-btn:hover:not(:disabled),
|
||||
.icon-btn:focus-visible:not(:disabled),
|
||||
.icon-btn.hover-preview:not(:disabled),
|
||||
:host(.hover-preview) .icon-btn:not(:disabled) {
|
||||
color: var(--tenant-primary);
|
||||
}
|
||||
|
||||
// Trash is special (uses danger color for hover/active)
|
||||
.icon-btn--trash {
|
||||
&:hover:not(:disabled),
|
||||
&:focus-visible:not(:disabled),
|
||||
&.hover-preview:not(:disabled) {
|
||||
color: var(--tenant-danger);
|
||||
}
|
||||
}
|
||||
|
||||
:host(.hover-preview) .icon-btn--trash:not(:disabled) {
|
||||
color: var(--tenant-danger);
|
||||
}
|
||||
|
||||
.icon-btn--user {
|
||||
i {
|
||||
width: 23px;
|
||||
height: 23px;
|
||||
font-size: 23px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';
|
||||
import { NgClass } from '@angular/common';
|
||||
|
||||
export type IconButtonVariant =
|
||||
| 'user'
|
||||
| 'trash'
|
||||
| 'angle-right'
|
||||
| 'angle-left'
|
||||
| 'angle-up'
|
||||
| 'angle-down'
|
||||
| 'copy';
|
||||
|
||||
@Component({
|
||||
selector: 'app-icon-button',
|
||||
imports: [NgClass],
|
||||
templateUrl: './icon-button.component.html',
|
||||
styleUrl: './icon-button.component.scss',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class IconButtonComponent {
|
||||
readonly variant = input.required<IconButtonVariant>();
|
||||
readonly disabled = input(false);
|
||||
readonly ariaLabel = input<string>('');
|
||||
|
||||
protected readonly iconClass = computed(() => {
|
||||
const classes: Record<IconButtonVariant, string> = {
|
||||
user: 'fa-regular fa-circle-user',
|
||||
trash: 'fa-solid fa-trash',
|
||||
'angle-right': 'fa-solid fa-angle-right',
|
||||
'angle-left': 'fa-solid fa-angle-left',
|
||||
'angle-up': 'fa-solid fa-angle-up',
|
||||
'angle-down': 'fa-solid fa-angle-down',
|
||||
copy: 'fa-solid fa-copy'
|
||||
};
|
||||
return classes[this.variant()];
|
||||
});
|
||||
|
||||
protected readonly buttonClasses = computed(() => {
|
||||
return ['icon-btn', `icon-btn--${this.variant()}`];
|
||||
});
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<div class="quantity-selector" aria-label="Selector de cantidad">
|
||||
<div class="quantity-selector d-inline-flex align-items-center overflow-hidden rounded" [class.quantity-selector--small]="size() === 'small'" aria-label="Selector de cantidad">
|
||||
<button
|
||||
type="button"
|
||||
class="quantity-selector__button"
|
||||
class="quantity-selector__button border-0 p-0 fw-bold lh-1"
|
||||
aria-label="Disminuir cantidad"
|
||||
[disabled]="quantity() <= min()"
|
||||
(click)="onDecrease()"
|
||||
@@ -9,11 +9,11 @@
|
||||
-
|
||||
</button>
|
||||
|
||||
<span class="quantity-selector__value">{{ quantity() }}</span>
|
||||
<span class="quantity-selector__value flex-grow-1 min-w-0 text-center fw-bold lh-1 user-select-none">{{ quantity() }}</span>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="quantity-selector__button"
|
||||
class="quantity-selector__button border-0 p-0 fw-bold lh-1"
|
||||
aria-label="Aumentar cantidad"
|
||||
[disabled]="quantity() >= max()"
|
||||
(click)="onIncrease()"
|
||||
|
||||
@@ -3,24 +3,19 @@
|
||||
}
|
||||
|
||||
.quantity-selector {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
border: 1px solid #d8d8d8;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
min-height: 44px;
|
||||
width: 78px;
|
||||
height: 40px;
|
||||
min-height: 40px;
|
||||
background: #f6f6f6;
|
||||
box-sizing: border-box;
|
||||
|
||||
&__button {
|
||||
width: 25px;
|
||||
height: 44px;
|
||||
padding: 0;
|
||||
width: 24px;
|
||||
height: 100%;
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
color: #6f6f6f;
|
||||
background: #f6f6f6;
|
||||
border: 0;
|
||||
transition: background-color 0.2s ease, color 0.2s ease;
|
||||
cursor: pointer;
|
||||
|
||||
@@ -30,18 +25,38 @@
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.4;
|
||||
color: #A0A0A0;
|
||||
opacity: 1;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
&__value {
|
||||
min-width: 35px;
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
color: #6f6f6f;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
&--small {
|
||||
width: 46px;
|
||||
height: 21px;
|
||||
min-height: 21px;
|
||||
border: 1px solid #cfcfcf;
|
||||
background: #ffffff;
|
||||
|
||||
.quantity-selector__button {
|
||||
width: 15px;
|
||||
font-size: 10px;
|
||||
background: #ffffff;
|
||||
color: #666666;
|
||||
|
||||
&:not(:disabled):hover {
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
}
|
||||
|
||||
.quantity-selector__value {
|
||||
font-size: 10px;
|
||||
color: #666666;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ChangeDetectionStrategy, Component, input, output } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, input, model, output } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-quantity-selector',
|
||||
@@ -9,27 +9,25 @@ import { ChangeDetectionStrategy, Component, input, output } from '@angular/core
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class QuantitySelectorComponent {
|
||||
readonly quantity = input<number>(1);
|
||||
readonly quantity = model<number>(1);
|
||||
readonly min = input<number>(1);
|
||||
readonly max = input<number>(100);
|
||||
readonly size = input<'small' | 'medium'>('medium');
|
||||
|
||||
readonly increase = output<void>();
|
||||
readonly decrease = output<void>();
|
||||
readonly quantityChange = output<number>();
|
||||
|
||||
protected onDecrease(): void {
|
||||
if (this.quantity() > this.min()) {
|
||||
const newValue = this.quantity() - 1;
|
||||
this.quantity.set(this.quantity() - 1);
|
||||
this.decrease.emit();
|
||||
this.quantityChange.emit(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
protected onIncrease(): void {
|
||||
if (this.quantity() < this.max()) {
|
||||
const newValue = this.quantity() + 1;
|
||||
this.quantity.set(this.quantity() + 1);
|
||||
this.increase.emit();
|
||||
this.quantityChange.emit(newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user