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

[0.6] Code Re-structure. Console commands. #8

Merged
merged 13 commits into from
Oct 19, 2023
Prev Previous commit
Improved toggle console feature
  • Loading branch information
Serhii-DV committed Oct 19, 2023
commit 89049be0d57014a9ed3e16033f3ce74fb87ea35c
22 changes: 18 additions & 4 deletions src/popup/components/console-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,26 @@ class ConsoleCommand extends HTMLElement {
self.commands[commandName]();
self.inputElement.value = '';
}
self.hide();
return self;
}

focusInput() {
this.inputElement.focus();
show() {
const self = this;
self.style.display = "block";
self.inputElement.focus();
return self;
}

hide() {
const self = this;
self.style.display = "none";
return self;
}

toggle() {
const self = this;
return self.style.display === "none" ? self.show() : self.hide();
}
}

Expand All @@ -73,8 +88,7 @@ customElements.define('console-command', ConsoleCommand);

document.addEventListener("keydown", event => {
if ((event.ctrlKey || event.metaKey) && event.key === "`") {
consoleCommand.style.display = consoleCommand.style.display === "none" ? "block" : "none";
consoleCommand.focusInput();
consoleCommand.toggle();
}
});
})();
1 change: 1 addition & 0 deletions src/popup/console.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Release } from "../app/release.js";
import { releaseToDiscogsCsv } from "../discogs/modules/discogs.js";
import { logStorage } from "../modules/storage.js";

const consoleCommand = document.querySelector('console-command');

Expand Down