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

added qfEligible icons #4804

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -1,30 +1,46 @@
import { Caption, neutralColors } from '@giveth/ui-design-system';
import { Caption, neutralColors, SublineBold } from '@giveth/ui-design-system';
import React from 'react';
import styled from 'styled-components';
import { useIntl } from 'react-intl';
import { getActiveRound } from '@/helpers/qf';
import { getChainName } from '@/lib/network';
import { useProjectContext } from '@/context/project.context';
import { IconWithTooltip } from '@/components/IconWithToolTip';
import config from '@/configuration';

const ProjectEligibleQFChains = () => {
const { projectData } = useProjectContext();
const { formatMessage } = useIntl();

const { activeStartedRound } = getActiveRound(projectData?.qfRounds);

const eligibleChainNames = activeStartedRound?.eligibleNetworks.map(
network => getChainName(network),
);

const chainsString = eligibleChainNames?.join(' & ');

return (
<Container>
<MakeDonationDescription>
{formatMessage({ id: 'label.donations_made_on' })}
&nbsp;<BoldCaption>{chainsString}</BoldCaption>&nbsp;
{formatMessage({ id: 'label.are_eligible_to_be_matched' })}
</MakeDonationDescription>
<Wrapper>
<Caption $medium>
{formatMessage({
id: 'label.eligible_networks_for_matching',
})}
</Caption>
<IconsWrapper>
{activeStartedRound?.eligibleNetworks?.map(network => (
<IconWithTooltip
icon={
<TooltipIconWrapper>
{config.NETWORKS_CONFIG_WITH_ID[
network
]?.chainLogo(24)}
</TooltipIconWrapper>
}
direction='top'
align='top'
key={network}
>
<SublineBold>
{config.NETWORKS_CONFIG_WITH_ID[network]?.name}
</SublineBold>
</IconWithTooltip>
))}
</IconsWrapper>
</Wrapper>
</Container>
);
};
Expand All @@ -34,15 +50,28 @@ const Container = styled.div`
padding: 16px 0;
`;

const MakeDonationDescription = styled(Caption)`
width: 100%;
display: inline-block;
color: ${neutralColors.gray[700]};
const TooltipIconWrapper = styled.div`
margin-top: 4px;
`;

const BoldCaption = styled(Caption)`
font-weight: 500;
display: inline;
const IconsWrapper = styled.div`
margin-top: 14px;
display: flex;
gap: 8px;
img {
filter: grayscale(100%);
opacity: 0.4;
transition: all 0.3s;
&:hover {
filter: grayscale(0);
opacity: 1;
}
}
`;
Comment on lines +57 to +69
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance the styling of disabled network icons.

The current styling applies a grayscale filter and reduced opacity to all network icons. Consider differentiating between enabled and disabled networks by applying the grayscale and opacity styles only to disabled networks. This will provide a clearer visual indication of which networks are currently eligible for matching.

Apply this diff to enhance the styling:

 const IconsWrapper = styled.div`
   margin-top: 14px;
   display: flex;
   gap: 8px;
   img {
-    filter: grayscale(100%);
-    opacity: 0.4;
     transition: all 0.3s;
     &:hover {
-      filter: grayscale(0);
-      opacity: 1;
+      transform: scale(1.1);
     }
+    &.disabled {
+      filter: grayscale(100%);
+      opacity: 0.4;
+    }
   }
 `;

Then update the IconWithTooltip component to conditionally apply the disabled class based on the network's eligibility:

 {activeStartedRound?.eligibleNetworks?.map(network => (
   <IconWithTooltip
     icon={
       <TooltipIconWrapper>
         {config.NETWORKS_CONFIG_WITH_ID[
           network
-        ]?.chainLogo(24)}
+        ]?.chainLogo({ size: 24, className: activeStartedRound?.eligibleNetworks?.includes(network) ? '' : 'disabled' })}
       </TooltipIconWrapper>
     }
     direction='top'
     align='top'
     key={network}
   >
     <SublineBold>
       {config.NETWORKS_CONFIG_WITH_ID[network]?.name}
     </SublineBold>
   </IconWithTooltip>
 ))}

Committable suggestion was skipped due to low confidence.


const Wrapper = styled.div`
border-radius: 8px;
background: ${neutralColors.gray[100]};
color: ${neutralColors.gray[800]};
`;
export default ProjectEligibleQFChains;
Loading