@@ -11,7 +11,7 @@ import {
11
11
useToken ,
12
12
VStack ,
13
13
} from "@chakra-ui/react" ;
14
- import { useEffect , useRef , useState } from "react" ;
14
+ import { useEffect , useMemo , useRef , useState } from "react" ;
15
15
import { IntlShape , useIntl } from "react-intl" ;
16
16
import HideSplitViewButton from "../common/SplitView/HideSplitViewButton" ;
17
17
import { topBarHeight } from "../deployment/misc" ;
@@ -43,14 +43,20 @@ const Simulator = ({
43
43
minWidth,
44
44
simFocus,
45
45
} : 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 ] ) ;
54
60
55
61
const ref = useRef < HTMLIFrameElement > ( null ) ;
56
62
const intl = useIntl ( ) ;
@@ -72,7 +78,6 @@ const Simulator = ({
72
78
updateTranslations ( simulator . current , intl ) ;
73
79
} , [ simulator , intl ] ) ;
74
80
const simControlsRef = useRef < HTMLDivElement > ( null ) ;
75
- const [ brand500 ] = useToken ( "colors" , [ "brand.500" ] ) ;
76
81
const [ running , setRunning ] = useState < RunningStatus > ( RunningStatus . STOPPED ) ;
77
82
const previouslyShown = usePrevious ( shown ) ;
78
83
@@ -117,7 +122,7 @@ const Simulator = ({
117
122
< Box
118
123
ref = { ref }
119
124
as = "iframe"
120
- src = { ` ${ url } ?color= ${ encodeURIComponent ( brand500 ) } ` }
125
+ src = { url }
121
126
title = { simulatorTitle }
122
127
name = { simulatorTitle }
123
128
frameBorder = "no"
0 commit comments