Skip to content

Commit

Permalink
add app
Browse files Browse the repository at this point in the history
  • Loading branch information
Tatyana-js committed May 28, 2024
1 parent 0d54be0 commit 2daacfc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default () => {
form: document.querySelector('form'),
input: document.getElementById('url-input'),
label: document.querySelector('[for="url-input"]'),
example: document.querySelector('.text-muted'),
example: document.querySelector('p.mt-2.mb-0.text-secondary'),
button: document.querySelector('[type="submit"]'),
};

Expand Down
15 changes: 7 additions & 8 deletions src/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@ import onChange from 'on-change';

export default (elements, i18n, state) => {
const { t } = i18n;

const watchedState = onChange(state, (path, value) => {
if (path === 'isValid') {
/* empty */
} else if (path === 'errors') {
// прописать ошибки//
}
});
const renderForm = () => {
Object.entries(elements).forEach(([key, value]) => {
const element = value;
element.textContent = t(`${key}`) ?? '';
});
};
const watchedState = onChange(state, (path) => {
if (path === 'isValid') {
/* empty */
} else if (path === 'errors') {
// прописать ошибки//
}
});
return {
watchedState,
renderForm,
Expand Down

0 comments on commit 2daacfc

Please sign in to comment.