Skip to content

Commit

Permalink
Format code (#7)
Browse files Browse the repository at this point in the history
Format code
  • Loading branch information
DannyFeliz committed Nov 5, 2019
2 parents 31a5ddf + d20ac86 commit f64e2ad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 33 deletions.
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"printWidth": 120
}
9 changes: 1 addition & 8 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export default {
"hggame.com",
"hotmail.co.uk",
"hotmail.com",
"hotmail.com",
"hotmail.fr",
"hotmail.it",
"kcidc.com",
Expand Down Expand Up @@ -56,13 +55,7 @@ export default {
"ymail.com",
"ytgame.com"
],
defaultDomains: [
"gmail.com",
"hotmail.com",
"msn.com",
"outlook.com",
"yahoo.com"
]
defaultDomains: ["gmail.com", "hotmail.com", "msn.com", "outlook.com", "yahoo.com"]
};
}
};
Expand Down
34 changes: 9 additions & 25 deletions src/components/EmailDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ export default {
return this.email.split("@")[1] || "";
},
fakeDomains() {
return this.domainsList.map(
domain => `${this.emailWithoutDomain}@${domain}`
);
return this.domainsList.map(domain => `${this.emailWithoutDomain}@${domain}`);
},
optionIsSelected() {
return this.fakeDomains.includes(this.email);
Expand All @@ -98,9 +96,7 @@ export default {
if (!this.includesAt) return [];
if (!this.emailDomain.length && this.defaultDomains.length) {
return this.defaultDomains
.sort((a, b) => a.localeCompare(b))
.slice(0, this.maxSuggestions);
return this.defaultDomains.sort((a, b) => a.localeCompare(b)).slice(0, this.maxSuggestions);
}
return this.domains
Expand All @@ -126,9 +122,7 @@ export default {
DOWN: 40
};
const eventObject = keycoder.fromEvent(event);
const isValidEventChar =
eventObject &&
!Object.values(INVALID_KEYS).includes(eventObject.charCode);
const isValidEventChar = eventObject && !Object.values(INVALID_KEYS).includes(eventObject.charCode);
if (isValidEventChar) {
const char = keycoder.eventToCharacter(event);
Expand Down Expand Up @@ -160,33 +154,23 @@ export default {
},
scroll(direction) {
if (!this.shouldShowList) return;
const length = this.domainsList.length;
if (!this.shouldShowList || this.shouldFocusInput(direction)) return;
if (this.shouldFocusInput(direction)) {
return;
}
if (direction == "up" && this.listIndex == 0) {
this.$refs.email.focus();
this.resetFocusFromList();
return;
}
const shouldScrollUp = direction == "up" && this.listIndex >= 1;
const shouldSchollDown = direction == "down" && this.listIndex < this.domainsList.length - 1;
if (this.isFirstFocus) {
if (direction == "up" && this.listIndex >= 1) {
if (shouldScrollUp) {
this.listIndex -= 1;
} else if (direction == "down" && this.listIndex < length - 1) {
} else if (shouldSchollDown) {
this.listIndex += 1;
}
} else {
this.isFirstFocus = true;
}
this.$nextTick(() => {
document
.querySelector(`[data-dropdown-item-index="${this.listIndex}"]`)
.focus();
document.querySelector(`[data-dropdown-item-index="${this.listIndex}"]`).focus();
});
}
}
Expand Down

0 comments on commit f64e2ad

Please sign in to comment.