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

561-refactor: Fsd widget required #682

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

Conversation

Quiddlee
Copy link
Member

@Quiddlee Quiddlee commented Dec 7, 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

Rolling Scopes Community Β· 11 39pm Β· 12-07

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

  • New Features

    • Introduced a refreshed course module display that streamlines content presentation.
    • Updated the course requirements view to offer a clearer overview.
  • Style

    • Enhanced search input appearance with improved focus effects.
    • Refined trainer card visuals with a modern shadow effect.
    • Applied consistent UI styling across various interactive components for a unified look.

@github-actions github-actions bot changed the title Refactor/561 fsd widget required 561-refactor: Fsd widget required Dec 7, 2024
@Quiddlee
Copy link
Member Author

Quiddlee commented Dec 7, 2024

run visual now

Copy link

github-actions bot commented Dec 7, 2024

Lighthouse Report:

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

View detailed report

Copy link

github-actions bot commented Feb 2, 2025

Lighthouse Report:

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

View detailed report

@Quiddlee
Copy link
Member Author

Quiddlee commented Feb 2, 2025

run visual now

@Quiddlee
Copy link
Member Author

Quiddlee commented Feb 2, 2025

run visual now

Copy link

github-actions bot commented Feb 2, 2025

Lighthouse Report:

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

View detailed report

Copy link

github-actions bot commented Feb 9, 2025

Lighthouse Report:

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

View detailed report

Copy link

github-actions bot commented Feb 9, 2025

Lighthouse Report:

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

View detailed report

@Quiddlee Quiddlee requested a review from Copilot February 9, 2025 13:24

Choose a reason for hiding this comment

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

Copilot reviewed 16 out of 31 changed files in this pull request and generated no comments.

Files not reviewed (15)
  • src/app/docs/components/search/search.module.scss: Language not supported
  • src/core/base-layout/components/header/dropdown/dropdown-wrapper.module.scss: Language not supported
  • src/core/base-layout/components/header/nav-item/nav-item.module.scss: Language not supported
  • src/core/styles/_mixins.scss: Language not supported
  • src/core/styles/normalize.scss: Language not supported
  • src/entities/course/ui/course-card/course-card.module.scss: Language not supported
  • src/entities/event/ui/event-card/event-card.module.scss: Language not supported
  • src/entities/trainer/ui/trainers-card/trainer-card.module.scss: Language not supported
  • src/shared/ui/social-media-item/social-media-item.module.scss: Language not supported
  • src/widgets/about-course/ui/about-course-grid/about-course-grid.module.scss: Language not supported
  • src/widgets/benefits/ui/benefits/benefits.module.scss: Language not supported
  • src/widgets/communication/ui/communication.module.scss: Language not supported
  • src/widgets/member-activity/ui/stage-card/step/step.scss: Language not supported
  • src/views/aws-developer.tsx: Evaluated as low risk
  • src/views/aws-devops.tsx: Evaluated as low risk
@SpaNb4 SpaNb4 marked this pull request as ready for review February 9, 2025 16:39
Copy link
Contributor

coderabbitai bot commented Feb 9, 2025

πŸ“ Walkthrough

Walkthrough

This pull request makes several refactoring changes. It updates import paths for types (e.g., Course and LinkList) by replacing references to the old required.types path with a new one. Multiple SCSS files are modified through removals, reordering, or reintroduction of style properties. In addition, the widget Required is refactored: view files no longer pass extra boolean props and the old Required component is removed in favor of a newly implemented one in the required subfolder. A new CourseModuleElement component is also introduced to modularize course module display.

Changes

