-
Notifications
You must be signed in to change notification settings - Fork 46
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: add staked pnk per court chart, slightly modify skeleton size, … #1707
Conversation
…abstract barchart
WalkthroughThe changes introduce a new Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
❌ Deploy Preview for kleros-v2-university failed. Why did it fail? →
|
✅ Deploy Preview for kleros-v2-testnet ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
❌ Deploy Preview for kleros-v2-neo failed. Why did it fail? →
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Outside diff range and nitpick comments (2)
web/src/pages/Home/CourtOverview/StakedPNKByCourtsChart.tsx (1)
10-20
: LGTM: Component implementation is clean and focused.The
StakedPNKByCourtsChart
component is well-implemented. It correctly uses the defined interface, transforms the input data appropriately, and renders theBarChart
component with the required props.Consider adding a prop for customizing the chart (e.g., colors, title) to make the component more flexible:
interface IStakedPNKByCourtsChart { data: StakedPNKByCourtsChartData; + chartOptions?: { + colors?: string[]; + title?: string; + }; } -const StakedPNKByCourtsChart: React.FC<IStakedPNKByCourtsChart> = ({ data }) => { +const StakedPNKByCourtsChart: React.FC<IStakedPNKByCourtsChart> = ({ data, chartOptions }) => { const chartData: IBarChartData = { labels: data.labels, data: data.stakes, total: data.totalStake, + ...chartOptions, }; return <BarChart chartData={chartData} />; };This change would allow users of this component to customize the chart appearance if needed.
web/src/pages/Home/CourtOverview/Chart.tsx (1)
103-114
: Consistent rendering and addition of new chart case
- The new case
"stakedPNKPerCourt"
is correctly added to theChartComponent
, renderingStakedPNKByCourtsChart
whenprocessedStakedPNKData
is available.- The
StyledSkeleton
height is consistently set to234
across all cases, ensuring uniformity in the UI.Consider defining a constant for the skeleton height to enhance maintainability and readability.
Apply this suggestion to define a constant:
+const SKELETON_HEIGHT = 234;
Then, replace hardcoded height values:
-<StyledSkeleton height={234} /> +<StyledSkeleton height={SKELETON_HEIGHT} />
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (4)
- web/src/pages/Home/CourtOverview/BarChart.tsx (1 hunks)
- web/src/pages/Home/CourtOverview/CasesByCourtsChart.tsx (2 hunks)
- web/src/pages/Home/CourtOverview/Chart.tsx (3 hunks)
- web/src/pages/Home/CourtOverview/StakedPNKByCourtsChart.tsx (1 hunks)
🧰 Additional context used
🔇 Additional comments (10)
web/src/pages/Home/CourtOverview/StakedPNKByCourtsChart.tsx (3)
1-2
: LGTM: Imports are appropriate.The imports are correct and necessary for the component being created. React is imported for the JSX syntax, and BarChart along with its interface are imported from a local file.
4-4
: LGTM: Type definition is well-structured.The
StakedPNKByCourtsChartData
type is well-defined and appropriately represents the data structure for staked PNK by courts. The naming is clear, and the export allows for reuse in other components if needed.
6-8
: LGTM: Interface is well-defined.The
IStakedPNKByCourtsChart
interface is correctly defined. It uses the previously created type and follows naming conventions. The interface is concise and focused, which contributes to good maintainability.web/src/pages/Home/CourtOverview/CasesByCourtsChart.tsx (3)
1-2
: Good use of the sharedBarChart
componentImporting and reusing the
BarChart
component enhances code reuse and simplifies theCasesByCourtsChart
component.
11-14
:chartData
mapping aligns withIBarChartData
The construction of
chartData
correctly maps the properties fromdata
to match theIBarChartData
interface, ensuring accurate data is passed to theBarChart
component.
17-17
: Component correctly rendersBarChart
withchartData
The return statement properly renders the
BarChart
component, passing the constructedchartData
as a prop.web/src/pages/Home/CourtOverview/Chart.tsx (4)
15-15
: Import statement forStakedPNKByCourtsChart
looks goodThe import of
StakedPNKByCourtsChart
and its associated data typeStakedPNKByCourtsChartData
is correct.
32-32
: Added 'Staked PNK per court' to chart optionsThe new chart option
{ text: "Staked PNK per court", value: "stakedPNKPerCourt" }
is appropriately added toCHART_OPTIONS
.
86-96
: Processing data for 'Staked PNK per court' is correctThe
processedStakedPNKData
is correctly computed by reducingcourtsChartData
. The labels, stakes, and totalStake are accurately calculated using the provided data.
114-114
: Updated dependencies inuseMemo
hookIncluding
processedStakedPNKData
in the dependencies array ensures that the memoizedChartComponent
updates when the data changes.
There was a problem hiding this 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
There was a problem hiding this 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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- web/src/pages/Home/CourtOverview/BarChart.tsx (1 hunks)
🧰 Additional context used
🔇 Additional comments (3)
web/src/pages/Home/CourtOverview/BarChart.tsx (3)
27-35
: Well-defined interfaces for improved type safetyThe interfaces
IBarChartData
andIBarChartProps
are well-structured and provide good type safety for the component. They clearly define the expected shape of the data and props, which will help prevent potential runtime errors and improve code maintainability.
48-94
: Well-configured chart options with consistent stylingThe chart options are comprehensively defined and well-structured. The use of theme values for styling ensures consistency with the overall application design. The configuration for scales, tooltips, and data labels is detailed and should provide a good user experience.
However, please note the previous comment about redundant tooltips configuration, which should be addressed.
96-117
: Clean and efficient render functionThe render function is concise and effectively utilizes the configured options and data. The use of the ChartDataLabels plugin is appropriate for displaying data labels on the chart. The component is correctly exported as the default export, making it easy to import and use in other parts of the application.
Code Climate has analyzed commit c0b259e and detected 2 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
There was a problem hiding this 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/pages/Home/CourtOverview/Header.tsx (1)
17-17
: LGTM: Responsive margin addition improves layout.The addition of a responsive margin-bottom to the
StyledHeader
component is a good improvement. It enhances the layout and spacing of the header, especially on larger screens.Consider adding a comment explaining the purpose of this margin, e.g.:
margin-bottom: ${responsiveSize(16, 0)}; // Adds space below header on larger screensThis would help future developers understand the intent behind this styling decision.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- web/src/pages/Home/CourtOverview/Header.tsx (1 hunks)
🧰 Additional context used
🔇 Additional comments (2)
web/src/pages/Home/CourtOverview/Header.tsx (2)
4-5
: LGTM: Import statement reorganization.Moving the
responsiveSize
import statement to the top of the file improves code organization and readability. This change doesn't affect the functionality and follows good coding practices.
Line range hint
1-37
: Overall assessment: Changes improve code quality and layout.The modifications to this file, including the import statement reorganization and the addition of responsive margin, contribute positively to the codebase. These changes align well with the PR objectives of modifying skeleton sizes and improving overall layout. The use of
responsiveSize
for the margin ensures consistent appearance across different screen sizes, which is a good practice for responsive design.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
...abstract BarChart component
closes #1695
Summary by CodeRabbit
Release Notes
New Features
BarChart
component for visualizing data with a bar chart.StakedPNKByCourtsChart
component for displaying staked PNK data.Chart
component to support a new chart option for "Staked PNK per court."Bug Fixes
CasesByCourtsChart
component by removing complex configurations and delegating chart logic to the newBarChart
component.Style
Header
component with a dynamic margin-bottom style for improved layout consistency.PR-Codex overview
This PR introduces a new chart component for displaying staked PNK data per court, enhances the existing charts, and refactors the code for better organization and readability.
Detailed summary
StakedPNKByCourtsChart
component for displaying staked PNK data.StakedPNKByCourtsChart
inChart
component.CasesByCourtsChart
to useBarChart
component.