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 use tooltip instead of popup #1396 #1397

Merged
merged 6 commits into from
Jul 5, 2024
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
24 changes: 8 additions & 16 deletions site/src/components/RelatedLinks.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React from "react";
import styled from "styled-components";
import { Popup } from "semantic-ui-react";

import ExternalLink from "./ExternalLink";
import getLinkNameAndSrc from "../utils/link";
import { useDisablePopup } from "../utils/hooks";
import ImageWithDark from "./ImageWithDark";
import Tooltip from "./Tooltip";

const Wrapper = styled.div`
display: flex;
Expand All @@ -24,25 +23,18 @@ const CustomImage = styled(ImageWithDark)`
`;

const RelatedLinks = ({ links }) => {
const disabledPopup = useDisablePopup();
return (
<Wrapper>
{(links || []).map((item, index) => {
const [, src] = getLinkNameAndSrc(item.link);
return (
<Popup
content={item.description}
size="mini"
disabled={disabledPopup || !item.description}
trigger={
<div>
<ExternalLink href={item.link}>
<CustomImage src={src} />
</ExternalLink>
</div>
}
key={index}
/>
<Tooltip key={index} tooltipContent={item.description}>
<div>
<ExternalLink href={item.link}>
<CustomImage src={src} />
</ExternalLink>
</div>
</Tooltip>
);
})}
</Wrapper>
Expand Down
3 changes: 2 additions & 1 deletion site/src/components/Tooltip/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Wrapper = styled.div`
display: inline-flex;
`;

export default function Tooltip({ children, tooltipContent }) {
export default function Tooltip({ children, tooltipContent, className = "" }) {
const [open, setOpen] = useState(false);

const arrowRef = useRef(null);
Expand Down Expand Up @@ -42,6 +42,7 @@ export default function Tooltip({ children, tooltipContent }) {
onFocus={show}
onMouseLeave={hide}
onBlur={hide}
className={className}
>
{children}
{open && tooltipContent && (
Expand Down
3 changes: 2 additions & 1 deletion site/src/components/Tooltip/styled.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import styled from "styled-components";
import { p_12_normal } from "../../styles/text";

const triangleWidth = 6;

Expand All @@ -12,7 +13,7 @@ export const TooltipArrow = styled.div`
export const TooltipContainer = styled.div`
background-color: var(--tooltipBg);
color: var(--textPrimaryContrast);
font-weight: bold;
${p_12_normal};
padding: 8px;
border-radius: 4px;
display: none;
Expand Down
28 changes: 16 additions & 12 deletions site/src/components/User/Username.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React from "react";
import styled, { css } from "styled-components";
import { Popup } from "semantic-ui-react";

import TextMinor from "../TextMinor";
import { useDisablePopup } from "../../utils/hooks";
import { truncate } from "../../styles/tailwindcss";
import { KNOWN_ADDR_MATCHERS } from "../../utils/knownAddr";
import IdentitySpecial from "../Icon/identity-special.svg";
Expand Down Expand Up @@ -42,9 +40,7 @@ const Text = styled.span`
color: var(--textPrimaryContrast);
`;

const Username = ({ address, name, ellipsis, popup, popupContent, noLink }) => {
const disabledPopup = useDisablePopup();

const Username = ({ address, name, ellipsis, popupContent, noLink }) => {
let displayAddress;
if (typeof address === "string") {
if (ellipsis) {
Expand Down Expand Up @@ -78,14 +74,22 @@ const Username = ({ address, name, ellipsis, popup, popupContent, noLink }) => {
<img src={IdentitySpecial} alt="special" width={12} height={12} />
</Tooltip>
)}
<Popup
content={
popupContent ? popupContent : name ? `${name} ${address}` : address
<Tooltip
tooltipContent={
popupContent ? (
popupContent
) : name ? (
<div>
<div>{name}</div>
<div>{address}</div>
</div>
) : (
address
)
}
size="mini"
disabled={!popup || disabledPopup}
trigger={<TextUsername noLink={noLink}>{displayName}</TextUsername>}
/>
>
<TextUsername noLink={noLink}>{displayName}</TextUsername>
</Tooltip>
</SpecialAccountWrapper>
);
};
Expand Down
42 changes: 17 additions & 25 deletions site/src/pages/Overview/CustomLabel/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from "react";
import styled, { css } from "styled-components";
import { Popup } from "semantic-ui-react";

import Text from "../../../components/Text";
import TextMinor from "../../../components/TextMinor";
Expand All @@ -15,6 +14,7 @@ import {
} from "../../../styles/tailwindcss";
import { sumBy } from "../../../utils/math";
import Icon from "./icon";
import Tooltip from "../../../components/Tooltip";

const Wrapper = styled.div`
min-width: 224px;
Expand Down Expand Up @@ -121,17 +121,13 @@ const Label = ({ data, icon, status, clickEvent, symbol }) => {
)}
<Title disabled={disabled}>{name}</Title>
{count && <TitleCount disabled={disabled}>{count}</TitleCount>}
<Popup
content={`${value} ${symbol}`}
size="mini"
trigger={
<ValueWrapper disabled={disabled}>
<TextMinor>{`${
Math.round(value) === value ? "" : "≈ "
}${Math.round(value).toLocaleString()} ${symbol}`}</TextMinor>
</ValueWrapper>
}
/>
<ValueWrapper disabled={disabled}>
<Tooltip tooltipContent={`${value} ${symbol}`}>
<TextMinor>{`${
Math.round(value) === value ? "" : "≈ "
}${Math.round(value).toLocaleString()} ${symbol}`}</TextMinor>
</Tooltip>
</ValueWrapper>
</TitleWrapper>

