Skip to content

Commit

Permalink
fix: removing the highlight bug and add fixed width (#34)
Browse files Browse the repository at this point in the history
* fix: removing the highlight bug

* feat: add fixed width
  • Loading branch information
kareraolivier authored Apr 29, 2024
1 parent 19beb21 commit b7d45af
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/cards/Canvas.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { parseEdges, parseNodes } from "@/utils/canvas";
import { useEffect, useMemo, useState } from "react";
import { useMemo } from "react";
import ReactFlow from "reactflow";
import "reactflow/dist/style.css";
import { NodeCard } from "./Node";
Expand Down
15 changes: 13 additions & 2 deletions src/context/highlight.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import { createContext, useCallback, useContext, useState } from "react";
import {
Dispatch,
SetStateAction,
createContext,
useCallback,
useContext,
useState,
} from "react";

export type HighlightContextType = {
field: string;
value: string | number;
setTag: (field: string, value: string | number) => void;
setField: Dispatch<SetStateAction<string>>;
setValue: Dispatch<SetStateAction<string | number>>;
};
const HighlightContext = createContext<HighlightContextType | undefined>(
undefined
Expand All @@ -22,7 +31,9 @@ export function HighlightProvider({ children }: { children: React.ReactNode }) {
);

return (
<HighlightContext.Provider value={{ field, value, setTag }}>
<HighlightContext.Provider
value={{ field, value, setTag, setField, setValue }}
>
{children}
</HighlightContext.Provider>
);
Expand Down
4 changes: 3 additions & 1 deletion src/hooks/useHighlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const useHighlight = (entry: Entry) => {
const [highlighted, setHighlighted] = useState<boolean>(false);

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

const onHighlight = useCallback(() => {
if (!field) return;
Expand All @@ -22,6 +22,8 @@ export const useHighlight = (entry: Entry) => {
timerRef.current = window.setTimeout(() => {
setHighlighted(false);
}, 2000);
setField("");
setValue("");
}, [field, value]);

useEffect(() => {
Expand Down
9 changes: 7 additions & 2 deletions src/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ import { Html, Head, Main, NextScript } from "next/document";
export default function Document() {
return (
<Html lang="en">
<Head />
<body className="max-w-custom mx-auto">
<Head>
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1"
/>
</Head>
<body className="min-w-minWidth max-w-maxWidth mx-auto overflow-x-auto">
<Main />
<NextScript />
</body>
Expand Down
5 changes: 4 additions & 1 deletion tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ const config: Config = {
theme: {
extend: {
maxWidth: {
custom: "3500px",
maxWidth: "3400px",
},
minWidth: {
minWidth: "2600px",
},
colors: {
black: {
Expand Down

0 comments on commit b7d45af

Please sign in to comment.