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: new court page design, indicators refactor, court tabs bug fix, statdisplay refactor, appeal tab refactor, add new kleros logo #1781

Merged
merged 16 commits into from
Dec 11, 2024

Conversation

kemuru
Copy link
Contributor

@kemuru kemuru commented Dec 10, 2024

also fixed this issue #1766

and a bug where the juror level was lower than it should, a beta feedback user noticed me


PR-Codex overview

This PR primarily focuses on improving the styling and layout of various components across the application, particularly in the styled-components usage. It also updates some logic and imports, enhancing the overall user interface and experience.

Detailed summary

  • Deleted VerdictBanner.tsx.
  • Adjusted gap properties in several styled.div components.
  • Changed layout from flex to grid in multiple OptionsContainer components.
  • Updated margin-bottom and padding values in various components.
  • Modified the RulingAndRewardsIndicators logic and labels.
  • Enhanced StatDisplay component with new props for responsive display.
  • Updated SVG assets for better visuals.
  • Refactored Stats component to improve data display and organization.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a new component, RulingAndRewardsIndicators, enhancing the display of ruling and rewards based on dispute status.
    • Updated text display in RulingAndRewardsIndicators to reflect current ruling state.
    • Added a styled label in ExtraStats to indicate when there is no activity in the selected time range.
    • Added isSmallDisplay prop to StatDisplay for improved responsiveness.
  • Bug Fixes

    • Improved conditional rendering logic for ruling indicators in the FinalDecision component.
  • Refactor

    • Simplified rendering logic in the VotingHistory component by removing unnecessary components and calculations.
    • Streamlined state management and tab handling in the Description component.
    • Adjusted styling and spacing in the Explore component.
    • Modified spacing in the LabelContainer for better layout.
    • Removed the VerdictBanner component to declutter the Verdict display logic.
    • Enhanced error handling in calculations within the useHomePageBlockQuery hook.
    • Updated layout and styling in StakePanel and Stats components for better organization.
    • Transitioned layout from flexbox to grid in multiple components for improved responsiveness.
    • Adjusted layout of OptionsContainer in AppealHistory and Stage components for a more structured design.
    • Removed specific styling from InputDisplay and Simulator components, affecting their visual presentation.

Copy link
Contributor

coderabbitai bot commented Dec 10, 2024

Walkthrough

The changes in this pull request involve several modifications across various components in the codebase. The LabelContainer styled component's gap property is adjusted from 10px to 8px. The FinalDecision component is updated to include a new RulingAndRewardsIndicators component, replacing VerdictBanner, with logic to conditionally render based on dispute states. The RulingAndRewardsIndicators component is also modified to update the displayed text based on the ruling state. Lastly, the VotingHistory component removes the RulingAndRewardsIndicators, simplifying its rendering logic.

Changes

