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

chore: ui improvements (detailed inside) #1786

Merged
merged 7 commits into from
Dec 13, 2024
Merged

chore: ui improvements (detailed inside) #1786

merged 7 commits into from
Dec 13, 2024

Conversation

kemuru
Copy link
Contributor

@kemuru kemuru commented Dec 12, 2024

  • render the Kleros logo smaller, we settled on 40px after discussing with our ui designer and trying various sizes.
  • fix appeal icon not showing on the dispute timeline
  • gap adjustments in courtDetails component, improve mobile view too to show 2 stats per line
  • fix the Overview pages margins, since the Escrow V2/Curate V2 disputes were not showing the margins correctly and its because they have an extra dispute template description element that the V2 Beta disputes don't, so these allowed me to debug and fix further
  • updated the stats icons on CourtDetails page, uploaded the rest that weren't present, controlled their heights dynamically since some of them did not adjust correctly due to how they are uploaded on Figma
  • apply a max-width of 1400px instead of what we had. I was testing in very big devices and the components on these looked very weird due to how the screen expands a lot more if we don't cap it to something lower. X and YouTube noticed do it too so its good practice. I tried various sizes and settled on 1400px. it now looks really great on my Desktop computer.
  • on the extra stats, made the courts clickable which leads you to the respective courts.
  • pass the chainId parameter to the usePopulate query since it was failing sometimes, this was the same issue we had on the Verdict query.

PR-Codex overview

This PR primarily focuses on enhancing the styling and layout of various components within the application, including adjustments to paddings, heights, and gaps. It also introduces new constants for landscape styles and modifies some components to improve responsiveness and visual consistency.

Detailed summary

  • Added height: 64px to DesktopHeader and MobileHeader.
  • Adjusted padding in HeaderContainer.
  • Modified gap in PNKLogoAndTitle and other components.
  • Introduced MAX_WIDTH_LANDSCAPE constant.
  • Updated StyledClosedCircle to be exported.
  • Changed max-width to use MAX_WIDTH_LANDSCAPE in several components.
  • Added getCourtId method to IStat interface and utilized it in ExtraStatsDisplay.
  • Replaced StyledLink with Link in Logo component.
  • Enhanced DisputeContext with ExternalLink and styled components.
  • Introduced new icons and adjusted their styles for consistency.

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

Summary by CodeRabbit

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced responsiveness across multiple components by adjusting layout properties to use a dynamic maximum width.
    • Improved functionality of the ExtraStatsDisplay component to link to specific court details.
  • Bug Fixes

    • Improved display of court names in the StakePanel for better adherence to naming conventions.
  • Style

    • Updated maximum width of various components from 1780px to 1400px for a more compact layout.
    • Adjusted padding and spacing in header and other components for improved visual consistency.
    • Modified placeholder text in the EvidenceSearch component for clarity.
    • Reduced horizontal spacing between the logo and title in the Header component.
  • Chores

    • Streamlined component structures by removing unnecessary wrappers and simplifying imports.

Copy link
Contributor

coderabbitai bot commented Dec 12, 2024

Walkthrough

This pull request includes several modifications primarily focused on adjusting the max-width property of various Container styled components across multiple files, changing it from a fixed value of 1780px to a dynamic value sourced from the newly introduced MAX_WIDTH_LANDSCAPE, set to 1400px. Additionally, layout adjustments have been made to components like ErrorFallback, DesktopHeader, and MobileHeader, including changes to padding and height properties. The Logo component has been simplified by removing a styled wrapper, while the StakePanel component now conditionally formats the court name. Overall, these changes aim to enhance the responsiveness and layout of the UI components.

Changes

