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

347-refactor: Fsd widget events #573

Merged
merged 20 commits into from
Oct 10, 2024
Merged

347-refactor: Fsd widget events #573

merged 20 commits into from
Oct 10, 2024

Conversation

LinderJK
Copy link
Collaborator

@LinderJK LinderJK commented Sep 28, 2024

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

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

Description

@widgets/events

  1. Moved events.test.tsx to the ui folder.
  2. Removed unused margins for the title and subtitle.
  3. Moved displayedCardsQuantity, actualEvents, nearestEvents, and rsLifetime to constants.ts.
  4. Deleted the Stub constant and added Image to JSX.
  5. Changed the alt text for the Image.
  6. Removed the type assertion as Event[].
  7. Changed map(i) to map(event).
  8. Added new global constant RS_FOUNDATION_YEAR

Related Tickets & Documents

Screenshots, Recordings

No 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

Summary by CodeRabbit

  • New Features
    • Added a constant for the foundation year and introduced constants for managing event data, including maximum displayed events and logic for filtering upcoming events.
  • Bug Fixes
    • Enhanced responsiveness of the event display layout with improved styling and media queries.
  • Refactor
    • Streamlined data handling in the event component by importing constants instead of defining them within the component.
  • Chores
    • Updated import paths in the test file to reflect the new file organization.

Copy link
Contributor

coderabbitai bot commented Sep 28, 2024

πŸ“ Walkthrough

Walkthrough

The pull request introduces a new constant declaration in src/shared/constants.ts and creates a new constants.ts file in src/widgets/events/ to manage event-related constants. It simplifies the events.tsx component by removing redundant logic and streamlining rendering. Additionally, the styling in events.module.scss is updated for better organization and responsiveness.

Changes

File Change Summary
src/shared/constants.ts Added constant: RS_FOUNDATION_YEAR.
src/widgets/events/constants.ts Added constants: maxUpcomingEventsQuantity, actualEvents, nearestEvents, rsLifetime.
src/widgets/events/ui/events.module.scss Modified class name from .events .content to .events-content, reorganized media queries.
src/widgets/events/ui/events.tsx Removed redundant imports and logic, simplified rendering of EventCard, replaced Stub with inline image.
src/widgets/events/ui/events.test.tsx Updated import path for the Events component.

Assessment against linked issues

