Skip to content

Commit

Permalink
fix(gui): terminal resize overflow (#2285)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellie authored Jul 16, 2024
1 parent 93db757 commit 97d978c
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 29 deletions.
7 changes: 5 additions & 2 deletions ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,11 @@ function App() {
];

return (
<div className="flex h-dvh w-full select-none">
<div className="relative flex h-full flex-col !border-r-small border-divider transition-width pb-6 pt-9 min-w-[4.5rem] items-center">
<div
className="flex h-dvh w-screen select-none"
style={{ maxWidth: "100vw" }}
>
<div className="relative flex h-full flex-col !border-r-small border-divider transition-width pb-6 pt-9 items-center">
<div className="flex items-center gap-0 px-3 justify-center">
<div className="flex h-8 w-8">
<img src={icon} alt="icon" className="h-8 w-8" />
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/runbooks/editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export default function Editor() {

// Renders the editor instance.
return (
<div className="p-4 w-full">
<div className="overflow-y-scroll w-full">
<BlockNoteView
editor={editor}
slashMenu={false}
Expand Down
41 changes: 21 additions & 20 deletions ui/src/components/runbooks/editor/blocks/RunBlock/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,31 +65,32 @@ const RunBlock = ({
};

return (
<div className="w-full !outline-none">
<div className="flex items-start">
<button
onClick={handleToggle}
className={`flex items-center justify-center flex-shrink-0 w-8 h-8 mr-2 rounded border focus:outline-none focus:ring-2 transition-all duration-300 ease-in-out ${
isRunning
? "border-red-200 bg-red-50 text-red-600 hover:bg-red-100 hover:border-red-300 focus:ring-red-300"
: "border-green-200 bg-green-50 text-green-600 hover:bg-green-100 hover:border-green-300 focus:ring-green-300"
}`}
aria-label={isRunning ? "Stop code" : "Run code"}
>
<span
className={`inline-block transition-transform duration-300 ease-in-out ${isRunning ? "rotate-180" : ""}`}
<div className="w-full !max-w-full !outline-none overflow-none">
<div className="flex flex-row items-start">
<div className="flex">
<button
onClick={handleToggle}
className={`flex items-center justify-center flex-shrink-0 w-8 h-8 mr-2 rounded border focus:outline-none focus:ring-2 transition-all duration-300 ease-in-out ${
isRunning
? "border-red-200 bg-red-50 text-red-600 hover:bg-red-100 hover:border-red-300 focus:ring-red-300"
: "border-green-200 bg-green-50 text-green-600 hover:bg-green-100 hover:border-green-300 focus:ring-green-300"
}`}
aria-label={isRunning ? "Stop code" : "Run code"}
>
{isRunning ? <Square size={16} /> : <Play size={16} />}
</span>
</button>
<div className="flex-grow">
<span
className={`inline-block transition-transform duration-300 ease-in-out ${isRunning ? "rotate-180" : ""}`}
>
{isRunning ? <Square size={16} /> : <Play size={16} />}
</span>
</button>
</div>
<div className="flex-1 min-w-0 w-40">
<CodeMirror
id={id}
placeholder={"Write your code here..."}
className="!pt-0 border border-gray-300 rounded"
className="!pt-0 max-w-full border border-gray-300 rounded"
value={code}
editable={isEditable}
width="100%"
autoFocus
onChange={(val) => {
setValue(val);
Expand All @@ -99,7 +100,7 @@ const RunBlock = ({
basicSetup={false}
/>
<div
className={`overflow-hidden transition-all duration-300 ease-in-out ${
className={`overflow-hidden transition-all duration-300 ease-in-out min-w-0 ${
showTerminal ? "block" : "hidden"
}`}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const TerminalComponent = ({ pty }: any) => {
terminal.loadAddon(fitAddon);
terminal.onResize(onResize(pty));

fitAddon.fit();
const windowResize = () => {
fitAddon.fit();
};
Expand All @@ -67,16 +68,16 @@ const TerminalComponent = ({ pty }: any) => {

window.addEventListener("resize", windowResize);

fitAddon.fit();

// Customize further as needed
return () => {
terminal.dispose();
window.removeEventListener("resize", windowResize);
};
}, [pty]);

return <div ref={terminalRef} />;
return (
<div className="!max-w-full min-w-0 overflow-hidden" ref={terminalRef} />
);
};

export default TerminalComponent;
2 changes: 1 addition & 1 deletion ui/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<NextUIProvider>
<main className="text-foreground bg-background">
<div data-tauri-drag-region className="w-full h-8 absolute" />
<div data-tauri-drag-region className="w-full min-h-8 absolute z-10" />
<App />
</main>
</NextUIProvider>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function Header({ name }: any) {

return (
<div className="md:flex md:items-center md:justify-between">
<div className="min-w-0 flex-1">
<div className="flex-1">
<h2 className="text-2xl font-bold leading-7 text-gray-900 sm:truncate sm:text-3xl sm:tracking-tight">
{greeting}
</h2>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/Runbooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default function Runbooks() {
const currentRunbook = useStore((store) => store.currentRunbook);

return (
<div className="w-full flex flex-row ">
<div className="flex w-full !max-w-full flex-row ">
<List />
{currentRunbook && <Editor />}

Expand Down

0 comments on commit 97d978c

Please sign in to comment.