font settings

This commit is contained in:
Jade (Rose) Rowland 2025-02-21 11:06:21 -05:00
parent 1ded398468
commit 4959bff060
10 changed files with 31 additions and 30 deletions

View file

@ -67,6 +67,7 @@ export function initEditor({ initialCode = '', onChange, onEvaluate, onStop, roo
const initialSettings = Object.keys(compartments).map((key) => const initialSettings = Object.keys(compartments).map((key) =>
compartments[key].of(extensions[key](parseBooleans(settings[key]))), compartments[key].of(extensions[key](parseBooleans(settings[key]))),
); );
initTheme(settings.theme); initTheme(settings.theme);
let state = EditorState.create({ let state = EditorState.create({
doc: initialCode, doc: initialCode,

View file

@ -9,11 +9,11 @@ import UserFacingErrorMessage from '@src/repl/components/UserFacingErrorMessage'
// } // }
export default function UdelsEditor(Props) { export default function UdelsEditor(Props) {
const { context } = Props; const { context, ...editorProps } = Props;
const { containerRef, editorRef, error, init, pending, started, handleTogglePlay } = context; const { containerRef, editorRef, error, init, pending, started, handleTogglePlay } = context;
return ( return (
<div className={'h-full flex w-full flex-col relative'}> <div className={'h-full flex w-full flex-col relative'} {...editorProps}>
<Loader active={pending} /> <Loader active={pending} />
<BigPlayButton started={started} handleTogglePlay={handleTogglePlay} /> <BigPlayButton started={started} handleTogglePlay={handleTogglePlay} />
<div className="grow flex relative overflow-hidden"> <div className="grow flex relative overflow-hidden">

View file

@ -4,7 +4,7 @@ export default function UdelsHeader(Props) {
const { numWindows, setNumWindows } = Props; const { numWindows, setNumWindows } = Props;
return ( return (
<header id="header" className="flex text-white z-[100] text-lg select-none bg-neutral-900"> <header id="header" className="flex text-white z-[100] text-lg select-none bg-neutral-800">
<div className="px-4 items-center gap-2 flex space-x-2 md:pt-0 select-none"> <div className="px-4 items-center gap-2 flex space-x-2 md:pt-0 select-none">
<h1 onClick={() => {}} className={'text-l cursor-pointer flex gap-4'}> <h1 onClick={() => {}} className={'text-l cursor-pointer flex gap-4'}>
<div className={'mt-[1px] cursor-pointer'}>🌀</div> <div className={'mt-[1px] cursor-pointer'}>🌀</div>

View file

@ -9,10 +9,12 @@ import UdelsEditor from '@components/Udels/UdelsEditor';
import ReplEditor from './components/ReplEditor'; import ReplEditor from './components/ReplEditor';
import EmbeddedReplEditor from './components/EmbeddedReplEditor'; import EmbeddedReplEditor from './components/EmbeddedReplEditor';
import { useReplContext } from './useReplContext'; import { useReplContext } from './useReplContext';
import { useSettings } from '@src/settings.mjs';
export function Repl({ embedded = false }) { export function Repl({ embedded = false }) {
const isEmbedded = embedded || isIframe(); const isEmbedded = embedded || isIframe();
const Editor = isUdels() ? UdelsEditor : isEmbedded ? EmbeddedReplEditor : ReplEditor; const Editor = isUdels() ? UdelsEditor : isEmbedded ? EmbeddedReplEditor : ReplEditor;
const context = useReplContext(); const context = useReplContext();
return <Editor context={context} />; const { fontFamily } = useSettings();
return <Editor context={context} style={{ fontFamily }} />;
} }

View file

@ -9,10 +9,10 @@ import { Header } from './Header';
// } // }
export default function EmbeddedReplEditor(Props) { export default function EmbeddedReplEditor(Props) {
const { context } = Props; const { context, ...editorProps } = Props;
const { pending, started, handleTogglePlay, containerRef, editorRef, error, init } = context; const { pending, started, handleTogglePlay, containerRef, editorRef, error, init } = context;
return ( return (
<div className="h-full flex flex-col relative"> <div className="h-full flex flex-col relative" {...editorProps}>
<Loader active={pending} /> <Loader active={pending} />
<Header context={context} embedded={true} /> <Header context={context} embedded={true} />
<BigPlayButton started={started} handleTogglePlay={handleTogglePlay} /> <BigPlayButton started={started} handleTogglePlay={handleTogglePlay} />

View file

@ -10,13 +10,13 @@ import { useSettings } from '@src/settings.mjs';
// } // }
export default function ReplEditor(Props) { export default function ReplEditor(Props) {
const { context } = Props; const { context, ...editorProps } = Props;
const { containerRef, editorRef, error, init, pending } = context; const { containerRef, editorRef, error, init, pending } = context;
const settings = useSettings(); const settings = useSettings();
const { panelPosition, isZen } = settings; const { panelPosition, isZen } = settings;
return ( return (
<div className="h-full flex flex-col relative"> <div className="h-full flex flex-col relative" {...editorProps}>
<Loader active={pending} /> <Loader active={pending} />
<Header context={context} /> <Header context={context} />
<div className="grow flex relative overflow-hidden"> <div className="grow flex relative overflow-hidden">

View file

@ -149,9 +149,8 @@ function PanelTab({ label, isSelected, onClick }) {
); );
} }
function Tabs({ setTab, tab, className }) { function Tabs({ setTab, tab, className }) {
const {fontFamily, fontSize} = useSettings()
return ( return (
<div className={cx('flex select-none max-w-full overflow-auto pb-2', className)} style={{fontFamily}}> <div className={cx('flex select-none max-w-full overflow-auto pb-2', className)}>
{Object.keys(tabNames).map((key) => { {Object.keys(tabNames).map((key) => {
const val = tabNames[key]; const val = tabNames[key];
return <PanelTab key={key} isSelected={tab === val} label={key} onClick={() => setTab(val)} />; return <PanelTab key={key} isSelected={tab === val} label={key} onClick={() => setTab(val)} />;

View file

@ -89,7 +89,7 @@ export function PatternsTab({ context }) {
const viewingPatternStore = useViewingPatternData(); const viewingPatternStore = useViewingPatternData();
const viewingPatternData = parseJSON(viewingPatternStore); const viewingPatternData = parseJSON(viewingPatternStore);
const { userPatterns, patternFilter, fontFamily } = useSettings(); const { userPatterns, patternFilter } = useSettings();
const examplePatterns = useExamplePatterns(); const examplePatterns = useExamplePatterns();
const collections = examplePatterns.collections; const collections = examplePatterns.collections;
@ -102,7 +102,7 @@ export function PatternsTab({ context }) {
const autoResetPatternOnChange = !isUdels(); const autoResetPatternOnChange = !isUdels();
return ( return (
<div className="px-4 w-full text-foreground space-y-2 flex flex-col overflow-hidden max-h-full h-full" style={{fontFamily}}> <div className="px-4 w-full text-foreground space-y-2 flex flex-col overflow-hidden max-h-full h-full">
<ButtonGroup <ButtonGroup
value={patternFilter} value={patternFilter}
onChange={(value) => settingsMap.setKey('patternFilter', value)} onChange={(value) => settingsMap.setKey('patternFilter', value)}
@ -180,7 +180,6 @@ export function PatternsTab({ context }) {
patterns={patterns} patterns={patterns}
activePattern={activePattern} activePattern={activePattern}
/> />
</section> </section>
); );
})} })}

View file

@ -1,7 +1,7 @@
import { useMemo, useState } from 'react'; import { useMemo, useState } from 'react';
import jsdocJson from '../../../../../doc.json'; import jsdocJson from '../../../../../doc.json';
import { useSettings } from '@src/settings.mjs';
const availableFunctions = jsdocJson.docs const availableFunctions = jsdocJson.docs
.filter(({ name, description }) => name && !name.startsWith('_') && !!description) .filter(({ name, description }) => name && !name.startsWith('_') && !!description)
.sort((a, b) => /* a.meta.filename.localeCompare(b.meta.filename) + */ a.name.localeCompare(b.name)); .sort((a, b) => /* a.meta.filename.localeCompare(b.meta.filename) + */ a.name.localeCompare(b.name));
@ -15,8 +15,6 @@ const getInnerText = (html) => {
export function Reference() { export function Reference() {
const [search, setSearch] = useState(''); const [search, setSearch] = useState('');
const {fontFamily} = useSettings()
const visibleFunctions = useMemo(() => { const visibleFunctions = useMemo(() => {
return availableFunctions.filter((entry) => { return availableFunctions.filter((entry) => {
if (!search) { if (!search) {
@ -28,7 +26,7 @@ export function Reference() {
}, [search]); }, [search]);
return ( return (
<div className="flex h-full w-full p-2 overflow-hidden" style={{fontFamily}}> <div className="flex h-full w-full p-2 overflow-hidden">
<div className="h-full flex flex-col gap-2 w-1/3 max-w-72 "> <div className="h-full flex flex-col gap-2 w-1/3 max-w-72 ">
<div class="w-full flex"> <div class="w-full flex">
<input <input
@ -69,7 +67,7 @@ export function Reference() {
<h3 id={`doc-${i}`}>{entry.name}</h3> <h3 id={`doc-${i}`}>{entry.name}</h3>
{!!entry.synonyms_text && ( {!!entry.synonyms_text && (
<p> <p>
Synonyms: <code className='text-foreground'>{entry.synonyms_text}</code> Synonyms: <code className="text-foreground">{entry.synonyms_text}</code>
</p> </p>
)} )}
{/* <small>{entry.meta.filename}</small> */} {/* <small>{entry.meta.filename}</small> */}
@ -82,7 +80,9 @@ export function Reference() {
))} ))}
</ul> </ul>
{entry.examples?.map((example, j) => ( {entry.examples?.map((example, j) => (
<pre className='bg-background' key={j}>{example}</pre> <pre className="bg-background" key={j}>
{example}
</pre>
))} ))}
</section> </section>
))} ))}

View file

@ -11,7 +11,7 @@ const getSamples = (samples) =>
export function SoundsTab() { export function SoundsTab() {
const sounds = useStore(soundMap); const sounds = useStore(soundMap);
const { soundsFilter, fontFamily } = useSettings(); const { soundsFilter } = useSettings();
const [search, setSearch] = useState(''); const [search, setSearch] = useState('');
const soundEntries = useMemo(() => { const soundEntries = useMemo(() => {
@ -52,7 +52,7 @@ export function SoundsTab() {
}); });
return ( return (
<div id="sounds-tab" className="px-4 flex flex-col w-full h-full text-foreground" style={{fontFamily}}> <div id="sounds-tab" className="px-4 flex flex-col w-full h-full text-foreground">
<input <input
className="w-full p-1 bg-background rounded-md my-2" className="w-full p-1 bg-background rounded-md my-2"
placeholder="Search" placeholder="Search"