mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-26 13:08:28 +00:00
move isZen to nanostore
+ correctly parse non strings in store
This commit is contained in:
parent
70f7e73b9a
commit
0006d57a4a
@ -136,7 +136,7 @@ export default function CodeMirror({
|
|||||||
return staticExtensions;
|
return staticExtensions;
|
||||||
}, [keybindings]);
|
}, [keybindings]);
|
||||||
return (
|
return (
|
||||||
<div style={{ fontSize: parseInt(fontSize), fontFamily }} className="w-full">
|
<div style={{ fontSize, fontFamily }} className="w-full">
|
||||||
<_CodeMirror
|
<_CodeMirror
|
||||||
value={value}
|
value={value}
|
||||||
theme={theme || strudelTheme}
|
theme={theme || strudelTheme}
|
||||||
|
|||||||
@ -10,10 +10,9 @@ import { themes } from './themes.mjs';
|
|||||||
import { useSettings, settingsMap, setActiveFooter, defaultSettings } from '../settings.mjs';
|
import { useSettings, settingsMap, setActiveFooter, defaultSettings } from '../settings.mjs';
|
||||||
|
|
||||||
export function Footer({ context }) {
|
export function Footer({ context }) {
|
||||||
const { isZen } = context;
|
|
||||||
const footerContent = useRef();
|
const footerContent = useRef();
|
||||||
const [log, setLog] = useState([]);
|
const [log, setLog] = useState([]);
|
||||||
const { activeFooter } = useSettings();
|
const { activeFooter, isZen } = useSettings();
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (footerContent.current && activeFooter === 'console') {
|
if (footerContent.current && activeFooter === 'console') {
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import SparklesIcon from '@heroicons/react/20/solid/SparklesIcon';
|
|||||||
import StopCircleIcon from '@heroicons/react/20/solid/StopCircleIcon';
|
import StopCircleIcon from '@heroicons/react/20/solid/StopCircleIcon';
|
||||||
import { cx } from '@strudel.cycles/react';
|
import { cx } from '@strudel.cycles/react';
|
||||||
import React, { useContext } from 'react';
|
import React, { useContext } from 'react';
|
||||||
|
import { useSettings, setIsZen } from '../settings.mjs';
|
||||||
// import { ReplContext } from './Repl';
|
// import { ReplContext } from './Repl';
|
||||||
import './Repl.css';
|
import './Repl.css';
|
||||||
|
|
||||||
@ -21,11 +22,9 @@ export function Header({ context }) {
|
|||||||
handleUpdate,
|
handleUpdate,
|
||||||
handleShuffle,
|
handleShuffle,
|
||||||
handleShare,
|
handleShare,
|
||||||
isZen,
|
|
||||||
setIsZen,
|
|
||||||
} = context;
|
} = context;
|
||||||
const isEmbedded = embedded || window.location !== window.parent.location;
|
const isEmbedded = embedded || window.location !== window.parent.location;
|
||||||
// useContext(ReplContext)
|
const { isZen } = useSettings();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<header
|
<header
|
||||||
@ -53,7 +52,11 @@ export function Header({ context }) {
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className={cx('mt-[1px]', started && 'animate-spin', 'cursor-pointer')}
|
className={cx('mt-[1px]', started && 'animate-spin', 'cursor-pointer')}
|
||||||
onClick={() => !isEmbedded && setIsZen((z) => !z)}
|
onClick={() => {
|
||||||
|
if (!isEmbedded) {
|
||||||
|
setIsZen(!isZen);
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
🌀
|
🌀
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -26,7 +26,6 @@ import { themes } from './themes.mjs';
|
|||||||
import { settingsMap, useSettings, setLatestCode } from '../settings.mjs';
|
import { settingsMap, useSettings, setLatestCode } from '../settings.mjs';
|
||||||
|
|
||||||
const { latestCode } = settingsMap.get();
|
const { latestCode } = settingsMap.get();
|
||||||
console.log('latestCode', latestCode);
|
|
||||||
|
|
||||||
initAudioOnFirstClick();
|
initAudioOnFirstClick();
|
||||||
|
|
||||||
@ -115,7 +114,6 @@ export function Repl({ embedded = false }) {
|
|||||||
const isEmbedded = embedded || window.location !== window.parent.location;
|
const isEmbedded = embedded || window.location !== window.parent.location;
|
||||||
const [view, setView] = useState(); // codemirror view
|
const [view, setView] = useState(); // codemirror view
|
||||||
const [lastShared, setLastShared] = useState();
|
const [lastShared, setLastShared] = useState();
|
||||||
const [isZen, setIsZen] = useState(false);
|
|
||||||
const [pending, setPending] = useState(false);
|
const [pending, setPending] = useState(false);
|
||||||
|
|
||||||
const { theme, keybindings, fontSize, fontFamily } = useSettings();
|
const { theme, keybindings, fontSize, fontFamily } = useSettings();
|
||||||
@ -254,8 +252,6 @@ export function Repl({ embedded = false }) {
|
|||||||
handleUpdate,
|
handleUpdate,
|
||||||
handleShuffle,
|
handleShuffle,
|
||||||
handleShare,
|
handleShare,
|
||||||
isZen,
|
|
||||||
setIsZen,
|
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
// bg-gradient-to-t from-blue-900 to-slate-900
|
// bg-gradient-to-t from-blue-900 to-slate-900
|
||||||
|
|||||||
@ -8,14 +8,21 @@ export const defaultSettings = {
|
|||||||
fontFamily: 'monospace',
|
fontFamily: 'monospace',
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
latestCode: '',
|
latestCode: '',
|
||||||
|
isZen: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const settingsMap = persistentMap('strudel-settings', defaultSettings);
|
export const settingsMap = persistentMap('strudel-settings', defaultSettings);
|
||||||
|
|
||||||
export function useSettings() {
|
export function useSettings() {
|
||||||
return useStore(settingsMap);
|
const state = useStore(settingsMap);
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
isZen: [true, 'true'].includes(state.isZen) ? true : false,
|
||||||
|
fontSize: Number(state.fontSize),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const setActiveFooter = (tab) => settingsMap.setKey('activeFooter', tab);
|
export const setActiveFooter = (tab) => settingsMap.setKey('activeFooter', tab);
|
||||||
|
|
||||||
export const setLatestCode = (code) => settingsMap.setKey('latestCode', code);
|
export const setLatestCode = (code) => settingsMap.setKey('latestCode', code);
|
||||||
|
export const setIsZen = (active) => settingsMap.setKey('isZen', !!active);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user