mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-23 19:48:31 +00:00
optimize rendering
This commit is contained in:
parent
90a58858ca
commit
13545d147b
@ -9,7 +9,7 @@ import { CodeMirror, cx, flash, useHighlighting, useStrudel, useKeydown } from '
|
|||||||
import { getAudioContext, initAudioOnFirstClick, resetLoadedSounds, webaudioOutput } from '@strudel.cycles/webaudio';
|
import { getAudioContext, initAudioOnFirstClick, resetLoadedSounds, webaudioOutput } from '@strudel.cycles/webaudio';
|
||||||
import { createClient } from '@supabase/supabase-js';
|
import { createClient } from '@supabase/supabase-js';
|
||||||
import { nanoid } from 'nanoid';
|
import { nanoid } from 'nanoid';
|
||||||
import React, { createContext, useCallback, useEffect, useState } from 'react';
|
import React, { createContext, useCallback, useEffect, useState, useMemo } from 'react';
|
||||||
import './Repl.css';
|
import './Repl.css';
|
||||||
import { Footer } from './Footer';
|
import { Footer } from './Footer';
|
||||||
import { Header } from './Header';
|
import { Header } from './Header';
|
||||||
@ -264,6 +264,11 @@ export function Repl({ embedded = false }) {
|
|||||||
handleShuffle,
|
handleShuffle,
|
||||||
handleShare,
|
handleShare,
|
||||||
};
|
};
|
||||||
|
const currentTheme = useMemo(() => themes[theme] || themes.strudelTheme, [theme]);
|
||||||
|
const handleViewChanged = useCallback((v) => {
|
||||||
|
setView(v);
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
// bg-gradient-to-t from-blue-900 to-slate-900
|
// bg-gradient-to-t from-blue-900 to-slate-900
|
||||||
// bg-gradient-to-t from-green-900 to-slate-900
|
// bg-gradient-to-t from-green-900 to-slate-900
|
||||||
@ -278,7 +283,7 @@ export function Repl({ embedded = false }) {
|
|||||||
<Header context={context} />
|
<Header context={context} />
|
||||||
<section className="grow flex text-gray-100 relative overflow-auto cursor-text pb-0" id="code">
|
<section className="grow flex text-gray-100 relative overflow-auto cursor-text pb-0" id="code">
|
||||||
<CodeMirror
|
<CodeMirror
|
||||||
theme={themes[theme] || themes.strudelTheme}
|
theme={currentTheme}
|
||||||
value={code}
|
value={code}
|
||||||
keybindings={keybindings}
|
keybindings={keybindings}
|
||||||
isLineNumbersDisplayed={isLineNumbersDisplayed}
|
isLineNumbersDisplayed={isLineNumbersDisplayed}
|
||||||
@ -287,10 +292,7 @@ export function Repl({ embedded = false }) {
|
|||||||
fontSize={fontSize}
|
fontSize={fontSize}
|
||||||
fontFamily={fontFamily}
|
fontFamily={fontFamily}
|
||||||
onChange={handleChangeCode}
|
onChange={handleChangeCode}
|
||||||
onViewChanged={(v) => {
|
onViewChanged={handleViewChanged}
|
||||||
setView(v);
|
|
||||||
// window.editorView = v;
|
|
||||||
}}
|
|
||||||
onSelectionChange={handleSelectionChange}
|
onSelectionChange={handleSelectionChange}
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user