Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/floating tooltip #118

Merged
merged 2 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,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