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

569-refactor: Widget training program #661

Merged
merged 16 commits into from
Dec 16, 2024

Conversation

Quiddlee
Copy link
Member

@Quiddlee Quiddlee commented Nov 25, 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-25 at 12 00 26β€―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 export for trainingProgramLink, enhancing localization for registration links in English and Russian.
    • Added a new SCSS module for the training program layout, improving responsiveness and styling.
  • Bug Fixes

    • Updated test references to use a mocked courses array for better data management.
  • Refactor

    • Streamlined the TrainingProgram component by improving class name management and enhancing type safety.
  • Chores

    • Removed the outdated training-program.scss file, consolidating styles into the new SCSS module.

@Quiddlee Quiddlee self-assigned this Nov 25, 2024
@github-actions github-actions bot changed the title Refactor/569 widget training program 569-refactor: Widget training program Nov 25, 2024
@Quiddlee Quiddlee marked this pull request as ready for review December 2, 2024 22:03
Copy link
Contributor

coderabbitai bot commented Dec 2, 2024

πŸ“ Walkthrough
πŸ“ Walkthrough

Walkthrough

The pull request introduces several changes across multiple files, primarily adding a new export, trainingProgramLink, to enhance localization in the training program module. It also includes a new SCSS module for styling, replaces hardcoded values in tests with dynamic references, and refactors the TrainingProgram component for improved type safety and semantic HTML. An existing SCSS file was deleted as part of this restructuring.

Changes

Files Change Summary
dev-data/index.ts Added new export trainingProgramLink from ./training-program.data.
dev-data/training-program.data.tsx Introduced new constant trainingProgramLink with localized link labels for English and Russian.
src/widgets/training-program/ui/training-program.module.scss Added new SCSS module for .training-program class with responsive two-column layout.
src/widgets/training-program/ui/training-program.scss Deleted file, previously contained styles for training program component.
src/widgets/training-program/ui/training-program.test.tsx Replaced hardcoded course data with mockedCourses array references; updated expected URL.
src/widgets/training-program/ui/training-program.tsx Refactored to use classnames/bind, updated lang property type, and improved semantic HTML.

Assessment against linked issues

Objective Addressed Explanation
Refactor SCSS in training-program.module.scss (569) ❌ SCSS refactoring tasks were not fully addressed.
Replace interface with type in training-program.tsx (569) βœ…
Move localized content to dev-data (569) βœ…
Replace div's with HTML5 tags in training-program.tsx (569) βœ…
Move test file to ui folder (569) ❌ Test file location change was not implemented.

Possibly related PRs

  • 430-refactor: Actions component refactorΒ #447: The changes in the main PR involve adding a new export trainingProgramLink in dev-data/index.ts, which is related to the modifications made in src/widgets/training-program/ui/training-program.tsx where trainingProgramLink is accessed for rendering localized strings.
  • 473-fix: Fsd refactor trainers cardΒ #492: This PR also modifies the TrainingProgram component, which is directly related to the changes in the main PR as it involves the same component and the new export trainingProgramLink.
  • 489-refactor: Widget AboutΒ #576: The changes in this PR involve the introduction of new localized content structures, which aligns with the addition of trainingProgramLink in the main PR, enhancing the management of localized content.
  • 614-fix: Pre school subtitleΒ #675: The addition of the subTitle property in the course objects in this PR complements the changes in the main PR, which also focuses on enhancing the structure of course-related data.
  • 567-refactor: Widget supportΒ #684: The refactor of the Support component in this PR includes updates to the structure and styling, which may indirectly relate to the overall improvements in the codebase's organization and maintainability as seen in the main PR.

Suggested reviewers

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

πŸ“œ Recent review details

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

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 4574a7d and c8213ad.

πŸ“’ Files selected for processing (1)
  • dev-data/index.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • dev-data/index.ts

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

🧹 Outside diff range and nitpick comments (3)
src/widgets/training-program/ui/training-program.tsx (1)

39-43: Consider adding loading and error handling for Image

The Image component should include loading and error handling properties.

 <Image
   src={image}
   alt={course?.title}
   className={cx('image', { badge: isCourseWithBadge })}
+  loading="lazy"
+  onError={(e) => {
+    e.currentTarget.style.display = 'none';
+  }}
 />
src/widgets/training-program/ui/training-program.module.scss (1)

5-5: Consider using CSS variables for spacing