File Path Change Summary
web/src/components/DisputeView/CardLabels/Label.tsx Modified LabelContainer styled component to change gap from 10px to 8px.
web/src/components/Verdict/FinalDecision.tsx Added import for isUndefined, introduced RulingAndRewardsIndicators component, updated rendering logic based on dispute state, added rounds variable, and created jurorRewardsDispersed memoized value.
web/src/components/Verdict/RulingAndRewardsIndicators.tsx Updated rendering logic to change displayed text based on ruled prop, replacing "Ruling executed" with "Case closed" and adding an hourglass icon for "Case in progress."
web/src/pages/Cases/CaseDetails/Voting/VotingHistory.tsx Removed RulingAndRewardsIndicators component from the render logic and eliminated the calculation for jurorRewardsDispersed, while maintaining the existing logic for displaying voting history and managing state.
web/src/components/Verdict/VerdictBanner.tsx Removed the VerdictBanner component and its associated elements, including VerdictIcon, VerdictText, and related interfaces.
web/src/layout/Header/navbar/Explore.tsx Adjusted padding for StyledLink component in landscape mode and removed gap from Container styled component.
web/src/pages/Courts/CourtDetails/Description.tsx Simplified state management for tab changes by removing local state and using TABS array directly for determining the current tab, along with adjustments to the rendering logic for tab navigation.
web/src/hooks/queries/useHomePageBlockQuery.ts Added default values for votesPerPnk and disputesPerPnk calculations to prevent NaN results.
web/src/pages/Home/CourtOverview/ExtraStats.tsx Introduced a new styled label component StyledLabel to display a message when there is no activity in the selected time range, modifying the control flow to handle cases of no activity more gracefully.
web/src/components/StatDisplay.tsx Enhanced responsiveness of StatDisplay component by introducing isSmallDisplay prop, modifying styled components, and adjusting layout based on display size.
web/src/pages/Courts/CourtDetails/StakePanel/InputDisplay.tsx Removed landscapeStyle from LabelArea and InputArea, potentially affecting layout responsiveness.
web/src/pages/Courts/CourtDetails/StakePanel/Simulator/index.tsx Removed max-width: 480px; from Container styled component, allowing for a wider layout.
web/src/pages/Courts/CourtDetails/StakePanel/index.tsx Modified layout and styling of StakePanel component by removing width properties and changing flex-direction to column.
web/src/pages/Courts/CourtDetails/Stats.tsx Streamlined imports, updated padding and layout of StyledAccordion and StyledCard, and reorganized statistics display into distinct sections.
web/src/pages/Courts/CourtDetails/index.tsx Added Divider component and created new styled component StakePanelAndStats to encapsulate both StakePanel and Stats, enhancing layout organization.
web/src/pages/Home/CourtOverview/Stats.tsx Adjusted styling of StyledCard, removed unused imports, and added isSmallDisplay prop to StatDisplay component.
web/src/pages/Cases/CaseDetails/Appeal/AppealHistory.tsx Changed OptionsContainer from flexbox to grid layout, adjusting item gaps and layout structure.
web/src/pages/Cases/CaseDetails/Appeal/Classic/Options/StageOne.tsx Updated OptionsContainer to use grid layout, modifying item gaps and display properties.
web/src/pages/Cases/CaseDetails/Appeal/Classic/Options/StageTwo.tsx Altered OptionsContainer to grid layout, adjusting gaps and ensuring responsive design.
web/src/utils/userLevelCalculation.ts Added condition to getUserLevelData function to check if criteria.level is greater than 0 before evaluating user disputes, enhancing control flow for user level determination.

Possibly related PRs

Suggested labels

Type: Enhancement :sparkles:, Type: UX

Suggested reviewers

  • alcercu

Poem

🐇 In the garden where changes bloom,
The labels dance, making space to zoom.
Rulings and rewards, a tale to unfold,
With every tweak, new stories told.
A hop, a skip, through code we play,
Enhancements brightening up the day! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6515f02 and e934b3a.

📒 Files selected for processing (1)
  • web/src/pages/Courts/CourtDetails/index.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/src/pages/Courts/CourtDetails/index.tsx

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Dec 10, 2024

Deploy Preview for kleros-v2-testnet-devtools failed. Why did it fail? →

Name Link
🔨 Latest commit 27eea66
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-testnet-devtools/deploys/675868085fa31b0008d50bf2

Copy link

netlify bot commented Dec 10, 2024

Deploy Preview for kleros-v2-testnet ready!

Name Link
🔨 Latest commit 27eea66
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-testnet/deploys/6758680866248a00085e3a8c
😎 Deploy Preview https://deploy-preview-1781--kleros-v2-testnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 10, 2024

Deploy Preview for kleros-v2-neo ready!

Name Link
🔨 Latest commit 27eea66
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-neo/deploys/67586808bd16bd00081905f7
😎 Deploy Preview https://deploy-preview-1781--kleros-v2-neo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 10, 2024

Deploy Preview for kleros-v2-university ready!

Name Link
🔨 Latest commit cb93e87
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-university/deploys/6759b398fac84b00088195f2
😎 Deploy Preview https://deploy-preview-1781--kleros-v2-university.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 10, 2024

Deploy Preview for kleros-v2-neo ready!

Name Link
🔨 Latest commit cb93e87
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-neo/deploys/6759b398e5c0d300085cde02
😎 Deploy Preview https://deploy-preview-1781--kleros-v2-neo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 10, 2024

Deploy Preview for kleros-v2-testnet-devtools failed. Why did it fail? →