File Path Change Summary
web/src/components/ErrorFallback.tsx Adjusted max-width from 1780px to MAX_WIDTH_LANDSCAPE in Container.
web/src/layout/Header/DesktopHeader.tsx Introduced a new height property of 64px to Container.
web/src/layout/Header/MobileHeader.tsx Introduced a new height property of 64px to Container.
web/src/layout/Header/Logo.tsx Removed StyledLink, repositioned imports, updated StyledKlerosCourtLogo styles.
web/src/layout/Header/index.tsx Changed HeaderContainer padding from 8px 24px to 0 24px.
web/src/pages/Cases/index.tsx Adjusted max-width from 1780px to MAX_WIDTH_LANDSCAPE in Container.
web/src/pages/Courts/CourtDetails/StakePanel/index.tsx Modified court name display logic in StakePanel.
web/src/pages/Courts/CourtDetails/Stats.tsx Updated imports and adjusted StyledAccordion styling for landscape mode.
web/src/pages/Courts/CourtDetails/index.tsx Adjusted StakePanelAndStats gap from 20px to 16px and modified child elements' flex properties.
web/src/pages/Courts/index.tsx Adjusted max-width from 1780px to MAX_WIDTH_LANDSCAPE in Container.
web/src/pages/Dashboard/index.tsx Adjusted max-width from 1780px to MAX_WIDTH_LANDSCAPE in Container.
web/src/pages/GetPnk/index.tsx Adjusted max-width from 1780px to MAX_WIDTH_LANDSCAPE in Container.
web/src/pages/Home/index.tsx Adjusted max-width from 1780px to MAX_WIDTH_LANDSCAPE in Container.
web/src/pages/Resolver/index.tsx Adjusted max-width from 1780px to MAX_WIDTH_LANDSCAPE in Container.
web/src/pages/Settings/index.tsx Adjusted max-width from 1780px to MAX_WIDTH_LANDSCAPE in Container.
web/src/components/DisputePreview/DisputeContext.tsx Simplified structure by replacing QuestionAndDescription with ReactMarkdownWrapper and updated rendering logic.
web/src/components/ExtraStatsDisplay.tsx Added courtId prop to ExtraStatsDisplay, altering rendering logic based on its presence.
web/src/hooks/queries/usePopulatedDisputeData.ts Added chainId parameter to graphqlBatcher.fetch using DEFAULT_CHAIN.
web/src/pages/Cases/CaseDetails/Evidence/EvidenceSearch.tsx Modified placeholder text in StyledSearchBar.
web/src/pages/Courts/CourtDetails/StakePanel/Simulator/Header.tsx Adjusted gap property in PNKLogoAndTitle styled component.
web/src/pages/Home/CourtOverview/ExtraStats.tsx Introduced getCourtId method in IStat interface for retrieving court IDs.

Possibly related PRs

Suggested labels

Type: Enhancement :sparkles:, Package: Web, Type: UX

Suggested reviewers

  • alcercu
  • Harman-singh-waraich

🐰 In the meadow, changes abound,
With widths adjusted, new heights found.
The headers stand tall, the logos shine bright,
A layout refreshed, a beautiful sight!
Hopping along, we celebrate this cheer,
For every small change brings us near! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9921bc0 and c65acd9.

📒 Files selected for processing (9)
  • web/src/components/ErrorFallback.tsx (1 hunks)
  • web/src/pages/Cases/index.tsx (2 hunks)
  • web/src/pages/Courts/index.tsx (2 hunks)
  • web/src/pages/Dashboard/index.tsx (2 hunks)
  • web/src/pages/GetPnk/index.tsx (2 hunks)
  • web/src/pages/Home/index.tsx (2 hunks)
  • web/src/pages/Resolver/index.tsx (2 hunks)
  • web/src/pages/Settings/index.tsx (1 hunks)
  • web/src/styles/landscapeStyle.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • web/src/styles/landscapeStyle.ts
🚧 Files skipped from review as they are similar to previous changes (8)
  • web/src/pages/Cases/index.tsx
  • web/src/components/ErrorFallback.tsx
  • web/src/pages/GetPnk/index.tsx
  • web/src/pages/Courts/index.tsx
  • web/src/pages/Dashboard/index.tsx
  • web/src/pages/Settings/index.tsx
  • web/src/pages/Resolver/index.tsx
  • web/src/pages/Home/index.tsx

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 12, 2024

Deploy Preview for kleros-v2-neo ready!

Name Link
🔨 Latest commit c65acd9
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-neo/deploys/675c36c939e56e00082f5105
😎 Deploy Preview https://deploy-preview-1786--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 12, 2024

Deploy Preview for kleros-v2-university ready!