{!!fiatValue && (
Expand Down Expand Up @@ -162,19 +158,15 @@ const Label = ({ data, icon, status, clickEvent, symbol }) => {
<ChildTitle disabled={status?.children?.[index]?.disabled}>
{item.name}
</ChildTitle>
<Popup
content={`${item.value} ${symbol}`}
size="mini"
trigger={
<ValueWrapper disabled={status?.children?.[index]?.disabled}>
<TextMinor>{`${
Math.round(item.value) === item.value ? "" : "≈ "
}${Math.round(
item.value,
).toLocaleString()} ${symbol}`}</TextMinor>
</ValueWrapper>
}
/>
<ValueWrapper disabled={status?.children?.[index]?.disabled}>
<Tooltip tooltipContent={`${item.value} ${symbol}`}>
<TextMinor>{`${
Math.round(item.value) === item.value ? "" : "≈ "
}${Math.round(
item.value,
).toLocaleString()} ${symbol}`}</TextMinor>
</Tooltip>
</ValueWrapper>
</TitleWrapper>

{!!item.fiatValue && (
Expand Down
34 changes: 16 additions & 18 deletions site/src/pages/TreasurySlash/SlashTable.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from "react";
import { NavLink } from "react-router-dom";
import styled from "styled-components";
import { Popup } from "semantic-ui-react";

import Table from "../../components/Table";
import TableLoading from "../../components/TableLoading";
Expand All @@ -12,6 +11,7 @@ import TableNoDataCell from "../../components/TableNoDataCell";
import Card from "../../components/Card";
import IconMask from "../../components/Icon/Mask";
import { useTableColumns } from "../../components/shared/useTableColumns";
import Tooltip from "../../components/Tooltip";

const CardWrapper = styled(Card)`
overflow-x: hidden;
Expand Down Expand Up @@ -115,29 +115,27 @@ const SlashTable = ({ data, loading, header, footer }) => {
</Table.Cell>
<Table.Cell>{`${item.section}(${item.method})`}</Table.Cell>
<Table.Cell>
<Popup
content={
<Tooltip
tooltipContent={
item.method === "Rejected"
? "Proposal ID"
: item.method === "BountyRejected"
? "Bounty ID"
: "Tip ID"
}
size="mini"
trigger={
item.method === "Rejected" ? (
<NavLink to={`/proposals/${item.proposalId}`}>
<ProposalID>#{item.proposalId}</ProposalID>
</NavLink>
) : item.method === "BountyRejected" ? (
<NavLink to={`/bounties/${item.bountyIndex}`}>
<ProposalID>#{item.bountyIndex}</ProposalID>
</NavLink>
) : (
""
)
}
/>
>
{item.method === "Rejected" ? (
<NavLink to={`/proposals/${item.proposalId}`}>
<ProposalID>#{item.proposalId}</ProposalID>
</NavLink>
) : item.method === "BountyRejected" ? (
<NavLink to={`/bounties/${item.bountyIndex}`}>
<ProposalID>#{item.bountyIndex}</ProposalID>
</NavLink>
) : (
""
)}
</Tooltip>
</Table.Cell>
<Table.Cell textAlign={"right"}>
<Balance value={item.balance} />
Expand Down
Loading