File(s) Change Summary
dev-data/courseTitles.data.ts, src/shared/types.ts, src/shared/ui/text-with-link/text-with-link.tsx, src/widgets/required/index.ts, src/widgets/required/types.ts Updated import/export paths for Course and LinkList types; adjusted type export (removed export on Description) to reflect the new module structure.
src/app/docs/components/search/search.module.scss, src/core/base-layout/components/header/dropdown/dropdown-wrapper.module.scss, src/core/base-layout/components/header/nav-item/nav-item.module.scss, src/core/styles/_mixins.scss, src/core/styles/normalize.scss, src/entities/course/ui/course-card/course-card.module.scss, src/entities/event/ui/event-card/event-card.module.scss, src/entities/trainer/ui/trainers-card/trainer-card.module.scss, src/shared/ui/social-media-item/social-media-item.module.scss, src/widgets/about-course/ui/about-course-grid/about-course-grid.module.scss, src/widgets/benefits/ui/benefits/benefits.module.scss, src/widgets/communication/ui/communication.module.scss, src/widgets/member-activity/ui/stage-card/step/step.scss, src/widgets/places/ui/places/places.module.scss, src/widgets/principles/ui/principle-card/principle-card.module.scss, src/widgets/required/ui/course-module/course-module.module.scss, src/widgets/required/ui/required/required.module.scss, (deleted: src/widgets/required/ui/required.scss) Various style adjustments including border removals/additions, reordering of CSS properties, introduction of new helper classes, and reintroduction of background colors to restore intended UI presentation.
src/views/angular.tsx, src/views/aws-developer.tsx, src/views/aws-devops.tsx, src/views/aws-fundamentals.tsx, src/widgets/required/ui/required/required.test.tsx, src/widgets/required/ui/required.tsx, src/widgets/required/ui/required/required.tsx Removed the extra marked boolean props from Required invocations in view components; removed the obsolete Required component (required.tsx) and introduced a new Required component in the required subfolder; updated the test file’s import path and removed redundant comments.
src/widgets/required/ui/course-module/course-module.tsx, src/widgets/required/ui/course-module/course-module.module.scss Introduced a new CourseModuleElement component with dedicated props to render a course module’s title and description, along with new styling classes for spacing and layout.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant R as Required Component
    participant D as courseDataMap
    participant WT as WidgetTitle
    participant L as List
    participant CME as CourseModuleElement

    U->>R: Provide courseName prop
    R->>D: Retrieve course data for courseName
    D-->>R: Return { title, knowBefore, willLearn }
    alt knowBefore exists
        R->>WT: Render knowBefore section
        R->>L: Render knowBefore list
    end
    alt willLearn exists
        loop each willLearn item
            R->>CME: Render CourseModuleElement
        end
    end
    R-->>U: Rendered UI
Loading
sequenceDiagram
    participant U as User
    participant CME as CourseModuleElement
    participant S as Subtitle
    participant L as List

    U->>CME: Provide courseModule prop
    CME->>S: Render courseModule.title
    CME->>L: Render courseModule.description list
    CME-->>U: Rendered module element
Loading

Assessment against linked issues