Name Link
🔨 Latest commit c65acd9
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-university/deploys/675c36c983bdd900083f04d5
😎 Deploy Preview https://deploy-preview-1786--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 12, 2024

Deploy Preview for kleros-v2-testnet ready!

Name Link
🔨 Latest commit c65acd9
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-testnet/deploys/675c36c95353220008414b5b
😎 Deploy Preview https://deploy-preview-1786--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 12, 2024

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

Name Link
🔨 Latest commit c65acd9
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-testnet-devtools/deploys/675c36c93882c800087a70cc

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 (6)
web/src/layout/Header/Logo.tsx (2)

7-7: Remove unnecessary empty line

This empty line disrupts the logical grouping of imports.

import { Link } from "react-router-dom";
-
import { ArbitratorTypes, getArbitratorType } from "consts/index";

64-64: Remove unnecessary space literal

The {" "} string literal appears to be unnecessary and can be removed.

  <Container>
-    {" "}
    <Link to={"/"}>
web/src/pages/GetPnk/index.tsx (1)

22-22: LGTM! Consistent container width adjustment.

The max-width reduction from 1780px to 1400px aligns with the systematic UI updates across multiple components, maintaining a more compact and consistent layout while preserving the responsive design.

This change is part of a broader design system update that standardizes container widths across the application, improving visual consistency.

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

67-68: Consider optimizing the court name logic.

While the conditional display logic works, it could be optimized for better performance and maintainability.

Consider this optimization:

-          {courtName}
-          {courtName.toLowerCase().endsWith("court") || courtName.toLowerCase().startsWith("corte") ? null : " Court"}
+          {(() => {
+            const lowerName = courtName.toLowerCase();
+            return courtName + (!lowerName.endsWith("court") && !lowerName.startsWith("corte") ? " Court" : "");
+          })()}
web/src/pages/Courts/CourtDetails/Stats.tsx (1)

43-43: LGTM: Responsive padding implementation looks good.

The conditional padding implementation using landscapeStyle is well-structured and aligns with the broader UI improvements mentioned in the PR objectives.

Consider extracting the padding value to a constant or theme variable for better maintainability:

+ const LANDSCAPE_PADDING = '24px';

  ${landscapeStyle(
    () => css`
      > * > div > div {
-       padding: 0 24px;
+       padding: 0 ${LANDSCAPE_PADDING};
      }
    `
  )}

Also applies to: 48-55

web/src/layout/Header/MobileHeader.tsx (1)

Line range hint 22-26: Consider adding transitions for orientation changes

The component is hidden in landscape mode using display: none. Consider adding CSS transitions for smoother orientation changes and ensuring the header height adjustment doesn't cause abrupt layout shifts.

 ${landscapeStyle(
   () => css`
+    transition: all 0.3s ease;
     display: none;
   `
 )}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e8e48f4 and c85d330.

📒 Files selected for processing (15)
  • web/src/components/ErrorFallback.tsx (1 hunks)
  • web/src/layout/Header/DesktopHeader.tsx (1 hunks)
  • web/src/layout/Header/Logo.tsx (3 hunks)
  • web/src/layout/Header/MobileHeader.tsx (1 hunks)
  • web/src/layout/Header/index.tsx (1 hunks)
  • web/src/pages/Cases/index.tsx (1 hunks)
  • web/src/pages/Courts/CourtDetails/StakePanel/index.tsx (1 hunks)
  • web/src/pages/Courts/CourtDetails/Stats.tsx (2 hunks)
  • web/src/pages/Courts/CourtDetails/index.tsx (1 hunks)
  • web/src/pages/Courts/index.tsx (1 hunks)
  • web/src/pages/Dashboard/index.tsx (1 hunks)
  • web/src/pages/GetPnk/index.tsx (1 hunks)
  • web/src/pages/Home/index.tsx (1 hunks)
  • web/src/pages/Resolver/index.tsx (1 hunks)
  • web/src/pages/Settings/index.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (5)
  • web/src/pages/Dashboard/index.tsx
  • web/src/pages/Settings/index.tsx
  • web/src/layout/Header/DesktopHeader.tsx
  • web/src/pages/Cases/index.tsx
  • web/src/pages/Courts/index.tsx
