Skip to content

Commit

Permalink
style (components): this.stat -> this.state
Browse files Browse the repository at this point in the history
  • Loading branch information
AveWycc220 committed Jan 19, 2021
1 parent f474446 commit 48fb8d9
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion dist/main.bundle.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/components/base.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default class Basement {
stat = {}
state = {}

constructor({apiWorker = undefined, node = undefined, typeOfElement = undefined, insert=undefined,
insertElement=undefined, cookieWorker = undefined, childComponents = undefined,
Expand All @@ -14,7 +14,7 @@ export default class Basement {
this.init()

const propThis = this
this.stat = new Proxy(this.stat, {
this.state = new Proxy(this.state, {
set(target, property, value) {
target[property] = value
propThis.push()
Expand Down
6 changes: 3 additions & 3 deletions src/components/loginPage/emailInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ export default class EmailInput extends Basement {
this.mainBasement.placeholder = 'Email'
this.mainBasement.setAttribute('maxlength', '50')
this.mainBasement.autocomplete = 'on'
this.stat.length = 0
this.state.length = 0
}

events() {
document.addEventListener('input', e => {
this.stat.length = this.mainBasement.value.length
this.state.length = this.mainBasement.value.length
})
}

render() {
if (this.stat.length === 0) { this.mainBasement.style.border = '2px solid red' }
if (this.state.length === 0) { this.mainBasement.style.border = '2px solid red' }
else { this.mainBasement.style = null }
}
}
12 changes: 6 additions & 6 deletions src/components/loginPage/infoDiv.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ import Basement from '../base'
export default class InfoDiv extends Basement {
init() {
this.mainBasement.classList.add('info')
this.stat.info = ''
this.state.info = ''
}

events() {
document.addEventListener('userExist', e => {
this.stat.info = e.type
this.state.info = e.type
})
document.addEventListener('wrongData', e => {
this.stat.info = e.type
this.state.info = e.type
})
}

render() {
if (!this.stat.info) { return '' }
else if (this.stat.info === 'userExist') { return 'User is Already Exist' }
else if (this.stat.info === 'wrongData') { return 'Wrong Email or Password' }
if (!this.state.info) { return '' }
else if (this.state.info === 'userExist') { return 'User is Already Exist' }
else if (this.state.info === 'wrongData') { return 'Wrong Email or Password' }
}
}
6 changes: 3 additions & 3 deletions src/components/loginPage/passwordInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ export default class PasswordInput extends Basement {
this.mainBasement.name = 'password'
this.mainBasement.placeholder = 'Password'
this.mainBasement.setAttribute('maxlength', '50')
this.stat.length = 0
this.state.length = 0
}

events() {
document.addEventListener('input', e => {
this.stat.length = this.mainBasement.value.length
this.state.length = this.mainBasement.value.length
})
}

render() {
if (this.stat.length === 0) { this.mainBasement.style.border = '2px solid red' }
if (this.state.length === 0) { this.mainBasement.style.border = '2px solid red' }
else { this.mainBasement.style = null }
}
}
6 changes: 3 additions & 3 deletions src/components/loginPage/userInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ export default class UserInput extends Basement {
this.mainBasement.placeholder = 'UserName'
this.mainBasement.setAttribute('maxlength', '100')
this.mainBasement.style.display = 'none'
this.stat.length = 0
this.state.length = 0
}

events() {
document.addEventListener('input', e => {
this.stat.length = this.mainBasement.value.length
this.state.length = this.mainBasement.value.length
})
}

render() {
if (this.stat.length === 0) { this.mainBasement.style.border = '2px solid red' }
if (this.state.length === 0) { this.mainBasement.style.border = '2px solid red' }
else { this.mainBasement.style = null }
}
}
10 changes: 5 additions & 5 deletions src/components/mainPage/messageList.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ export default class MessageList extends Basement {
const message = document.createElement('div')
message.classList.add('message')
message.id = this.lastId
const isMyMessage = this.cookieWorker.getCookie('name') === this.stat[this.lastId].name
const isMyMessage = this.cookieWorker.getCookie('name') === this.state[this.lastId].name
isMyMessage ? message.classList.add('my') : message.classList.add('someone')
message.innerHTML =
`<div class="control">
<p class="nickname">${this.stat[this.lastId].name}</p>
<p class="nickname">${this.state[this.lastId].name}</p>
${isMyMessage ? btnList : ''}
</div>
<p class="time">
${new Date(+this.stat[this.lastId].time).toString().split(' ').slice(1, 5).join(' ')}
${new Date(+this.state[this.lastId].time).toString().split(' ').slice(1, 5).join(' ')}
</p>
<p class="message-text">${this.stat[this.lastId].message}</p>`
<p class="message-text">${this.state[this.lastId].message}</p>`
return message
}
return ''
Expand All @@ -52,7 +52,7 @@ export default class MessageList extends Basement {
_readMessages() {
this.apiWorker.messageList.forEach((item) => {
this.lastId = item.id
this.stat[item.id] = item
this.state[item.id] = item
})
}
}

0 comments on commit 48fb8d9

Please sign in to comment.