From 895a294098f1eaf36ea3a6a70b8a761620553f57 Mon Sep 17 00:00:00 2001 From: izawartka <59137928+izawartka@users.noreply.github.com> Date: Wed, 29 Jul 2026 19:44:18 +0200 Subject: [PATCH] Add EmbeddedContext - Added EmbeddedContext and ?embeded=true param support --- src/components/App.js | 29 ++++++++++++++++------------- src/contexts/EmbeddedContext.js | 23 +++++++++++++++++++++++ 2 files changed, 39 insertions(+), 13 deletions(-) create mode 100644 src/contexts/EmbeddedContext.js 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; +}