Name Link
🔨 Latest commit cb93e87
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-testnet-devtools/deploys/6759b398732c3d0008dcee03

Copy link

netlify bot commented Dec 10, 2024

Deploy Preview for kleros-v2-testnet ready!

Name Link
🔨 Latest commit cb93e87
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-testnet/deploys/6759b398183ebd0008c0717b
😎 Deploy Preview https://deploy-preview-1781--kleros-v2-testnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (2)
web/src/components/Verdict/RulingAndRewardsIndicators.tsx (1)

Line range hint 21-31: Consider using enums for status text and colors.

The implementation looks good and improves status clarity. Consider extracting the status text and colors into enums for better maintainability and reusability.

enum CaseStatus {
  CLOSED = "Case closed",
  IN_PROGRESS = "Case in progress"
}

enum StatusColor {
  CLOSED = "green",
  IN_PROGRESS = "blue"
}
web/src/components/Verdict/FinalDecision.tsx (1)

94-95: Add type safety for rounds array.

Good use of memoization, but consider adding type safety:

const rounds = votingHistory?.dispute?.rounds as Array<{ jurorRewardsDispersed: boolean }> | undefined;
const jurorRewardsDispersed = useMemo(
  () => Boolean(rounds?.every((round) => round.jurorRewardsDispersed)),
  [rounds]
);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 039d745 and e6855c2.

📒 Files selected for processing (4)
  • web/src/components/DisputeView/CardLabels/Label.tsx (1 hunks)
  • web/src/components/Verdict/FinalDecision.tsx (3 hunks)
  • web/src/components/Verdict/RulingAndRewardsIndicators.tsx (2 hunks)
  • web/src/pages/Cases/CaseDetails/Voting/VotingHistory.tsx (0 hunks)
💤 Files with no reviewable changes (1)
  • web/src/pages/Cases/CaseDetails/Voting/VotingHistory.tsx
✅ Files skipped from review due to trivial changes (1)
  • web/src/components/DisputeView/CardLabels/Label.tsx
🔇 Additional comments (2)
web/src/components/Verdict/RulingAndRewardsIndicators.tsx (1)

Line range hint 1-19: LGTM! Clean imports and well-defined interface.

The addition of the Hourglass icon and maintained interface structure align well with the component's enhanced functionality.

web/src/components/Verdict/FinalDecision.tsx (1)

Line range hint 1-24: Verify the necessity of isUndefined utility.

The isUndefined utility is used for null checks. Consider if a direct check would be more straightforward:

!disputeDetails?.dispute?.ruled === undefined

web/src/components/Verdict/FinalDecision.tsx Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
web/src/pages/Courts/CourtDetails/Description.tsx (2)

70-72: Add bounds checking to handleTabChange

The function assumes the index will always be valid, but this might not be true if the tabs array changes.

Consider adding validation:

const handleTabChange = (index: number) => {
+ if (index < 0 || index >= TABS.length) return;
  navigate(TABS[index].path);
};

99-99: Add a comment explaining the newline replacement

The .replace(/\n/g, " \n") operation might not be immediately obvious to other developers.

Consider adding a comment:

const formatMarkdown = (markdown?: string) =>
+ // Add two spaces before newlines to ensure proper markdown line breaks
  markdown ? <ReactMarkdown>{markdown.replace(/\n/g, "  \n")}</ReactMarkdown> : <StyledSkeleton />;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e6855c2 and 772c3a8.

⛔ Files ignored due to path filters (2)
  • web/src/assets/svgs/footer/secured-by-kleros.svg is excluded by !**/*.svg
  • web/src/assets/svgs/header/kleros-court.svg is excluded by !**/*.svg
📒 Files selected for processing (3)
  • web/src/components/Verdict/VerdictBanner.tsx (0 hunks)
  • web/src/layout/Header/navbar/Explore.tsx (1 hunks)
  • web/src/pages/Courts/CourtDetails/Description.tsx (3 hunks)
💤 Files with no reviewable changes (1)
  • web/src/components/Verdict/VerdictBanner.tsx
🔇 Additional comments (4)
web/src/layout/Header/navbar/Explore.tsx (2)

