-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from frontend-park-mail-ru/dev-10
Dev 10: add lookpin page
- Loading branch information
Showing
41 changed files
with
1,327 additions
and
414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,57 @@ | ||
'use strict'; | ||
|
||
import { BaseComponent } from '../base.js'; | ||
import { BaseComponent } from '../base/base.js'; | ||
|
||
export class ButtonComponent extends BaseComponent { | ||
#clickHandler = () => { }; | ||
|
||
/** | ||
* Creates an instance of ButtonComponent. | ||
* @constructor | ||
* @param {HTMLElement} parent - The parent element where the button will be rendered. | ||
* @param {Object} [state] - The initial state of the button component. (optional) | ||
* @param {Function} [changeHandler] - The function that will handle the button events. (optional) | ||
*/ | ||
constructor(parent, state, clickHandler) { | ||
super(parent, state); | ||
this.#clickHandler = clickHandler || this.#clickHandler; | ||
} | ||
|
||
/** | ||
* Renders the button component. | ||
* @returns {string} - The rendered HTML template of the button. | ||
*/ | ||
renderTemplate() { | ||
const template = Handlebars.templates['button.hbs']; | ||
const renderedTemplate = template(this.State); | ||
|
||
return renderedTemplate; | ||
} | ||
|
||
/** | ||
* Handles the button click event. | ||
* @param {Event} event - The button click event object. | ||
*/ | ||
handleButtonClick(event) { | ||
event.stopPropagation(); | ||
if (typeof this.#clickHandler === 'function' && !this.State.disabled) { | ||
this.#clickHandler(event); | ||
} | ||
} | ||
|
||
/** | ||
* Sets the click event handler for the button. | ||
* @param {Function} changeHandler - The function to handle the button click event. | ||
*/ | ||
setClickHandler(clickHandler) { | ||
this.#clickHandler = clickHandler; | ||
} | ||
|
||
/** | ||
* Gets the current click event handler for the button. | ||
* @returns {Function} - The current click event handler. | ||
*/ | ||
getClickHandler() { | ||
return this.#clickHandler; | ||
#clickHandler = () => {}; | ||
|
||
/** | ||
* Creates an instance of ButtonComponent. | ||
* @constructor | ||
* @param {HTMLElement} parent - The parent element where the button will be rendered. | ||
* @param {Object} [state] - The initial state of the button component. (optional) | ||
* @param {Function} [changeHandler] - The function that will handle the button events. (optional) | ||
*/ | ||
constructor(parent, state, clickHandler) { | ||
super(parent, state); | ||
this.#clickHandler = clickHandler || this.#clickHandler; | ||
} | ||
|
||
/** | ||
* Renders the button component. | ||
* @returns {string} - The rendered HTML template of the button. | ||
*/ | ||
renderTemplate() { | ||
const template = Handlebars.templates['button.hbs']; | ||
const renderedTemplate = template(this.State); | ||
|
||
return renderedTemplate; | ||
} | ||
|
||
/** | ||
* Handles the button click event. | ||
* @param {Event} event - The button click event object. | ||
*/ | ||
handleButtonClick(event) { | ||
event.stopPropagation(); | ||
if (typeof this.#clickHandler === 'function' && !this.State.disabled) { | ||
this.#clickHandler(event); | ||
} | ||
} | ||
|
||
/** | ||
* Sets the click event handler for the button. | ||
* @param {Function} changeHandler - The function to handle the button click event. | ||
*/ | ||
setClickHandler(clickHandler) { | ||
this.#clickHandler = clickHandler; | ||
} | ||
|
||
/** | ||
* Gets the current click event handler for the button. | ||
* @returns {Function} - The current click event handler. | ||
*/ | ||
getClickHandler() { | ||
return this.#clickHandler; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,7 @@ | |
cursor: pointer; | ||
} | ||
|
||
|
||
.preview__author-info { | ||
display: flex; | ||
flex-direction: column; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
.input-text-area { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.textarea-container { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.icon { | ||
display: flex; | ||
align-items: center; | ||
margin-right: 10px; /* Отступ между иконкой и полем */ | ||
} | ||
|
||
.icon img { | ||
width: 20px; /* Размер иконки */ | ||
height: 20px; | ||
} | ||
|
||
.input-area { | ||
flex-grow: 1; /* Заполняет оставшееся пространство */ | ||
min-height: 50px; | ||
resize: none; | ||
padding: 8px; | ||
font-size: 16px; | ||
border: 1px solid var(--input-border-color); | ||
border-radius: 4px; | ||
box-sizing: border-box; | ||
} | ||
|
||
|
||
.input-area::placeholder { | ||
text-align: left; /* Центрирует текст placeholder */ | ||
color: var(--input-label-color); /* Цвет текста для placeholder */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<div class="input-text-area"> | ||
<label class="input-text-area-title">{{title}}</label> | ||
<div class="textarea-container"> | ||
{{#if icon}} | ||
<span class="icon" style="margin-right: {{iconMargin}};"> | ||
<img src="{{icon}}" alt="icon" /> | ||
</span> | ||
{{/if}} | ||
<textarea | ||
class="input-area" | ||
{{#if placeHolder}} placeholder="{{placeHolder}}" {{/if}} | ||
{{#if maxLength}} maxlength="{{maxLength}}" {{/if}} | ||
{{#if fontSize}} style="font-size: {{fontSize}};" {{/if}} | ||
{{#if minHeight}} style="min-height: {{minHeight}};" {{/if}} | ||
{{#if maxHeight}} style="max-height: {{maxHeight}};" {{/if}} | ||
{{#if autoExpand}} oninput="this.style.height = 'auto'; this.style.height = this.scrollHeight + 'px'" {{/if}} | ||
></textarea> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
'use strict'; | ||
|
||
import { BaseComponent } from '../base/base.js'; | ||
|
||
/** | ||
* Represents a Text Area Component. | ||
* @class | ||
*/ | ||
export class TextAreaComponent extends BaseComponent { | ||
/** | ||
* The function that will handle the text area input event. | ||
* @type {Function} | ||
*/ | ||
#inputHandler = () => {}; | ||
|
||
/** | ||
* Creates an instance of TextAreaComponent. | ||
* @constructor | ||
* @param {HTMLElement} parent - The parent element where the text area will be rendered. | ||
* @param {Object} [state] - The initial state of the text area component. (optional) | ||
* @param {Function} [inputHandler] - The function that will handle the text area input event. (optional) | ||
*/ | ||
constructor(parent, state = {}, inputHandler = () => {}) { | ||
super(parent, state); | ||
this.#inputHandler = inputHandler; | ||
} | ||
|
||
/** | ||
* Renders the text area component. | ||
* @returns {string} - The rendered HTML template of the text area. | ||
*/ | ||
renderTemplate() { | ||
const template = Handlebars.templates['input-text-area.hbs']; | ||
const renderedTemplate = template(this.State); | ||
|
||
const parent = this.Parent; | ||
if (parent) { | ||
parent.innerHTML += renderedTemplate; | ||
} | ||
|
||
this.attachEvents(); | ||
|
||
return renderedTemplate; | ||
} | ||
|
||
/** | ||
* Attaches events to the rendered text area component. | ||
*/ | ||
attachEvents() { | ||
const parent = this.Parent; | ||
if (parent instanceof HTMLElement) { | ||
const textAreaElement = parent.querySelector('.input-area'); | ||
if (textAreaElement) { | ||
textAreaElement.addEventListener('input', (event) => this.handleInput(event)); | ||
|
||
if (this.State.autoExpand) { | ||
textAreaElement.style.overflowY = 'hidden'; | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Handles the input event for the text area. | ||
* Adjusts the height if autoExpand is enabled. | ||
* @param {Event} event - The text area input event object. | ||
*/ | ||
handleInput(event) { | ||
if (typeof this.#inputHandler === 'function') { | ||
this.#inputHandler(event.target.value); | ||
} | ||
|
||
if (this.State.autoExpand) { | ||
event.target.style.height = 'auto'; | ||
event.target.style.height = `${event.target.scrollHeight}px`; | ||
} | ||
} | ||
|
||
/** | ||
* Sets the input event handler for the text area. | ||
* @param {Function} inputHandler - The function to handle the text area input event. | ||
*/ | ||
setInputHandler(inputHandler) { | ||
this.#inputHandler = inputHandler; | ||
} | ||
|
||
/** | ||
* Gets the current input event handler for the text area. | ||
* @returns {Function} - The current input event handler. | ||
*/ | ||
getInputHandler() { | ||
return this.#inputHandler; | ||
} | ||
} |
Oops, something went wrong.