From a1297280b181712a59a9e45afeeabc0d988caa6a Mon Sep 17 00:00:00 2001 From: Max <133934232+Kleostro@users.noreply.github.com> Date: Mon, 29 Apr 2024 23:10:26 +0300 Subject: [PATCH] feat: add RegistrationPage component --- .../model/RegistrationPageModel.ts | 17 ++++++++ .../view/RegistrationPageView.ts | 41 +++++++++++++++++++ .../registrationPageView.module.scss} | 0 3 files changed, 58 insertions(+) create mode 100644 src/pages/RegistrationPage/model/RegistrationPageModel.ts create mode 100644 src/pages/RegistrationPage/view/RegistrationPageView.ts rename src/pages/RegistrationPage/{.gitkeep => view/registrationPageView.module.scss} (100%) diff --git a/src/pages/RegistrationPage/model/RegistrationPageModel.ts b/src/pages/RegistrationPage/model/RegistrationPageModel.ts new file mode 100644 index 00000000..018d0c9e --- /dev/null +++ b/src/pages/RegistrationPage/model/RegistrationPageModel.ts @@ -0,0 +1,17 @@ +import type { PageInterface } from '@/shared/types/interfaces.ts'; + +import RegistrationPageView from '../view/RegistrationPageView.ts'; + +class LoginPageModel implements PageInterface { + private view: RegistrationPageView; + + constructor(parent: HTMLDivElement) { + this.view = new RegistrationPageView(parent); + } + + public getHTML(): HTMLDivElement { + return this.view.getHTML(); + } +} + +export default LoginPageModel; diff --git a/src/pages/RegistrationPage/view/RegistrationPageView.ts b/src/pages/RegistrationPage/view/RegistrationPageView.ts new file mode 100644 index 00000000..c615678a --- /dev/null +++ b/src/pages/RegistrationPage/view/RegistrationPageView.ts @@ -0,0 +1,41 @@ +import { TAG_NAMES } from '@/shared/constants/enums.ts'; +import createBaseElement from '@/shared/utils/createBaseElement.ts'; + +import REGISTRATION_PAGE_STYLES from './registrationPageView.module.scss'; + +class RegistrationPageView { + private page: HTMLDivElement; + + private parent: HTMLDivElement; + + constructor(parent: HTMLDivElement) { + this.parent = parent; + this.page = this.createHTML(); + } + + private createHTML(): HTMLDivElement { + this.page = createBaseElement({ + cssClasses: [REGISTRATION_PAGE_STYLES.registrationPage], + tag: TAG_NAMES.DIV, + }); + + this.parent.append(this.page); + + return this.page; + } + + public getHTML(): HTMLDivElement { + return this.page; + } + + public hide(): boolean { + this.page.classList.add(REGISTRATION_PAGE_STYLES.registrationPage_hidden); + return true; + } + + public show(): boolean { + this.page.classList.remove(REGISTRATION_PAGE_STYLES.registrationPage_hidden); + return true; + } +} +export default RegistrationPageView; diff --git a/src/pages/RegistrationPage/.gitkeep b/src/pages/RegistrationPage/view/registrationPageView.module.scss similarity index 100% rename from src/pages/RegistrationPage/.gitkeep rename to src/pages/RegistrationPage/view/registrationPageView.module.scss