updated carousel view

This commit is contained in:
sdarbinyan
2026-01-18 19:44:46 +04:00
parent bd80896886
commit 49d19181df
5 changed files with 825 additions and 1470 deletions

2107
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -7,7 +7,7 @@
} @else if (products().length > 0) { } @else if (products().length > 0) {
<p-carousel <p-carousel
[value]="products()" [value]="products()"
[numVisible]="4" [numVisible]="6"
[numScroll]="1" [numScroll]="1"
[circular]="true" [circular]="true"
[responsiveOptions]="responsiveOptions" [responsiveOptions]="responsiveOptions"
@@ -32,6 +32,7 @@
<span class="rating-count">({{ product.callbacks?.length || 0 }})</span> <span class="rating-count">({{ product.callbacks?.length || 0 }})</span>
</div> </div>
<div class="item-price-row">
<div class="item-price"> <div class="item-price">
@if (product.discount > 0) { @if (product.discount > 0) {
<span class="original-price">{{ product.price }} {{ product.currency }}</span> <span class="original-price">{{ product.price }} {{ product.currency }}</span>
@@ -40,13 +41,17 @@
<span class="current-price">{{ product.price }} {{ product.currency }}</span> <span class="current-price">{{ product.price }} {{ product.currency }}</span>
} }
</div> </div>
<button class="cart-icon-btn" (click)="addToCart($event, product)" title="Добавить в корзину">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="9" cy="21" r="1"></circle>
<circle cx="20" cy="21" r="1"></circle>
<path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"></path>
</svg>
</button>
</div>
</div> </div>
</a> </a>
<button class="add-to-cart-btn" (click)="addToCart(product)">
В корзину
</button>
</div> </div>
</ng-template> </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> <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>

View File

@@ -156,7 +156,7 @@
.item-image { .item-image {
position: relative; position: relative;
width: 100%; width: 100%;
height: 125px; height: 140px;
overflow: hidden; overflow: hidden;
background: #f5f5f5; background: #f5f5f5;
@@ -188,15 +188,15 @@
.item-details { .item-details {
padding: 0.75rem; padding: 0.625rem;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 0.5rem; gap: 0.375rem;
flex: 1; flex: 1;
} }
.item-name { .item-name {
font-size: 0.875rem; font-size: 0.8125rem;
font-weight: 600; font-weight: 600;
margin: 0; margin: 0;
line-height: 1.3; line-height: 1.3;
@@ -230,15 +230,23 @@
} }
} }
.item-price-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.5rem;
}
.item-price { .item-price {
display: flex; display: flex;
align-items: baseline; align-items: baseline;
gap: 0.375rem; gap: 0.375rem;
flex-wrap: wrap; flex-wrap: wrap;
flex: 1;
.current-price, .current-price,
.discounted-price { .discounted-price {
font-size: 1rem; font-size: 0.9375rem;
font-weight: 700; font-weight: 700;
color: #1a1a1a; color: #1a1a1a;
} }
@@ -248,33 +256,36 @@
} }
.original-price { .original-price {
font-size: 0.875rem; font-size: 0.8125rem;
color: #9ca3af; color: #9ca3af;
text-decoration: line-through; text-decoration: line-through;
} }
} }
.cart-icon-btn {
padding: 0.5rem;
.add-to-cart-btn {
width: 100%;
padding: 0.625rem 1rem;
background: var(--primary-color, #5568d3); background: var(--primary-color, #5568d3);
color: white; color: white;
border: none; border: none;
border-radius: 0 0 12px 12px; border-radius: 8px;
font-size: 0.875rem;
font-weight: 600;
cursor: pointer; cursor: pointer;
transition: all 0.3s ease; transition: all 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
svg {
display: block;
}
&:hover { &:hover {
background: var(--primary-hover, #4456b3); background: var(--primary-hover, #4456b3);
transform: scale(1.05);
} }
&:active { &:active {
&:active { transform: scale(0.95);
transform: scale(0.98);
} }
} }
@@ -302,7 +313,7 @@
border: 1px solid #e5e5e5; border: 1px solid #e5e5e5;
} }
.add-to-cart-btn { .cart-icon-btn {
background: var(--primary-color, #5568d3); background: var(--primary-color, #5568d3);
&:hover { &:hover {
@@ -342,105 +353,3 @@
} }
} }
} }
.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;
}
}

View File

@@ -41,7 +41,7 @@ export class ItemsCarouselComponent implements OnInit {
this.responsiveOptions = [ this.responsiveOptions = [
{ {
breakpoint: '1400px', breakpoint: '1400px',
numVisible: 3, numVisible: 5,
numScroll: 1 numScroll: 1
}, },
{ {
@@ -49,6 +49,11 @@ export class ItemsCarouselComponent implements OnInit {
numVisible: 4, numVisible: 4,
numScroll: 1 numScroll: 1
}, },
{
breakpoint: '991px',
numVisible: 3,
numScroll: 1
},
{ {
breakpoint: '767px', breakpoint: '767px',
numVisible: 2, numVisible: 2,
@@ -102,7 +107,9 @@ export class ItemsCarouselComponent implements OnInit {
return item.price; return item.price;
} }
addToCart(item: Item): void { addToCart(event: Event, item: Item): void {
event.preventDefault();
event.stopPropagation();
this.cartService.addItem(item.itemID, 1); this.cartService.addItem(item.itemID, 1);
} }
} }

View File

@@ -4,6 +4,7 @@
"extends": "./tsconfig.json", "extends": "./tsconfig.json",
"compilerOptions": { "compilerOptions": {
"outDir": "./out-tsc/app", "outDir": "./out-tsc/app",
"rootDir": "./src",
"types": [] "types": []
}, },
"include": [ "include": [