tickle/modules/utils/documentMode.mjs

15 lines
431 B
JavaScript
Raw Normal View History

//@ts-check
/**
* Creates a helper to add or remove global classes that begin with `is-`
* @param {string} name
*/
export const documentMode = (name) => ({
on: () => document.body.classList.add(`is-${name}`),
off: () => document.body.classList.remove(`is-${name}`),
toggle: () => document.body.classList.toggle(`is-${name}`),
2023-05-09 02:00:53 +00:00
has: () => document.body.classList.contains(`is-${name}`),
});
export default documentMode;