🧰 Additional context used
📓 Learnings (1)
web/src/pages/Courts/CourtDetails/StakePanel/index.tsx (1)
Learnt from: Harman-singh-waraich
PR: kleros/kleros-v2#1775
File: web/src/pages/Courts/CourtDetails/StakePanel/StakeWithdrawButton.tsx:0-0
Timestamp: 2024-12-09T12:36:59.441Z
Learning: In the `StakeWithdrawButton` component, the transaction flow logic is tightly linked to component updates, so extracting it into a custom hook does not provide significant benefits.
🔇 Additional comments (10)
web/src/layout/Header/Logo.tsx (2)

32-34: LGTM! Good approach to logo resizing

The use of max-height with auto width is the correct approach to maintain the logo's aspect ratio while controlling its size.


64-66: LGTM! Good component simplification

The removal of the unnecessary styled wrapper for the Link component improves code maintainability.

web/src/pages/Home/index.tsx (1)

25-25: LGTM! Consistent with application-wide container updates.

The max-width adjustment maintains visual consistency with other pages while preserving the existing layout structure and component hierarchy.

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

67-68: Verify the language-specific court name handling.

The current implementation assumes "corte" as a valid prefix. Please verify if this covers all necessary language variations for court names in the system.

✅ Verification successful

Based on the search results, I can now provide a final response regarding the language-specific court name handling:

The current implementation is sufficient for handling multilingual court names.

The codebase shows that:

  1. Court names are managed through a policy registry system where names are set and stored with their proper localized forms
  2. The check for both "court" suffix and "corte" prefix is appropriate as:
    • It handles English courts with the "Court" suffix
    • It handles Spanish/Portuguese courts with the "Corte" prefix
    • It avoids duplicate suffixes for already properly named courts

The implementation is flexible enough to handle the current multilingual requirements without needing additional language variations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other court name patterns in the codebase
echo "Searching for court name patterns..."
rg -i "court|corte" --type tsx --type ts | grep -i "name.*=.*['\"].*court"

Length of output: 189


Script:

#!/bin/bash
# Search for court name patterns in the codebase using ripgrep
echo "Searching for court name patterns..."
rg -i "court|corte" -t ts -t tsx -C 2

# Also search for any translations or language-specific configurations
echo -e "\nSearching for translation files..."
fd -e json -e yaml -e yml | xargs rg -i "court|corte"

Length of output: 82767


Script:

#!/bin/bash
# Search for court name patterns in the codebase using ripgrep with proper file type recognition
echo "Searching for court name patterns..."
rg -i "court|corte" -g "*.{ts,tsx}" -C 2

# Search for any translation files or language configurations
echo -e "\nSearching for language-specific files..."
fd -e json -e yaml -e yml | xargs rg -i "language|translation|locale"

Length of output: 68243

web/src/components/ErrorFallback.tsx (1)

20-20: LGTM: Consistent max-width standardization

The max-width reduction to 1400px aligns with the standardization being applied across multiple components in the application. This change helps maintain consistent container widths throughout the UI.

web/src/pages/Resolver/index.tsx (1)

41-41: LGTM: Consistent container width adjustment

The max-width reduction to 1400px maintains consistency with other components while preserving the responsive layout of the dispute resolver interface.

✅ Verification successful

LGTM: Verified consistent max-width usage across components

The max-width change to 1400px in the Resolver component is consistent with the established pattern across major page components. All main page containers (Dashboard, Home, Courts, Cases, Settings, GetPnk) use the same 1400px max-width, confirming this is the intended standard width for primary content areas.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistent max-width usage across components
# Look for any remaining instances of 1780px that might have been missed

rg -l "1780px" 'web/src'

Length of output: 22


Script:

#!/bin/bash
# Let's search for various max-width values to understand the pattern
rg "max-width:\s*\d+" web/src

Length of output: 1538

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

80-88: LGTM: Refined spacing in panel layout

The adjustments to gap (20px → 16px) and flex basis calculation (50% - 10px → 50% - 8px) maintain the balanced two-column layout while implementing tighter spacing. These changes align with the PR's objective of layout refinements.

✅ Verification successful

The previous search might have failed because:

  1. The code is using styled-components which might not be recognized as CSS
  2. The gap property might be written in a different format
  3. We should search in the entire web/src directory without type restriction

