Skip to content

Commit 6572619

Browse files
committed
chore: remember user-defined hight of the code editor and output
1 parent 5cb1834 commit 6572619

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

app/components/EditorNOutput/EditorNOutput.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

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

4949
if (newTopWidth > 32) {
5050
setTopWidth(newTopWidth);
51+
localStorage.setItem("verticalTopHeight", String(newTopWidth));
5152
} else {
53+
localStorage.setItem("verticalTopHeight", String(containerRect.top));
5254
setTopWidth(containerRect.top);
5355
}
5456
};
5557

58+
useEffect(() => {
59+
const topHeight = localStorage.getItem("verticalTopHeight");
60+
if (topHeight) {
61+
setTopWidth(Number(topHeight));
62+
}
63+
}, []);
64+
5665
return (
5766
<div
5867
className={styles.codeEditorNOutput}

0 commit comments

Comments
 (0)