Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/app/views/header/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ export default class HeaderView extends View {
callback();
}
Router.navigateTo(href);
document.body.classList.toggle('lock');
this.menuContainerList.node.classList.toggle('menu-active');
});

item.appendChild(link);
Expand Down
49 changes: 48 additions & 1 deletion src/app/views/product/product-page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
grid-column: 1 / 2;
grid-row: 1;
min-width: 0;
background-color: #fff;

@media (width <= 1024px) {
grid-column: 1 / 2;
Expand All @@ -49,6 +50,7 @@
grid-row: 1;
min-width: 0;
padding: 20px;
background-color: #fff;

@media (width <= 1024px) {
grid-column: 1 / 2;
Expand All @@ -60,6 +62,7 @@
grid-column: 1 / 3;
grid-row: 2 / 3;
min-width: 0;
background-color: #fff;

@media (width <= 1024px) {
grid-column: 1 / 2;
Expand Down Expand Up @@ -103,6 +106,11 @@
max-height: 3.75rem;
}

.product-cart {
display: flex;
gap: 100px;
}

.product-description {
max-width: 80%;
margin: 0 auto;
Expand Down Expand Up @@ -172,15 +180,47 @@
color: #e60023;
}

.button-add-cart {
.button-add-cart.btn {
height: 40px;
font-size: 20px;
background-color: #c18183;
border: 2px solid #fff;
box-shadow: 0 4px 8px rgb(0 0 0 / 60%);
transition:
background-color 0.4s ease,
transform 0.2s ease,
box-shadow 0.2s ease;

&:active {
transform: translateY(2px);
box-shadow: 0 2px 4px rgb(0 0 0 / 20%);
}

@media (any-hover: hover) {
&:hover {
background-color: #855a5b;
border: 2px solid #cd4646;

.no-text-transform {
color: black;
}
}
}
}

.button-delete-cart.btn {
height: 40px;
font-size: 20px;
visibility: hidden;
opacity: 0;
background-color: #c18183;
border: 2px solid #fff;
box-shadow: 0 4px 8px rgb(0 0 0 / 60%);
transition:
background-color 0.4s ease,
transform 0.2s ease,
visibility 0s linear,
opacity 0.5s linear,
box-shadow 0.2s ease;

&:active {
Expand Down Expand Up @@ -208,3 +248,10 @@
pointer-events: none;
opacity: 0.5;
}

.button-visibl.button-delete-cart.btn,
.button-delete-cart.btn-large,
.button-delete-cart.btn-small {
visibility: visible;
opacity: 1;
}
21 changes: 21 additions & 0 deletions src/app/views/product/product-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export default class ProductPageView extends View {

private addCartButton!: BaseComponent;

private deleteCartButton!: BaseComponent;

constructor(productId: string) {
const attrs: IAttributes = {
classList: ['main-container-product'],
Expand Down Expand Up @@ -243,17 +245,36 @@ export default class ProductPageView extends View {
this.addCartButton = new ButtonComponent(addCartButtonAttrs);
cartContainer.appendChild(this.addCartButton);

const deleteCartButtonAttrs: IButtonAttributes = {
classList: [
'button-delete-cart',
'waves-light',
'btn',
'no-text-transform',
],
content: 'Delete to cart',
};
this.deleteCartButton = new ButtonComponent(deleteCartButtonAttrs);
cartContainer.appendChild(this.deleteCartButton);

if (currentCart.isProductInside(this.productId)) {
this.addCartButton.node.classList.add('button-disabled');
this.deleteCartButton.node.classList.add('button-visibl');
}

this.addCartButton.node.addEventListener('click', (event) => {
event.preventDefault();
currentCart.addProduct(this.productId, 1, () => {
this.addCartButton.node.classList.add('button-disabled');
this.deleteCartButton.node.classList.add('button-visibl');
});
});

this.deleteCartButton.node.addEventListener('click', (event) => {
event.preventDefault();
/* TODO: кодить сюда */
});

detailsProduct.appendChild(cartContainer);

// Проверяем и восстанавливаем состояние кнопки из localStorage
Expand Down