Skip to content

Commit

Permalink
chore: remember user-defined hight of the code editor and output
Browse files Browse the repository at this point in the history
  • Loading branch information
JeelRajodiya committed Jul 6, 2024
1 parent 5cb1834 commit 6572619
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/components/EditorNOutput/EditorNOutput.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import React, { useState, useReducer, useRef } from "react";
import React, { useState, useReducer, useRef, useEffect } from "react";
import CodeEditor from "../CodeEditor";
import styles from "./EditorNOutput.module.css";
import { Box } from "@chakra-ui/react";
Expand Down Expand Up @@ -48,11 +48,20 @@ export default function EditorNOutput({

if (newTopWidth > 32) {
setTopWidth(newTopWidth);
localStorage.setItem("verticalTopHeight", String(newTopWidth));
} else {
localStorage.setItem("verticalTopHeight", String(containerRect.top));
setTopWidth(containerRect.top);
}
};

useEffect(() => {
const topHeight = localStorage.getItem("verticalTopHeight");
if (topHeight) {
setTopWidth(Number(topHeight));
}
}, []);

return (
<div
className={styles.codeEditorNOutput}
Expand Down

0 comments on commit 6572619

Please sign in to comment.