Skip to content

Commit 87238f6

Browse files
committed
fix: prevent layout shifts and improve visual consistency in copy component
Signed-off-by: yash37158 <[email protected]>
1 parent c8928b7 commit 87238f6

File tree

1 file changed

+16
-14
lines changed
  • src/sections/Projects/Sistent/identity/color

1 file changed

+16
-14
lines changed

src/sections/Projects/Sistent/identity/color/code.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ const CopyColor = ({ hex, token, copyValue }) => {
437437
isCopied: false
438438
}));
439439

440+
// Reset error state after 1.5 seconds
440441
setTimeout(() => {
441442
setCopyState(prev => ({
442443
...prev,
@@ -508,6 +509,7 @@ const CopyColor = ({ hex, token, copyValue }) => {
508509
color: (theme) => theme.palette.text.primary,
509510
transition: "all 0.2s ease-in-out",
510511
outline: "none",
512+
minWidth: "fit-content", // Prevent width changes
511513
"&:hover": {
512514
backgroundColor: (theme) =>
513515
theme.palette.action?.hover || "rgba(0, 0, 0, 0.04)",
@@ -527,11 +529,9 @@ const CopyColor = ({ hex, token, copyValue }) => {
527529
},
528530
...(copyState.isCopied && {
529531
backgroundColor: (theme) => theme.palette.success.light,
530-
color: (theme) => theme.palette.success.contrastText,
531532
}),
532533
...(copyState.text === "Failed" && {
533534
backgroundColor: (theme) => theme.palette.error.light,
534-
color: (theme) => theme.palette.error.contrastText,
535535
}),
536536
}}
537537
onClick={handleCopy}
@@ -540,18 +540,20 @@ const CopyColor = ({ hex, token, copyValue }) => {
540540
onKeyPress={handleKeyPress}
541541
>
542542
<span>{getCopyValue()}</span>
543-
{copyState.isHovered && !copyState.isCopied && (
544-
<Box
545-
component="span"
546-
sx={{
547-
marginLeft: "4px",
548-
fontSize: "0.75rem",
549-
opacity: 0.7,
550-
}}
551-
>
552-
{copyState.text}
553-
</Box>
554-
)}
543+
<Box
544+
component="span"
545+
sx={{
546+
marginLeft: "4px",
547+
fontSize: "0.75rem",
548+
opacity: copyState.isHovered && !copyState.isCopied ? 0.7 : 0,
549+
visibility: copyState.isHovered && !copyState.isCopied ? "visible" : "hidden",
550+
minWidth: "32px",
551+
textAlign: "left",
552+
transition: "opacity 0.2s ease-in-out",
553+
}}
554+
>
555+
{copyState.text}
556+
</Box>
555557
</Box>
556558
</CustomTooltip>
557559
);

0 commit comments

Comments
 (0)