Skip to content

Commit b7d45af

Browse files
fix: removing the highlight bug and add fixed width (#34)
* fix: removing the highlight bug * feat: add fixed width
1 parent 19beb21 commit b7d45af

File tree

5 files changed

+28
-7
lines changed

5 files changed

+28
-7
lines changed

src/components/cards/Canvas.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { parseEdges, parseNodes } from "@/utils/canvas";
2-
import { useEffect, useMemo, useState } from "react";
2+
import { useMemo } from "react";
33
import ReactFlow from "reactflow";
44
import "reactflow/dist/style.css";
55
import { NodeCard } from "./Node";

src/context/highlight.tsx

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1-
import { createContext, useCallback, useContext, useState } from "react";
1+
import {
2+
Dispatch,
3+
SetStateAction,
4+
createContext,
5+
useCallback,
6+
useContext,
7+
useState,
8+
} from "react";
29

310
export type HighlightContextType = {
411
field: string;
512
value: string | number;
613
setTag: (field: string, value: string | number) => void;
14+
setField: Dispatch<SetStateAction<string>>;
15+
setValue: Dispatch<SetStateAction<string | number>>;
716
};
817
const HighlightContext = createContext<HighlightContextType | undefined>(
918
undefined
@@ -22,7 +31,9 @@ export function HighlightProvider({ children }: { children: React.ReactNode }) {
2231
);
2332

2433
return (
25-
<HighlightContext.Provider value={{ field, value, setTag }}>
34+
<HighlightContext.Provider
35+
value={{ field, value, setTag, setField, setValue }}
36+
>
2637
{children}
2738
</HighlightContext.Provider>
2839
);

src/hooks/useHighlight.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const useHighlight = (entry: Entry) => {
77
const [highlighted, setHighlighted] = useState<boolean>(false);
88

99
const timerRef = useRef<number | null>(null);
10-
const { field, value } = useHighlightContext();
10+
const { field, value, setField, setValue } = useHighlightContext();
1111

1212
const onHighlight = useCallback(() => {
1313
if (!field) return;
@@ -22,6 +22,8 @@ export const useHighlight = (entry: Entry) => {
2222
timerRef.current = window.setTimeout(() => {
2323
setHighlighted(false);
2424
}, 2000);
25+
setField("");
26+
setValue("");
2527
}, [field, value]);
2628

2729
useEffect(() => {

src/pages/_document.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ import { Html, Head, Main, NextScript } from "next/document";
33
export default function Document() {
44
return (
55
<Html lang="en">
6-
<Head />
7-
<body className="max-w-custom mx-auto">
6+
<Head>
7+
<meta
8+
name="viewport"
9+
content="width=device-width, initial-scale=1, maximum-scale=1"
10+
/>
11+
</Head>
12+
<body className="min-w-minWidth max-w-maxWidth mx-auto overflow-x-auto">
813
<Main />
914
<NextScript />
1015
</body>

tailwind.config.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ const config: Config = {
4848
theme: {
4949
extend: {
5050
maxWidth: {
51-
custom: "3500px",
51+
maxWidth: "3400px",
52+
},
53+
minWidth: {
54+
minWidth: "2600px",
5255
},
5356
colors: {
5457
black: {

0 commit comments

Comments
 (0)