48-48: Verify layout consistency across viewports

The increased horizontal padding (from 8px to 10px) in landscape mode could affect the navbar's overall width and item alignment. Please ensure this change maintains consistent spacing across different screen sizes and doesn't cause wrapping issues.

Let's check for potential layout issues in other navigation-related components:

✅ Verification successful

Based on the search results, I can now generate the final response since I have enough information about the layout styles across the codebase:

Padding change is consistent with landscape mode styling patterns

The padding change from 16px 8px to 16px 10px in Explore.tsx follows the established landscape mode styling patterns across the codebase. The codebase shows consistent use of landscapeStyle for responsive adjustments, with similar padding values used in navigation components. This change maintains visual harmony with other landscape mode styles.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Look for related navigation components and their padding/spacing styles
# to ensure consistency across the codebase

# Search for styled navigation components with padding definitions
rg -l "padding.*px.*px" "web/src/layout/**/nav*.tsx"

# Search for other landscape style applications to verify consistency
ast-grep --pattern 'landscapeStyle($$$)'

Length of output: 46231


Line range hint 8-14: Consider impact of gap removal on mobile layout

The removal of the gap property from the Container component might affect vertical spacing in mobile view. Since this component uses flex-direction: column in mobile view, ensure that the spacing between navigation items remains visually balanced.

Let's check if similar spacing adjustments were made in related components:

✅ Verification successful

Let me gather more specific information about the mobile layout and spacing in the Explore component and its direct siblings.


Let me check the specific styling patterns in the related navbar components to understand the spacing consistency.


Gap removal is properly compensated with margins and padding

The removal of the gap property is not a concern because:

  • Child elements maintain proper spacing through margin-bottom: 8px
  • Elements have appropriate padding (padding: 8px 8px 8px 0 in mobile, padding: 16px 10px in landscape)
  • The spacing pattern is consistent with other navbar components like Menu and DappList which also use a combination of margins and padding for spacing
  • The component properly handles responsive layout transitions between mobile (column) and landscape (row) modes

The visual balance in the mobile view is maintained through these alternative spacing mechanisms.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Look for similar flex container patterns to ensure consistent spacing approach

# Search for flex containers with gap properties
rg "gap:.*px" "web/src/layout"

# Search for similar flex column layouts
ast-grep --pattern 'styled.$_`
  display: flex;
  flex-direction: column;
  $$$
`'

Length of output: 1062


Script:

#!/bin/bash
# Check the Explore component's context and its siblings in the navbar
rg -B 5 -A 10 "const Container = styled" "web/src/layout/Header/navbar/Explore.tsx"

# Check for media queries and responsive styles in the same file
rg "@media|landscapeStyle" "web/src/layout/Header/navbar/Explore.tsx" -A 3

# Check other components in the same navbar directory for spacing patterns
fd "\.tsx$" "web/src/layout/Header/navbar" --exec rg -l "landscapeStyle|@media.*flex"

Length of output: 1126


Script:

#!/bin/bash
# Check styling patterns in related navbar components
rg -B 2 -A 5 "styled\." "web/src/layout/Header/navbar/DappList.tsx" "web/src/layout/Header/navbar/Menu/index.tsx"

# Look for any margin or padding that might be compensating for gap removal
rg "margin|padding" "web/src/layout/Header/navbar/Explore.tsx"

# Check if there are any child components that might handle their own spacing
ast-grep --pattern 'styled.$_`
  $$$
  margin: $_;
  $$$
