diff --git a/src/components/App.js b/src/components/App.js index 7bfb534..fe6e8aa 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -10,6 +10,7 @@ import {GradientsManager} from "./GradientsManager"; import SideMenuContext from '../contexts/SideMenuContext'; import SceneryManager from './SceneryManager'; import ThemeManager from './ThemeManager'; +import {EmbeddedContextProvider} from '../contexts/EmbeddedContext'; import './Themes.css'; import './App.css'; @@ -18,19 +19,21 @@ function App() { const [distancePoints, setDistancePoints] = useState(null); return ( - - - - - - - - - - - - - + + + + + + + + + + + + + + + ); } diff --git a/src/contexts/EmbeddedContext.js b/src/contexts/EmbeddedContext.js new file mode 100644 index 0000000..ae6d8ca --- /dev/null +++ b/src/contexts/EmbeddedContext.js @@ -0,0 +1,23 @@ +import { createContext, useContext } from 'react'; + +const EmbeddedContext = createContext(); + +export const EmbeddedContextProvider = ({ children }) => { + const urlParams = new URLSearchParams(window.location.search); + const isEmbedded = urlParams.get('embedded') === 'true'; + + return ( + + {children} + + ); +} + +export const useEmbeddedContext = () => { + const context = useContext(EmbeddedContext); + if (context === undefined) { + throw new Error('useEmbeddedContext must be used within an EmbeddedContextProvider'); + } + + return context; +}