Replace magic numbers with semantic variables:

-    gap: 100px;
+    gap: var(--spacing-xxl);
-      gap: 26px;
+      gap: var(--spacing-md);

Also applies to: 13-13

dev-data/training-program.data.tsx (1)

308-311: Consider adding TypeScript interface for link labels

The localization structure is clean, but could benefit from type safety.

+interface LinkLabel {
+  linkLabel: string;
+}
+
+interface TrainingProgramLink {
+  en: LinkLabel;
+  ru: LinkLabel;
+}
+
-export const trainingProgramLink = {
+export const trainingProgramLink: TrainingProgramLink = {
   en: { linkLabel: 'Register' },
   ru: { linkLabel: 'Π—Π°Ρ€Π΅Π³ΠΈΡΡ‚Ρ€ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒΡΡ' },
 };
πŸ“œ Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 70228c3 and 32512d0.

πŸ“’ Files selected for processing (6)
  • dev-data/index.ts (1 hunks)
  • dev-data/training-program.data.tsx (1 hunks)
  • src/widgets/training-program/ui/training-program.module.scss (1 hunks)
  • src/widgets/training-program/ui/training-program.scss (0 hunks)
  • src/widgets/training-program/ui/training-program.test.tsx (3 hunks)
  • src/widgets/training-program/ui/training-program.tsx (1 hunks)
πŸ’€ Files with no reviewable changes (1)
  • src/widgets/training-program/ui/training-program.scss
πŸ”‡ Additional comments (5)
src/widgets/training-program/ui/training-program.tsx (2)

2-2: Good use of classNames/bind and semantic HTML

The changes improve code quality through:

  • Using classNames/bind for better CSS module handling
  • Converting div to article for semantic HTML

Also applies to: 12-12, 25-27


5-5: Improved type safety and localization

Good improvements:

  • Using Language type instead of string literal union
  • Centralizing localization through trainingProgramLink

Also applies to: 16-16, 34-34

src/widgets/training-program/ui/training-program.module.scss (1)

18-18: Ensure font-weight meets accessibility standards

Verify that $font-weight-bold provides sufficient contrast and readability.

Also applies to: 26-26

βœ… Verification successful

Font-weight value meets accessibility standards

The $font-weight-bold variable is set to 700, which is a standard bold weight that provides sufficient contrast and readability. This value follows common accessibility practices for emphasizing text.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find the value of $font-weight-bold
rg -l "\$font-weight-bold:" | xargs cat

Length of output: 40


Script:

#!/bin/bash
# Search for SCSS/CSS variable definitions related to font-weight
rg -g "*.scss" -g "*.css" "font-weight|weight" -A 2 -B 2

# Also try to find any design tokens or variables file
fd -e scss -e css "variables|tokens|theme|styles"

Length of output: 14863

dev-data/index.ts (1)

36-36: Clean export addition

The trainingProgramLink export is well-placed alongside related contentMap export.

src/widgets/training-program/ui/training-program.test.tsx (1)

4-4: Good refactor using centralized test data!

Using mockedCourses array improves maintainability and reduces data duplication.

Also applies to: 9-10

@Quiddlee
Copy link
Member Author

Quiddlee commented Dec 9, 2024

run visual now

Copy link

github-actions bot commented Dec 9, 2024

Lighthouse Report:

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

View detailed report

Copy link

Lighthouse Report:

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

View detailed report

@Quiddlee Quiddlee mentioned this pull request Dec 14, 2024
8 tasks
@Quiddlee Quiddlee requested a review from Copilot December 14, 2024 20:19

Choose a reason for hiding this comment

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

Copilot reviewed 4 out of 6 changed files in this pull request and generated no comments.

Files not reviewed (2)
  • src/widgets/training-program/ui/training-program.module.scss: Language not supported
  • src/widgets/training-program/ui/training-program.scss: Language not supported
Comments suppressed due to low confidence (1)

dev-data/training-program.data.tsx:303

  • The 'trainingProgramLink' object should have a proper type definition to ensure type safety.
export const trainingProgramLink = {
@Quiddlee Quiddlee merged commit 3827450 into main Dec 16, 2024
3 checks passed
@Quiddlee Quiddlee deleted the refactor/569-widget-training-program branch December 16, 2024 13:49
Copy link

Lighthouse Report:

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

View detailed report

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 Training Program
4 participants