`' "web/src/layout/Header/navbar/Explore.tsx"

Length of output: 2735

web/src/pages/Courts/CourtDetails/Description.tsx (2)

76-76: LGTM! Well-structured routing logic

The routing implementation properly handles all cases including:

  • Missing policy data
  • Default navigation
  • Consistent fallback behavior

Also applies to: 80-89


64-65: 🛠️ Refactor suggestion

Consider handling invalid path scenarios

The findIndex operation could return -1 if the current path doesn't match any tab paths, which might cause unexpected UI behavior.

Let's verify if there's proper error handling for invalid paths:

Consider adding a default fallback:

- const currentTab = TABS.findIndex(({ path }) => path === currentPathName);
+ const currentTab = TABS.findIndex(({ path }) => path === currentPathName) ?? 0;

Also applies to: 68-69

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
web/src/pages/Home/CourtOverview/ExtraStats.tsx (1)

86-92: Consider adding loading state and extracting messages.

The conditional rendering logic is well-implemented and provides clear feedback. Consider these improvements:

  1. Extract the "No activity in this period" message to a constant/config for maintainability
  2. Add a loading state handler for better UX during data fetching
+ const NO_ACTIVITY_MESSAGE = "No activity in this period";
+
  const ExtraStats = () => {
    const [selectedRange, setSelectedRange] = useState(timeRanges[0].value);
    const data = useHomePageExtraStats(selectedRange);
+   const isLoading = !data.data;

    return (
      <StyledCard>
        <ExtraStatsDisplay
          title="Activity"
          content={/* ... */}
          icon={LawBalance}
        />
+       {isLoading ? (
+         <StyledLabel>Loading...</StyledLabel>
+       ) : data.data?.mostDisputedCourt?.numberDisputes === 0 ? (
-         <StyledLabel>No activity in this period</StyledLabel>
+         <StyledLabel>{NO_ACTIVITY_MESSAGE}</StyledLabel>
        ) : (
          stats.map(/* ... */)
        )}
      </StyledCard>
    );
  };
web/src/hooks/queries/useHomePageBlockQuery.ts (1)

131-132: Good addition of fallback values, consider additional safeguards.

The addition of || 0 fallbacks effectively handles division by zero cases. However, consider adding additional safeguards:

-  const votesPerPnk = Number(court.numberVotes) / (Number(court.effectiveStake) / 1e18) || 0;
-  const disputesPerPnk = Number(court.numberDisputes) / (Number(court.effectiveStake) / 1e18) || 0;
+  const effectiveStakeEth = Number(court.effectiveStake) / 1e18;
+  const votesPerPnk = effectiveStakeEth > 0 ? Number(court.numberVotes) / effectiveStakeEth : 0;
+  const disputesPerPnk = effectiveStakeEth > 0 ? Number(court.numberDisputes) / effectiveStakeEth : 0;

This refactor:

  1. Improves readability by extracting the denominator
  2. Explicitly checks for positive values
  3. Reduces repeated calculations
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 3ec316b and 79aa34a.

📒 Files selected for processing (2)
  • web/src/hooks/queries/useHomePageBlockQuery.ts (2 hunks)
  • web/src/pages/Home/CourtOverview/ExtraStats.tsx (2 hunks)
🔇 Additional comments (2)
web/src/pages/Home/CourtOverview/ExtraStats.tsx (1)

20-24: LGTM! Clean and consistent styling.

The StyledLabel component follows good styling practices with appropriate font size, weight, and spacing.

web/src/hooks/queries/useHomePageBlockQuery.ts (1)

157-158: Consider similar safeguards for difference calculations.

The fallback values are good, but the calculations with average stake could benefit from similar safeguards as suggested above. Additionally, let's verify the usage of these calculations in the codebase.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
web/src/pages/Courts/CourtDetails/Stats.tsx (1)

136-141: Consider using JurorIcon for "Active Jurors"

The icon PNKRedistributedIcon may not accurately represent "Active Jurors". Using JurorIcon would provide a clearer visual representation.

Apply this diff to update the icon:

-    icon: PNKRedistributedIcon,
+    icon: JurorIcon,
web/src/pages/Courts/CourtDetails/index.tsx (1)

75-91: LGTM: Well-structured responsive layout

The new StakePanelAndStats component implements a robust responsive layout using flex and proper spacing. Consider extracting the magic numbers into theme constants for better maintainability.

+ // Consider extracting these to theme constants
- flex: 1 1 calc(50% - 12px);
- max-width: calc(50% - 12px);
+ flex: 1 1 calc(50% - ${theme.spacing.medium});
+ max-width: calc(50% - ${theme.spacing.medium});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 79aa34a and 872c9de.

📒 Files selected for processing (8)
  • web/src/components/StatDisplay.tsx (3 hunks)
  • web/src/layout/Header/navbar/Explore.tsx (0 hunks)
  • web/src/pages/Courts/CourtDetails/StakePanel/InputDisplay.tsx (0 hunks)
  • web/src/pages/Courts/CourtDetails/StakePanel/Simulator/index.tsx (0 hunks)
  • web/src/pages/Courts/CourtDetails/StakePanel/index.tsx (1 hunks)
  • web/src/pages/Courts/CourtDetails/Stats.tsx (5 hunks)
  • web/src/pages/Courts/CourtDetails/index.tsx (4 hunks)
  • web/src/pages/Home/CourtOverview/Stats.tsx (3 hunks)
💤 Files with no reviewable changes (3)
  • web/src/pages/Courts/CourtDetails/StakePanel/Simulator/index.tsx
  • web/src/layout/Header/navbar/Explore.tsx
  • web/src/pages/Courts/CourtDetails/StakePanel/InputDisplay.tsx
🔇 Additional comments (17)
web/src/pages/Courts/CourtDetails/Stats.tsx (7)

1-2: Import statements are correctly updated

The added imports are appropriate and necessary for the component.

Also applies to: 6-6


42-45: Styling adjustments enhance component layout

The padding and margin changes improve the spacing within the StyledAccordion component, leading to a cleaner UI.


57-57: Padding adjustment in AllTimeContainer

The updated padding ensures consistent vertical spacing in the AllTimeContainer.


73-76: New AccordionContainer component added

Introducing the AccordionContainer helps in organizing the accordion items and enhances readability.


79-82: Refactored StyledCard for flexible layout

Changing StyledCard to a flex container with wrapping enhances responsiveness and displays stats effectively on various screen sizes.


98-100: Consistent unit display in stats

Appending units like PNK and ETH to the stats ensures clarity on the values being displayed.

Also applies to: 108-114, 122-125, 131-133, 157-159, 165-168


185-246: Verify the grouping of statistics is accurate

The grouping into "Parameters", "Activity", and "Total Rewards" improves data organization. Ensure that each stat is in the correct group and that the slice indices accurately reflect the intended stats.

web/src/pages/Courts/CourtDetails/StakePanel/index.tsx (2)

22-22: Verify layout changes in landscape orientation

Changing flex-direction to column in landscape mode may affect the user interface. Please verify that the component displays correctly on devices in landscape orientation.


Line range hint 77-77: Removal of width properties improves flexibility

By removing fixed widths, the layout becomes more responsive across different screen sizes.

web/src/components/StatDisplay.tsx (3)

4-15: Responsive adjustments for small displays

The implementation of the isSmallDisplay prop and the corresponding style adjustments enhance the component's adaptability to different screen sizes.

Also applies to: 18-40


43-47: Styled components updated for dynamic styling

Creating StyledTitle, StyledValue, and StyledUSDValue with conditional font sizes based on isSmallDisplay improves text readability on various devices.

Also applies to: 49-60


74-85: Updated StatDisplay component signature

Including the isSmallDisplay prop with a default value ensures backward compatibility while adding new functionality.

Also applies to: 96-101

web/src/pages/Home/CourtOverview/Stats.tsx (3)

2-2: Cleaned up imports

Removing the unused css import from styled-components reduces clutter.


27-28: Adjusted StyledCard spacing

Updating the gap and padding improves the overall layout and visual spacing between elements.


102-102: Explicitly setting isSmallDisplay to false

Specifying isSmallDisplay={false} ensures consistent styling and makes the prop's usage clear.

web/src/pages/Courts/CourtDetails/index.tsx (2)

23-23: LGTM: Import and styling changes

The addition of the Divider component and margin adjustment contribute to a more consistent layout structure.

Also applies to: 37-37


126-130: Verify courtName prop handling

The layout structure looks good, but let's verify the courtName prop handling in case of loading or error states.

✅ Verification successful

From the search results, I can see that the StakePanel component properly handles the courtName prop with a default value:

const StakePanel: React.FC<{ courtName: string }> = ({ courtName = "General Court" }) => {

This shows that:

  1. The prop is properly typed as a required string
  2. There's a default value "General Court" if the prop is undefined
  3. The component has proper type safety

The courtName prop handling is implemented correctly

The component has proper type safety and fallback handling, making it resilient to loading or error states by providing a default value. The layout changes are well-structured and the prop passing is implemented safely.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check StakePanel component for courtName prop handling
ast-grep --pattern 'interface Props {
  $$$
  courtName?: $_
  $$$
}'

# Check for null checks or loading states
ast-grep --pattern 'const StakePanel = ({ courtName }: Props) => {
  $$$
}'

Length of output: 149


Script:

#!/bin/bash
# Let's try a broader search for StakePanel component definition and usage
rg -A 10 "StakePanel" --type tsx

# Also search for any Props or interfaces related to StakePanel
rg "interface.*StakePanel" --type tsx

# Look for courtName prop usage within StakePanel
rg "courtName" --type tsx

Length of output: 182


Script:

#!/bin/bash
# Search for StakePanel component definition and usage without file type restriction
rg -A 10 "StakePanel"

# Look for courtName prop usage
rg "courtName"

# Find all TypeScript/React files that might contain the StakePanel component
fd -e tsx -e ts

Length of output: 87541

@kemuru kemuru marked this pull request as ready for review December 11, 2024 10:04
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
web/src/pages/Cases/CaseDetails/Appeal/Classic/Options/StageOne.tsx (2)

21-23: LGTM! Improved responsive layout implementation.

The transition from flexbox to CSS Grid with auto-fit and minmax provides better responsiveness and consistent card sizing across different screen sizes. The reduced gap also creates a more cohesive visual rhythm.

Consider documenting these spacing values (16px, 250px) in a design system constants file for better maintainability and consistency across components.


Line range hint 39-40: Add proper accessibility attributes to the label element.

The label element should be associated with its form controls using either the htmlFor attribute or by wrapping the form control. This improves screen reader accessibility.

-      <label> Which option do you want to fund? </label>
+      <label id="options-label" className="options-heading"> Which option do you want to fund? </label>
       <OptionsContainer role="radiogroup" aria-labelledby="options-label">
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 872c9de and 97f214a.

📒 Files selected for processing (3)
  • web/src/pages/Cases/CaseDetails/Appeal/AppealHistory.tsx (1 hunks)
  • web/src/pages/Cases/CaseDetails/Appeal/Classic/Options/StageOne.tsx (1 hunks)
  • web/src/pages/Cases/CaseDetails/Appeal/Classic/Options/StageTwo.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • web/src/pages/Cases/CaseDetails/Appeal/AppealHistory.tsx
🔇 Additional comments (1)
web/src/pages/Cases/CaseDetails/Appeal/Classic/Options/StageTwo.tsx (1)

23-25: LGTM! Improved responsive layout implementation.

The transition from flexbox to CSS Grid with auto-fit and minmax provides better responsive behavior. The standardized 16px gap maintains consistency with the design system.

Let's verify the consistency of this layout pattern across related components:

✅ Verification successful

Layout standardization verified across appeal stages

The verification confirms that both StageOne and StageTwo components use identical grid layouts with:

  • display: grid
  • grid-template-columns: repeat(auto-fit, minmax(250px, 1fr))
  • gap: 16px
  • margin-top: 12px

This demonstrates consistent implementation of the responsive grid pattern across appeal stages.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for similar grid layout implementations in related components
# Expected: Should find similar grid layouts in StageOne and AppealHistory

# Search for grid layout implementations
rg -A 3 "display: grid" "web/src/pages/Cases/CaseDetails/Appeal/Classic"

# Search for OptionsContainer styled components
ast-grep --pattern 'const OptionsContainer = styled.$_`
  $$$
