@@ -11,7 +11,7 @@ import {
1111 useToken ,
1212 VStack ,
1313} from "@chakra-ui/react" ;
14- import { useEffect , useRef , useState } from "react" ;
14+ import { useEffect , useMemo , useRef , useState } from "react" ;
1515import { IntlShape , useIntl } from "react-intl" ;
1616import HideSplitViewButton from "../common/SplitView/HideSplitViewButton" ;
1717import { topBarHeight } from "../deployment/misc" ;
@@ -43,14 +43,20 @@ const Simulator = ({
4343 minWidth,
4444 simFocus,
4545} : SimulatorProps ) => {
46- const production =
47- "https://python-simulator.usermbit.org/v/0.1/simulator.html" ;
48- const staging =
49- "https://python-simulator.usermbit.org/staging/simulator.html" ;
50- const url = stage === "PRODUCTION" ? production : staging ;
51- // For testing with sim branches:
52- //const branch = "upgrade-mpy";
53- //const url = `https://review-python-simulator.usermbit.org/${branch}/simulator.html`;
46+ const [ brand500 ] = useToken ( "colors" , [ "brand.500" ] ) ;
47+ const url = useMemo ( ( ) => {
48+ const production =
49+ "https://python-simulator.usermbit.org/v/0.1/simulator.html" ;
50+ const staging =
51+ "https://python-simulator.usermbit.org/staging/simulator.html?flag=sw" ;
52+
53+ // For testing with sim branches:
54+ //const branch = "upgrade-mpy";
55+ //const url = new URL(`https://review-python-simulator.usermbit.org/${branch}/simulator.html`);
56+ const url = new URL ( stage === "PRODUCTION" ? production : staging ) ;
57+ url . searchParams . append ( "color" , brand500 ) ;
58+ return url . toString ( ) ;
59+ } , [ brand500 ] ) ;
5460
5561 const ref = useRef < HTMLIFrameElement > ( null ) ;
5662 const intl = useIntl ( ) ;
@@ -72,7 +78,6 @@ const Simulator = ({
7278 updateTranslations ( simulator . current , intl ) ;
7379 } , [ simulator , intl ] ) ;
7480 const simControlsRef = useRef < HTMLDivElement > ( null ) ;
75- const [ brand500 ] = useToken ( "colors" , [ "brand.500" ] ) ;
7681 const [ running , setRunning ] = useState < RunningStatus > ( RunningStatus . STOPPED ) ;
7782 const previouslyShown = usePrevious ( shown ) ;
7883
@@ -117,7 +122,7 @@ const Simulator = ({
117122 < Box
118123 ref = { ref }
119124 as = "iframe"
120- src = { ` ${ url } ?color= ${ encodeURIComponent ( brand500 ) } ` }
125+ src = { url }
121126 title = { simulatorTitle }
122127 name = { simulatorTitle }
123128 frameBorder = "no"
0 commit comments