tickle/modules/utils/documentState.mjs
2023-06-07 22:07:47 +02:00

17 lines
488 B
JavaScript

//@ts-check
import {createElementStatusModes} from "./createElementStatusModes.mjs"
/**
* Creates a document state object that can toggle between exclusive states.
* All passed states' css classnames will be prepended with `mode-`.
* @see {createElementStatusModes}
* @param {string[]} states
*/
export const documentState = (states) => {
const all = states.map((state) => `mode-${state}`);
return createElementStatusModes(all, document.body)
};
export default documentState;