Skip to content

Commit

Permalink
Merge pull request #118 from alleslabs/fix/floating-tooltip
Browse files Browse the repository at this point in the history
Fix/floating tooltip
  • Loading branch information
poomthiti authored Jan 24, 2023
2 parents 379bbd0 + aa972d8 commit 0fa3793
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Bug fixes

- [#118](https://github.com/alleslabs/celatone-frontend/pull/118) Fix floating tooltip when scrolling out of copy button
- [#111](https://github.com/alleslabs/celatone-frontend/pull/111) Fix recent activities navigation and instantiate encode/decode
- [#105](https://github.com/alleslabs/celatone-frontend/pull/105) Propoerly show instantiator of code contracts and contract in the instantiated list
- [#42](https://github.com/alleslabs/celatone-frontend/pull/42) Properly show CTAs on contract-list page and edit zero/disconnected state
Expand Down
35 changes: 23 additions & 12 deletions src/lib/components/Copier.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import { CopyIcon } from "@chakra-ui/icons";
import type { LayoutProps } from "@chakra-ui/react";
import { Tooltip, useClipboard } from "@chakra-ui/react";
import { useEffect } from "react";

interface CopierProps {
value: string;
ml?: string;
className?: string;
display?: LayoutProps["display"];
}

export const Copier = ({ value, ml = "8px" }: CopierProps) => {
export const Copier = ({
value,
ml = "8px",
className,
display = "flex",
}: CopierProps) => {
const { onCopy, hasCopied, setValue } = useClipboard(value);

useEffect(() => setValue(value), [value, setValue]);
Expand All @@ -21,17 +29,20 @@ export const Copier = ({ value, ml = "8px" }: CopierProps) => {
arrowSize={8}
bg="primary.dark"
>
<CopyIcon
display="flex"
boxSize="16px"
color="text.dark"
cursor="pointer"
marginLeft={ml}
onClick={(e) => {
e.stopPropagation();
onCopy();
}}
/>
<div>
<CopyIcon
className={className}
display={display}
boxSize="16px"
color="text.dark"
cursor="pointer"
marginLeft={ml}
onClick={(e) => {
e.stopPropagation();
onCopy();
}}
/>
</div>
</Tooltip>
);
};
17 changes: 9 additions & 8 deletions src/lib/components/ExplorerLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,16 @@ export const ExplorerLink = ({

return (
<Box
role="group"
display="inline-flex"
alignItems="center"
_hover={{
...(!readOnly && {
textDecoration: "underline",
textDecorationColor: "primary.main",
}),
"& .copy-button": {
display: "flex",
},
}}
{...componentProps}
>
Expand All @@ -161,13 +163,12 @@ export const ExplorerLink = ({
isEllipsis={textFormat === "ellipsis"}
maxWidth={maxWidth}
/>
<Box
alignItems="center"
display={canCopyWithHover ? "none" : undefined}
_groupHover={canCopyWithHover ? { display: "flex" } : undefined}
>
<Copier value={copyValue || value} ml="8px" />
</Box>
<Copier
value={copyValue || value}
ml="8px"
className="copy-button"
display={canCopyWithHover ? "none" : "flex"}
/>
</>
)}
</Box>
Expand Down

2 comments on commit 0fa3793

@vercel
Copy link

@vercel vercel bot commented on 0fa3793 Jan 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 0fa3793 Jan 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.