Skip to content

Commit

Permalink
feat: add catalog component
Browse files Browse the repository at this point in the history
  • Loading branch information
stardustmeg committed May 10, 2024
1 parent 74f3e30 commit 4cd5885
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/pages/CatalogPage/model/CatalogPageModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import type { Page } from '@/shared/types/common.ts';
import getStore from '@/shared/Store/Store.ts';
import { setCurrentPage } from '@/shared/Store/actions.ts';
import { PAGE_ID } from '@/shared/constants/pages.ts';
import CatalogModel from '@/widgets/Catalog/model/CatalogModel.ts';

import CatalogPageView from '../view/CatalogPageView.ts';

class CatalogPageModel implements Page {
private catalog = new CatalogModel();

private view: CatalogPageView;

constructor(parent: HTMLDivElement) {
Expand All @@ -16,6 +19,7 @@ class CatalogPageModel implements Page {

private init(): void {
getStore().dispatch(setCurrentPage(PAGE_ID.CATALOG_PAGE));
this.getHTML().append(this.catalog.getHTML());
}

public getHTML(): HTMLDivElement {
Expand Down
11 changes: 11 additions & 0 deletions src/widgets/Catalog/model/CatalogModel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import CatalogView from '../view/CatalogView.ts';

class CatalogModel {
private view = new CatalogView();

public getHTML(): HTMLDivElement {
return this.view.getHTML();
}
}

export default CatalogModel;
41 changes: 41 additions & 0 deletions src/widgets/Catalog/view/CatalogView.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import createBaseElement from '@/shared/utils/createBaseElement.ts';

import styles from './catalogView.module.scss';

class CatalogView {
private catalog: HTMLDivElement;

private itemsList: HTMLUListElement;

constructor() {
this.itemsList = this.createItemsList();
this.catalog = this.createHTML();
}

private createHTML(): HTMLDivElement {
this.catalog = createBaseElement({
cssClasses: [styles.catalog],
tag: 'div',
});
this.catalog.append(this.itemsList);
return this.catalog;
}

private createItemsList(): HTMLUListElement {
this.itemsList = createBaseElement({
cssClasses: [styles.itemsList],
tag: 'ul',
});
return this.itemsList;
}

public getHTML(): HTMLDivElement {
return this.catalog;
}

public getItemsList(): HTMLUListElement {
return this.itemsList;
}
}

export default CatalogView;
12 changes: 12 additions & 0 deletions src/widgets/Catalog/view/catalogView.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.catalog {
display: flex;
width: 500px;
height: 500px;
background-color: var(--noble-gray-300);
}

.itemsList {
width: 500px;
height: 500px;
background-color: var(--noble-gray-800);
}

0 comments on commit 4cd5885

Please sign in to comment.