Let's gather more context about the layout patterns and gap usage.


Based on the search results, I can now verify the gap usage patterns in the codebase:

Gap adjustments align with design system

The change from 20px to 16px gap and corresponding flex basis adjustment (50% - 10px → 50% - 8px) aligns with the common gap values used throughout the codebase:

  • 16px is a frequently used gap value across many components (navbar, forms, cards, etc.)
  • The flex basis calculation consistently follows the pattern of subtracting half the gap value to maintain proper spacing
  • Other components using similar two-column layouts also use 16px gaps

The changes maintain consistency with the established design system patterns.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistent gap usage in similar layouts
# Look for other components using the same pattern to ensure consistency

rg "gap: \d+px" --type css 'web/src'

Length of output: 36


Script:

#!/bin/bash
# Let's try a broader search pattern that includes styled-components syntax
rg "gap:\s*\d+px" web/src

# Also search for the landscapeStyle usage to understand the context better
rg "landscapeStyle" web/src -A 5

Length of output: 65685

web/src/pages/Courts/CourtDetails/Stats.tsx (1)

2-2: LGTM: Import changes are appropriate.

The addition of css from styled-components and landscapeStyle imports are necessary for the new conditional styling implementation.

Also applies to: 4-4

web/src/layout/Header/index.tsx (1)

20-20: Verify header alignment with padding removal

The removal of vertical padding (8px → 0) while maintaining horizontal padding could affect the vertical alignment of header elements. This change should be verified in conjunction with the new fixed heights (64px) in both Desktop and Mobile headers.

✅ Verification successful

Header vertical alignment is properly maintained

The padding removal (8px → 0) in the HeaderContainer is compensated by proper height configurations across header components:

  • Both DesktopHeader and MobileHeader have explicit height: 64px
  • Logo component has controlled height with max-height: 40px
  • Child components maintain their internal spacing with appropriate paddings and margins
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any other padding/margin/height adjustments in header components
rg -t tsx "padding|margin|height" "web/src/layout/Header"

Length of output: 85


Script:

#!/bin/bash
# Search for any other padding/margin/height adjustments in header components
# Using ripgrep without file type filter since .tsx extension isn't recognized
rg "padding|margin|height" "web/src/layout/Header/"

Length of output: 5177

web/src/layout/Header/MobileHeader.tsx (1)

20-20: Consider responsive height adjustments

While setting a fixed height ensures consistency, consider using min-height or making the height responsive for different screen sizes and content lengths. The current fixed height of 64px might be restrictive on smaller devices or with varying content.

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 12, 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: 2

🧹 Outside diff range and nitpick comments (1)
web/src/pages/Courts/CourtDetails/StakePanel/Simulator/Header.tsx (1)

Line range hint 1-65: Consider enhancing component maintainability

While the current implementation is functional, there are a few suggestions to improve maintainability:

  1. Consider extracting magic numbers (32px, 14px) to theme constants
  2. The Last30Days text could be externalized for i18n support

Example implementation:

+ import { useTranslation } from 'react-i18next';
+ import { theme } from 'styles/theme';

const StyledPNKLogo = styled(PNKLogo)`
-  width: 32px;
-  height: 32px;
+  width: ${theme.iconSizes.medium};
+  height: ${theme.iconSizes.medium};
  // ...
`;

const Last30DaysText = styled.p`
  margin: 0;
-  font-size: 14px;
+  font-size: ${theme.typography.sizes.small};
  font-weight: 600;
`;

const Header: React.FC = () => {
+  const { t } = useTranslation();
  return (
    // ...
-        <Last30DaysText>Last 30 Days</Last30DaysText>
+        <Last30DaysText>{t('common.last30Days')}</Last30DaysText>
    // ...
  );
};
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c85d330 and cee02b7.

