-
Notifications
You must be signed in to change notification settings - Fork 9
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
523-refactor: Widget contribute #601
base: main
Are you sure you want to change the base?
Conversation
Lighthouse Report:
|
Lighthouse Report:
|
Lighthouse Report:
|
Lighthouse Report:
|
Lighthouse Report:
|
π WalkthroughWalkthroughThis pull request introduces several changes related to the contribution features of the application. A new file, Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
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? πͺ§ 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
Documentation and Community
|
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 (1)
src/app/const/index.ts (1)
9-10
: LGTM. Minor suggestion for consistency.The addition of
BECOME_CONTRIBUTE
is appropriate. Consider using single quotes for consistency with other entries.BECOME_CONTRIBUTE: - 'https://docs.google.com/forms/d/e/1FAIpQLSdGKdEHK1CnZjgll9PpMU0xD1m0hm6xGoXc98H7woCDulyQkg/viewform', + 'https://docs.google.com/forms/d/e/1FAIpQLSdGKdEHK1CnZjgll9PpMU0xD1m0hm6xGoXc98H7woCDulyQkg/viewform',
π Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
π Files selected for processing (12)
- dev-data/contribute-options.data.ts (1 hunks)
- dev-data/index.ts (1 hunks)
- src/app/const/index.ts (1 hunks)
- src/widgets/contribute/contribute.test.tsx (0 hunks)
- src/widgets/contribute/ui/contribute.module.scss (1 hunks)
- src/widgets/contribute/ui/contribute.scss (0 hunks)
- src/widgets/contribute/ui/contribute.test.tsx (1 hunks)
- src/widgets/contribute/ui/contribute.tsx (2 hunks)
- src/widgets/option-item/index.ts (0 hunks)
- src/widgets/option-item/ui/option-item.module.scss (0 hunks)
- src/widgets/option-item/ui/option-item.test.tsx (0 hunks)
- src/widgets/option-item/ui/option-item.tsx (0 hunks)
π€ Files with no reviewable changes (6)
- src/widgets/contribute/contribute.test.tsx
- src/widgets/contribute/ui/contribute.scss
- src/widgets/option-item/index.ts
- src/widgets/option-item/ui/option-item.module.scss
- src/widgets/option-item/ui/option-item.test.tsx
- src/widgets/option-item/ui/option-item.tsx
π§° Additional context used
π Additional comments (13)
dev-data/contribute-options.data.ts (2)
1-1
: Import statement looks good.
3-18
: Well-structured data for contribution options.The
contributeOptions
array is well-organized and provides clear information for each contribution opportunity. Good use of constants for links.src/widgets/contribute/ui/contribute.module.scss (7)
1-10
: LGTM: Responsive layout for contribute section.Flex layout with responsive adjustments for laptop screens.
12-21
: LGTM: Responsive image handling.Proper use of object-fit for responsive images on mobile.
23-29
: LGTM: Responsive width for info section.Adapts width for different screen sizes.
31-33
: LGTM: Full-width paragraph.Ensures paragraph takes full width of its container.
35-46
: LGTM: Responsive layout for general section.Adapts layout for different screen sizes, especially tablets.
48-60
: LGTM: Responsive layout for contribute options.Adapts layout and alignment for different screen sizes.
62-75
: LGTM: Responsive layout for option items.Adapts max-width and layout for various screen sizes.
dev-data/index.ts (1)
19-19
: New export added correctly.The
contributeOptions
export is properly integrated.β Verification successful
New export verified successfully.
The
contributeOptions
export is correctly used in the codebase.π Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify the new export's usage rg --type typescript 'contributeOptions'Length of output: 75
Script:
#!/bin/bash # Verify the new export's usage with correct file type rg --type ts 'contributeOptions'Length of output: 386
src/widgets/contribute/ui/contribute.test.tsx (3)
1-27
: Imports and mock data are well-structured.The necessary dependencies are imported, and mock data is properly defined.
29-43
: Test setup follows best practices.The beforeEach hook and test IDs for element selection ensure consistent and reliable tests.
45-52
: Main test case covers essential rendering aspects.The test verifies visibility and content of key elements, ensuring proper component rendering.
describe('Paragraph content checks', () => { | ||
test.each(descriptions)('checks that the paragraph contains the text: %s', (description) => { | ||
const matches = paragraph.some((item) => description.test(item.textContent || '')); | ||
|
||
expect(matches).toBe(true); | ||
}); | ||
}); | ||
|
||
describe('Option content checks', () => { | ||
it.each(optionsMock.map((option, index) => [option, index]))( | ||
'renders the correct options content for option %#', | ||
(option, index) => { | ||
const optionElement = options[index]; | ||
const subtitle = within(optionElement).getByTestId('subtitle'); | ||
const description = within(optionElement).getByTestId('paragraph'); | ||
|
||
expect(subtitle).toBeInTheDocument(); | ||
expect(subtitle).toHaveTextContent(option.title); | ||
expect(description).toBeInTheDocument(); | ||
expect(description).toHaveTextContent(option.description); | ||
}, | ||
); | ||
}); | ||
}); |
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.
π οΈ Refactor suggestion
Improve option content checks using Vitest's built-in API.
The content checks are well-structured, but the option content checks can be improved.
Replace the current implementation with Vitest's test.each
:
test.each(optionsMock)('renders the correct options content for %s', (option) => {
const optionElement = screen.getByText(option.title).closest('[data-testid="option-item"]');
const subtitle = within(optionElement).getByTestId('subtitle');
const description = within(optionElement).getByTestId('paragraph');
expect(subtitle).toHaveTextContent(option.title);
expect(description).toHaveTextContent(option.description);
});
This change aligns with the past review comment and simplifies the test structure.
<div className="general"> | ||
<div className="info"> | ||
<section id="contribute" className={cx('container')} data-testid="contribute"> | ||
<div className={cx('contribute', ' content')}> |
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.
Remove extra space in class name
There's an extra space before 'content'
in the className
, which could lead to an unintended class name or styling issues.
Apply this diff to fix the className
:
-<div className={cx('contribute', ' content')}>
+<div className={cx('contribute', 'content')}>
π Committable suggestion
βΌοΈ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
<div className={cx('contribute', ' content')}> | |
<div className={cx('contribute', 'content')}> |
import { WidgetTitle } from '@/shared/ui/widget-title'; | ||
import { OptionItem } from '@/widgets/option-item'; | ||
import { contributeOptions } from 'data'; |
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.
Check the import path of 'contributeOptions'
The import statement import { contributeOptions } from 'data';
may not resolve correctly if 'data'
is not a configured module or alias. Consider specifying the relative path to ensure the module is found.
Apply this diff to correct the import path:
-import { contributeOptions } from 'data';
+import { contributeOptions } from './contribute-options.data';
Committable suggestion was skipped due to low confidence.
linkLabel={linkLabel} | ||
href={href} | ||
/> | ||
<article key={title} className={cx('option-item')} data-testid="option-item"> |
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.
Use unique keys for list items
Using title
as the key may cause issues if titles are not unique. It's recommended to use a unique identifier to prevent potential rendering bugs.
If contributeOptions
includes a unique id
, consider using it as the key:
-{contributeOptions.map(({ title, description, linkLabel, href }) => (
- <article key={title} className={cx('option-item')} data-testid="option-item">
+{contributeOptions.map(({ id, title, description, linkLabel, href }) => (
+ <article key={id} className={cx('option-item')} data-testid="option-item">
Committable suggestion was skipped due to low confidence.
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.
please review the comments from the bot
What type of PR is this? (select all that apply)
Description
Related Tickets & Documents
Screenshots, Recordings
Please replace this line with any relevant images for UI changes.
Added/updated tests?
[optional] Are there any post deployment tasks we need to perform?
[optional] What gif best describes this PR or how it makes you feel?
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Contribute
component for improved rendering and user experience.Documentation
Contribute
component to ensure proper functionality.Chores
OptionItem
component to streamline the codebase.