Files
frontend/src/core/utils/cacheRtl.js
Amirhossein Mahmoodi f2e199ee8a formatting
2024-08-18 11:11:58 +03:30

29 lines
793 B
JavaScript

"use client";
import createCache from "@emotion/cache";
import { prefixer } from "stylis";
import stylisRTLPlugin from "stylis-plugin-rtl";
import { CacheProvider } from "@emotion/react";
const isBrowser = typeof document !== "undefined";
const createEmotionCache = () => {
let insertionPoint;
if (isBrowser) {
const emotionInsertionPoint = document.querySelector('meta[name="emotion-insertion-point"]');
insertionPoint = emotionInsertionPoint ?? undefined;
}
return createCache({
insertionPoint,
key: "mui-rtl",
stylisPlugins: [prefixer, stylisRTLPlugin],
});
};
const cacheProviderRtl = (props) => {
return <CacheProvider value={createEmotionCache()}>{props.children}</CacheProvider>;
};
export default cacheProviderRtl;