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

522-refactor: Widget community #577

Merged
merged 13 commits into from
Oct 5, 2024
Merged

Conversation

KristiBo
Copy link
Collaborator

@KristiBo KristiBo commented Sep 30, 2024

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

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

Description

  1. Renamed community to community-media.
  2. Renamed social-media to social-media-item.
  3. Moved the data to community-media.data.tsx.
  4. Added HTML5 tags.
  5. Refactored the community.tsx's scss into scss modules.
  6. Gave the sloth mascote image better name with a descriptive alt attribute.
  7. Moved community.test.tsx to the ui folder.
  8. Update the tests.

Related Tickets & Documents

Screenshots, Recordings

community

Added/updated tests?

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

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a CommunityMedia component showcasing social media links for the Rolling Scopes School.
    • Added a communityGroups constant for easy access to social media details.
  • Improvements

    • Updated styling for community media, ensuring responsiveness and improved layout.
    • Enhanced the Pictures component to utilize the new SocialMediaItem for rendering links.
  • Bug Fixes

    • Removed deprecated Community component and associated exports to streamline the codebase.
  • Tests

    • Added unit tests for the new CommunityMedia component to ensure functionality and rendering accuracy.

Copy link

Lighthouse Report:

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

View detailed report

Copy link

Lighthouse Report:

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

View detailed report

Copy link

Lighthouse Report:

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

View detailed report

@KristiBo KristiBo marked this pull request as ready for review October 1, 2024 11:46
Copy link

coderabbitai bot commented Oct 1, 2024

πŸ“ Walkthrough
πŸ“ Walkthrough

Walkthrough

The changes introduce a new CommunityMedia component to replace the existing Community component, enhancing the representation of social media links associated with the Rolling Scopes School. This includes the addition of a communityGroups data structure, which holds social media information, and updates to various files to reflect the renaming and restructuring of components. The changes also involve the introduction of SCSS modules for styling and unit tests for the new component.

Changes

Files Change Summary
dev-data/community-media.data.tsx Added communityGroups constant with social media data.
dev-data/index.ts Exported communityGroups from community-media.data.tsx.
src/pages/community.tsx Replaced CommunitySection with CommunityMedia.
src/shared/ui/social-media-item/index.ts Exported SocialMediaItem and SocialMediaProps.
src/shared/ui/social-media-item/social-media-item.tsx Renamed SocialMedia to SocialMediaItem; updated import for styles.
src/shared/ui/social-media-item/social-media-item.test.tsx Updated tests to reflect renaming of component.
src/widgets/community-media/index.ts Exported CommunityMedia component.
src/widgets/community-media/ui/community-media.module.scss Added new styles for community media layout.
src/widgets/community-media/ui/community-media.test.tsx Introduced unit tests for CommunityMedia component.
src/widgets/community-media/ui/community-media.tsx Added CommunityMedia component with social media links.
src/widgets/community/index.ts Removed export for Community component.
src/widgets/community/ui/community.tsx Removed Community component.

Assessment against linked issues

Objective Addressed Explanation
Refactor community.tsx's scss to scss modules (522) βœ…
Move community.test.tsx to ui folder (522) βœ…
Replace div's with HTML5 tags (522) ❌ HTML5 tag replacements are not included.
Rename image constant with a better name (522) ❌ No renaming of image constants found.
Add more descriptive alt attribute for the image (522) ❌ No updates to alt attributes found.

Possibly related issues

  • FSD: Widget About-homeΒ #490: The changes in the CommunityMedia component may provide a similar refactoring approach as the about-community component, indicating a potential for shared styling and structure.

Suggested reviewers

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

πŸ“œ Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

πŸ“₯ Commits

Files that changed from the base of the PR and between bc2a289 and 5743a1e.

πŸ“’ Files selected for processing (2)
  • src/widgets/community-media/ui/community-media.test.tsx (1 hunks)
  • src/widgets/community-media/ui/community-media.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/widgets/community-media/ui/community-media.test.tsx
  • src/widgets/community-media/ui/community-media.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 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: 2

🧹 Outside diff range and nitpick comments (7)
src/widgets/community-media/ui/community-media.module.scss (1)

13-19: Consider adding a media query for small screens.

The class handles laptop screens well, but might cause overflow on very small screens.

Add a media query for small screens:

@include media-mobile {
  width: 100%;
  max-width: 640px;
}
src/shared/ui/social-media-item/social-media-item.test.tsx (1)

19-19: Component rendering updated correctly.

Consider updating the test data identifier from 'social-media' to 'social-media-item' for consistency.

dev-data/community-media.data.tsx (1)

10-56: communityGroups constant looks good overall.

The structure is consistent and appropriate for its purpose. Consider adding language codes to all relevant entries for consistency.

Example improvement:

-    title: 'LinkedIn',
+    title: 'LinkedIn EN',
src/widgets/community-media/ui/community-media.tsx (2)

7-7: Consider using an absolute import path for 'data'.

Using relative import paths can lead to maintenance issues as the project grows.

Replace the import with an absolute path:

-import { communityGroups } from 'data';
+import { communityGroups } from '@/data/community-groups';

31-31: Enhance image alt text for better accessibility.

The current alt text is good, but it could be more descriptive to improve accessibility.

Consider updating the alt text:

-<Image className={cx('sloth-mascot')} src={image} alt="A sloth mascot with a welcome" data-testid="welcome-sloth" />
+<Image className={cx('sloth-mascot')} src={image} alt="A friendly sloth mascot welcoming you to the RS Community" data-testid="welcome-sloth" />
src/widgets/community-media/ui/community-media.test.tsx (1)

