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

Feat(web)/case cards indicators #1463

Merged
merged 19 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
2d8daef
feat(web): basic-indicator-ui-hardcoded
Harman-singh-waraich Jan 24, 2024
3496827
feat(web): card-labels-first-iteration
Harman-singh-waraich Jan 26, 2024
7c3fa54
refactor(web): better-label-info-query
Harman-singh-waraich Jan 27, 2024
1b34347
fix(web): remove-won-lost-labels
Harman-singh-waraich Jan 29, 2024
b2620e4
feat(web): add-reward-amount-to-contribution-entity
Harman-singh-waraich Jan 29, 2024
ed267eb
feat(web): add-funding-rewards-logic
Harman-singh-waraich Jan 29, 2024
64c0f6b
fix(web): align-skeleton-loader
Harman-singh-waraich Jan 29, 2024
7cb7d86
refactor(web): change-label-query-stale-time
Harman-singh-waraich Jan 29, 2024
c36f002
fix(web): hide-labels-if-disconnected
Harman-singh-waraich Jan 29, 2024
c67884b
fix(web): fix-label-showing-voted-on-commit
Harman-singh-waraich Jan 29, 2024
c73b7ed
refactor(web): refactor-ensure-classic-contribution-function
Harman-singh-waraich Jan 29, 2024
24f87d0
refactor(web): fix-sonar-issues
Harman-singh-waraich Jan 29, 2024
f88927b
refactor(web): improve typing on color card labels colors
alcercu Jan 31, 2024
65a2d39
refactor(web): make more clear when a value is small but not 0 number…
alcercu Jan 31, 2024
b79b60e
fix(web): account for values lower than 0
alcercu Feb 1, 2024
370bdbe
Merge pull request #1467 from kleros/refactor(web)/number-display-and…
Harman-singh-waraich Feb 2, 2024
a177460
chore(subgraph): update package version
alcercu Feb 2, 2024
8edd9b0
Merge branch 'dev' into feat(web)/case-cards-indicators
alcercu Feb 2, 2024
95073a0
Merge branch 'feat(web)/case-cards-indicators' of github.com:kleros/k…
alcercu Feb 2, 2024
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 subgraph/core/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ type ClassicContribution implements Contribution @entity {

localRound: ClassicRound!
amount: BigInt!
rewardAmount: BigInt
choice: BigInt!
rewardWithdrawn: Boolean!
}
1 change: 1 addition & 0 deletions subgraph/core/src/DisputeKitClassic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,6 @@ export function handleWithdrawal(event: Withdrawal): void {
const contribution = ensureClassicContributionFromEvent(event);
if (!contribution) return;
contribution.rewardWithdrawn = true;
contribution.rewardAmount = event.params._amount;
contribution.save();
}
10 changes: 5 additions & 5 deletions subgraph/core/src/entities/ClassicContribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { Contribution as ContributionEvent, Withdrawal } from "../../generated/D
import { DISPUTEKIT_ID } from "../DisputeKitClassic";

export function ensureClassicContributionFromEvent<T>(event: T): ClassicContribution | null {
if (!(event instanceof ContributionEvent) && !(event instanceof Withdrawal)) {
return null;
}
if (!(event instanceof ContributionEvent) && !(event instanceof Withdrawal)) return null;
const coreDisputeID = event.params._coreDisputeID.toString();
const coreRoundIndex = event.params._coreRoundID.toString();
const roundID = `${DISPUTEKIT_ID}-${coreDisputeID}-${coreRoundIndex}`;
Expand All @@ -25,9 +23,11 @@ export function ensureClassicContributionFromEvent<T>(event: T): ClassicContribu
classicContribution.rewardWithdrawn = false;
} else {
const currentAmount = classicContribution.amount;
classicContribution.amount = currentAmount.plus(event.params._amount);
// we dont want to increase amount on withdraw event, the amount in that event is reward/reimburse amount
if (event instanceof ContributionEvent) {
classicContribution.amount = currentAmount.plus(event.params._amount);
}
}

