@ducor/react
Version:
admin template ui interface
15 lines (14 loc) • 700 B
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { createContext, useState, useEffect } from "react";
export var HtmlDirectionContext = createContext(undefined);
export var HtmlDirectionProvider = function (_a) {
var children = _a.children;
var _b = useState("ltr"), htmlDirection = _b[0], setHtmlDirection = _b[1];
useEffect(function () {
var dir = document.body.getAttribute("dir");
if (dir !== htmlDirection) {
document.body.setAttribute("dir", htmlDirection);
}
}, [htmlDirection]);
return (_jsx(HtmlDirectionContext.Provider, { value: { htmlDirection: htmlDirection, setHtmlDirection: setHtmlDirection }, children: children }));
};