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

523-refactor: Widget contribute #601

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Conversation

YulikK
Copy link
Collaborator

@YulikK YulikK commented Oct 10, 2024

What type of PR is this? (select all that apply)

  • πŸ• Feature
  • πŸ› Bug Fix
  • 🚧 Breaking Change
  • πŸ§‘β€πŸ’» Code Refactor
  • πŸ“ Documentation Update

Description

  • move contribute.test.tsx to ui folder
  • replace div's with section and article tags
  • give the imported image better name and change alt attribute to more descriptive
  • remove OptionItem component. Move all the markup inside the contribute component instead
  • make module scss file
  • make file constants
  • update tests

Related Tickets & Documents

Screenshots, Recordings

Please replace this line with any relevant images for UI changes.

Added/updated tests?

  • πŸ‘Œ Yes
  • πŸ™…β€β™‚οΈ No, because they aren't needed
  • πŸ™‹β€β™‚οΈ No, because I need help

[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

    • Introduced a new section for contribution opportunities, including "Mentorship" and roles for developers, coordinators, and trainers.
    • Added a link directing users to a Google Forms page for contributions.
  • Bug Fixes

    • Restructured the Contribute component for improved rendering and user experience.
  • Documentation

    • Updated unit tests for the Contribute component to ensure proper functionality.
  • Chores

    • Removed deprecated files related to the OptionItem component to streamline the codebase.

@YulikK YulikK self-assigned this Oct 10, 2024
@github-actions github-actions bot changed the title Refactor/523 widget contribute 523-refactor: Widget contribute Oct 10, 2024
Copy link

Lighthouse Report:

  • Performance: 94 / 100
  • Accessibility: 100 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

src/widgets/contribute/constants.ts Outdated Show resolved Hide resolved
src/widgets/contribute/constants.ts Outdated Show resolved Hide resolved
src/widgets/contribute/constants.ts Outdated Show resolved Hide resolved
src/widgets/contribute/ui/contribute.module.scss Outdated Show resolved Hide resolved
src/widgets/contribute/ui/contribute.module.scss Outdated Show resolved Hide resolved
src/widgets/contribute/ui/contribute.module.scss Outdated Show resolved Hide resolved
src/widgets/contribute/ui/contribute.module.scss Outdated Show resolved Hide resolved
src/widgets/contribute/ui/contribute.module.scss Outdated Show resolved Hide resolved
src/widgets/contribute/ui/contribute.test.tsx Outdated Show resolved Hide resolved
Copy link

Lighthouse Report:

  • Performance: 83 / 100
  • Accessibility: 100 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

Copy link

Lighthouse Report:

  • Performance: 71 / 100
  • Accessibility: 100 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

Copy link

Lighthouse Report:

  • Performance: 98 / 100
  • Accessibility: 100 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

@Quiddlee Quiddlee marked this pull request as ready for review October 15, 2024 13:09
Copy link

Lighthouse Report:

  • Performance: 84 / 100
  • Accessibility: 100 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

Copy link

coderabbitai bot commented Oct 16, 2024

πŸ“ Walkthrough

Walkthrough

This pull request introduces several changes related to the contribution features of the application. A new file, contribute-options.data.ts, is added to define contribution opportunities. The contribute.tsx component is restructured, with the removal of the OptionItem component and the introduction of new styling through SCSS modules. Additionally, unit tests for the Contribute component are added, while some files related to the OptionItem component are deleted.

Changes

File Path Change Summary
dev-data/contribute-options.data.ts New file added, exporting contributeOptions constant with contribution opportunities.
dev-data/index.ts New export added for contributeOptions.
src/app/const/index.ts New constant BECOME_CONTRIBUTE added in LINKS.
src/widgets/contribute/contribute.test.tsx New unit tests for the Contribute component added.
src/widgets/contribute/ui/contribute.module.scss New SCSS module added with styles for contribute UI components.
src/widgets/contribute/ui/contribute.scss File deleted; contained styles for .contribute component.
src/widgets/contribute/ui/contribute.tsx Component restructured, updated imports, and rendering of contribution options modified.
src/widgets/option-item/index.ts File deleted; previously exported OptionItem component.
src/widgets/option-item/ui/option-item.module.scss File deleted; contained styles for .option-item class.
src/widgets/option-item/ui/option-item.tsx File deleted; contained OptionItem component.

Assessment against linked issues

Objective Addressed Explanation
Refactor contribute.tsx's scss to scss modules (523) βœ…
Replace div's with HTML5 tags (523) βœ…
Remove OptionItem component (523) βœ…
Move contribute.test.tsx to ui folder (523) βœ…

Possibly related PRs

Suggested reviewers

  • dzmitry-varabei
  • andron13
  • natanchik
  • KristiBo
  • ansivgit
  • Quiddlee
  • SpaNb4

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 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 anywhere in the PR title to generate the title automatically.

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

@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: 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

πŸ“₯ Commits

Files that changed from the base of the PR and between b35aa92 and bda5e6a.

πŸ“’ 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.

Comment on lines +54 to +77
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);
},
);
});
});
Copy link

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')}>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

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.

Suggested change
<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';
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

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">
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

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.

Copy link
Collaborator

@SpaNb4 SpaNb4 left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FSD: Widget Contribute
4 participants