`'

Length of output: 912

@kemuru kemuru changed the title refactor: remove indicators from voting tab, move to overview tab, su… feat: new court page design, indicators refactor, court tabs bug fix, statdisplay refactor, appeal tab refactor Dec 11, 2024
@kemuru kemuru changed the title feat: new court page design, indicators refactor, court tabs bug fix, statdisplay refactor, appeal tab refactor feat: new court page design, indicators refactor, court tabs bug fix, statdisplay refactor, appeal tab refactor, add new kleros logo Dec 11, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (1)
web/src/utils/userLevelCalculation.ts (1)

29-35: Consider consolidating level 0 logic with other levels

The separate check for level 0 creates code duplication with similar conditions. Consider refactoring to make the logic more maintainable.

Here's a suggested approach:

export const getUserLevelData = (coherenceScore: number, totalResolvedDisputes: number) => {
- for (const criteria of levelCriteria) {
+ // Sort criteria by level in descending order to prioritize higher levels
+ const sortedCriteria = [...levelCriteria].sort((a, b) => b.level - a.level);
+ for (const criteria of sortedCriteria) {
    if (
-     criteria.level > 0 &&
      totalResolvedDisputes >= criteria.minDisputes &&
      coherenceScore >= criteria.minScore &&
      coherenceScore <= criteria.maxScore
    ) {
      return criteria;
    }
  }

- if (
-   totalResolvedDisputes >= levelCriteria[0].minDisputes &&
-   coherenceScore >= levelCriteria[0].minScore &&
-   coherenceScore <= levelCriteria[0].maxScore
- ) {
-   return levelCriteria[0];
- }

  return levelCriteria.find(({ level }) => level === 1);
};
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 97f214a and 0ae2e08.

📒 Files selected for processing (1)
  • web/src/utils/userLevelCalculation.ts (1 hunks)
🔇 Additional comments (1)
web/src/utils/userLevelCalculation.ts (1)

20-26: Verify the impact of excluding level 0 from the main loop

The addition of criteria.level > 0 changes the evaluation order, making level 0 a special case that's only checked after higher levels. This means a user meeting criteria for both level 0 and a higher level will always get the higher level, which seems intentional but should be verified.

Run the following script to check if this matches the intended behavior:

✅ Verification successful

The level evaluation logic is correctly implemented and intentional

After examining the complete implementation, the separation of level 0 (Diogenes) from the main evaluation loop is correct and well-designed because:

  1. The code first checks for higher levels (1-4) in descending order, which is intentional as it prioritizes assigning the highest level a user qualifies for
  2. Level 0 (Diogenes) is specifically checked afterward for users with low coherence scores (0-49) who have resolved at least 3 disputes
  3. Level 1 (Pythagoras) serves as the default fallback level, which is appropriate as it has no minimum dispute requirement

The logic ensures:

  • Users meeting criteria for multiple levels get the highest one
  • Level 0 is reserved only for those who don't qualify for any higher level but meet its specific criteria
  • Everyone else defaults to Level 1 (Pythagoras)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Look for tests or documentation that might specify the intended level assignment behavior
# Specifically checking if there are test cases for users meeting multiple level criteria

# Search for test files related to user levels
fd -e test.ts -e spec.ts userLevel

# Search for documentation about level assignment rules
rg -i "level.*assignment|user.*level" -g "*.md"

Length of output: 86


Script:

#!/bin/bash
# Let's try a broader search to understand the user level calculation logic

# Find the full implementation of userLevelCalculation.ts
cat web/src/utils/userLevelCalculation.ts

# Search for any test files that might contain "level" in their name
fd -e test.ts -e spec.ts level

# Look for level-related constants or configurations
rg -l "level.*criteria|level.*config" --type ts

# Search for level-related function calls to understand usage
ast-grep --pattern 'getUserLevel($$$)'

Length of output: 1358

web/src/utils/userLevelCalculation.ts Outdated Show resolved Hide resolved
coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 11, 2024
@kemuru kemuru requested a review from alcercu December 11, 2024 10:32
coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 11, 2024
coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 11, 2024
coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 11, 2024
Copy link
Contributor

@alcercu alcercu left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link

codeclimate bot commented Dec 11, 2024

Code Climate has analyzed commit cb93e87 and detected 11 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 10
Style 1

View more on Code Climate.

Copy link

sonarcloud bot commented Dec 11, 2024

@alcercu alcercu added this pull request to the merge queue Dec 11, 2024
Merged via the queue into dev with commit 3c9e792 Dec 11, 2024
20 of 28 checks passed
@kemuru kemuru mentioned this pull request Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect drawing/rewards chance statistic when there is no history of dispute for a court
2 participants