Skip to content
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

Помощь друга #10

Merged
merged 11 commits into from
Dec 17, 2023

Conversation

PavelUd
Copy link
Contributor

@PavelUd PavelUd commented Dec 12, 2023

@keksobot keksobot changed the title Module9 task2 Помощь друга Dec 12, 2023
js/form.js Outdated Show resolved Hide resolved
js/form.js Outdated Show resolved Hide resolved
js/image-effects.js Outdated Show resolved Hide resolved
js/image-effects.js Outdated Show resolved Hide resolved
js/image-scale.js Outdated Show resolved Hide resolved
js/form.js Outdated
Comment on lines 10 to 13
const formErorrorsMessages = {
hashTag: 'Уникальные хештеги, каждый не более 20 символов, должны быть разделены пробелом',
comment: 'Комментарий не более 140 символов'
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ErrorMessage
перечитывайте критерии

@@ -0,0 +1,58 @@
const EFFECT = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Effect

options: {range: {min: 1, max: 4}, step: 0.1, start: 4},
}
};
const DefaultSliderParams = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

param

js/form.js Outdated

const MAX_HASHTAG_LENGTH = 20;
const MAX_COMMENT_LENGTH = 140;
const MAX_HASHTAG_COUNT = 5;
const VALID_IMAGE_TYPES = ['image/gif', 'image/jpeg', 'image/png'];
const HASHTAG_RULE = /^#[А-яа-яA-za-zёЁ]{1,19}$/;
const ErrorMessage = {
hashTag: 'Уникальные хештеги, каждый не более 20 символов, должны быть разделены пробелом',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BAD_HASHTAG: '',
BAD_COMMENT: '',

Comment on lines 2 to 19
'none': { name: 'none', filter: '', unit: '',
options: {range: {min: 0, max: 100}, step: 1, start: 100},
},
'chrome': {name: 'chrome', filter: 'grayscale', unit: '%',
options: { range: {min: 0, max: 100}, step: 1, start: 100},
},
'sepia': { name: 'sepia', filter: 'sepia', unit: '%',
options: { range: {min: 0, max: 100}, step: 1, start: 100},
},
'marvin': { name: 'marvin', filter: 'invert', unit: '%',
options: {range: {min: 0, max: 100}, step: 1, start: 100},
},
'phobos': {name: 'phobos', filter: 'blur', unit: 'px',
options: {range: {min: 1, max: 10}, step: 0.1, start: 10},
},
'heat': {name: 'heat', filter: 'brightness', unit: '',
options: {range: {min: 1, max: 4}, step: 0.1, start: 4},
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NONE CHROME и тд

}
};
const DefaultSliderParam = {
range: {min: 0, max: 100},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

форматирование как везде должно быть ( перенос на др строки)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я не понял

};

export const resetFilters = () => {
image.style.filter = Effect['none'].name;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

none в константу

};

export const onEffectsFilterChange = (evt) =>{
const effect = evt.target.value;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

evt.target.value.toUpperCase() - чтобы под новый формат константы соответствовать

range: {min: 0, max: 100}, start: 100, step: 0.1
};

const NONE = 'NONE';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DEFAULT_FILTER

Comment on lines 32 to 57
export const createEffectSlider = () =>{
sliderWrapper.classList.add('hidden');
noUiSlider.create(slider, DefaultSliderParam);
};

export const resetFilters = () => {
image.style.filter = Effect[NONE].name;
sliderWrapper.classList.add('hidden');
};

export const onEffectsFilterChange = (evt) =>{
const effect = evt.target.value.toUpperCase();
if(effect === Effect[NONE].name){
resetFilters();
}
else{
sliderWrapper.classList.remove('hidden');
image.removeAttribute('class');
image.classList.add(`effects__preview--${effect}`);
slider.noUiSlider.updateOptions(Effect[effect].options);
slider.noUiSlider.on('update', () => {
sliderValue.value = slider.noUiSlider.get();
image.style.filter = `${Effect[effect].filter}(${sliderValue.value}${Effect[effect].unit})`;
});
}
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В итоге получился не модуль а файл с набором функций. Если делаете модуль, делайте его инкапсулированым, без лишго путающего и ненужного экспорта его внутренних органов ( слушателей, или каких-то функций внтуреннего жизненного цикла). Создайте функции которые запускают модуль (вешают обработчики событий, меняют классы), тормозят модуль (ставят все значения в дефолт, удаляют обработчики и тд) и возможно меняют его состояние (допустим нужно просто вернуть все в дефолт

Comment on lines 25 to 27
const onScaleBiggerClick = updateScale;

const onScaleSmallerClick = updateScale;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(evt) => updateScale(evt.target.dataset.value);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и соответственно поправить updateScale

Comment on lines +21 to +23
const DefaultSliderParam = {
range: {min: 0, max: 100}, start: 100, step: 0.1
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DefaultSliderParam = {
RANGE: {min: 0, max: 100}, START: 100, STEP: 0.1
};

Copy link
Contributor Author

@PavelUd PavelUd Dec 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

к сожалению, noUiSlider не поддерживает критерии html академии

@keksobot keksobot merged commit 18af112 into htmlacademy-univer-javascript-1:master Dec 17, 2023
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants