tickle/modules/utils/documentState.mjs

17 lines
488 B
JavaScript
Raw Permalink Normal View History

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