Skip to content

Instantly share code, notes, and snippets.

@felipeorlando
Created April 26, 2017 19:48
Show Gist options
  • Save felipeorlando/17dd5ded4af899ff07d21734e3c472ec to your computer and use it in GitHub Desktop.
Save felipeorlando/17dd5ded4af899ff07d21734e3c472ec to your computer and use it in GitHub Desktop.
module.exports = {
changeTab() {
this.content.change();
this.button.change();
},
content: {
change() {
this.disabled().className += ` ${this.enabledClass}`;
this.enabled().classList.remove(this.enabledClass);
},
enabled() {
return document.querySelector(`.${this.enabledClass}`);
},
disabled() {
return document.querySelector(`.${this.disabledClass}`);
},
enabledClass: "tab__content--active",
disabledClass: "tab__content:not(.tab__content--active)",
},
button: {
change() {
this.disabled().className += ` ${this.enabledClass}`;
this.enabled().classList.remove(this.enabledClass);
},
enabled() {
return document.querySelector(`.${this.enabledClass}`);
},
disabled() {
return document.querySelector(`.${this.disabledClass}`);
},
enabledClass: "tab__button--active",
disabledClass: "tab__button:not(.tab__button--active)",
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment