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

560-refactor: Widget principles #636

Merged
merged 10 commits into from
Nov 13, 2024
Merged

Conversation

Quiddlee
Copy link
Member

@Quiddlee Quiddlee commented Nov 9, 2024

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

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

Description

Related Tickets & Documents

Screenshots, Recordings

Screenshot 2024-11-09 at 11 31 14β€―PM

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?

gif

Summary by CodeRabbit

  • New Features
    • Introduced a new Principles component to display a list of principle cards.
    • Added support for SVG assets in principle cards, enhancing visual representation.
  • Bug Fixes
    • Updated tests to reflect changes in component structure and data imports.
  • Documentation
    • Added new type definition for PrincipleCard to standardize card properties.
  • Style
    • Restructured CSS for principle cards and principles layout, improving organization and responsiveness.
  • Chores
    • Removed outdated icon components to streamline the codebase.

@Quiddlee Quiddlee self-assigned this Nov 9, 2024
@github-actions github-actions bot changed the title Refactor/560 widget principles 560-refactor: Widget principles Nov 9, 2024
Copy link

Lighthouse Report:

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

View detailed report

Copy link

Lighthouse Report:

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

View detailed report

@Quiddlee Quiddlee marked this pull request as ready for review November 10, 2024 15:36
Copy link
Contributor

coderabbitai bot commented Nov 10, 2024

πŸ“ Walkthrough
πŸ“ Walkthrough

Walkthrough

This pull request introduces several changes across multiple files, primarily focusing on the principleCards entity. A new export for principleCards is added in dev-data/index.ts, and the dev-data/principle-cards.data.tsx file is modified to replace React icon components with SVG assets, updating the card structure. Additionally, the src/widgets/principles directory sees the introduction of a new Principles component, along with related type definitions and styling adjustments. Several old icon components are removed, streamlining the icon usage in the application.

Changes

File Path Change Summary
dev-data/index.ts Added export for principleCards from ./principle-cards.data.tsx.
dev-data/principle-cards.data.tsx Updated imports to use SVG assets; changed cards to principleCards: PrincipleCard[].
src/shared/icons/index.tsx Removed exports for OpenSourcePhilosophyIcon, OpenToEveryoneIcon, and TeachItForwardIcon.
src/shared/icons/open-source-philosophy-icon.tsx Removed component OpenSourcePhilosophyIcon.
src/shared/icons/open-to-everyone-icon.tsx Removed component OpenToEveryoneIcon.
src/shared/icons/teach-It-forward-icon.tsx Removed component TeachItForwardIcon.
src/widgets/principles/index.ts Added export for PrincipleCard type; updated export path for Principles.
src/widgets/principles/types.ts Introduced new type PrincipleCard with properties title, description, and icon.
src/widgets/principles/ui/principle-card/principle-card.module.scss Restructured styles for .principle-card, removed .icon-wrapper, and updated layout to grid.
src/widgets/principles/ui/principle-card/principle-card.tsx Updated imports, replaced PrincipleCardProps with TPrincipleCard, and modified structure.
src/widgets/principles/ui/principle-card/principles.tsx Removed component Principles.
src/widgets/principles/ui/principles/principles.module.scss Simplified CSS hierarchy by removing nested .content styles.
src/widgets/principles/ui/principles/principles.test.tsx Updated tests to use principleCards instead of cards and adjusted assertions accordingly.
src/widgets/principles/ui/principles/principles.tsx Introduced new Principles component to render principle cards.

Assessment against linked issues