28-40: Comprehensive content test with room for improvement.

The test covers various aspects of the component's content and structure. Consider adding a test for the href attributes of social media links to ensure they're correctly set.

Add a test for social media link hrefs:

socialMediaItems.forEach((item, index) => {
  expect(item).toHaveAttribute('href', communityGroups[index].link);
});
src/widgets/pictures/ui/pictures.tsx (1)

Line range hint 1-90: Partial refactoring detected.

The changes in this file address the component renaming. However, other objectives mentioned in the PR, such as refactoring SCSS to modules and replacing div elements with HTML5 tags, are not reflected here. Consider completing these tasks for a comprehensive refactor.

πŸ“œ Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

πŸ“₯ Commits

Files that changed from the base of the PR and between 2fb40a4 and 9e8d6f6.

πŸ“’ Files selected for processing (16)
  • dev-data/community-media.data.tsx (1 hunks)
  • dev-data/index.ts (1 hunks)
  • src/pages/community.tsx (2 hunks)
  • src/shared/ui/social-media-item/index.ts (1 hunks)
  • src/shared/ui/social-media-item/social-media-item.test.tsx (2 hunks)
  • src/shared/ui/social-media-item/social-media-item.tsx (2 hunks)
  • src/shared/ui/social-media/index.ts (0 hunks)
  • src/widgets/community-media/index.ts (1 hunks)
  • src/widgets/community-media/ui/community-media.module.scss (1 hunks)
  • src/widgets/community-media/ui/community-media.test.tsx (1 hunks)
  • src/widgets/community-media/ui/community-media.tsx (1 hunks)
  • src/widgets/community/community.test.tsx (0 hunks)
  • src/widgets/community/index.ts (0 hunks)
  • src/widgets/community/ui/community.scss (0 hunks)
  • src/widgets/community/ui/community.tsx (0 hunks)
  • src/widgets/pictures/ui/pictures.tsx (2 hunks)
πŸ’€ Files with no reviewable changes (5)
  • src/shared/ui/social-media/index.ts
  • src/widgets/community/community.test.tsx
  • src/widgets/community/index.ts
  • src/widgets/community/ui/community.scss
  • src/widgets/community/ui/community.tsx
πŸ”‡ Additional comments (19)
src/widgets/community-media/index.ts (1)

1-1: Export looks good.

The export statement is correct and aligns with the PR objectives of renaming components.

src/shared/ui/social-media-item/index.ts (1)

1-1: Looks good.

Correct export syntax. Facilitates clean imports.

src/shared/ui/social-media-item/social-media-item.tsx (2)

5-5: Import path updated correctly.

The import statement now reflects the component's new name.


15-15: Component renamed as per PR objectives.

The renaming improves clarity. Ensure all usages are updated.

Verify component usage:

src/widgets/community-media/ui/community-media.module.scss (2)

1-11: Responsive layout implemented correctly.

The .community-media-content class uses appropriate media queries for different screen sizes.


21-33: Well-structured grid layout with proper responsiveness.

The .social-media-container class implements a flexible grid layout that adapts well to different screen sizes.

src/pages/community.tsx (2)

6-6: Import statement updated correctly.

The import for CommunityMedia has been added, replacing the previous Community (imported as CommunitySection) import. This change is consistent with the PR objectives.


31-31: Component usage updated correctly.

<CommunityMedia /> now replaces <CommunitySection />, maintaining consistency with the import change. This aligns with the PR's renaming objectives.

src/shared/ui/social-media-item/social-media-item.test.tsx (3)

4-4: Import statement updated correctly.


7-7: Test suite description updated appropriately.


Line range hint 1-46: Overall, changes reflect component renaming accurately.

The test file has been updated consistently with the component renaming. Consider updating the test data identifier for full consistency.

dev-data/community-media.data.tsx (1)

1-8: Imports look good.

The necessary icons and types are imported correctly.

dev-data/index.ts (1)

17-17: New export aligns with refactoring goals.

The addition of communityGroups export is consistent and supports the community widget refactoring.

src/widgets/community-media/ui/community-media.tsx (1)

9-11: Styles setup looks good.

The use of CSS modules and classNames binding is appropriate and follows best practices.

src/widgets/community-media/ui/community-media.test.tsx (3)

1-12: Imports and variable declarations look good.

The necessary testing libraries and components are imported, and variables for DOM elements are properly declared.


14-22: Test setup is well-structured.

The describe block and beforeEach hook are used effectively to set up the testing environment for the CommunityMedia component.


24-26: Smoke test is implemented correctly.

The test checks if the component renders without crashing, which is a good baseline test.

src/widgets/pictures/ui/pictures.tsx (2)

15-15: Import change approved.

The import statement now correctly reflects the renamed component and includes the props type.


86-86: Component usage updated correctly.

The SocialMediaItem component is now used consistently. Ensure that the prop types match the new component's expectations.

Copy link

github-actions bot commented Oct 2, 2024

Lighthouse Report:

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

View detailed report

Copy link

github-actions bot commented Oct 2, 2024

Lighthouse Report:

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

View detailed report

@SpaNb4
Copy link
Collaborator

SpaNb4 commented Oct 5, 2024

run visual now

@KristiBo KristiBo merged commit 3482d67 into main Oct 5, 2024
5 checks passed
@KristiBo KristiBo deleted the refactor/522-widget-community branch October 5, 2024 19:57
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 Community
5 participants