Skip to content

Commit 08db344

Browse files
committed
Fix: hydration issue
1 parent 70a3f18 commit 08db344

File tree

3 files changed

+15
-56
lines changed

3 files changed

+15
-56
lines changed

src/components/operations/export-button.tsx

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { useState } from "react";
22
import { Copy } from "lucide-react";
33
import { twMerge } from "tailwind-merge";
4-
import { useBreakpoint } from "@/hooks";
54
import { ISTKData } from "@/types";
65
import { IStyles } from "@/types/styles";
76
import { stateToJSON } from "@/utils";
8-
import { Button, IconButton } from "../core";
7+
import { Button, Tooltip, TooltipContent, TooltipTrigger } from "../core";
98

109
interface IExportActionProps {
1110
text?: string;
@@ -15,7 +14,6 @@ interface IExportActionProps {
1514

1615
const ExportAction: React.FC<IExportActionProps> = ({ text = "Export JSON", onExport, styles }) => {
1716
const [loading, setLoading] = useState(false);
18-
const { md } = useBreakpoint();
1917

2018
const onExportJson = () => {
2119
const json = stateToJSON();
@@ -34,29 +32,21 @@ const ExportAction: React.FC<IExportActionProps> = ({ text = "Export JSON", onEx
3432
}
3533
};
3634

37-
if (md)
38-
return (
39-
<Button
40-
loading={loading}
41-
className={twMerge(styles?.core?.button?.className)}
42-
style={styles?.core?.button?.properties}
43-
onClick={onExportJson}
44-
variant="secondary"
45-
>
46-
{text}
47-
</Button>
48-
);
49-
5035
return (
51-
<IconButton
52-
icon={<Copy className="w-5 h-5" />}
53-
label={text}
54-
onClick={onExportJson}
55-
loading={loading}
56-
className={twMerge("w-10", styles?.core?.button?.className)}
57-
style={styles?.core?.button?.properties}
58-
variant="secondary"
59-
/>
36+
<Tooltip>
37+
<TooltipTrigger>
38+
<Button
39+
loading={loading}
40+
className={twMerge("w-10 md:w-auto px-2 md:px-4 transition-none", styles?.core?.button?.className)}
41+
style={styles?.core?.button?.properties}
42+
onClick={onExportJson}
43+
variant="secondary"
44+
>
45+
<Copy className="w-5 h-5 md:hidden" /> <span className="hidden md:block">{text}</span>
46+
</Button>
47+
</TooltipTrigger>
48+
<TooltipContent className="md:hidden">{text}</TooltipContent>
49+
</Tooltip>
6050
);
6151
};
6252

src/hooks/breakpoint.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/hooks/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export { default as useBreakpoint } from "./breakpoint";
21
export { default as useInteractions } from "./interactions";
32
export { default as useResize } from "./resize";
43
export { default as useSkipFirstRender } from "./skip-first-render";

0 commit comments

Comments
 (0)