Skip to content

Commit

Permalink
Merge pull request #21 from frontend-park-mail-ru/dev-15
Browse files Browse the repository at this point in the history
Dev-15: страница доски
  • Loading branch information
wiseStann authored Nov 4, 2024
2 parents fc9557b + fbf8959 commit a1b51ca
Show file tree
Hide file tree
Showing 28 changed files with 793 additions and 81 deletions.
58 changes: 57 additions & 1 deletion public/app.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions public/assets/icons/delete.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
2 changes: 1 addition & 1 deletion public/components/boards-list/boards-list.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

import { BaseComponent } from "../base/base.js";
import { BaseComponent } from "../base.js";

/**
* A component that is used to display all boards of currently authorized user.
Expand Down
2 changes: 1 addition & 1 deletion public/components/button/button.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import { BaseComponent } from '../../components/base/base.js';
import { BaseComponent } from '../base.js';

export class ButtonComponent extends BaseComponent {
#clickHandler = () => { };
Expand Down
3 changes: 3 additions & 0 deletions public/components/button/icon-button.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="icon-button__content-container {{state.className}}">
<img class="{{state.className}}" src="{{state.iconPath}}">
</div>
30 changes: 30 additions & 0 deletions public/components/button/icon-button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict'

import { BaseComponent } from "../base.js"

/**
* Component that is used to display button with icon inside of it.
*/
export class IconButtonComponent extends BaseComponent {
/**
* Creates an IconButtonComponent.
* @param {HTMLElement} parent - HTML element of the parent container.
* @param {String} iconPath - file path to the icon.
*/
constructor(parent, state) {
super(parent, state);
}

/**
* Renders a template of IconButtonComponent.
* @returns rendered template of IconButtonComponent.
*/
renderTemplate() {
const template = Handlebars.templates['icon-button.hbs'];
const renderedTemplate = template({
state: this.State
});

return renderedTemplate;
}
};
21 changes: 16 additions & 5 deletions public/components/complex/grid/grid.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import { BaseComponent } from '../../base/base.js';
import { BaseComponent } from '../../base.js';

import { PinComponent } from '../pin/pin.js';

