Skip to content

Commit

Permalink
Controls: Make timeline shorter on narrow screens
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTipson committed Jul 21, 2024
1 parent da69c60 commit 81c318a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/components/Controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ import { Label } from "@/components/ui/label";
import { Input } from "@/components/ui/input";
import type { STGSettings } from "@/components/Machine";

export default function Controls({ className, machine, step, setStep, breakpoints, settings }: {
export default function Controls({ className, machine, step, setStep, breakpoints, settings, isDesktop }: {
className?: string,
machine: stg_machine,
step: number,
setStep: Function,
breakpoints: Map<number, number>,
settings: STGSettings
settings: STGSettings,
isDesktop: boolean,
}) {
const { toast } = useToast();
const [markers, setMarkers] = useState<Map<number, string>>(() => {
Expand Down Expand Up @@ -105,7 +106,7 @@ export default function Controls({ className, machine, step, setStep, breakpoint
<div className="text-center">
Step <span className="font-semibold">{machine.step_number}</span>
</div>
<Timeline className="m-auto w-[500px]" width={500} step={step} moveTo={moveTo} markers={[...markers.entries()]}></Timeline>
<Timeline className={"m-auto " + (isDesktop ? "w-[500px]" : "w-[300px]")} width={isDesktop ? 500 : 300} step={step} moveTo={moveTo} markers={[...markers.entries()]}></Timeline>
{
definition &&
<div className="text-center p-2">
Expand Down
4 changes: 2 additions & 2 deletions src/components/Machine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default function Machine() {
</Panel>
</PanelGroup>
{loaded &&
<Controls className="bg-background p-2 border" machine={machine} step={step} setStep={setStep} breakpoints={breakpoints} settings={settings} />
<Controls className="bg-background p-2 border" machine={machine} step={step} setStep={setStep} breakpoints={breakpoints} settings={settings} isDesktop={isDesktop} />
}
<Toaster />
</div>
Expand All @@ -98,7 +98,7 @@ export default function Machine() {
<Panel defaultSize={55}><HeapView machine={machine} className="h-full" step={step} settings={settings} /></Panel>
<Handle withHandle />
<Panel defaultSize={15}><StackView machine={machine} className="h-full" /></Panel>
<Controls className="absolute left-0 right-0 m-auto bottom-0 bg-background z-10 p-2 w-fit rounded-t border" machine={machine} step={step} setStep={setStep} breakpoints={breakpoints} settings={settings} />
<Controls className="absolute left-0 right-0 m-auto bottom-0 bg-background z-10 p-2 w-fit rounded-t border" machine={machine} step={step} setStep={setStep} breakpoints={breakpoints} settings={settings} isDesktop={isDesktop} />
</>
|| // not loaded
<>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function Timeline({ className, width, markers, step, moveTo }:
}

return (
<div className={className + ` w-[${width}px]`}>
<div className={className + ` w-[${width}px] relative z-0`}>

<div className="relative mx-2 h-8">
{markers.filter(([i, _]) => i <= limit).map(([i, name]) =>
Expand Down

0 comments on commit 81c318a

Please sign in to comment.