Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(RSS-ECOMM-3_33): implement burger menu #221

Merged
merged 1 commit into from
May 10, 2024
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
1 change: 1 addition & 0 deletions src/app/styles/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@
--small-br: 5px;
--medium-br: 5px;
--large-br: 10px;
--regular-font: 400 10px 'Cerapro', sans-serif;
}
}
2 changes: 1 addition & 1 deletion src/entities/Navigation/view/NavigationView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class NavigationView {
tag: 'nav',
});
this.navigation.append(
this.toMainLink.getHTML(),
this.toLoginLink.getHTML(),
this.toRegisterLink.getHTML(),
this.toMainLink.getHTML(),
this.toCatalogLink.getHTML(),
this.toAboutLink.getHTML(),
);
Expand Down
3 changes: 2 additions & 1 deletion src/entities/Navigation/view/navigationView.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
align-self: center;
justify-content: center;
order: 2;
margin: 0 auto;
height: 70px;
gap: var(--extra-small-offset);
}

.link {
position: relative;
display: flex;
align-items: center;
padding: 0 calc(var(--extra-small-offset) / 2);
height: 100%;
font: var(--regular-font);
letter-spacing: 1px;
Expand Down
8 changes: 6 additions & 2 deletions src/pages/NotFoundPage/view/notFoundPageView.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
position: relative;
display: flex;
flex-direction: column;
margin: 0 auto;
align-self: center;
margin: 0 var(--small-offset);
border-bottom: calc(var(--extra-small-offset) / 2) solid var(--steam-green-800);
padding: calc(var(--extra-large-offset) / 2) var(--extra-large-offset);
border-radius: var(--medium-br);
padding: var(--small-offset);
padding-bottom: calc(var(--extra-large-offset) / 2 + calc(var(--extra-small-offset) / 2));
max-width: 500px;
background-color: var(--white);
Expand Down Expand Up @@ -50,8 +52,10 @@
}

.toMainButton {
align-self: center;
border-radius: var(--small-br);
padding: calc(var(--extra-small-offset) / 2) var(--small-offset);
width: max-content;
font: var(--bold-font);
letter-spacing: 1px;
color: var(--white);
Expand Down
256 changes: 0 additions & 256 deletions src/shared/img/svg/cat.svg

This file was deleted.

3 changes: 3 additions & 0 deletions src/shared/img/svg/dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/shared/img/svg/drop.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/shared/img/svg/heartFill.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/shared/img/svg/heartOutline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/shared/img/svg/house.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/shared/img/svg/light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/shared/img/svg/plant.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/shared/img/svg/search.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/shared/img/svg/settings.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 11 additions & 11 deletions src/widgets/Catalog/view/catalogView.module.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.catalog {
display: flex;
width: 500px;
height: 500px;
background-color: var(--noble-gray-300);
}
// .catalog {
// display: flex;
// width: 500px;
// height: 500px;
// background-color: var(--noble-gray-300);
// }

.itemsList {
width: 500px;
height: 500px;
background-color: var(--noble-gray-800);
}
// .itemsList {
// width: 500px;
// height: 500px;
// background-color: var(--noble-gray-800);
// }
1 change: 0 additions & 1 deletion src/widgets/Header/model/HeaderModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class HeaderModel {

private init(): boolean {
this.view.getWrapper().append(this.navigation.getHTML());
this.checkAuthUser();
this.checkCurrentUser();
this.setLogoHandler();
this.observeCurrentUser();
Expand Down
59 changes: 58 additions & 1 deletion src/widgets/Header/view/HeaderView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import observeCurrentLanguage from '@/shared/utils/observeCurrentLanguage.ts';
import styles from './headerView.module.scss';

class HeaderView {
private burgerButton: ButtonModel;

private header: HTMLElement;

private linkLogo: LinkModel;
Expand All @@ -36,8 +38,50 @@ class HeaderView {
this.toProfileLink = this.createToProfileLink();
this.switchLanguageButton = this.createSwitchLanguageButton();
this.navigationWrapper = this.createNavigationWrapper();
this.burgerButton = this.createBurgerButton();
this.wrapper = this.createWrapper();
this.header = this.createHTML();

document.addEventListener('click', ({ target }) => {
if (
target !== this.navigationWrapper &&
this.burgerButton.getHTML().classList.contains(styles.open) &&
target !== this.burgerButton.getHTML()
) {
this.burgerButton.getHTML().classList.toggle(styles.open);
this.navigationWrapper.classList.toggle(styles.open);
document.body.classList.toggle(styles.stopScroll);
}
});
}

private createBurgerButton(): ButtonModel {
this.burgerButton = new ButtonModel({
classes: [styles.burgerButton],
});

const burgerLine1 = createBaseElement({
cssClasses: [styles.burgerLine],
tag: 'span',
});
const burgerLine2 = createBaseElement({
cssClasses: [styles.burgerLine],
tag: 'span',
});
const burgerLine3 = createBaseElement({
cssClasses: [styles.burgerLine],
tag: 'span',
});

this.burgerButton.getHTML().addEventListener('click', () => {
this.burgerButton.getHTML().classList.toggle(styles.open);
this.navigationWrapper.classList.toggle(styles.open);
document.body.classList.toggle(styles.stopScroll);
});

this.burgerButton.getHTML().append(burgerLine1, burgerLine2, burgerLine3);

return this.burgerButton;
}

private createHTML(): HTMLElement {
Expand Down Expand Up @@ -92,6 +136,7 @@ class HeaderView {
this.toCartLink.getHTML(),
this.toProfileLink.getHTML(),
);

return this.navigationWrapper;
}

Expand Down Expand Up @@ -174,10 +219,14 @@ class HeaderView {
tag: 'div',
});

this.wrapper.append(this.linkLogo.getHTML(), this.navigationWrapper);
this.wrapper.append(this.linkLogo.getHTML(), this.navigationWrapper, this.burgerButton.getHTML());
return this.wrapper;
}

public getBurgerButton(): ButtonModel {
return this.burgerButton;
}

public getHTML(): HTMLElement {
return this.header;
}
Expand Down Expand Up @@ -205,6 +254,14 @@ class HeaderView {
public getWrapper(): HTMLDivElement {
return this.wrapper;
}

public hideNavigationWrapper(): void {
this.navigationWrapper.classList.add(styles.hidden);
}

public showNavigationWrapper(): void {
this.navigationWrapper.classList.remove(styles.hidden);
}
}

export default HeaderView;
Loading
Loading