very first commit
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<div class="carousel-container" [class.novo-theme]="isnovo">
|
||||
@if (loading()) {
|
||||
<div class="carousel-loading">
|
||||
<div class="spinner"></div>
|
||||
<p>Загрузка товаров...</p>
|
||||
</div>
|
||||
} @else if (products().length > 0) {
|
||||
<p-carousel
|
||||
[value]="products()"
|
||||
[numVisible]="4"
|
||||
[numScroll]="1"
|
||||
[circular]="true"
|
||||
[responsiveOptions]="responsiveOptions"
|
||||
[autoplayInterval]="3000"
|
||||
[showNavigators]="true"
|
||||
[showIndicators]="true">
|
||||
<ng-template let-product pTemplate="item">
|
||||
<div class="item-card">
|
||||
<a [routerLink]="['/item', product.itemID]" class="item-link">
|
||||
<div class="item-image">
|
||||
<img [src]="getItemImage(product)" [alt]="product.name" loading="lazy" />
|
||||
@if (product.discount > 0) {
|
||||
<div class="discount-badge">-{{ product.discount }}%</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="item-details">
|
||||
<h3 class="item-name">{{ product.name }}</h3>
|
||||
|
||||
<div class="item-rating" *ngIf="product.rating">
|
||||
<span class="rating-stars">⭐ {{ product.rating }}</span>
|
||||
<span class="rating-count">({{ product.callbacks?.length || 0 }})</span>
|
||||
</div>
|
||||
|
||||
<div class="item-price">
|
||||
@if (product.discount > 0) {
|
||||
<span class="original-price">{{ product.price }} {{ product.currency }}</span>
|
||||
<span class="discounted-price">{{ getDiscountedPrice(product) | number:'1.0-0' }} {{ product.currency }}</span>
|
||||
} @else {
|
||||
<span class="current-price">{{ product.price }} {{ product.currency }}</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<button class="add-to-cart-btn" (click)="addToCart(product)">
|
||||
В корзину
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</ng-template>
|
||||
<ul class="p-carousel-indicator-list" data-pc-section="indicatorlist"><li class="p-carousel-indicator" data-p-active="false" data-pc-section="indicator"><button type="button" class="p-carousel-indicator-button" tabindex="-1" aria-label="1" data-pc-section="indicatorbutton"></button></li><li class="p-carousel-indicator" data-p-active="false" data-pc-section="indicator"><button type="button" class="p-carousel-indicator-button" tabindex="-1" aria-label="2" data-pc-section="indicatorbutton"></button></li><li class="p-carousel-indicator" data-p-active="false" data-pc-section="indicator"><button type="button" class="p-carousel-indicator-button" tabindex="-1" aria-label="3" data-pc-section="indicatorbutton"></button></li><li class="p-carousel-indicator" data-p-active="false" data-pc-section="indicator"><button type="button" class="p-carousel-indicator-button" tabindex="-1" aria-label="4" data-pc-section="indicatorbutton"></button></li><li class="p-carousel-indicator" data-p-active="false" data-pc-section="indicator"><button type="button" class="p-carousel-indicator-button" tabindex="-1" aria-label="5" data-pc-section="indicatorbutton"></button></li><li class="p-carousel-indicator" data-p-active="false" data-pc-section="indicator"><button type="button" class="p-carousel-indicator-button" tabindex="-1" aria-label="6" data-pc-section="indicatorbutton"></button></li><li class="p-carousel-indicator p-carousel-indicator-active" data-p-active="true" data-pc-section="indicator"><button type="button" class="p-carousel-indicator-button" tabindex="0" aria-label="7" aria-current="page" data-pc-section="indicatorbutton"></button></li><!----></ul>
|
||||
</p-carousel>
|
||||
}
|
||||
</div>
|
||||
446
src/app/components/items-carousel/items-carousel.component.scss
Normal file
446
src/app/components/items-carousel/items-carousel.component.scss
Normal file
@@ -0,0 +1,446 @@
|
||||
.carousel-container {
|
||||
width: 100%;
|
||||
padding: 2rem 0;
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
|
||||
::ng-deep {
|
||||
// PrimeNG carousel wrapper
|
||||
.p-carousel {
|
||||
.p-carousel-content {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
// Navigation buttons
|
||||
.p-carousel-prev,
|
||||
.p-carousel-next {
|
||||
width: 3rem;
|
||||
height: 3rem;
|
||||
border-radius: 50%;
|
||||
background: white;
|
||||
border: 2px solid #e5e7eb;
|
||||
color: #374151;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
align-self: center;
|
||||
z-index: 10;
|
||||
flex-shrink: 0;
|
||||
|
||||
&:hover {
|
||||
background: #f9fafb;
|
||||
border-color: #d1d5db;
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
&:not(:disabled):hover {
|
||||
background: var(--primary-color, #5568d3);
|
||||
border-color: var(--primary-color, #5568d3);
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
|
||||
// Items container
|
||||
.p-carousel-items-container {
|
||||
.p-carousel-items-content {
|
||||
width: 100%;
|
||||
|
||||
.p-carousel-item {
|
||||
padding: 0 0.5rem !important;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add gap between items
|
||||
.p-carousel-items-content .p-carousel-item-list {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.p-carousel-item {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
// Pagination dots - using actual PrimeNG rendered classes
|
||||
.p-carousel-indicator-list {
|
||||
display: flex !important;
|
||||
justify-content: center !important;
|
||||
gap: 0.5rem !important;
|
||||
padding: 1.5rem 0 !important;
|
||||
margin: 0 !important;
|
||||
list-style: none !important;
|
||||
|
||||
.p-carousel-indicator {
|
||||
display: inline-block !important;
|
||||
|
||||
.p-carousel-indicator-button {
|
||||
width: 12px !important;
|
||||
height: 12px !important;
|
||||
border-radius: 50% !important;
|
||||
background-color: #d1d5db !important;
|
||||
border: 0 !important;
|
||||
padding: 0 !important;
|
||||
cursor: pointer !important;
|
||||
transition: all 0.3s ease !important;
|
||||
|
||||
&:hover {
|
||||
background-color: #9ca3af !important;
|
||||
transform: scale(1.2);
|
||||
}
|
||||
}
|
||||
|
||||
&.p-carousel-indicator-active .p-carousel-indicator-button {
|
||||
background-color: var(--primary-color, #5568d3) !important;
|
||||
width: 32px !important;
|
||||
border-radius: 6px !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.carousel-loading,
|
||||
.carousel-empty {
|
||||
text-align: center;
|
||||
padding: 3rem 1rem;
|
||||
color: #666;
|
||||
|
||||
.spinner {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
margin: 0 auto 1rem;
|
||||
border: 4px solid #f3f3f3;
|
||||
border-top: 4px solid var(--primary-color, #5568d3);
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
// Item card styles matching your existing design
|
||||
.item-card {
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
transition: all 0.3s ease;
|
||||
position: relative;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: calc(100% - 1rem) !important;
|
||||
box-sizing: border-box;
|
||||
margin: 0 auto;
|
||||
|
||||
&:hover {
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
|
||||
transform: translateY(-4px);
|
||||
}
|
||||
}
|
||||
|
||||
.item-link {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.item-image {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 125px;
|
||||
overflow: hidden;
|
||||
background: #f5f5f5;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
&:hover img {
|
||||
transform: scale(1.08);
|
||||
}
|
||||
}
|
||||
|
||||
.discount-badge {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
right: 12px;
|
||||
background: #e74c3c;
|
||||
color: white;
|
||||
padding: 0.4rem 0.8rem;
|
||||
border-radius: 6px;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 700;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.item-details {
|
||||
padding: 0.75rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.item-name {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
margin: 0;
|
||||
line-height: 1.3;
|
||||
min-height: 2.6em;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
color: #1a1a1a;
|
||||
transition: color 0.2s;
|
||||
|
||||
&:hover {
|
||||
color: var(--primary-color, #5568d3);
|
||||
}
|
||||
}
|
||||
|
||||
.item-rating {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
font-size: 0.75rem;
|
||||
|
||||
.rating-stars {
|
||||
color: #fbbf24;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.rating-count {
|
||||
color: #6b7280;
|
||||
}
|
||||
}
|
||||
|
||||
.item-price {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 0.375rem;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.current-price,
|
||||
.discounted-price {
|
||||
font-size: 1rem;
|
||||
font-weight: 700;
|
||||
color: #1a1a1a;
|
||||
}
|
||||
|
||||
.discounted-price {
|
||||
color: #e74c3c;
|
||||
}
|
||||
|
||||
.original-price {
|
||||
font-size: 0.875rem;
|
||||
color: #9ca3af;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
.add-to-cart-btn {
|
||||
width: 100%;
|
||||
padding: 0.625rem 1rem;
|
||||
background: var(--primary-color, #5568d3);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 0 0 12px 12px;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
|
||||
&:hover {
|
||||
background: var(--primary-hover, #4456b3);
|
||||
}
|
||||
|
||||
&:active {
|
||||
&:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
}
|
||||
|
||||
// Novo theme styles
|
||||
.novo-theme {
|
||||
::ng-deep {
|
||||
.p-carousel {
|
||||
.p-carousel-prev,
|
||||
.p-carousel-next {
|
||||
&:not(:disabled):hover {
|
||||
background: var(--primary-color, #5568d3);
|
||||
border-color: var(--primary-color, #5568d3);
|
||||
}
|
||||
}
|
||||
|
||||
.p-carousel-indicators {
|
||||
.p-carousel-indicator.p-highlight button {
|
||||
background: var(--primary-color, #5568d3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.item-card {
|
||||
border: 1px solid #e5e5e5;
|
||||
}
|
||||
|
||||
.add-to-cart-btn {
|
||||
background: var(--primary-color, #5568d3);
|
||||
|
||||
&:hover {
|
||||
background: var(--primary-hover, #4456b3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Responsive styles
|
||||
@media (max-width: 968px) {
|
||||
.carousel-container {
|
||||
padding: 0 1rem;
|
||||
}
|
||||
|
||||
.item-image {
|
||||
height: 220px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.item-image {
|
||||
height: 200px;
|
||||
}
|
||||
|
||||
.item-details {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.item-name {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.item-price {
|
||||
.current-price,
|
||||
.discounted-price {
|
||||
font-size: 1.125rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.carousel-title {
|
||||
font-size: 1.5rem;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.carousel-track {
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.carousel-item {
|
||||
flex: 0 0 calc(50% - 0.5rem);
|
||||
}
|
||||
|
||||
.item-image {
|
||||
height: 200px;
|
||||
}
|
||||
|
||||
.item-name {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.item-price {
|
||||
.price-current,
|
||||
.price-discount {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
.btn-add-cart {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
|
||||
svg {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
.carousel-btn {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.carousel-wrapper {
|
||||
gap: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.items-carousel {
|
||||
padding: 1rem 0;
|
||||
}
|
||||
|
||||
.carousel-container {
|
||||
padding: 0 0.5rem;
|
||||
}
|
||||
|
||||
.carousel-title {
|
||||
font-size: 1.25rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.carousel-track {
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.carousel-item {
|
||||
flex: 0 0 100%;
|
||||
}
|
||||
|
||||
.item-image {
|
||||
height: 220px;
|
||||
}
|
||||
|
||||
.carousel-wrapper {
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.carousel-btn {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
|
||||
svg {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
.item-info {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.btn-add-cart {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.carousel-indicators {
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
}
|
||||
109
src/app/components/items-carousel/items-carousel.component.ts
Normal file
109
src/app/components/items-carousel/items-carousel.component.ts
Normal file
@@ -0,0 +1,109 @@
|
||||
import { Component, OnInit, signal } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterLink } from '@angular/router';
|
||||
import { CarouselModule } from 'primeng/carousel';
|
||||
import { ButtonModule } from 'primeng/button';
|
||||
import { TagModule } from 'primeng/tag';
|
||||
import { ApiService, CartService } from '../../services';
|
||||
import { Item } from '../../models';
|
||||
import { environment } from '../../../environments/environment';
|
||||
|
||||
@Component({
|
||||
selector: 'app-items-carousel',
|
||||
templateUrl: './items-carousel.component.html',
|
||||
standalone: true,
|
||||
imports: [CommonModule, RouterLink, CarouselModule, ButtonModule, TagModule],
|
||||
styleUrls: ['./items-carousel.component.scss']
|
||||
})
|
||||
export class ItemsCarouselComponent implements OnInit {
|
||||
products = signal<Item[]>([]);
|
||||
loading = signal(true);
|
||||
isnovo = environment.theme === 'novo';
|
||||
|
||||
responsiveOptions: any[] | undefined;
|
||||
|
||||
constructor(
|
||||
private apiService: ApiService,
|
||||
private cartService: CartService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.apiService.getRandomItems(10).subscribe({
|
||||
next: (items) => {
|
||||
this.products.set(items);
|
||||
this.loading.set(false);
|
||||
},
|
||||
error: () => {
|
||||
this.loading.set(false);
|
||||
}
|
||||
});
|
||||
|
||||
this.responsiveOptions = [
|
||||
{
|
||||
breakpoint: '1400px',
|
||||
numVisible: 3,
|
||||
numScroll: 1
|
||||
},
|
||||
{
|
||||
breakpoint: '1199px',
|
||||
numVisible: 4,
|
||||
numScroll: 1
|
||||
},
|
||||
{
|
||||
breakpoint: '767px',
|
||||
numVisible: 2,
|
||||
numScroll: 1
|
||||
},
|
||||
{
|
||||
breakpoint: '575px',
|
||||
numVisible: 1,
|
||||
numScroll: 1
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
getSeverity(remainings: string) {
|
||||
switch (remainings) {
|
||||
case 'high':
|
||||
return 'success';
|
||||
case 'low':
|
||||
return 'warn';
|
||||
case 'out':
|
||||
return 'danger';
|
||||
default:
|
||||
return 'success';
|
||||
}
|
||||
}
|
||||
|
||||
getInventoryStatus(remainings: string): string {
|
||||
switch (remainings) {
|
||||
case 'high':
|
||||
return 'INSTOCK';
|
||||
case 'low':
|
||||
return 'LOWSTOCK';
|
||||
case 'out':
|
||||
return 'OUTOFSTOCK';
|
||||
default:
|
||||
return 'INSTOCK';
|
||||
}
|
||||
}
|
||||
|
||||
getItemImage(item: Item): string {
|
||||
if (item.photos && item.photos.length > 0 && item.photos[0]?.url) {
|
||||
return item.photos[0].url;
|
||||
}
|
||||
return '/assets/images/placeholder.jpg';
|
||||
}
|
||||
|
||||
getDiscountedPrice(item: Item): number {
|
||||
if (item.discount > 0) {
|
||||
return item.price * (1 - item.discount / 100);
|
||||
}
|
||||
return item.price;
|
||||
}
|
||||
|
||||
addToCart(item: Item): void {
|
||||
this.cartService.addItem(item.itemID, 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user