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: improved overview page, evidence page, voting history page, rem… #1779

Merged
merged 6 commits into from
Dec 9, 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
18 changes: 14 additions & 4 deletions web/src/components/DisputePreview/DisputeContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const QuestionAndDescription = styled.div`
word-wrap: break-word;
div:first-child p:first-of-type {
font-size: 16px;
font-weight: 600;
font-weight: 400;
margin: 0;
}
`;
Expand Down Expand Up @@ -56,6 +56,16 @@ const Answer = styled.div`
}
`;

const StyledSmall = styled.small`
color: ${({ theme }) => theme.secondaryText};
font-weight: 400;
`;

const StyledLabel = styled.label`
color: ${({ theme }) => theme.primaryText};
font-weight: 600;
`;

const AliasesContainer = styled.div`
display: flex;
flex-wrap: wrap;
Expand Down Expand Up @@ -88,11 +98,11 @@ export const DisputeContext: React.FC<IDisputeContext> = ({ disputeDetails, isRp
<AnswersContainer>
{disputeDetails?.answers?.map((answer: IAnswer, i: number) => (
<Answer key={answer.title}>
<small>Option {i + 1}:</small>
<label>
<StyledSmall>{i + 1 + `.`}</StyledSmall>
<StyledLabel>
{answer.title}
{answer.description.trim() ? ` - ${answer.description}` : null}
</label>
</StyledLabel>
</Answer>
))}
</AnswersContainer>
Expand Down
100 changes: 60 additions & 40 deletions web/src/components/EvidenceCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,33 @@ const StyledCard = styled(Card)`
height: auto;
`;

const TextContainer = styled.div`
const TopContent = styled.div`
display: flex;
flex-direction: column;
padding: ${responsiveSize(8, 24)};
gap: ${responsiveSize(4, 8)};
overflow-wrap: break-word;

> * {
overflow-wrap: break-word;
margin: 0;
}
> h3 {
p {
margin: 0;
}
h3 {
display: inline-block;
margin: 0px 4px;
margin: 0;
}
`;

const IndexAndName = styled.div`
display: flex;
flex-direction: row;
align-items: center;
gap: 6px;
`;

const Index = styled.p`
display: inline-block;
`;
Expand All @@ -49,6 +64,9 @@ const StyledReactMarkdown = styled(ReactMarkdown)`
code {
color: ${({ theme }) => theme.secondaryText};
}
p {
margin: 0;
}
`;

const BottomShade = styled.div`
Expand All @@ -65,25 +83,7 @@ const BottomShade = styled.div`
}
`;

const AccountContainer = styled.div`
display: flex;
flex-direction: row;
gap: 8px;
align-items: center;

canvas {
width: 24px;
height: 24px;
}

> * {
flex-basis: 1;
flex-shrink: 0;
margin: 0;
}
`;

const LeftContent = styled.div`
const BottomLeftContent = styled.div`
display: block;

& > *:not(:last-child) {
Expand All @@ -105,21 +105,45 @@ const LeftContent = styled.div`
)}
`;

const AccountContainer = styled.div`
display: flex;
flex-direction: row;
gap: 8px;
align-items: center;

canvas {
width: 24px;
height: 24px;
}

> * {
flex-basis: 1;
flex-shrink: 0;
margin: 0;
}
`;

const HoverStyle = css`
:hover {
text-decoration: underline;
color: ${({ theme }) => theme.primaryBlue};
cursor: pointer;
}
:hover {
label {
text-decoration: underline;
color: ${({ theme }) => theme.primaryBlue};
cursor: pointer;
}
}
`;

const Address = styled.p`
${HoverStyle}
margin: 0;
`;

const Timestamp = styled.label`
color: ${({ theme }) => theme.secondaryText};
const StyledExternalLink = styled(ExternalLink)`
${HoverStyle}
`;