Objective Addressed Explanation
Move constants to constants.ts (#[537]) βœ…
Remove stub constant and place Image directly into returned JSX (#[537]) βœ…
Change image alt to more meaningful description (#[537]) ❌ No changes made to the image alt attribute.
Remove as Event[] type casting (#[537]) βœ…
Change map(i) to map(event) (#[537]) βœ…

Suggested reviewers

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

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.

@github-actions github-actions bot changed the title Refactor/347 fsd widget events 347-refactor: Fsd widget events Sep 28, 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 (2)
src/widgets/events/ui/events.tsx (2)

37-37: Image rendering looks good, minor suggestion.

The changes align with the PR objectives. The Stub constant has been removed, and the Image component is now directly incorporated into the JSX with an improved alt text.

Consider extracting the condition !actualEvents.length to a descriptive variable for improved readability:

-{!actualEvents.length && (<Image src={photo3} alt="Speaker presenting at a event" className={cx('event-img')} />)}
+{const noActualEvents = !actualEvents.length;
+noActualEvents && (<Image src={photo3} alt="Speaker presenting at a event" className={cx('event-img')} />)}

39-40: Mapping function improvements look good.

The changes align with the PR objectives. The mapping function now uses a more descriptive parameter name, and unnecessary type casting has been removed.

For consistency with modern JavaScript practices, consider using object property shorthand:

-{(nearestEvents).map((event) => (
-  <EventCard key={event.title} {...event} date={dayjs(event.date).format('DD MMM YYYY')} />
-))}
+{nearestEvents.map((event) => (
+  <EventCard key={event.title} {...event} date={dayjs(event.date).format('DD MMM YYYY')} />
+))}
πŸ“œ Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

πŸ“₯ Commits

Files that changed from the base of the PR and between 2fb40a4 and 3be22b8.

πŸ“’ Files selected for processing (4)
  • src/widgets/events/constants.ts (1 hunks)
  • src/widgets/events/ui/events.module.scss (1 hunks)
  • src/widgets/events/ui/events.test.tsx (1 hunks)
  • src/widgets/events/ui/events.tsx (2 hunks)
πŸ”‡ Additional comments (7)
src/widgets/events/constants.ts (3)

5-5: Constant placement approved.

Matches PR objectives.


6-9: Constant implementation looks good.

Clarify staleAfter unit (days/hours)?


11-11: Nearest events constant approved.

Correctly uses displayedCardsQuantity.

src/widgets/events/ui/events.module.scss (2)

8-8: Width increase for .info class.

The width has been increased from 460px to 640px, allowing for more content.


Line range hint 1-46: Removed margin-top for .title and .subtitle.

Margin-top properties for .title and .subtitle classes have been removed. This may affect vertical spacing.

src/widgets/events/ui/events.tsx (1)

4-4: Import changes look good.

The modifications align with the PR objectives. Unused imports have been removed, and constants are now imported from a separate file, improving code organization.

Also applies to: 10-10

src/widgets/events/ui/events.test.tsx (1)

Line range hint 1-67: Rest of the file looks good.

The existing tests cover various aspects of the Events component thoroughly. No further changes or improvements are necessary.

src/widgets/events/constants.ts Outdated Show resolved Hide resolved
src/widgets/events/ui/events.test.tsx Outdated Show resolved Hide resolved
@LinderJK LinderJK self-assigned this Sep 28, 2024
src/widgets/events/ui/events.module.scss Outdated Show resolved Hide resolved
src/widgets/events/ui/events.tsx Outdated Show resolved Hide resolved
src/widgets/events/ui/events.tsx Outdated Show resolved Hide resolved
src/widgets/events/constants.ts Outdated Show resolved Hide resolved
src/widgets/events/ui/events.tsx Outdated Show resolved Hide resolved
src/widgets/events/ui/events.tsx Outdated Show resolved Hide resolved
Copy link

Lighthouse Report:

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

View detailed report

src/widgets/events/ui/events.tsx Outdated Show resolved Hide resolved
src/widgets/events/constants.ts Outdated Show resolved Hide resolved
src/widgets/events/constants.ts Outdated Show resolved Hide resolved
src/widgets/events/ui/events.test.tsx Outdated Show resolved Hide resolved
Copy link

Lighthouse Report:

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

View detailed report

@LinderJK LinderJK requested review from ansivgit and SpaNb4 September 30, 2024 14:16
src/widgets/events/ui/events.tsx Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Oct 1, 2024

Lighthouse Report:

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

View detailed report

@SpaNb4 SpaNb4 mentioned this pull request Oct 1, 2024
8 tasks
Copy link

github-actions bot commented Oct 2, 2024

Lighthouse Report:

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

View detailed report

src/widgets/events/ui/events.tsx Outdated Show resolved Hide resolved
src/widgets/events/ui/events.tsx Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Oct 2, 2024

Lighthouse Report:

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

View detailed report

@SpaNb4 SpaNb4 marked this pull request as ready for review October 5, 2024 13:27
@SpaNb4
Copy link
Collaborator

SpaNb4 commented Oct 5, 2024

run visual now

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)
src/widgets/events/constants.ts (1)

6-6: Consider renaming for consistency.

Rename maxUpcomingEventsQuantity to maxEventsCount for consistency with other parts of the codebase.

πŸ“œ Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

πŸ“₯ Commits

Files that changed from the base of the PR and between 3be22b8 and 6f1ed2c.

πŸ“’ Files selected for processing (5)
  • src/shared/constants.ts (1 hunks)
  • src/widgets/events/constants.ts (1 hunks)
  • src/widgets/events/ui/events.module.scss (1 hunks)
  • src/widgets/events/ui/events.test.tsx (1 hunks)
  • src/widgets/events/ui/events.tsx (2 hunks)
βœ… Files skipped from review due to trivial changes (1)
  • src/shared/constants.ts
πŸ”‡ Additional comments (14)
src/widgets/events/constants.ts (3)

1-4: Imports look good.

The necessary dependencies are correctly imported.


7-12: Constants implementation looks good.

The actualEvents and nearestEvents are correctly implemented as per the PR objectives.


14-14: rsLifetime calculation looks good.

The constant correctly uses RS_FOUNDATION_YEAR from shared constants, addressing previous concerns about hardcoding.

src/widgets/events/ui/events.module.scss (4)

1-4: Improved class structure.

Simplified class naming and direct application of flexbox properties.


6-11: Width adjustment as discussed.

Width set to 460px with responsive adjustment, aligning with previous review discussion.


14-34: Review .event-img width.

Consider if 500px width for .event-img is appropriate for all viewports between mobile landscape and full width.


37-40: Enhanced responsiveness for medium laptops.

New media query improves layout adaptation for medium laptop screens.

src/widgets/events/ui/events.test.tsx (1)

Line range hint 1-69: Test cases appropriately maintained.

The existing test cases have been preserved, which is correct as the PR doesn't introduce new functionality requiring additional tests.

src/widgets/events/ui/events.tsx (6)

3-3: Import cleanup approved.

Removal of unused Event import aligns with PR objectives.


9-9: Constants import approved.

Import of constants from a separate file improves code organization.


17-18: Class name updates approved.

Simplified article class and updated div classes improve consistency.


32-32: Text update approved.

Updated text provides more specific information about the events.


37-39: Image rendering update approved.

Direct use of Image component and improved alt text enhance code clarity and accessibility.


41-46: Event mapping update approved.

Use of event instead of i and simplified EventCard rendering improve code readability.

src/widgets/events/ui/events.test.tsx Show resolved Hide resolved
@SpaNb4 SpaNb4 merged commit b35aa92 into main Oct 10, 2024
5 checks passed
@SpaNb4 SpaNb4 deleted the refactor/347-fsd-widget-events branch October 10, 2024 08:56
@coderabbitai coderabbitai bot mentioned this pull request Dec 6, 2024
8 tasks
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 Events
6 participants