Objective (from #561) Addressed Explanation
Required module SCSS refactor – remove parent selectors, use variables, replace element selectors (e.g. img β†’ .image) ❓ New required module SCSS introduces new classes but does not clearly indicate removal of parent selectors or replacement of tag selectors with class selectors as specified.
Required component refactor – replace divs with HTML5 tags, use type instead of interface, remove ternary operator inside return ❓ A new Required component is added but the summary does not confirm the use of semantic HTML5 tags or removal of ternary operators.
Test file refactor – move test file to ui folder and remove all comments βœ… The test file has its import path updated and the comment was removed.
Rename required.types.ts and move LinkList to shared/types.ts ❌ Import paths were updated but LinkList remains imported from '@/widgets/required/types' rather than from shared/types.ts.

Possibly related PRs

Suggested reviewers

  • andron13
  • dzmitry-varabei
  • natanchik
  • ansivgit
  • KristiBo
✨ Finishing Touches
  • πŸ“ Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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

🧹 Nitpick comments (2)
src/widgets/required/types.ts (1)

1-21: Consider adding JSDoc comments for better documentation.

The type hierarchy is well-structured and follows TypeScript best practices. Consider adding JSDoc comments to document the purpose of each type, especially for the exported ones.

+/** Represents an item with a clickable link and associated text */
 type ItemWithLink = {
   id: number;
   text: string;
   title: string;
   link: string;
 };

+/** List of items with links */
 export type LinkList = ItemWithLink[];

 type Description = (string | LinkList)[];

+/** Represents a module within a course with a title and description */
 export type CourseModule = {
   title: string;
   description: Description;
 };

+/** Represents a course with optional prerequisites and learning objectives */
 export type Course = {
   title: string;
   knowBefore?: CourseModule;
   willLearn?: CourseModule[];
 };
src/widgets/required/ui/course-module/course-module.tsx (1)

15-26: Consider adding optional className prop for better customization.

The component is well-structured but could benefit from allowing custom class names.

 type CourseModuleElementProps = {
   courseModule: CourseModule;
+  className?: string;
 };

-export function CourseModuleElement({ courseModule }: CourseModuleElementProps) {
+export function CourseModuleElement({ courseModule, className }: CourseModuleElementProps) {
   const { title, description } = courseModule;

   return (
-    <article className={cx('course-module-element')}>
+    <article className={cx('course-module-element', className)}>
πŸ“œ Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 78db4a9 and 6245f4d.

πŸ“’ Files selected for processing (31)
  • dev-data/courseTitles.data.ts (1 hunks)
  • src/app/docs/components/search/search.module.scss (1 hunks)
  • src/core/base-layout/components/header/dropdown/dropdown-wrapper.module.scss (1 hunks)
  • src/core/base-layout/components/header/nav-item/nav-item.module.scss (1 hunks)
  • src/core/styles/_mixins.scss (1 hunks)
  • src/core/styles/normalize.scss (1 hunks)
  • src/entities/course/ui/course-card/course-card.module.scss (2 hunks)
  • src/entities/event/ui/event-card/event-card.module.scss (3 hunks)
  • src/entities/trainer/ui/trainers-card/trainer-card.module.scss (1 hunks)
  • src/shared/types.ts (1 hunks)
  • src/shared/ui/social-media-item/social-media-item.module.scss (1 hunks)
  • src/shared/ui/text-with-link/text-with-link.tsx (2 hunks)
  • src/views/angular.tsx (1 hunks)
  • src/views/aws-developer.tsx (1 hunks)
  • src/views/aws-devops.tsx (1 hunks)
  • src/views/aws-fundamentals.tsx (1 hunks)
  • src/widgets/about-course/ui/about-course-grid/about-course-grid.module.scss (1 hunks)
  • src/widgets/benefits/ui/benefits/benefits.module.scss (2 hunks)
  • src/widgets/communication/ui/communication.module.scss (1 hunks)
  • src/widgets/member-activity/ui/stage-card/step/step.scss (1 hunks)
  • src/widgets/places/ui/places/places.module.scss (0 hunks)
  • src/widgets/principles/ui/principle-card/principle-card.module.scss (3 hunks)
  • src/widgets/required/index.ts (1 hunks)
  • src/widgets/required/types.ts (1 hunks)
  • src/widgets/required/ui/course-module/course-module.module.scss (1 hunks)
  • src/widgets/required/ui/course-module/course-module.tsx (1 hunks)
  • src/widgets/required/ui/required.scss (0 hunks)
  • src/widgets/required/ui/required.tsx (0 hunks)
  • src/widgets/required/ui/required/required.module.scss (1 hunks)
  • src/widgets/required/ui/required/required.test.tsx (1 hunks)
  • src/widgets/required/ui/required/required.tsx (1 hunks)
πŸ’€ Files with no reviewable changes (3)
  • src/widgets/places/ui/places/places.module.scss
  • src/widgets/required/ui/required.scss
  • src/widgets/required/ui/required.tsx
βœ… Files skipped from review due to trivial changes (18)
  • src/widgets/about-course/ui/about-course-grid/about-course-grid.module.scss
  • src/widgets/required/index.ts
  • dev-data/courseTitles.data.ts
  • src/widgets/member-activity/ui/stage-card/step/step.scss
  • src/widgets/communication/ui/communication.module.scss
  • src/entities/course/ui/course-card/course-card.module.scss
  • src/core/base-layout/components/header/dropdown/dropdown-wrapper.module.scss
  • src/shared/ui/social-media-item/social-media-item.module.scss
  • src/shared/types.ts
  • src/core/styles/normalize.scss
  • src/core/styles/_mixins.scss
  • src/core/base-layout/components/header/nav-item/nav-item.module.scss
  • src/widgets/benefits/ui/benefits/benefits.module.scss
  • src/entities/trainer/ui/trainers-card/trainer-card.module.scss
  • src/shared/ui/text-with-link/text-with-link.tsx
  • src/widgets/required/ui/course-module/course-module.module.scss
  • src/entities/event/ui/event-card/event-card.module.scss
  • src/widgets/principles/ui/principle-card/principle-card.module.scss
πŸ”‡ Additional comments (9)
src/widgets/required/types.ts (1)

10-10: Verify removal of export for Description type.

The removal of the export modifier for the Description type is a good encapsulation practice since it's only used internally by CourseModule. However, let's verify that this change doesn't break any existing imports.

βœ… Verification successful

🏁 Script executed:

#!/bin/bash
# Search for any remaining imports of the Description type
rg "import.*Description.*from.*required/types"

Length of output: 48


I'm running an enhanced search to confirm that there are no remaining imports of the Description type. Please allow a moment for the updated check.


🏁 Script executed:

#!/bin/bash
# Search for any import statements referencing the Description type
rg -n "import\s*\{[^}]*\bDescription\b[^}]*\}\s*from\s*['\"]src/widgets/required/types['\"]"

Length of output: 98


Final Verification: Removal of the export for the Description type is safe.

No external imports of Description were found, confirming this internal refactoring aligns with our encapsulation goals.

src/widgets/required/ui/course-module/course-module.tsx (1)

11-13: LGTM! Well-defined prop type.

The CourseModuleElementProps type is clear and focused.

src/views/aws-devops.tsx (1)

24-24: LGTM! Simplified Required component usage.

Removal of marked1 prop aligns with the refactoring objectives.

src/views/aws-fundamentals.tsx (1)

23-23: LGTM! Consistent with other view changes.

Removal of marked2 prop maintains consistency with the refactoring pattern.

src/views/aws-developer.tsx (1)

28-28: LGTM! Verify prop removal across all views.

The change maintains consistency with other views.

βœ… Verification successful

🏁 Script executed:

#!/bin/bash
# Verify Required component usage is consistent across all views
rg -l '<Required.*marked[12]' src/views/

Length of output: 42


I'll run an additional script to view all usages of the Required component in src/views and check if any instance still includes "marked" properties (e.g., marked1 or marked2).


🏁 Script executed:

#!/bin/bash
echo "Searching for all Required component usages in src/views:"
rg '<Required ' src/views/ > usage.txt && cat usage.txt

echo "Checking if any of these lines include 'marked':"
grep -E 'marked1|marked2' usage.txt || echo "No 'marked1' or 'marked2' props found."

Length of output: 984


Verification Complete: Removal of marked props is consistent across views.

  • The script confirms that no instances of "marked1" or "marked2" are present in any Usage of the Required component.
  • All views use the component in the form <Required courseName={courseName} />.
src/views/angular.tsx (1)

31-31: LGTM! Prop removal aligns with widget refactor.

The removal of the marked1 prop simplifies the component's interface.

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

4-4: LGTM! Import path updated correctly.

The import path change aligns with the new component structure.

src/widgets/required/ui/required/required.module.scss (1)

1-26: LGTM! Well-structured responsive layout.

The SCSS implementation follows best practices with appropriate breakpoints and nesting.

src/app/docs/components/search/search.module.scss (1)

11-14: .search-input Styling Update.
The border property has been removed and an outline-offset set to -2px has been added. Please verify visually that the absence of a border and the new focus offset maintain a harmonious design with the rest of the UI.

Comment on lines +41 to +43
{willLearn.map((willLearn, index) => (
<CourseModuleElement key={index} courseModule={willLearn} />
))}
Copy link
Contributor

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

Avoid using array indices as React keys.

Using array indices as keys can lead to issues if items are reordered.

Consider adding unique identifiers to your willLearn items or using a stable unique property if available.

Comment on lines +19 to +20
const isKnowBeforeExist = knowBefore && Boolean(knowBefore.description.length);
const isWillLearnExist = willLearn && Boolean(willLearn.length);
Copy link
Contributor

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

Replace Boolean coercion with explicit checks.

Based on team's previous discussions, we should avoid implicit coercion.

-  const isKnowBeforeExist = knowBefore && Boolean(knowBefore.description.length);
-  const isWillLearnExist = willLearn && Boolean(willLearn.length);
+  const isKnowBeforeExist = knowBefore && knowBefore.description.length > 0;
+  const isWillLearnExist = willLearn && willLearn.length > 0;
πŸ“ 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
const isKnowBeforeExist = knowBefore && Boolean(knowBefore.description.length);
const isWillLearnExist = willLearn && Boolean(willLearn.length);
const isKnowBeforeExist = knowBefore && knowBefore.description.length > 0;
const isWillLearnExist = willLearn && willLearn.length > 0;

Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest to change dev-data/required.data.ts like
Screenshot 2025-02-14 at 15 31 50

Comment on lines +1 to +11
.course-module-element {
margin-top: 20px;

&:first-child {
margin-top: 0;
}

.course-module-title {
margin-bottom: 8px;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
.course-module-element {
margin-top: 20px;
&:first-child {
margin-top: 0;
}
.course-module-title {
margin-bottom: 8px;
}
}
.course-module-element {
display: flex;
flex-direction: column;
gap: 8px;
}

gap: 8rem;

.course-module-elements-column {
flex: 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we really need flex: 1 here?

Suggested change
flex: 1;
display: flex;
flex-direction: column;
gap: 24px;

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 Required
5 participants