Expand Down Expand Up @@ -191,29 +215,25 @@ const EvidenceCard: React.FC<IEvidenceCard> = ({

return (
<StyledCard>
<TextContainer>
<Index>#{index}:</Index>
{name && description ? (
<>
<h3>{name}</h3>
<StyledReactMarkdown>{description}</StyledReactMarkdown>
</>
) : (
<p>{evidence}</p>
)}
</TextContainer>
<TopContent>
<IndexAndName>
<Index>#{index}: </Index>
<h3>{name}</h3>
</IndexAndName>
{name && description ? <StyledReactMarkdown>{description}</StyledReactMarkdown> : <p>{evidence}</p>}
</TopContent>
<BottomShade>
<LeftContent>
<BottomLeftContent>
<AccountContainer>
<Identicon size="24" string={sender} />
<ExternalLink to={addressExplorerLink} rel="noopener noreferrer" target="_blank">
<Address>{shortenAddress(sender)}</Address>
</ExternalLink>
</AccountContainer>
<ExternalLink to={transactionExplorerLink} rel="noopener noreferrer" target="_blank">
<Timestamp>{formatDate(Number(timestamp), true)}</Timestamp>
</ExternalLink>
</LeftContent>
<StyledExternalLink to={transactionExplorerLink} rel="noopener noreferrer" target="_blank">
<label>{formatDate(Number(timestamp), true)}</label>
</StyledExternalLink>
</BottomLeftContent>
{fileURI && fileURI !== "-" ? (
<FileLinkContainer>
<StyledInternalLink to={`attachment/?url=${getIpfsUrl(fileURI)}`}>
Expand Down
21 changes: 6 additions & 15 deletions web/src/components/Verdict/Answer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,6 @@ const Container = styled.div`
gap: 6px;
`;

const AnswerTitle = styled.h3`
margin: 0;
`;

const AnswerDescription = styled.h4`
margin: 0;
font-size: 15px;
color: ${({ theme }) => theme.primaryText};
padding-bottom: 0.5px;
`;

interface IAnswer {
answer?: Answer;
currentRuling: number;
Expand All @@ -32,14 +21,16 @@ const AnswerDisplay: React.FC<IAnswer> = ({ answer, currentRuling }) => {
<>
{answer ? (
<Container>
<AnswerTitle>
<small>
{answer.title}
{answer.description.trim() ? " -" : null}
</AnswerTitle>
<AnswerDescription>{answer.description.trim()}</AnswerDescription>
</small>
<small>{answer.description.trim()}</small>
</Container>
) : (
<Container>{currentRuling !== 0 ? <h3>Answer 0x{currentRuling}</h3> : <h3>Refuse to Arbitrate</h3>}</Container>
<Container>
{currentRuling !== 0 ? <small>Answer 0x{currentRuling}</small> : <small>Refuse to Arbitrate</small>}
</Container>
)}
</>
);
Expand Down
1 change: 0 additions & 1 deletion web/src/components/Verdict/DisputeTimeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { responsiveSize } from "styles/responsiveSize";
const Container = styled.div`
display: flex;
position: relative;
margin-left: 8px;
flex-direction: column;
`;

Expand Down
52 changes: 36 additions & 16 deletions web/src/components/Verdict/FinalDecision.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ArrowIcon from "svgs/icons/arrow.svg";

import { REFETCH_INTERVAL } from "consts/index";
import { Periods } from "consts/periods";
import { DEFAULT_CHAIN } from "consts/chains";
import { useReadKlerosCoreCurrentRuling } from "hooks/contracts/generated";
import { usePopulatedDisputeData } from "hooks/queries/usePopulatedDisputeData";
import { useVotingHistory } from "hooks/queries/useVotingHistory";
Expand Down Expand Up @@ -41,6 +42,14 @@ const JuryContainer = styled.div`
}
`;

const VerdictContainer = styled.div`
display: flex;
flex-direction: row;
align-items: center;
flex-wrap: wrap;
gap: ${responsiveSize(6, 8)};
`;

const JuryDecisionTag = styled.small`
font-weight: 400;
line-height: 19px;
Expand All @@ -51,6 +60,15 @@ const StyledDivider = styled(Divider)`
margin: ${responsiveSize(16, 24)} 0px;
`;

const ReStyledArrowLink = styled(StyledArrowLink)`
font-size: 14px;

> svg {
height: 15px;
width: 15px;
}
`;

interface IFinalDecision {
arbitrable?: `0x${string}`;
}
Expand All @@ -68,6 +86,7 @@ const FinalDecision: React.FC<IFinalDecision> = ({ arbitrable }) => {
const { data: currentRulingArray } = useReadKlerosCoreCurrentRuling({
query: { refetchInterval: REFETCH_INTERVAL },
args: [BigInt(id ?? 0)],
chainId: DEFAULT_CHAIN,
});
const currentRuling = Number(currentRulingArray?.[0]);
const answer = populatedDisputeData?.answers?.[currentRuling! - 1];
Expand All @@ -81,27 +100,28 @@ const FinalDecision: React.FC<IFinalDecision> = ({ arbitrable }) => {

return (
<Container>
<VerdictBanner ruled={ruled} />

{ruled && (
<JuryContainer>
<JuryDecisionTag>The jury decided in favor of:</JuryDecisionTag>
<AnswerDisplay {...{ answer, currentRuling }} />
</JuryContainer>
)}
{!ruled && periodIndex > 1 && localRounds?.at(localRounds.length - 1)?.totalVoted > 0 && (
<JuryContainer>
<JuryDecisionTag>This option is winning:</JuryDecisionTag>
<AnswerDisplay {...{ answer, currentRuling }} />
</JuryContainer>
)}
<VerdictContainer>
<VerdictBanner ruled={ruled} />
{ruled && (
<JuryContainer>
<JuryDecisionTag>The jury decided in favor of:</JuryDecisionTag>
<AnswerDisplay {...{ answer, currentRuling }} />
</JuryContainer>
)}
{!ruled && periodIndex > 1 && localRounds?.at(localRounds.length - 1)?.totalVoted > 0 && (
<JuryContainer>
<JuryDecisionTag>This option is winning:</JuryDecisionTag>
<AnswerDisplay {...{ answer, currentRuling }} />
</JuryContainer>
)}
</VerdictContainer>
<StyledDivider />
{isLoading && !isDisconnected ? (
<Skeleton width={250} height={20} />
) : (
<StyledArrowLink to={`/cases/${id?.toString()}/voting`}>
<ReStyledArrowLink to={`/cases/${id?.toString()}/voting`}>
{buttonText} <ArrowIcon />
</StyledArrowLink>
</ReStyledArrowLink>
)}
</Container>
);
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Verdict/VerdictBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import HourglassIcon from "svgs/icons/hourglass.svg";
const BannerContainer = styled.div`
display: flex;
gap: 8px;
margin-bottom: 8px;
align-items: center;
svg {
width: 16px;
height: 16px;
Expand Down
4 changes: 2 additions & 2 deletions web/src/layout/Header/navbar/Menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled, { css } from "styled-components";
import DarkModeIcon from "svgs/menu-icons/dark-mode.svg";
import HelpIcon from "svgs/menu-icons/help.svg";
import LightModeIcon from "svgs/menu-icons/light-mode.svg";
import NotificationsIcon from "svgs/menu-icons/notifications.svg";
// import NotificationsIcon from "svgs/menu-icons/notifications.svg";
import SettingsIcon from "svgs/menu-icons/settings.svg";

import { useToggleTheme } from "hooks/useToggleThemeContext";
Expand Down Expand Up @@ -57,7 +57,7 @@ const Menu: React.FC<ISettings & IHelp & IMenu> = ({ toggleIsHelpOpen, toggleIsS
const isLightTheme = theme === "light";

const buttons = [
{ text: "Notifications", Icon: NotificationsIcon },
// { text: "Notifications", Icon: NotificationsIcon },
{
text: "Settings",
Icon: SettingsIcon,
Expand Down
1 change: 0 additions & 1 deletion web/src/pages/Cases/CaseDetails/Evidence/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const ScrollButton = styled(Button)`
background-color: transparent;
padding: 0;
flex-direction: row-reverse;
margin: 0 0 18px;
gap: 8px;
.button-text {
color: ${({ theme }) => theme.primaryBlue};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const StyledBox = styled(Box)`
display: flex;
gap: 8px;
align-items: center;
margin-bottom: -4px;
> p {
margin: 0;
}
Expand Down
Loading
Loading