Objective Addressed Explanation
Refactor principles.tsx and related SCSS files (##560) βœ…
Create principles folder and move related pieces (##560) βœ…
Replace div with HTML5 tags in principles.tsx (##560) βœ…
Replace interface with type in principle-card.tsx (##560) βœ…
Move type to types.ts and rename to PrincipleCard (##560) βœ…

Possibly related issues

Suggested reviewers

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

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

πŸ”§ eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

dev-data/index.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-boundaries".

(The package "eslint-plugin-boundaries" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-boundaries@latest --save-dev

The plugin "eslint-plugin-boundaries" was referenced from the config file in " Β» @feature-sliced/eslint-config Β» /node_modules/@feature-sliced/eslint-config/rules/layers-slices".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.


πŸ“œ Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 95da89e and 89c45ed.

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

1-1: Remove the .ts file extension from the import path.

TypeScript resolves .ts extensions automatically, and including them is not a common practice.

-export type { PrincipleCard } from './types.ts';
+export type { PrincipleCard } from './types';

2-2: Consider simplifying the component path.

The export path looks good, but contains a redundant "principles" segment. Consider simplifying it.

-export { Principles } from './ui/principles/principles';
+export { Principles } from './ui/principles';
src/widgets/principles/types.ts (1)

3-7: Consider adding JSDoc comments for better documentation.

The type definition is clean and well-structured. To improve maintainability, consider adding JSDoc comments to document the purpose of each property.

+/**
+ * Represents a principle card with title, description, and icon.
+ */
 export type PrincipleCard = {
+  /** The title of the principle card */
   title: string;
+  /** The description explaining the principle */
   description: string;
+  /** The icon to be displayed with the principle */
   icon: ReactNode;
 };
src/widgets/principles/ui/principle-card/principle-card.tsx (1)

10-15: Consider adding error boundary for icon rendering.

While the implementation is solid with semantic HTML and proper component composition, the direct rendering of the icon prop could benefit from error handling.

-    <span className={cx('icon')}>{icon}</span>
+    <span className={cx('icon')}>
+      {React.isValidElement(icon) ? icon : null}
+    </span>
src/widgets/principles/ui/principles/principles.tsx (1)

3-3: Remove file extension from import path

The .tsx extension in the import statement is unnecessary and non-standard in TypeScript/React projects.

-import { PrincipleCard } from '@/widgets/principles/ui/principle-card/principle-card.tsx';
+import { PrincipleCard } from '@/widgets/principles/ui/principle-card/principle-card';
src/widgets/principles/ui/principles/principles.test.tsx (1)

Line range hint 20-26: Consider enhancing test coverage

While the basic visibility checks are good, consider adding assertions for:

  • Correct order of cards
  • Proper HTML structure
  • Accessibility attributes
 principleCards.forEach(({ title, description }, index) => {
   const titleElement = screen.getByText(title);
   const descriptionElement = screen.getByText(description);
 
   expect(titleElement).toBeVisible();
   expect(descriptionElement).toBeVisible();
+  expect(titleElement).toHaveAttribute('role', 'heading');
+  const card = screen.getAllByTestId('principle-card')[index];
+  expect(card).toContainElement(titleElement);
+  expect(card).toContainElement(descriptionElement);
 });
dev-data/principle-cards.data.tsx (1)

12-12: Add width and height props to Image components

While the Image implementation is good, adding explicit dimensions would prevent layout shifts during loading.

-    icon: <Image src={openToEveryoneIcon} alt="" aria-hidden="true" />,
+    icon: <Image src={openToEveryoneIcon} alt="" aria-hidden="true" width={24} height={24} />,

Also applies to: 18-18, 24-24

src/widgets/principles/ui/principle-card/principle-card.module.scss (1)

60-81: Consider extracting magic numbers to variables.

The icon dimensions and blur values should be defined as SCSS variables for consistency and maintainability.

+ $icon-size: 44px;
+ $accent-size: 20px;
+ $accent-blur: 8px;

  .icon {
    img {
-     width: 44px;
-     height: 44px;
+     width: $icon-size;
+     height: $icon-size;
    }

    &::before {
-     width: 20px;
-     height: 20px;
+     width: $accent-size;
+     height: $accent-size;
      filter: blur($accent-blur);
    }
  }
πŸ“œ Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 86e1188 and 95da89e.

πŸ“’ Files selected for processing (14)
  • dev-data/index.ts (1 hunks)
  • dev-data/principle-cards.data.tsx (1 hunks)
  • src/shared/icons/index.tsx (0 hunks)
  • src/shared/icons/open-source-philosophy-icon.tsx (0 hunks)
  • src/shared/icons/open-to-everyone-icon.tsx (0 hunks)
  • src/shared/icons/teach-It-forward-icon.tsx (0 hunks)
  • src/widgets/principles/index.ts (1 hunks)
  • src/widgets/principles/types.ts (1 hunks)
  • src/widgets/principles/ui/principle-card/principle-card.module.scss (4 hunks)
  • src/widgets/principles/ui/principle-card/principle-card.tsx (1 hunks)
  • src/widgets/principles/ui/principle-card/principles.tsx (0 hunks)
  • src/widgets/principles/ui/principles/principles.module.scss (1 hunks)
  • src/widgets/principles/ui/principles/principles.test.tsx (3 hunks)
  • src/widgets/principles/ui/principles/principles.tsx (1 hunks)
πŸ’€ Files with no reviewable changes (5)
  • src/shared/icons/index.tsx
  • src/shared/icons/open-source-philosophy-icon.tsx
  • src/shared/icons/open-to-everyone-icon.tsx
  • src/shared/icons/teach-It-forward-icon.tsx
  • src/widgets/principles/ui/principle-card/principles.tsx
βœ… Files skipped from review due to trivial changes (1)
  • src/widgets/principles/ui/principles/principles.module.scss
πŸ”‡ Additional comments (11)
src/widgets/principles/types.ts (1)

1-1: LGTM! Clean and necessary import.

The ReactNode import is appropriate for typing the icon property.

src/widgets/principles/ui/principle-card/principle-card.tsx (1)

1-8: LGTM! Well-structured imports and setup.

The imports are well-organized, utilizing shared UI components and proper CSS module binding.

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

10-23: LGTM! Well-structured component implementation

The component follows React best practices with:

  • Proper semantic HTML usage
  • Efficient list rendering with unique keys
  • Clean CSS module implementation
src/widgets/principles/ui/principles/principles.test.tsx (1)

3-4: LGTM: Import changes align with restructuring

The updated imports correctly reflect the new data source structure.

dev-data/principle-cards.data.tsx (2)

1-5: LGTM: Clean import organization

The switch to SVG assets with Next.js Image component is a good optimization choice.


7-7: LGTM: Improved type and naming

The rename to principleCards and type update to PrincipleCard improve code clarity.

src/widgets/principles/ui/principle-card/principle-card.module.scss (4)

7-9: LGTM: Grid layout improves structure.

The switch to grid layout with explicit column sizing provides better structure and maintainability.


20-33: Consider performance impact of blur effect.

The blur effect using filter: blur(32px) on a large element (310x300px) might impact rendering performance on lower-end devices.

Consider:

  1. Reducing the blur radius
  2. Using a smaller element size
  3. Adding will-change: filter if animations are involved

48-51: Skip z-index review.

The z-index usage has been previously discussed and justified with visual evidence.


111-114: LGTM: Responsive adjustments are appropriate.

The font-size and line-height adjustments for laptop viewports are reasonable.

dev-data/index.ts (1)

58-58: LGTM! Clean export statement.

The new export for principleCards is properly placed and follows the established patterns in the file.

Copy link

Lighthouse Report:

  • Performance: 67 / 100
  • Accessibility: 99 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

Copy link

Lighthouse Report:

  • Performance: 70 / 100
  • Accessibility: 99 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

@Quiddlee Quiddlee merged commit 2642a10 into main Nov 13, 2024
3 checks passed
@Quiddlee Quiddlee deleted the refactor/560-widget-principles branch November 13, 2024 07:31
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 Principles
4 participants