mirror of
https://github.com/sergeyyarkov/digital-store.git
synced 2026-10-11 02:09:05 +03:00
18 lines
680 B
JavaScript
18 lines
680 B
JavaScript
import { Component } from "../core/component";
|
|
import { insertCount } from "../other/counter";
|
|
|
|
export class HeaderComponent extends Component {
|
|
constructor(id) {
|
|
super(id);
|
|
}
|
|
|
|
init() {
|
|
if (this.$el) {
|
|
const currentPage = this.$el.querySelector('#desktop-nav');
|
|
const pages = Array.from(this.$el.querySelectorAll('#page'));
|
|
pages.forEach(li => li.dataset.page === currentPage.dataset.current ? li.classList.add('active') : false);
|
|
// ф-я счетика товаров
|
|
localStorage.getItem('cart') ? insertCount('counter', JSON.parse(localStorage.getItem('cart'))) : false;
|
|
}
|
|
}
|
|
} |