Expand All @@ -21,15 +21,18 @@ const PREVIEW_IMG_X_FACTOR = 1.5;
*/
export class GridComponent extends BaseComponent {
#pins = []; // pins stored on the grid
#marginTop;

/**
* Creates an instance of GridComponent.
* @param {HTMLElement} parent - The parent element for rendering.
* @param {Array} pins - An array of objects representing pin data.
* @param {Boolean} marginTop - Should grid be margin topped or not.
*/
constructor(parent, pins) {
constructor(parent, pins, marginTop) {
super(parent);
this.#pins = pins;
this.#marginTop = marginTop;

// Providing layout rebuild on resize events
window.addEventListener('resize', (event) => {
Expand All @@ -51,7 +54,6 @@ export class GridComponent extends BaseComponent {
}

this.buildLayout();

}, true);
}

Expand Down Expand Up @@ -83,7 +85,14 @@ export class GridComponent extends BaseComponent {
const columnsN = this.adaptiveColumnsN;
const widthGutter = 30, heightGutter = 15;
let heights = new Array(columnsN).fill(0);
const headerHeight = document.querySelector('.header__content-container').clientHeight;

let headerHeight = 0;
if (this.#marginTop) {
const header = document.querySelector('.header__content-container');
if (header) {
headerHeight = header.clientHeight;
}
}

const columnWidth = (this.parentContainerWidth - widthGutter * (columnsN + 1)) / columnsN;

Expand Down Expand Up @@ -131,6 +140,7 @@ export class GridComponent extends BaseComponent {
let newColumnN = Math.floor(this.parentContainerWidth / this.parentContainerColumnsRatio);
if (newColumnN == 0)
newColumnN = 1;

return newColumnN;
}

Expand All @@ -140,7 +150,7 @@ export class GridComponent extends BaseComponent {
*/
buildPinPreview(pin) {
const pinPreviewBtn = document.querySelector(`.pin__image-preview-button-${pin.PinID}`);
const parent = this.Parent;
const parent = document.getElementById('root');

const previewState = {
MediaUrl: pin.MediaUrl,
Expand Down Expand Up @@ -248,6 +258,7 @@ export class GridComponent extends BaseComponent {

previewContainer.style.width = `${intWidth * PREVIEW_IMG_X_FACTOR + previewRightSide.clientWidth}px`;
previewContainer.style.height = `${intHeight * PREVIEW_IMG_X_FACTOR + previewTopSide.clientHeight + previewBottomSide.clientHeight}px`;
previewContainer.style.marginTop = '3%';

// Create dark transparent background and add event listeners
this.createBackgroundListeners();
Expand Down
2 changes: 1 addition & 1 deletion public/components/complex/header/header.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import { BaseComponent } from '../../base/base.js';
import { BaseComponent } from '../../base.js';

import { SearchInputComponent as SeachInput } from '../../search-input/search-input.js';
import { ButtonComponent as Button } from '../../button/button.js';
Expand Down
9 changes: 2 additions & 7 deletions public/components/complex/pin/pin.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,19 @@ div[class^=pin__content-container] {
flex-direction: column;
}

div[class^=pin__content-container] {
transition: all 0.2s ease-in-out;
}

.pin__image-container {
position: relative;
width: 100%;
height: 100%;
}

img[class^=pin__image] {
border-radius: 20px;
transition: 0.5s;
}

.pin__image-container:hover img[class^=pin__image] {
filter: brightness(70%);
cursor: pointer;
transition: 0.5s;
}

div[class^=pin__image-preview-button] {
Expand All @@ -30,7 +25,7 @@ div[class^=pin__image-preview-button] {
justify-content: center;
align-items: center;
position: absolute;
bottom: 70px;
bottom: 20px;
right: 15px;
width: 40px;
height: 40px;
Expand Down
15 changes: 8 additions & 7 deletions public/components/complex/pin/pin.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
<img src="./assets/icons/magnifier.svg" alt="Preview">
</div>
</div>
<div class="pin__author-container-{{pin.PinID}}">
{{!-- <img class="pin__author-avatar" src="{{pin.AuthorAvatar}}"> --}}
<img class="pin__author-avatar" src="./assets/imgs/avatar.jpg">
<div class="pin__author-info">
<p class="pin__author-name">{{{pin.AuthorName}}}</p>
<p class="pin__author-followers-number">{{{pin.AuthorFollowersNumber}}} Followers</p>
{{#unless pin.imageOnly}}
<div class="pin__author-container-{{pin.PinID}}">
<img class="pin__author-avatar" src="{{pin.AuthorAvatar}}">
<div class="pin__author-info">
<p class="pin__author-name">{{{pin.AuthorName}}}</p>
<p class="pin__author-followers-number">{{{pin.AuthorFollowersNumber}}} Followers</p>
</div>
</div>
</div>
{{/unless}}
</div>
2 changes: 1 addition & 1 deletion public/components/complex/pin/pin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import { BaseComponent } from '../../base/base.js';
import { BaseComponent } from '../../base.js';

/**
* Represents an Image Card Component.
Expand Down
2 changes: 1 addition & 1 deletion public/components/complex/preview/preview.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

import { BaseComponent } from '../../base/base.js';
import { BaseComponent } from '../../base.js';

export class PreviewComponent extends BaseComponent {
/**
Expand Down
2 changes: 1 addition & 1 deletion public/components/complex/savebox/savebox.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

import { BaseComponent } from '../../base/base.js';
import { BaseComponent } from '../../base.js';

import { SearchInputComponent as SearchInput } from '../../search-input/search-input.js';

Expand Down
2 changes: 1 addition & 1 deletion public/components/details-menu/details-menu.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

import { BaseComponent } from "../base/base.js"
import { BaseComponent } from "../base.js"

/**
* A component that is used to display options when clicking on 'more' button.
Expand Down
2 changes: 1 addition & 1 deletion public/components/drop-down-menu/drop-down-menu.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

import { BaseComponent } from "../base/base.js"
import { BaseComponent } from "../base.js"

/**
* Drop down menu component which is used on profile icon hover.
Expand Down
2 changes: 1 addition & 1 deletion public/components/input/input.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import { BaseComponent } from '../base/base.js';
import { BaseComponent } from '../base.js';

/**
* Represents an Input Component.
Expand Down
2 changes: 1 addition & 1 deletion public/components/search-input/search-input.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

import { BaseComponent } from '../base/base.js'
import { BaseComponent } from '../base.js'

/**
* A component that is used to display search bar.
Expand Down
3 changes: 3 additions & 0 deletions public/constants.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,7 @@
--pinset-profile-user-name-text-color: #333333;
--pinset-profile-user-edit-block-color: #757575;
--pinset-profile-user-edit-block-hovered-color: #585858;

--pinset-delete-button-color: #C20000;
--pinset-delete-button-hovered-color: #910000;
}
2 changes: 1 addition & 1 deletion public/pages/login/login.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import { BaseComponent } from '../../components/base/base.js';
import { BaseComponent } from '../../components/base.js';

import { InputComponent as Input } from '../../components/input/input.js';
import { ButtonComponent as Button } from '../../components/button/button.js';
Expand Down
23 changes: 14 additions & 9 deletions public/pages/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { BACKEND_LOGOUT_ROUTE } from '../../constants/api.js'
import { postMethod } from '../../modules/network.js'

import { app } from '../../index.js'
import { BaseComponent } from '../../components/base/base.js'
import { BaseComponent } from '../../components/base.js'

import { DropDownMenuComponent as DropDownMenu } from '../../components/drop-down-menu/drop-down-menu.js'

Expand Down Expand Up @@ -41,7 +41,7 @@ export class MainPageComponent extends BaseComponent {
async renderTemplate() {
const template = Handlebars.templates['main.hbs'];

const grid = new Grid(this.Parent, this.#pins);
const grid = new Grid(this.Parent, this.#pins, true);

const renderedTemplate = template({
header: new Header(this.Parent, await isAuthorized()).renderTemplate(),
Expand Down Expand Up @@ -75,6 +75,10 @@ export class MainPageComponent extends BaseComponent {
const searchInputClearIcon = document.querySelector(`.header__search-input-content-container
.searchinput__content-container
.searchinput__clear-icon`);
if (!searchInputClearIcon) {
return;
}

searchInputClearIcon.addEventListener('click', (event) => {
event.preventDefault();
const searchInputField = document.querySelector(`.header__search-input-content-container
Expand All @@ -91,13 +95,14 @@ export class MainPageComponent extends BaseComponent {
*/
addLogoListener() {
const headerLogInButton = document.querySelector('.header__logo-container')
headerLogInButton.addEventListener('click', (event) => {
event.preventDefault();

root.innerHTML = '';
console.log(app.LastPage);
app.renderPage(ROUTES.main);
});
if (headerLogInButton) {
headerLogInButton.addEventListener('click', (event) => {
event.preventDefault();

root.innerHTML = '';
app.renderPage(ROUTES.main);
});
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion public/pages/profile/board-grid.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="profile__board-info-container-{{this.boardID}}">
<div class="profile__board-title-container">
<p class="profile__board-title">{{{this.title}}}</p>
{{#if profile.currentUser}}
{{#if ../profile.currentUser}}
{{#if this.private}}
<img src="./assets/icons/private.svg" alt="Private">
{{/if}}
Expand Down
16 changes: 13 additions & 3 deletions public/pages/profile/board-grid.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
'use strict'

import { BaseComponent } from "../../components/base/base.js"
import { BaseComponent } from "../../components/base.js"

/**
* Component that is used to display boards grid on user profile page.
*/
export class BoardGridComponent extends BaseComponent {
#boards;

#currentUser;

/**
*
* @param {HTMLElement} parent - HTML element of the parent container.
* @param {Array} boards - list of boards of currently authorized user.
* @param {Boolean} currentUser - whether print boards of authorized user or not.
*/
constructor(parent, boards) {
constructor(parent, boards, currentUser) {
super(parent);
this.#boards = boards;
this.#currentUser = currentUser;
}

/**
* Renders a template of board grid component.
* @returns rendered template of board grid component.
*/
renderTemplate() {
const template = Handlebars.templates['board-grid.hbs'];
const renderedTemplate = template({
boards: this.#boards,
profile: {
currentUser: this.#currentUser,
},
});

return renderedTemplate;
Expand Down
Loading

0 comments on commit a1b51ca

Please sign in to comment.