-
Notifications
You must be signed in to change notification settings - Fork 0
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
Dev 10: add lookpin page #23
Merged
Changes from 7 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0dffd2f
Добавлен компонент text area, с иконкой слева и плейсхолдером
oruchim1001 0335dc8
add lookpin page
AlexNov03 702f11e
created editpin page
AlexNov03 3bde366
improved editpin page
AlexNov03 30771a3
Merge branch 'dev' into dev-10
wiseStann dc7d871
отладка
wiseStann 9806066
добавил инпуты
wiseStann aa0f3a5
added image input field
AlexNov03 1e67960
верстка страницы добавления и изменения пина доделана
AlexNov03 b7fdd32
added editpin page
AlexNov03 4ec278a
Исправление замечаний из git
ironyyyr d6a7155
Перенес цвета в константы
ironyyyr 8227071
Вернул запись в родителя
ironyyyr 84ad1e2
Еще раз поправил константы цветов
ironyyyr cfe864c
Правки оформления
ironyyyr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
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
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
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 #ccc; | ||
border-radius: 4px; | ||
box-sizing: border-box; | ||
} | ||
|
||
|
||
.input-area::placeholder { | ||
text-align: left; /* Центрирует текст placeholder */ | ||
color: #888; /* Цвет текста для placeholder */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. В cssVars |
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Перевод строки в конце файла |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Цвет в cssVars