refactor(build): modularize JS code
- replace gulp with rollup - remove JS output from repo
This commit is contained in:
21
_javascript/modules/components/mode-watcher.js
Normal file
21
_javascript/modules/components/mode-watcher.js
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Add listener for theme mode toggle
|
||||
*/
|
||||
const $toggleElem = $('.mode-toggle');
|
||||
|
||||
export function modeWatcher() {
|
||||
if ($toggleElem.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$toggleElem.off().on('click', (e) => {
|
||||
const $target = $(e.target);
|
||||
let $btn =
|
||||
$target.prop('tagName') === 'button'.toUpperCase()
|
||||
? $target
|
||||
: $target.parent();
|
||||
|
||||
modeToggle.flipMode(); // modeToggle: `_includes/mode-toggle.html`
|
||||
$btn.trigger('blur'); // remove the clicking outline
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user