File tree Expand file tree Collapse file tree 5 files changed +181
-43
lines changed
matrix_implementations_pt1 Expand file tree Collapse file tree 5 files changed +181
-43
lines changed Original file line number Diff line number Diff line change 11<script >
2- import { onMount } from " svelte" ;
32
4- let mounted = false ;
3+ import { theme } from ' $lib/components/theme.svelte' ;
4+ import HTML from " ./page.html?raw" ;
55 /**
66 * @type {string | null | undefined}
77 */
8- let HTML ;
8+ let iframeElement = $state (null ); // Reference to the iframe DOM element
9+ let visible = $state (false );
10+ let textColor = $state (" black" );
11+ let bgColor = $state (" white" );
912
10- onMount (async () => {
11- HTML = (await import (" ./page.html?raw" )).default ;
12- mounted = true ;
13- });
13+ function styleIframeContent () {
14+ if (! iframeElement? .contentDocument ) return ;
15+
16+ const body = iframeElement .contentDocument .body ;
17+ if (! body) return ;
18+
19+ const rootStyle = getComputedStyle (document .documentElement );
20+ bgColor = rootStyle .getPropertyValue (' --bg-primary' ).trim ();
21+ textColor = rootStyle .getPropertyValue (' --text-primary' ).trim ();
22+ body .style .backgroundColor = bgColor;
23+ body .style .color = textColor;
24+ visible = true ;
25+
26+ }
27+ function onLoad () {
28+ styleIframeContent ();
29+ }
30+
31+ $effect (() => {
32+ $theme .darkstate
33+ if (visible){styleIframeContent ()};
34+ })
1435< / script>
1536
16- <iframe title ="jupyter" srcdoc ={HTML }></iframe >
37+ < iframe title= " jupyter" srcdoc= {HTML } bind: this = {iframeElement} onload= {onLoad}
38+ style= " visibility:{visible ? " visible" : " hidden" };
39+ background-color: {bgColor};
40+ color: {textColor};"
41+ >< / iframe>
42+
43+ {#if ! visible}
44+ < p> Loading... < / p>
45+ {/ if }
1746
1847< style>
1948 iframe {
Original file line number Diff line number Diff line change 11<script >
2- import { onMount } from " svelte" ;
32
4- let mounted = false ;
3+ import { theme } from ' $lib/components/theme.svelte' ;
4+ import HTML from " ./page.html?raw" ;
55 /**
66 * @type {string | null | undefined}
77 */
8- let HTML ;
8+ let iframeElement = $state (null ); // Reference to the iframe DOM element
9+ let visible = $state (false );
10+ let textColor = $state (" black" );
11+ let bgColor = $state (" white" );
912
10- onMount (async () => {
11- HTML = (await import (" ./page.html?raw" )).default ;
12- mounted = true ;
13- });
13+ function styleIframeContent () {
14+ if (! iframeElement? .contentDocument ) return ;
15+
16+ const body = iframeElement .contentDocument .body ;
17+ if (! body) return ;
18+
19+ const rootStyle = getComputedStyle (document .documentElement );
20+ bgColor = rootStyle .getPropertyValue (' --bg-primary' ).trim ();
21+ textColor = rootStyle .getPropertyValue (' --text-primary' ).trim ();
22+ body .style .backgroundColor = bgColor;
23+ body .style .color = textColor;
24+ visible = true ;
25+
26+ }
27+ function onLoad () {
28+ styleIframeContent ();
29+ }
30+
31+ $effect (() => {
32+ $theme .darkstate
33+ if (visible){styleIframeContent ()};
34+ })
1435< / script>
1536
16- <iframe title ="jupyter" srcdoc ={HTML }></iframe >
37+ < iframe title= " jupyter" srcdoc= {HTML } bind: this = {iframeElement} onload= {onLoad}
38+ style= " visibility:{visible ? " visible" : " hidden" };
39+ background-color: {bgColor};
40+ color: {textColor};"
41+ >< / iframe>
42+
43+ {#if ! visible}
44+ < p> Loading... < / p>
45+ {/ if }
1746
1847< style>
1948 iframe {
Original file line number Diff line number Diff line change 11<script >
2- import { onMount } from " svelte" ;
32
4- let mounted = false ;
3+ import { theme } from ' $lib/components/theme.svelte' ;
4+ import HTML from " ./page.html?raw" ;
55 /**
66 * @type {string | null | undefined}
77 */
8- let HTML ;
8+ let iframeElement = $state (null ); // Reference to the iframe DOM element
9+ let visible = $state (false );
10+ let textColor = $state (" black" );
11+ let bgColor = $state (" white" );
912
10- onMount (async () => {
11- HTML = (await import (" ./page.html?raw" )).default ;
12- mounted = true ;
13- });
13+ function styleIframeContent () {
14+ if (! iframeElement? .contentDocument ) return ;
15+
16+ const body = iframeElement .contentDocument .body ;
17+ if (! body) return ;
18+
19+ const rootStyle = getComputedStyle (document .documentElement );
20+ bgColor = rootStyle .getPropertyValue (' --bg-primary' ).trim ();
21+ textColor = rootStyle .getPropertyValue (' --text-primary' ).trim ();
22+ body .style .backgroundColor = bgColor;
23+ body .style .color = textColor;
24+ visible = true ;
25+
26+ }
27+ function onLoad () {
28+ styleIframeContent ();
29+ }
30+
31+ $effect (() => {
32+ $theme .darkstate
33+ if (visible){styleIframeContent ()};
34+ })
1435< / script>
1536
16- <iframe title ="jupyter" srcdoc ={HTML }></iframe >
37+ < iframe title= " jupyter" srcdoc= {HTML } bind: this = {iframeElement} onload= {onLoad}
38+ style= " visibility:{visible ? " visible" : " hidden" };
39+ background-color: {bgColor};
40+ color: {textColor};"
41+ >< / iframe>
1742
18- {#if ! mounted }
43+ {#if ! visible }
1944 < p> Loading... < / p>
2045{/ if }
2146
Original file line number Diff line number Diff line change 11<script >
2- import { onMount } from " svelte" ;
32
4- let mounted = false ;
3+ import { theme } from ' $lib/components/theme.svelte' ;
4+ import HTML from " ./page.html?raw" ;
55 /**
66 * @type {string | null | undefined}
77 */
8- let HTML ;
8+ let iframeElement = $state (null ); // Reference to the iframe DOM element
9+ let visible = $state (false );
10+ let textColor = $state (" black" );
11+ let bgColor = $state (" white" );
912
10- onMount (async () => {
11- HTML = (await import (" ./page.html?raw" )).default ;
12- mounted = true ;
13- });
13+ function styleIframeContent () {
14+ if (! iframeElement? .contentDocument ) return ;
15+
16+ const body = iframeElement .contentDocument .body ;
17+ if (! body) return ;
18+
19+ const rootStyle = getComputedStyle (document .documentElement );
20+ bgColor = rootStyle .getPropertyValue (' --bg-primary' ).trim ();
21+ textColor = rootStyle .getPropertyValue (' --text-primary' ).trim ();
22+ body .style .backgroundColor = bgColor;
23+ body .style .color = textColor;
24+ visible = true ;
25+
26+ }
27+ function onLoad () {
28+ styleIframeContent ();
29+ }
30+
31+ $effect (() => {
32+ $theme .darkstate
33+ if (visible){styleIframeContent ()};
34+ })
1435< / script>
1536
16- <iframe title ="jupyter" srcdoc ={HTML }> </iframe >
37+ < iframe title= " jupyter" srcdoc= {HTML } bind: this = {iframeElement} onload= {onLoad}
38+ style= " visibility:{visible ? " visible" : " hidden" };
39+ background-color: {bgColor};
40+ color: {textColor};"
41+ >< / iframe>
42+
43+ {#if ! visible}
44+ < p> Loading... < / p>
45+ {/ if }
1746
1847< style>
1948 iframe {
Original file line number Diff line number Diff line change 11<script >
2- import { onMount } from " svelte" ;
32
4- let mounted = false ;
3+ import { theme } from ' $lib/components/theme.svelte' ;
4+ import HTML from " ./page.html?raw" ;
55 /**
66 * @type {string | null | undefined}
77 */
8- let HTML ;
8+ let iframeElement = $state (null ); // Reference to the iframe DOM element
9+ let visible = $state (false );
10+ let textColor = $state (" black" );
11+ let bgColor = $state (" white" );
912
10- onMount (async () => {
11- HTML = (await import (" ./page.html?raw" )).default ;
12- mounted = true ;
13- });
13+ function styleIframeContent () {
14+ if (! iframeElement? .contentDocument ) return ;
15+
16+ const body = iframeElement .contentDocument .body ;
17+ if (! body) return ;
18+
19+ const rootStyle = getComputedStyle (document .documentElement );
20+ bgColor = rootStyle .getPropertyValue (' --bg-primary' ).trim ();
21+ textColor = rootStyle .getPropertyValue (' --text-primary' ).trim ();
22+ body .style .backgroundColor = bgColor;
23+ body .style .color = textColor;
24+ visible = true ;
25+
26+ }
27+ function onLoad () {
28+ styleIframeContent ();
29+ }
30+
31+ $effect (() => {
32+ $theme .darkstate
33+ if (visible){styleIframeContent ()};
34+ })
1435< / script>
1536
16- <iframe title ="jupyter" srcdoc ={HTML }> </iframe >
17- {#if ! mounted }
37+ < iframe title= " jupyter" srcdoc= {HTML } bind: this = {iframeElement} onload= {onLoad}
38+ style= " visibility:{visible ? " visible" : " hidden" };
39+ background-color: {bgColor};
40+ color: {textColor};"
41+ >< / iframe>
42+
43+ {#if ! visible}
1844 < p> Loading... < / p>
19- {/if }
45+ {/ if }
2046
2147< style>
2248 iframe {
You can’t perform that action at this time.
0 commit comments