Skip to content

Commit

Permalink
Merge pull request tidalcycles#1200 from tidalcycles/more-settings
Browse files Browse the repository at this point in the history
add 2 new ui settings
  • Loading branch information
felixroos authored Oct 21, 2024
2 parents 1d05051 + be4c8cb commit dd696ba
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 16 deletions.
7 changes: 4 additions & 3 deletions website/src/components/Header/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ const baseNoTrailing = BASE_URL.endsWith('/') ? BASE_URL.slice(0, -1) : BASE_URL
title="Top Navigation"
>
<div class="flex overflow-visible items-center grow" style="overflow:visible">
<a href={`${baseNoTrailing}/`} class="flex items-center text-2xl space-x-2">
<div class="flex items-center text-2xl space-x-2">
<h1 class="font-bold flex space-x-2 items-baseline text-xl">
<span>🌀</span>
<div class="flex space-x-1 items-baseline">
<div class="flex space-x-2 items-baseline">
<span class="">strudel</span>
<span class="text-sm">DOCS</span>
<a href={`${baseNoTrailing}/`} class="text-sm opacity-25">REPL</a>
</div>
</h1>
</a>
</div>
</div>
{/* KNOWN_LANGUAGE_CODES.length > 1 && <LanguageSelect lang={lang} client:idle /> */}
<div class="search-item h-10">
Expand Down
34 changes: 22 additions & 12 deletions website/src/repl/components/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,19 @@ export function Header({ context, embedded = false }) {
const { started, pending, isDirty, activeCode, handleTogglePlay, handleEvaluate, handleShuffle, handleShare } =
context;
const isEmbedded = typeof window !== 'undefined' && (embedded || window.location !== window.parent.location);
const { isZen } = useSettings();
const { isZen, isButtonRowHidden, isCSSAnimationDisabled } = useSettings();

return (
<header
id="header"
className={cx(
'flex-none text-black z-[100] text-lg select-none',
'flex-none text-black z-[100] text-lg select-none h-14',
!isZen && !isEmbedded && 'bg-lineHighlight',
isZen ? 'h-12 w-8 fixed top-0 left-0' : 'sticky top-0 w-full py-1 justify-between',
isEmbedded ? 'flex' : 'md:flex',
)}
>
<div className="px-4 flex space-x-2 md:pt-0 select-none">
{/* <img
src={logo}
className={cx('Tidal-logo', isEmbedded ? 'w-8 h-8' : 'w-10 h-10', started && 'animate-pulse')} // 'bg-[#ffffff80] rounded-full'
alt="logo"
/> */}
<h1
onClick={() => {
if (isEmbedded) window.open(window.location.href.replace('embed', ''));
Expand All @@ -43,7 +38,12 @@ export function Header({ context, embedded = false }) {
)}
>
<div
className={cx('mt-[1px]', started && 'animate-spin', 'cursor-pointer', isZen && 'fixed top-2 right-4')}
className={cx(
'mt-[1px]',
started && !isCSSAnimationDisabled && 'animate-spin',
'cursor-pointer',
isZen && 'fixed top-2 right-4',
)}
onClick={() => {
if (!isEmbedded) {
setIsZen(!isZen);
Expand All @@ -53,18 +53,28 @@ export function Header({ context, embedded = false }) {
🌀
</div>
{!isZen && (
<div className={cx(started && 'animate-pulse')}>
<span className="">strudel</span> <span className="text-sm">REPL</span>
<div className={cx(started && !isCSSAnimationDisabled && 'animate-pulse', 'space-x-2')}>
<span className="">strudel</span>
<span className="text-sm">REPL</span>
{!isEmbedded && (
<a href={`${baseNoTrailing}/learn`} className="text-sm opacity-25">
DOCS
</a>
)}
</div>
)}
</h1>
</div>
{!isZen && (
{!isZen && !isButtonRowHidden && (
<div className="flex max-w-full overflow-auto text-foreground">
<button
onClick={handleTogglePlay}
title={started ? 'stop' : 'play'}
className={cx(!isEmbedded ? 'p-2' : 'px-2', 'hover:opacity-50', !started && 'animate-pulse')}
className={cx(
!isEmbedded ? 'p-2' : 'px-2',
'hover:opacity-50',
!started && !isCSSAnimationDisabled && 'animate-pulse',
)}
>
{!pending ? (
<span className={cx('flex items-center space-x-1', isEmbedded ? '' : 'w-16')}>
Expand Down
14 changes: 13 additions & 1 deletion website/src/repl/components/panel/SettingsTab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ export function SettingsTab({ started }) {
isAutoCompletionEnabled,
isTooltipEnabled,
isFlashEnabled,
isButtonRowHidden,
isCSSAnimationDisabled,
isSyncEnabled,
isLineWrappingEnabled,
fontSize,
Expand Down Expand Up @@ -196,7 +198,7 @@ export function SettingsTab({ started }) {
value={togglePanelTrigger == 'hover'}
/> */}
</FormItem>
<FormItem label="Code Settings">
<FormItem label="More Settings">
<Checkbox
label="Enable bracket matching"
onChange={(cbEvent) => settingsMap.setKey('isBracketMatchingEnabled', cbEvent.target.checked)}
Expand Down Expand Up @@ -256,6 +258,16 @@ export function SettingsTab({ started }) {
disabled={shouldAlwaysSync}
value={isSyncEnabled}
/>
<Checkbox
label="Hide top buttons"
onChange={(cbEvent) => settingsMap.setKey('isButtonRowHidden', cbEvent.target.checked)}
value={isButtonRowHidden}
/>
<Checkbox
label="Disable CSS Animations"
onChange={(cbEvent) => settingsMap.setKey('isCSSAnimationDisabled', cbEvent.target.checked)}
value={isCSSAnimationDisabled}
/>
</FormItem>
<FormItem label="Zen Mode">Try clicking the logo in the top left!</FormItem>
<FormItem label="Reset Settings">
Expand Down
4 changes: 4 additions & 0 deletions website/src/settings.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export const defaultSettings = {
userPatterns: '{}',
audioDeviceName: defaultAudioDeviceName,
audioEngineTarget: audioEngineTargets.webaudio,
isButtonRowHidden: false,
isCSSAnimationDisabled: false,
};

let search = null;
Expand Down Expand Up @@ -70,6 +72,8 @@ export function useSettings() {
isActiveLineHighlighted: parseBoolean(state.isActiveLineHighlighted),
isAutoCompletionEnabled: parseBoolean(state.isAutoCompletionEnabled),
isPatternHighlightingEnabled: parseBoolean(state.isPatternHighlightingEnabled),
isButtonRowHidden: parseBoolean(state.isButtonRowHidden),
isCSSAnimationDisabled: parseBoolean(state.isCSSAnimationDisabled),
isTooltipEnabled: parseBoolean(state.isTooltipEnabled),
isLineWrappingEnabled: parseBoolean(state.isLineWrappingEnabled),
isFlashEnabled: parseBoolean(state.isFlashEnabled),
Expand Down

0 comments on commit dd696ba

Please sign in to comment.