classicContribution.save();
return classicContribution;
}
2 changes: 1 addition & 1 deletion subgraph/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kleros/kleros-v2-subgraph",
"version": "0.4.0",
"version": "0.5.0",
"license": "MIT",
"scripts": {
"update:core:arbitrum-sepolia-devnet": "./scripts/update.sh arbitrumSepoliaDevnet arbitrum-sepolia core/subgraph.yaml",
Expand Down
2 changes: 1 addition & 1 deletion web/src/assets/svgs/icons/eth.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions web/src/assets/svgs/label-icons/appeal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions web/src/assets/svgs/label-icons/evidence.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions web/src/assets/svgs/label-icons/forgot-vote.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions web/src/assets/svgs/label-icons/funded.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions web/src/assets/svgs/label-icons/minus-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions web/src/assets/svgs/label-icons/rewards-lost.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions web/src/assets/svgs/label-icons/rewards-won.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions web/src/assets/svgs/label-icons/vote.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions web/src/assets/svgs/label-icons/voted.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions web/src/components/DisputeCard/CardLabels/Label.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import React, { useMemo } from "react";
import styled, { Theme, useTheme } from "styled-components";

const COLORS: Record<string, Array<keyof Theme>> = {
red: ["error", "errorLight"],
green: ["success", "successLight"],
blue: ["primaryBlue", "mediumBlue"],
purple: ["secondaryPurple", "mediumPurple"],
lightPurple: ["tint", "mediumPurple"],
grey: ["secondaryText", "lightGrey"],
};

export type IColors = keyof typeof COLORS;

const LabelContainer = styled.div<{ backgroundColor: string }>`
display: inline-flex;
padding: 4px 8px;
align-items: center;
gap: 10px;
border-radius: 300px;
background-color: ${({ backgroundColor }) => backgroundColor};
`;

const IconContainer = styled.div<{ contentColor: string }>`
height: 14px;
width: 14px;
display: flex;
align-items: center;
justify-content: center;
> svg {
fill: ${({ contentColor }) => contentColor};
}
`;

const StyledText = styled.label<{ contentColor: string }>`
font-size: 12px;
font-weight: 400;
color: ${({ contentColor }) => contentColor};
`;

export interface ILabelProps {
text: string;
icon: React.FC<React.SVGAttributes<SVGElement>>;
color: keyof typeof COLORS;
}

const Label: React.FC<ILabelProps> = ({ text, icon: Icon, color }) => {
const theme = useTheme();
const [contentColor, backgroundColor] = useMemo(() => {
return COLORS[color].map((color) => theme[color]);
}, [theme, color]);

return (
<LabelContainer {...{ backgroundColor }}>
<IconContainer {...{ contentColor }}>
<Icon />
</IconContainer>
<StyledText {...{ contentColor }}>{text}</StyledText>
</LabelContainer>
);
};

export default Label;
46 changes: 46 additions & 0 deletions web/src/components/DisputeCard/CardLabels/RewardsAndFundLabel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from "react";
import styled, { useTheme } from "styled-components";
import EthIcon from "assets/svgs/icons/eth.svg";
import PnkIcon from "assets/svgs/icons/kleros.svg";
import NumberDisplay from "components/NumberDisplay";

const Container = styled.div`
display: flex;
gap: 4px;
align-items: center;
flex-wrap: wrap;
`;

const StyledIcon = styled.div<{ color: string }>`
width: 12px;
height: 12px;
path {
fill: ${({ color }) => color};
}
`;

const StyledLabel = styled.label<{ color: string }>`
color: ${({ color }) => color};
`;
interface IRewardsAndFundLabel {
value: string;
unit: "ETH" | "PNK";
isFund?: boolean;
}

const RewardsAndFundLabel: React.FC<IRewardsAndFundLabel> = ({ value, unit = "ETH", isFund = false }) => {
const theme = useTheme();
const isWon = Number(value) > 0;
const color = isWon ? theme.success : theme.error;
return Number(value) !== 0 ? (
<Container>
<StyledLabel color={isFund ? theme.tint : color}>
<NumberDisplay {...{ value, unit }} showUnitInDisplay={false} />
</StyledLabel>
<StyledIcon as={unit === "ETH" ? EthIcon : PnkIcon} color={isFund ? theme.tint : color} />
</Container>
) : null;
};

export default RewardsAndFundLabel;
Loading
Loading