📒 Files selected for processing (7)
  • web/src/components/DisputePreview/DisputeContext.tsx (2 hunks)
  • web/src/components/ExtraStatsDisplay.tsx (3 hunks)
  • web/src/hooks/queries/usePopulatedDisputeData.ts (2 hunks)
  • web/src/pages/Cases/CaseDetails/Evidence/EvidenceSearch.tsx (1 hunks)
  • web/src/pages/Courts/CourtDetails/StakePanel/Simulator/Header.tsx (1 hunks)
  • web/src/pages/Courts/CourtDetails/StakePanel/index.tsx (2 hunks)
  • web/src/pages/Home/CourtOverview/ExtraStats.tsx (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • web/src/pages/Cases/CaseDetails/Evidence/EvidenceSearch.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/src/pages/Courts/CourtDetails/StakePanel/index.tsx
🧰 Additional context used
📓 Learnings (1)
web/src/hooks/queries/usePopulatedDisputeData.ts (1)
Learnt from: Harman-singh-waraich
PR: kleros/kleros-v2#1703
File: web/src/hooks/queries/usePopulatedDisputeData.ts:58-61
Timestamp: 2024-11-12T04:49:53.174Z
Learning: In `web/src/hooks/queries/usePopulatedDisputeData.ts`, the query and subsequent logic only execute when `disputeData.dispute?.arbitrableChainId` and `disputeData.dispute?.externalDisputeId` are defined, so `initialContext` properties based on these values are safe to use without additional null checks.
🔇 Additional comments (10)
web/src/pages/Courts/CourtDetails/StakePanel/Simulator/Header.tsx (1)

17-17: LGTM! Gap adjustment aligns with design system changes

The reduction in gap from 16px to 12px is consistent with the PR's objective of standardizing spacing across components.

web/src/components/ExtraStatsDisplay.tsx (2)

34-36: LGTM: Styled component follows best practices

The StyledInternalLink component is well-implemented, maintaining consistency with the existing styling patterns.


44-44: Verify the court detail routes

The implementation looks good, but let's ensure the court detail routes are consistently defined across the application.

Also applies to: 50-62

✅ Verification successful

Let me gather more information about the route definitions to ensure completeness of the verification.


Based on the gathered information, I can now provide the final response:

Court route patterns are consistently implemented

The verification shows that court-related routes are consistently implemented across the application:

  • Main courts route pattern /courts/:id is consistently used in links and navigation
  • The parent route courts/* in app.tsx properly handles all court-related routes
  • A special case /court/* exists in the Resolver context, which is a separate feature
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistency in court detail route patterns
# Expected: All court detail routes should follow the pattern '/courts/:id'

# Search for court detail route definitions
rg -g '*.{ts,tsx}' "courts/.*" --type-add 'tsx:*.{ts,tsx}'

# Search for route components handling court details
ast-grep --pattern 'Route $_ path="/courts/$_"'

Length of output: 952


Script:

#!/bin/bash
# Search for all route-related patterns in the codebase
ast-grep --pattern 'Route $_ path=$_'

# Search for any court-related route definitions or constants
rg -g '*.{ts,tsx}' 'const.*[Rr]oute.*court' --type-add 'tsx:*.{ts,tsx}'
rg -g '*.{ts,tsx}' 'path.*court' --type-add 'tsx:*.{ts,tsx}'

Length of output: 464

web/src/pages/Home/CourtOverview/ExtraStats.tsx (1)

90-91: LGTM: Component update is well-implemented

The ExtraStats component correctly implements the new courtId functionality.

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

51-51: LGTM: Chain ID handling is appropriate

The addition of DEFAULT_CHAIN to the graphqlBatcher.fetch call is well-implemented. Based on the retrieved learning, the null checks in this context are properly handled.

web/src/components/DisputePreview/DisputeContext.tsx (5)

17-17: LGTM! Good use of ExternalLink component.

Using the ExternalLink component instead of a regular anchor tag ensures consistent styling and behavior across the application.


69-76: LGTM! Improved markdown content structure.

The separate ReactMarkdownWrapper components for question and description provide better organization and styling control.


79-81: LGTM! Good use of ExternalLink with proper attributes.

The implementation maintains important accessibility attributes (target, rel) while using the consistent ExternalLink component.


88-91: LGTM! Better semantic HTML structure.

The simplified structure using semantic HTML elements (<small> and <label>) improves accessibility and maintainability.


24-28: Consider making ReactMarkdownWrapper more reusable.

The styling for markdown content might be needed in other components. Consider moving this styled component to a shared location if it's used elsewhere in the application.

✅ Verification successful

Let's check if there are existing styled wrappers for markdown content and examine the shared ReactMarkdown component to see if this styling concern is already addressed elsewhere or if it should be consolidated there.


Consider consolidating markdown styling in VotingHistory component

The codebase already has a similar styled wrapper in web/src/pages/Cases/CaseDetails/Voting/VotingHistory.tsx that removes paragraph margins. Instead of creating a new styled component, consider reusing the StyledReactMarkDown from VotingHistory or consolidating both styling needs into that component.

  • web/src/pages/Cases/CaseDetails/Voting/VotingHistory.tsx: Contains StyledReactMarkDown with p { margin: 0; }
  • web/src/components/DisputePreview/DisputeContext.tsx: Your new component with p:first-of-type { margin: 0; }
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if ReactMarkdown is used in other components
rg "ReactMarkdown" -l | grep -v "DisputeContext.tsx"

Length of output: 513


Script:

#!/bin/bash
# Check if similar styled wrappers for ReactMarkdown exist
rg -A 5 "styled.*ReactMarkdown|styled.*markdown" --ignore-case

# Check the shared ReactMarkdown component implementation
cat web/src/components/ReactMarkdown.tsx

Length of output: 4933

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 12, 2024
coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 12, 2024
@kemuru kemuru marked this pull request as ready for review December 13, 2024 00:28
@kemuru kemuru changed the title chore: smaller logo size, dont show court keyword if it ends with it,… chore: ui improvements Dec 13, 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: 0

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

Line range hint 67-116: Consider extracting icon mapping logic

The timeline item generation logic handles multiple icon conditions. Consider extracting the icon mapping into a separate function or constant for better maintainability and readability.

Example approach:

const getTimelineIcon = (
  isLastRound: boolean,
  isRuled: boolean,
  isOverridden: boolean,
  itemType: 'decision' | 'appeal'
) => {
  if (itemType === 'appeal') return StyledClosedCircle;
  if (isLastRound && isRuled && !isOverridden) return ClosedCaseIcon;
  return undefined;
};
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 10db6b7 and 9921bc0.

📒 Files selected for processing (4)
  • web/src/components/StyledIcons/ClosedCircleIcon.tsx (2 hunks)
  • web/src/components/Verdict/DisputeTimeline.tsx (3 hunks)
  • web/src/pages/Courts/CourtDetails/StakePanel/index.tsx (2 hunks)
  • web/src/pages/Courts/CourtDetails/index.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • web/src/pages/Courts/CourtDetails/index.tsx
  • web/src/pages/Courts/CourtDetails/StakePanel/index.tsx
🔇 Additional comments (3)
web/src/components/StyledIcons/ClosedCircleIcon.tsx (1)

5-5: LGTM! Export change enhances component reusability

The export of StyledClosedCircle allows for consistent icon styling across components, which aligns with the PR's objective of maintaining visual consistency.

web/src/components/Verdict/DisputeTimeline.tsx (2)

4-5: LGTM! Import organization enhances code readability

The reorganization of imports and addition of StyledClosedCircle improves code structure while maintaining functionality.

Also applies to: 23-23


105-105: LGTM! Icon replacement maintains visual consistency

The replacement of the appeal status icon with StyledClosedCircle aligns with the PR's objective of maintaining consistent styling across components.

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 13, 2024
@kemuru kemuru requested a review from alcercu December 13, 2024 00:40
@kemuru kemuru changed the title chore: ui improvements chore: ui improvements (detailed inside) Dec 13, 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.

it could be interesting to create a variable for the max width, so that we can easily change it everywhere in case it's needed, other than that, lgtm 👍🏻

Copy link

codeclimate bot commented Dec 13, 2024

Code Climate has analyzed commit c65acd9 and detected 12 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 1
Duplication 11

View more on Code Climate.

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

@alcercu alcercu added this pull request to the merge queue Dec 13, 2024
Merged via the queue into dev with commit 69ff44d Dec 13, 2024
24 of 29 checks passed
@kemuru kemuru deleted the feat/ui-improvements branch December 13, 2024 16:36
@coderabbitai coderabbitai bot mentioned this pull request Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants