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

refactor: timeline review #1222

Merged
merged 4 commits into from
Oct 15, 2024
Merged

refactor: timeline review #1222

merged 4 commits into from
Oct 15, 2024

Conversation

cpvalente
Copy link
Owner

@cpvalente cpvalente commented Sep 22, 2024

Making some tweaks to the timeline

  • timeline is compound of all events
  • stop event from growing beyond bounds
  • create loader element
  • reorganise directory ahead of new structure

Copy link
Contributor

coderabbitai bot commented Sep 22, 2024

Walkthrough

The changes involve modifications to several components and styles related to the timeline feature. Key updates include the removal of the Timeline and TimelineProgressBar components, adjustments to the TimelineEntry to incorporate a new data-status attribute, and enhancements to the SCSS files for improved styling of timeline elements. New classes and properties have been introduced to better handle visual representation based on statuses. Additionally, modifications to utility functions and tests ensure consistency and correctness in functionality.

Changes

File Change Summary
apps/client/src/features/viewers/timeline/Timeline.module.scss Removed variables $timeline-entry-height and $lane-height; updated .timeline class; introduced .timelineBlock class with new styles for status handling.
apps/client/src/features/viewers/timeline/Timeline.tsx Removed Timeline component; adjusted formatting and structure of the Timeline component.
apps/client/src/features/viewers/timeline/TimelineEntry.tsx Added data-status attribute to main <div>; introduced new <div> with class timelineBlock.
apps/client/src/features/viewers/timeline/tests/timeline.utils.test.ts Corrected function name from makeTmelineSections to makeTimelineSections; updated expected output for tests.
apps/client/src/features/viewers/timeline/timeline-markers/TimelineMarkers.module.scss Modified .markers class properties; adjusted child span elements for visual separation.
apps/client/src/features/viewers/timeline/timeline-markers/TimelineMarkers.tsx Simplified rendering of <span> elements in the TimelineMarkers component.
apps/client/src/features/viewers/timeline/timeline-progress-bar/TimelineProgressBar.module.scss Deleted file containing styles for the removed ProgressBar component.
apps/client/src/features/viewers/timeline/timeline-progress-bar/TimelineProgressBar.tsx Deleted file containing the ProgressBar component implementation.
apps/client/src/features/viewers/timeline/timeline.utils.ts Updated makeTimelineSections function to store hour indices instead of formatted time strings.
apps/client/src/features/viewers/ViewWrapper.tsx Commented out conditional rendering based on viewSettings data availability.
apps/client/src/features/viewers/backstage/Backstage.tsx Removed viewSettings from BackstageProps interface and related logic.
apps/client/src/features/viewers/clock/Clock.tsx Removed viewSettings from ClockProps interface and related logic.
apps/client/src/features/viewers/countdown/Countdown.tsx Removed viewSettings from CountdownProps interface and related logic.
apps/client/src/features/viewers/minimal-timer/MinimalTimer.tsx Removed conditional rendering based on shouldRender.
apps/client/src/features/viewers/public/Public.tsx Removed viewSettings from PublicProps interface and related logic.
apps/client/src/features/viewers/studio/StudioClock.tsx Removed viewSettings from StudioClockProps interface.
apps/client/src/views/ViewLoader.module.scss Introduced new styles for a loading component.
apps/client/src/views/ViewLoader.tsx Added new ViewLoader component for enhanced loading behavior.
apps/client/src/views/timeline/Timeline.module.scss Updated variable usage and styling rules; introduced new $view-background variable.
apps/client/src/views/timeline/Timeline.tsx Introduced new Timeline component for rendering a visual timeline.
apps/client/src/views/timeline/TimelineEntry.tsx Enhanced TimelineEntry with real-time progress updates based on status.
apps/client/src/views/timeline/TimelinePage.scss Enhanced styling for .section-content class.
apps/client/src/views/timeline/TimelinePage.tsx Simplified props structure by removing viewSettings.
apps/client/src/views/timeline/tests/timeline.utils.test.ts Updated tests for makeTimelineSections function.

Possibly related PRs

  • feat: timeline view #1131: The changes in the Timeline component and its associated styles are directly related to the main PR, as they both involve enhancements to the timeline view and its presentation.
  • fix: use unfiltered events in timeline #1171: This PR modifies the TimelinePage component to use backstageEvents, which aligns with the changes made in the main PR regarding the timeline's event handling and rendering logic.
  • fix: handle multiple days #1201: The improvements in handling multiple days in the timeline are relevant as they enhance the overall functionality of the timeline component, which is a focus of the main PR.
  • Fit text #1217: The introduction of the FitText component for dynamic text fitting can enhance the visual presentation of timeline elements, making it relevant to the styling changes in the main PR.
  • fix: issue where event next was stale #1224: Fixing the stale eventNext issue is pertinent as it ensures that the timeline accurately reflects the current state of events, which is crucial for the functionality described in the main PR.

Suggested reviewers

  • alex-Arc

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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5b47198 and 6a55d13.

Files selected for processing (1)
  • apps/client/src/features/viewers/timeline/TimelinePage.scss (1 hunks)

Comment on lines +88 to +95

max-height: 2em;
display: -webkit-box;
-webkit-line-clamp: 2;
line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
Copy link
Contributor

Choose a reason for hiding this comment

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

Approve changes with minor suggestions for improved cross-browser compatibility

The changes effectively control the growth of the text content, aligning well with the PR objective. The implementation limits the text to two lines and adds an ellipsis for overflow, which should improve the timeline's layout consistency.

To enhance cross-browser compatibility, consider the following suggestions:

  1. Add the standard display: box; alongside -webkit-box for better compatibility:
 .section-content {
   max-height: 2em;
+  display: box;
   display: -webkit-box;
   -webkit-line-clamp: 2;
   line-clamp: 2;
   -webkit-box-orient: vertical;
   overflow: hidden;
   text-overflow: ellipsis;
 }
  1. Consider adding a fallback method for browsers that don't support line-clamp. One approach is to use the max-height and overflow properties you've already set, combined with word-wrap: break-word; to ensure long words don't overflow:
 .section-content {
   max-height: 2em;
   display: box;
   display: -webkit-box;
   -webkit-line-clamp: 2;
   line-clamp: 2;
   -webkit-box-orient: vertical;
   overflow: hidden;
   text-overflow: ellipsis;
+  word-wrap: break-word;
 }

These changes will help ensure a more consistent appearance across different browsers while maintaining the desired functionality.

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
max-height: 2em;
display: -webkit-box;
-webkit-line-clamp: 2;
line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
max-height: 2em;
display: box;
display: -webkit-box;
-webkit-line-clamp: 2;
line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
word-wrap: break-word;

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: 0

🧹 Outside diff range and nitpick comments (6)
apps/client/src/features/viewers/timeline/Timeline.module.scss (3)

10-11: LGTM with a minor suggestion.

The addition of box-sizing: content-box and box-shadow enhances the visual presentation of the timeline. However, consider using a CSS variable for the box-shadow color to improve maintainability.

Consider refactoring the box-shadow color:

- box-shadow: inset 0 1rem 0 0 $gray-1100;
+ box-shadow: inset 0 1rem 0 0 var(--timeline-shadow-color, $gray-1100);

24-40: LGTM with a suggestion for consistency.

The new .timelineBlock class effectively implements status-based styling. However, for consistency and maintainability, consider using a color variable for the 'live' status.

Replace the hardcoded color value with a variable:

  &[data-status='live'] {
    &::before {
-     background-color: red;
+     background-color: $active-red;
    }
  }

Line range hint 75-83: LGTM with a note on the TODO.

The status-based styling for 'done' and 'live' statuses is a good addition. Regarding the TODO, the :has selector could indeed be used to simplify the CSS, but browser support should be considered.

Would you like me to provide an example of how to use the :has selector for this case, or create an issue to track this potential optimization?

apps/client/src/features/viewers/timeline/TimelineEntry.tsx (1)

81-81: LGTM: Improved comment clarity.

The rewording of the comment is an improvement. It's more concise while maintaining the original meaning.

Minor suggestion: Consider adding a brief explanation of why isolating re-renders is beneficial in this context. This could provide valuable insight for future maintainers.

Here's a suggested enhancement:

-// extract component to isolate re-renders provoked by the clock changes
+// Extract component to isolate re-renders provoked by clock changes, improving performance
apps/client/src/features/viewers/timeline/Timeline.tsx (1)

64-88: Well-structured timeline entry rendering with room for minor improvement.

The code effectively calculates and renders timeline entries with appropriate positioning and props. The comment about using dataset for midnight-crossing issues is helpful.

Consider renaming the start prop to startTime or startTimestamp for improved clarity:

-            start={normalisedStart} // dataset solves issues related to crossing midnight
+            startTime={normalisedStart} // dataset solves issues related to crossing midnight

This change would make the prop's purpose more immediately clear to other developers.

apps/client/src/features/viewers/timeline/timeline.utils.ts (1)

Line range hint 1-205: Consider broader implications of the makeTimelineSections change.

While the change to makeTimelineSections is an improvement, consider the following points:

  1. Update any code that expects formatted time strings from this function.
  2. Verify type safety in TypeScript files using this function.
  3. Update documentation to reflect the new return type (numbers instead of formatted time strings).

To ensure a smooth transition:

  1. Search for all usages of makeTimelineSections in the codebase and update as necessary.
  2. Run TypeScript compiler to catch any type-related issues.
  3. Update relevant documentation, including any API docs or comments related to this function.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6a55d13 and ee7c9a3.

📒 Files selected for processing (9)
  • apps/client/src/features/viewers/timeline/Timeline.module.scss (3 hunks)
  • apps/client/src/features/viewers/timeline/Timeline.tsx (1 hunks)
  • apps/client/src/features/viewers/timeline/TimelineEntry.tsx (2 hunks)
  • apps/client/src/features/viewers/timeline/tests/timeline.utils.test.ts (1 hunks)
  • apps/client/src/features/viewers/timeline/timeline-markers/TimelineMarkers.module.scss (1 hunks)
  • apps/client/src/features/viewers/timeline/timeline-markers/TimelineMarkers.tsx (1 hunks)
  • apps/client/src/features/viewers/timeline/timeline-progress-bar/TimelineProgressBar.module.scss (0 hunks)
  • apps/client/src/features/viewers/timeline/timeline-progress-bar/TimelineProgressBar.tsx (0 hunks)
  • apps/client/src/features/viewers/timeline/timeline.utils.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • apps/client/src/features/viewers/timeline/timeline-progress-bar/TimelineProgressBar.module.scss
  • apps/client/src/features/viewers/timeline/timeline-progress-bar/TimelineProgressBar.tsx
🧰 Additional context used
🔇 Additional comments (16)
apps/client/src/features/viewers/timeline/timeline-markers/TimelineMarkers.module.scss (3)

13-15: LGTM! Verify visual separation for various numbers of markers.

The new styling for span elements improves the visual separation between markers:

  1. Only span elements that are not the first child have a left border.
  2. This creates a clear delineation between markers while avoiding a border on the leftmost marker.

These changes should enhance the clarity of the timeline visualization.

To ensure these changes work as intended, consider the following verification steps:

  1. Test the timeline with various numbers of markers (e.g., 2, 3, 5, 10) to ensure proper visual separation.
  2. Verify that the leftmost marker doesn't have a left border in all cases.
  3. Check the appearance on different color schemes or themes, if applicable.
#!/bin/bash
# Description: Search for timeline-related test files and theme configurations

# Test: Look for timeline-related test files
rg --type typescript "(describe|it).*(timeline|marker)" apps/client/src/features/viewers/timeline

# Test: Check for theme or color scheme configurations
rg --type typescript --type scss "(theme|color scheme|dark mode|light mode)" apps/client/src/features/viewers/timeline

2-3: LGTM! Consider verifying responsive behavior.

The changes to the .markers class improve its flexibility:

  1. Absolute positioning with left: 0; ensures consistent left alignment.
  2. Changing height to 100% allows the markers to span the full height of their container.

These modifications enhance the adaptability of the timeline markers to different container sizes.

To ensure these changes work as intended across different viewport sizes, consider running the following verification steps:

  1. Test the timeline component at various screen sizes (mobile, tablet, desktop).
  2. Verify that the markers align correctly and span the full height of the timeline container in all cases.
  3. Check for any potential overflow issues, especially on smaller screens.

Also applies to: 5-5


6-6: Clarify the impact of removed text-related properties.

The line-height, margin-bottom, and font-size properties have been removed from the .markers class. While this simplifies the styling, it may affect the text appearance within the markers.

Please clarify:

  1. Was the removal of these properties intentional?
  2. How does this change impact the visual appearance of the marker text?
  3. Are these text-related styles now being applied from a parent element or a global style?

To verify the visual appearance, consider the following steps:

  1. Compare the rendered timeline markers before and after these changes.
  2. Ensure that the marker text is still legible and properly aligned.
  3. Check if the removal of margin-bottom affects the spacing between markers.
apps/client/src/features/viewers/timeline/timeline-markers/TimelineMarkers.tsx (1)

18-20: Simplified rendering logic, but consider potential implications.

The changes have made the code more concise and potentially more efficient. However, there are a few points to consider:

  1. Removing the content from the <span> elements might affect the visual representation or accessibility of the timeline markers. Ensure that this change aligns with the intended design and doesn't compromise user experience.

  2. Using tag alone as the key is fine if it's guaranteed to be unique for each element. If there's any possibility of duplicate tags, consider reverting to the previous key format (${index}-${tag}) to avoid potential React reconciliation issues.

To ensure the uniqueness of tags and verify the impact on accessibility, please run the following script:

apps/client/src/features/viewers/timeline/Timeline.module.scss (2)

22-22: LGTM: Minor syntax correction.

The removal of the trailing comma is a good cleanup.


Line range hint 97-111: LGTM: Consistent status-based styling.

The addition of status-based styling for 'done', 'live', and 'future' states in the .timeOverview class is consistent with the overall design and improves the visual feedback for different timeline entry states.

apps/client/src/features/viewers/timeline/__tests__/timeline.utils.test.ts (3)

56-58: Function name corrected: makeTmelineSectionsmakeTimelineSections

The function name has been correctly updated from makeTmelineSections to makeTimelineSections, fixing a typo. This change improves code consistency and readability.


56-61: Consider adding test for midnight wrapping scenario

The test for wrapping around midnight has been removed. If this functionality is still required, consider adding a test case to ensure it works correctly. If the requirement has changed, update the documentation to reflect this.

To confirm if midnight wrapping is still a requirement, please check the project documentation or consult with the product owner. If it's no longer needed, ensure that this change is documented in the PR description or related issue.


59-59: Verify the change in expected output format

The expected output has been changed from an array of time strings (e.g., ['11:00', '12:00', ...]) to an array of integers (e.g., [11, 12, ...]). This change suggests a modification in the makeTimelineSections function implementation.

Please ensure that:

  1. The makeTimelineSections function in the main code has been updated to return an array of integers instead of time strings.
  2. All other parts of the codebase that use makeTimelineSections have been updated to handle the new output format.

Run the following script to verify the function implementation:

✅ Verification successful

Verified: makeTimelineSections returns an array of integers and all usages are compatible

  • The makeTimelineSections function now returns [11, 12, 13, 14, 15, 16] as expected.
  • All parts of the codebase using makeTimelineSections, including TimelineMarkers.tsx and the corresponding test, handle the integer array correctly.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of makeTimelineSections function

# Test: Search for the function definition and its usage
rg --type typescript -A 10 'function makeTimelineSections'
rg --type typescript -A 5 'makeTimelineSections\('

Length of output: 183


Script:

#!/bin/bash
# Description: Retry searching for makeTimelineSections function without using --type flag

# Search for the function definition in .ts and .tsx files
rg 'function makeTimelineSections' --glob '*.ts' --glob '*.tsx'

# Search for the function usage in .ts and .tsx files
rg 'makeTimelineSections\(' --glob '*.ts' --glob '*.tsx'

Length of output: 660


Script:

#!/bin/bash
# Description: Extract the implementation of makeTimelineSections function

# Extract lines of the makeTimelineSections function
rg 'export function makeTimelineSections' --glob '*.ts' --glob '*.tsx' -A 20

Length of output: 1863

apps/client/src/features/viewers/timeline/TimelineEntry.tsx (3)

44-44: LGTM: Addition of data-status attribute enhances component flexibility.

The new data-status attribute on the main div element is a good addition. It allows for more granular styling and selection based on the entry's status, which aligns well with the PR's objective of refactoring the timeline component.


Line range hint 1-96: Summary: Good refactoring with room for minor improvements

Overall, the changes to the TimelineEntry component align well with the PR objectives. The addition of the data-status attribute enhances flexibility, and the component extraction continues to support performance optimization.

To further improve this PR:

  1. Clarify the purpose of the new timelineBlock element.
  2. Consider enhancing the comment for the TimelineEntryStatus component to provide more context.

These changes contribute positively to the timeline's functionality and maintainability.


52-52: Please clarify the purpose of the new timelineBlock element.

A new div element with the class style.timelineBlock has been added. While this might be intended for styling purposes, its exact role in the timeline's visual structure is not clear from the code alone. Could you please provide some context on the purpose of this element and how it contributes to the timeline's layout or functionality?

To help understand the usage of this new class, let's check its definition in the SCSS file:

✅ Verification successful

Verified the purpose of the timelineBlock element.

The .timelineBlock class is defined in apps/client/src/features/viewers/timeline/Timeline.module.scss and applies specific styles such as height, background color, and width. This confirms that the empty <div> with the timelineBlock class is intended for visual styling within the timeline's layout.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for the definition of .timelineBlock in the SCSS files

rg --type scss '.timelineBlock'

Length of output: 60


Script:

#!/bin/bash
# Description: Search for the definition of .timelineBlock in SCSS files using glob pattern

rg '\.timelineBlock' --glob '*.scss'

Length of output: 118


Script:

#!/bin/bash
# Description: Retrieve the styles for .timelineBlock in Timeline.module.scss

cat apps/client/src/features/viewers/timeline/Timeline.module.scss

Length of output: 1995

apps/client/src/features/viewers/timeline/Timeline.tsx (3)

41-45: LGTM: Clear and concise event filtering logic.

The code effectively filters out non-playable events and delays, which aligns with the component's purpose of rendering a timeline of playable events.


47-61: Well-implemented event status tracking and multi-day handling.

This code segment effectively manages the progress status of events and handles scenarios where events cross midnight. The use of elapsedDays to normalize event start times across multiple days is a robust approach.


Line range hint 1-88: Verify the removal of TimelineProgressBar component.

The AI summary mentioned the removal of the TimelineProgressBar component, but this change is not visible in the provided code diff.

Please run the following script to confirm the removal and check for any remaining references:

If the TimelineProgressBar has been completely removed, ensure that its functionality is not needed or has been implemented differently. If it's still required, consider discussing its reimplementation or alternative solutions with the team.

apps/client/src/features/viewers/timeline/timeline.utils.ts (1)

74-74: Approve the simplification, but verify impact on dependent code.

The change to makeTimelineSections simplifies the implementation and potentially improves performance by storing hour indices directly instead of formatted time strings. This is a good optimization.

However, ensure that any code depending on the output of this function is updated to handle numbers instead of formatted time strings.

To verify the impact of this change, please run the following script:

This script will help identify any code that might need to be updated due to the change in the makeTimelineSections function's output.

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: 5

🧹 Outside diff range and nitpick comments (14)
apps/client/src/views/ViewLoader.tsx (2)

1-7: LGTM! Consider destructuring PropsWithChildren import.

The imports are well-organized and appropriate for the component's functionality. The use of custom hooks and CSS modules demonstrates good separation of concerns.

Consider destructuring the PropsWithChildren import for consistency with React best practices:

-import { PropsWithChildren } from 'react';
+import type { PropsWithChildren } from 'react';

13-28: LGTM! Consider extracting the loader to a separate component.

The loader implementation and conditional rendering logic are well-structured. The comment about future React Suspense usage is helpful for context.

Consider extracting the loader into a separate component for better reusability:

const Loader = () => (
  <div className={style.loader}>
    <div className={style.ellipsis}>
      <div />
      <div />
      <div />
      <div />
    </div>
  </div>
);

// Then in the ViewLoader component:
if (!shouldRender) {
  return <Loader />;
}

This would improve the readability of the ViewLoader component and make the loader reusable across the application if needed.

apps/client/src/views/ViewLoader.module.scss (3)

6-11: LGTM: Effective full-screen loader implementation.

The use of CSS Grid for centering and CSS variables for theming is commendable. Consider adding a z-index to ensure the loader appears above other content.

You might want to add a z-index to ensure the loader appears above other content:

 .loader {
   display: grid;
   place-items: center;
   background-color: var(--background-color-override, $viewer-background-color);
   height: 100vh;
+  z-index: 9999; // Adjust the value as needed
 }

13-46: LGTM: Well-implemented loading animation.

The ellipsis animation is efficiently styled and provides a smooth loading effect. The use of CSS variables for colors is great for theming.

Consider adding an aria-label to the loader for better accessibility:

 .ellipsis {
   display: inline-block;
   position: relative;
   width: 5rem;
+  &::before {
+    content: "Loading";
+    position: absolute;
+    width: 1px;
+    height: 1px;
+    padding: 0;
+    margin: -1px;
+    overflow: hidden;
+    clip: rect(0, 0, 0, 0);
+    white-space: nowrap;
+    border: 0;
+  }
 }

This addition will provide screen readers with context about the loading state without visually affecting the layout.


48-73: LGTM: Well-crafted keyframe animations.

The keyframe animations are well-defined and create a smooth, staggered effect. The use of transform for animations is good for performance.

Consider using CSS custom properties for animation durations to make it easier to adjust timing across all animations:

+:root {
+  --animation-duration: 0.6s;
+}

 .ellipsis {
   div {
     &:nth-child(1) {
-      animation: lds-ellipsis1 0.6s infinite;
+      animation: lds-ellipsis1 var(--animation-duration) infinite;
     }
     // Apply similar changes to other animation declarations
   }
 }

This change would allow you to easily adjust the animation speed for all dots by modifying a single variable.

apps/client/src/views/timeline/Timeline.module.scss (3)

4-4: Good addition of centralized variable

The introduction of $view-background is a positive change that enhances maintainability. It allows for easier global updates to the background color if needed in the future.

Consider adding a brief comment explaining the purpose of this variable, e.g.:

// Centralized background color for the timeline view
$view-background: $ui-black;

26-38: Excellent addition of structured timeline block styling

The new .timelineBlock class is a great addition, providing clear and structured styling for timeline elements. The use of data-status for conditional styling is a good practice that separates styling from logic.

Consider using CSS custom properties for the status colors to improve maintainability:

.timelineBlock {
  --status-done-color: #{$active-red};
  --status-live-color: #{$active-red};
  
  &[data-status='done'] {
    background: var(--status-done-color);
  }

  &[data-status='live'] {
    background: linear-gradient(to right, var(--status-live-color) var(--progress, 0%), $white-60 var(--progress, 0%));
  }
}

This approach would allow for easier updates to status colors in the future.


Line range hint 1-114: Overall excellent refactoring of timeline styles

The changes in this file significantly improve the structure and maintainability of the timeline styles. Key improvements include:

  1. Introduction of the $view-background variable for consistent color management.
  2. Addition of the .timelineBlock class for better organization of timeline elements.
  3. Consistent use of data-status attributes for conditional styling.
  4. Improved border styling for content elements.

These changes align well with the PR objective of refactoring to control container growth. The new structure should make future modifications and maintenance easier.

To further improve the architecture, consider:

  1. Creating a separate file for timeline-specific variables and importing it here.
  2. Using CSS custom properties for values that might need to be dynamically changed, such as status colors or progress percentages.

These suggestions could enhance the modularity and flexibility of the timeline component.

apps/client/src/views/timeline/TimelinePage.scss (1)

88-95: Approve changes with a minor suggestion for consistency.

The new styles effectively limit the section content to two lines and add an ellipsis for overflow, which aligns with the PR objective of controlling container growth. These changes improve the visual presentation and prevent uncontrolled expansion of the timeline entries.

For consistency, consider adding a white-space: normal; property to ensure the text wraps as expected across all browsers.

Here's a suggested modification:

 .section-content {
   min-height: 2em;
   line-height: 1em;
   font-size: 3rem;
   text-transform: uppercase;
   font-weight: 600;

   max-height: 2em;
   display: -webkit-box;
   -webkit-line-clamp: 2;
   line-clamp: 2;
   -webkit-box-orient: vertical;
   overflow: hidden;
   text-overflow: ellipsis;
+  white-space: normal;
 }
apps/client/src/features/viewers/public/Public.tsx (1)

Line range hint 1-114: Summary of changes and potential impact.

The modifications to the Public component primarily involve the removal of viewSettings-related code, including:

  1. Removal of the ViewSettings import
  2. Removal of the viewSettings property from the BackstageProps interface
  3. Removal of the useRuntimeStylesheet hook and related rendering logic

These changes appear to be part of a refactoring effort to simplify the component. While they streamline the code, it's crucial to ensure that:

  1. The removal of runtime stylesheet loading doesn't negatively impact the application of styles.
  2. The component's rendering behavior remains correct without the previous conditional logic.
  3. Any components that previously relied on the viewSettings prop have been appropriately updated.

To maintain code quality and prevent potential issues:

  1. Consider adding comments explaining the rationale behind these changes.
  2. Update the component's documentation to reflect the new prop structure and behavior.
  3. Ensure that comprehensive tests are in place to verify the component's functionality after these changes.
apps/client/src/views/timeline/timeline.utils.ts (1)

Line range hint 1-200: Summary: Positive changes, verify impact on the broader codebase.

The changes in this file are part of a larger refactoring effort to improve code organization and simplify functionality. The modifications to import paths and the makeTimelineSections function are positive improvements. However, it's crucial to verify the impact of these changes on the broader codebase to ensure no unintended side effects are introduced.

Next steps:

  1. Run the suggested verification scripts to check for consistency in import paths and usage of makeTimelineSections.
  2. Review and update any code that relies on the old behavior of makeTimelineSections.
  3. Consider updating documentation or comments to reflect the new behavior of makeTimelineSections.
apps/client/src/AppRouter.tsx (1)

Line range hint 1-186: Summary: Consistent implementation of ViewLoader and project structure reorganization.

The changes in this file demonstrate a systematic approach to improving the application's routing and view loading mechanism:

  1. Introduction of a new ViewLoader component.
  2. Consistent application of ViewLoader across all relevant routes.
  3. Reorganization of the project structure, as evidenced by the updated Timeline component import path.

These changes should lead to improved loading behavior and a more organized codebase. The consistency of the changes across routes is commendable and indicates a well-executed refactoring effort.

To ensure the refactoring is complete:

  1. Verify that the ViewLoader component is implemented correctly and provides the expected functionality.
  2. Check if there are any remaining references to the old Timeline component path in other parts of the codebase.
  3. Consider updating the project documentation to reflect the new structure and the use of ViewLoader.
apps/client/src/views/timeline/Timeline.tsx (1)

42-42: Fix typo in comment

In the comment on line 42, "dont" should be "don't".

apps/client/src/views/timeline/TimelineEntry.tsx (1)

81-81: Nitpick: Improve comment wording

Consider rephrasing the comment for clarity and capitalization:

Original:

// extract component to isolate re-renders provoked by the clock changes

Suggested:

// Extract component to isolate re-renders caused by clock changes
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ee7c9a3 and a9b28ac.

📒 Files selected for processing (25)
  • apps/client/src/AppRouter.tsx (3 hunks)
  • apps/client/src/features/viewers/ViewWrapper.tsx (1 hunks)
  • apps/client/src/features/viewers/backstage/Backstage.tsx (2 hunks)
  • apps/client/src/features/viewers/clock/Clock.tsx (2 hunks)
  • apps/client/src/features/viewers/countdown/Countdown.tsx (2 hunks)
  • apps/client/src/features/viewers/minimal-timer/MinimalTimer.tsx (0 hunks)
  • apps/client/src/features/viewers/public/Public.tsx (1 hunks)
  • apps/client/src/features/viewers/studio/StudioClock.tsx (2 hunks)
  • apps/client/src/features/viewers/timeline/Timeline.tsx (0 hunks)
  • apps/client/src/features/viewers/timeline/timeline-markers/TimelineMarkers.module.scss (0 hunks)
  • apps/client/src/features/viewers/timeline/timeline-progress-bar/TimelineProgressBar.module.scss (0 hunks)
  • apps/client/src/features/viewers/timeline/timeline-progress-bar/TimelineProgressBar.tsx (0 hunks)
  • apps/client/src/views/ViewLoader.module.scss (1 hunks)
  • apps/client/src/views/ViewLoader.tsx (1 hunks)
  • apps/client/src/views/timeline/Timeline.module.scss (2 hunks)
  • apps/client/src/views/timeline/Timeline.tsx (1 hunks)
  • apps/client/src/views/timeline/TimelineEntry.tsx (4 hunks)
  • apps/client/src/views/timeline/TimelinePage.scss (2 hunks)
  • apps/client/src/views/timeline/TimelinePage.tsx (2 hunks)
  • apps/client/src/views/timeline/tests/timeline.utils.test.ts (1 hunks)
  • apps/client/src/views/timeline/timeline-markers/TimelineMarkers.module.scss (1 hunks)
  • apps/client/src/views/timeline/timeline-markers/TimelineMarkers.tsx (1 hunks)
  • apps/client/src/views/timeline/timeline-section/TimelineSection.tsx (1 hunks)
  • apps/client/src/views/timeline/timeline.options.ts (1 hunks)
  • apps/client/src/views/timeline/timeline.utils.ts (2 hunks)
💤 Files with no reviewable changes (5)
  • apps/client/src/features/viewers/minimal-timer/MinimalTimer.tsx
  • apps/client/src/features/viewers/timeline/Timeline.tsx
  • apps/client/src/features/viewers/timeline/timeline-markers/TimelineMarkers.module.scss
  • apps/client/src/features/viewers/timeline/timeline-progress-bar/TimelineProgressBar.module.scss
  • apps/client/src/features/viewers/timeline/timeline-progress-bar/TimelineProgressBar.tsx
✅ Files skipped from review due to trivial changes (3)
  • apps/client/src/views/timeline/timeline-markers/TimelineMarkers.module.scss
  • apps/client/src/views/timeline/timeline-section/TimelineSection.tsx
  • apps/client/src/views/timeline/timeline.options.ts
🧰 Additional context used
🔇 Additional comments (45)
apps/client/src/views/timeline/timeline-markers/TimelineMarkers.tsx (2)

10-10: Good addition of descriptive comment

The added comment clearly describes the purpose of the TimelineMarkers component. It follows JSDoc style, which is beneficial for documentation and IDE support.


18-20: Verify the impact of empty span elements

  1. The change to use only tag as the key prop is good, assuming tag is unique for each element. This can improve performance by avoiding the use of array indices in keys.

  2. However, the removal of content from the <span> elements is noteworthy:

    • Ensure that this change doesn't negatively impact the visual representation of the timeline markers.
    • Verify that there are appropriate CSS styles applied to these spans to create the desired visual markers.

Could you please confirm that the empty <span> elements still correctly represent the timeline markers visually? You might want to check the associated CSS (likely in TimelineMarkers.module.scss) to ensure the styling creates visible markers without relying on content.

To help verify this, you can run the following command to check the CSS file:

✅ Verification successful

Confirm CSS Styling for Span Elements

  1. The empty <span> elements are styled with CSS classes that define flex-grow and border-left properties.
  2. These styles ensure that the spans render as visual timeline markers without needing inner content.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the CSS for the TimelineMarkers component

# Test: Search for styles related to the markers or spans
rg --type scss -A 5 $'(markers|span)'

Length of output: 67


Script:

#!/bin/bash
# Description: Check the CSS for the TimelineMarkers component by searching .scss files

# Test: Search for styles related to the markers or spans
rg -A 5 '(markers|span)' --glob '*.scss'

Length of output: 1136

apps/client/src/views/ViewLoader.tsx (2)

30-32: LGTM! Clear and well-commented return statement.

The use of a fragment to return children is appropriate, and the ESLint disable comment provides a clear explanation for its usage.


9-11: LGTM! Review the conditional hook argument.

The component declaration and hook usage are well-structured. However, please review the argument passed to useRuntimeStylesheet.

The conditional data.overrideStyles && overrideStylesURL might cause issues if data.overrideStyles is falsy but not undefined. Consider using a more explicit condition:

If the hook is consistently used with this pattern, consider updating the hook to handle this logic internally.

✅ Verification successful

Verified conditional argument usage in useRuntimeStylesheet.

The usage of useRuntimeStylesheet with a conditional argument is consistent across the codebase in the following components:

  • apps/client/src/views/ViewLoader.tsx
  • apps/client/src/features/viewers/lower-thirds/LowerThird.tsx
  • apps/client/src/features/viewers/timer/Timer.tsx

No issues found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of useRuntimeStylesheet in other components

# Test: Search for other usages of useRuntimeStylesheet
rg --type typescript -A 5 $'useRuntimeStylesheet'

Length of output: 83


Script:

#!/bin/bash
# Description: Verify the usage of useRuntimeStylesheet in other components

# Test: Search for other usages of useRuntimeStylesheet in TypeScript files
rg --type ts -A 5 'useRuntimeStylesheet'
rg --type tsx -A 5 'useRuntimeStylesheet'

Length of output: 3586

apps/client/src/views/ViewLoader.module.scss (2)

1-4: LGTM: Well-structured import and variable declarations.

The import of viewer definitions and the use of variables for dot size and spacing promote consistency and maintainability.


1-73: Great implementation of a loading animation component.

This new ViewLoader.module.scss file is well-structured, uses modern CSS techniques, and creates an effective loading animation. It aligns well with the PR objective of refactoring and controlling container growth by providing a clean, modular implementation of a loading component.

Key strengths:

  1. Use of CSS Grid for centering
  2. CSS variables for theming
  3. Efficient use of keyframe animations
  4. Modular and maintainable code structure

The suggested improvements (z-index, accessibility, and animation duration variable) are minor and don't detract from the overall quality of the implementation.

apps/client/src/views/timeline/__tests__/timeline.utils.test.ts (3)

56-56: Function name corrected: makeTmelineSectionsmakeTimelineSections

The function name has been corrected from makeTmelineSections to makeTimelineSections, fixing a typo. This change improves code clarity and consistency.


59-59: Change in expected output format from string to number

The expected output format has changed from string representation (e.g., '11:00') to numerical representation (e.g., 11). This change suggests a modification in the makeTimelineSections function implementation.

To ensure consistency, please verify that this change is reflected in the implementation of makeTimelineSections:


56-60: Removal of midnight wrapping test case

The test case for wrapping around midnight has been removed. This could indicate a change in the expected behavior of the makeTimelineSections function or a simplification of the test cases.

To ensure this removal is intentional and doesn't leave any functionality untested, please verify the following:

  1. Check if the midnight wrapping functionality is still supported in the makeTimelineSections implementation:

  2. If the functionality is still present, consider adding a test case to cover it:

it('handles wrapping around midnight', () => {
  const result = makeTimelineSections(22, 2);
  expect(result).toEqual([22, 23, 0, 1]);
});

If the functionality has been intentionally removed, please update the function's documentation to reflect this change.

✅ Verification successful

Midnight Wrapping Functionality Removed

The makeTimelineSections function no longer handles wrapping around midnight. The removal of the midnight wrapping test case is intentional. To ensure clarity, please update the function's documentation to reflect this change.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if midnight wrapping is still handled in makeTimelineSections

# Test: Search for midnight handling in makeTimelineSections
rg --type typescript 'makeTimelineSections.*\{' -A 20 | rg '(?i)midnight|24|00:00|23:59'

Length of output: 125


Script:

#!/bin/bash
# Description: Check if midnight wrapping is still handled in makeTimelineSections

# Test: Search for midnight handling in makeTimelineSections with correct file types
rg --type ts --type tsx 'makeTimelineSections.*\{' -A 20 | rg '(?i)midnight|24|00:00|23:59'

Length of output: 121


Script:

#!/bin/bash
# Description: Check if midnight wrapping is still handled in makeTimelineSections

# Test: Search for midnight handling in makeTimelineSections with glob patterns
rg --glob '*.ts' --glob '*.tsx' 'makeTimelineSections.*\{' -A 20 | rg '(?i)midnight|24|00:00|23:59'

Length of output: 101

apps/client/src/views/timeline/Timeline.module.scss (4)

1-1: LGTM: Import path simplification

The updated import path for viewerDefs is more concise and easier to maintain. This change suggests a positive step towards better project structure.


21-21: LGTM: Consistent use of centralized variable

The update to use $view-background for the border-left color in the .column class maintains consistency with the earlier changes. This improves the overall maintainability of the styles.


70-71: LGTM: Consistent border styling

The updates to use $view-background for both border-bottom and the new border-top in the .content class are consistent with earlier changes. This creates a more complete and visually consistent border around the content.


10-13: Approved changes with a query on box-sizing

The use of $view-background and the addition of the box-shadow for the progress background are good improvements.

Could you clarify the reason for setting box-sizing: content-box? This might affect the layout calculations. If it's intentional, consider adding a comment explaining its purpose.

To verify the impact of this change, you can run the following script:

✅ Verification successful

Verified changes with no layout issues detected

The use of box-sizing: content-box in Timeline.module.scss aligns with other instances in the codebase and does not introduce any layout problems. No further actions are required.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any other occurrences of box-sizing in the project
# and potential layout issues caused by this change.

echo "Searching for other box-sizing declarations:"
rg --type css "box-sizing:"

echo "\nChecking for potential layout issues in React components:"
rg --type typescript --type javascript "className.*timeline"

Length of output: 1415


Script:

#!/bin/bash
# Description: Check for any other occurrences of box-sizing in the project
# and potential layout issues caused by the box-sizing change.

echo "Searching for other box-sizing declarations:"
rg --type css "box-sizing:"

echo "\nChecking for potential layout issues in React components:"
rg --type ts --type tsx --type js --type jsx "className.*timeline"

Length of output: 1414


Script:

#!/bin/bash
# Description: Check for any other occurrences of box-sizing in the project
# and potential layout issues caused by the box-sizing change.

echo "Searching for other box-sizing declarations:"
rg --type css "box-sizing:"

echo "\nChecking for potential layout issues in React components:"
rg --glob "*.ts" --glob "*.tsx" --glob "*.js" --glob "*.jsx" "className.*timeline"

Length of output: 1877

apps/client/src/views/timeline/TimelinePage.tsx (3)

32-32: LGTM! Verify impact on parent components.

The removal of the viewSettings prop from TimelinePageProps simplifies the component's interface. This change aligns with the removal of viewSettings-related logic in the component.

Run the following script to verify that no parent components are still trying to pass viewSettings to TimelinePage:

#!/bin/bash
# Description: Verify that no parent components are passing viewSettings to TimelinePage.

# Test: Search for TimelinePage usage with viewSettings prop. Expect: No results.
rg --type typescript '<TimelinePage.*viewSettings.*?>' || echo "No usage of TimelinePage with viewSettings prop found."

32-32: LGTM! Ensure no functionality loss.

The removal of viewSettings from the destructured props is consistent with its removal from the interface. This change streamlines the component.

To ensure no functionality has been lost, please run the following script to check for any remaining references to viewSettings within the component:

#!/bin/bash
# Description: Check for any remaining references to viewSettings within TimelinePage.

# Test: Search for viewSettings usage within TimelinePage. Expect: No results.
ast-grep --lang typescript --pattern $'function TimelinePage($_) {
  $$$
  viewSettings
  $$$
}'

Additionally, please thoroughly test the TimelinePage component to verify that all functionality remains intact after this change.


Line range hint 1-85: Overall assessment: Changes look good, but verify broader impact.

The modifications to TimelinePage.tsx appear to be part of a larger refactoring effort to streamline the component and improve the project structure. The removal of the viewSettings prop and related logic simplifies the component interface and implementation.

Key points:

  1. Import paths have been updated, likely due to project restructuring.
  2. The viewSettings prop has been removed from both the interface and component implementation.
  3. No other significant changes to the component's logic are visible.

Recommendations:

  1. Ensure that the new import paths are used consistently across the project.
  2. Verify that no parent components are still trying to pass viewSettings to TimelinePage.
  3. Thoroughly test the TimelinePage component to ensure no functionality has been lost due to the removal of viewSettings.
  4. If this change is part of a larger refactoring effort, consider adding a brief comment in the PR description explaining the motivation and scope of these changes.

To get a broader view of the impact of these changes, run the following script:

#!/bin/bash
# Description: Check for any remaining references to viewSettings in other components and verify TimelinePage usage.

# Test: Search for viewSettings usage in other components. Expect: No results or clear explanation for remaining usage.
rg --type typescript 'viewSettings' -g '!TimelinePage.tsx'

# Test: Check TimelinePage usage in other components. Expect: Consistent usage without viewSettings prop.
rg --type typescript '<TimelinePage' -A 5

Please review the results of this script to ensure the changes are consistent across the project.

apps/client/src/features/viewers/clock/Clock.tsx (4)

22-22: LGTM! Props destructuring updated correctly.

The destructuring of props has been correctly updated to reflect the changes in the ClockProps interface. This change maintains consistency with the interface modifications.


Line range hint 1-158: Overall, the changes look good and align with the PR objectives.

The modifications to the Clock component successfully simplify its structure by removing the viewSettings prop and associated logic. This refactoring aligns well with the PR's objective of controlling container growth.

Key points:

  1. The ClockProps interface has been simplified.
  2. Unnecessary stylesheet rendering logic has been removed.
  3. The core functionality of the Clock component remains intact.

These changes should improve the maintainability of the component without introducing new issues. Great job on the refactoring!


22-22: Verify impact of removed stylesheet rendering logic.

The removal of the useRuntimeStylesheet logic and associated conditional rendering simplifies the component. However, we should ensure this change doesn't negatively impact the component's functionality or styling.

Let's verify if there are any remaining references to useRuntimeStylesheet or related logic:

Please confirm that the removal of this logic doesn't affect the component's rendering or styling. Consider adding a comment explaining why this logic was removed if it's not obvious from the context.

✅ Verification successful

Let's retry the search without using the --type flag and instead target .ts and .tsx files directly:


Removal of useRuntimeStylesheet verified.

The useRuntimeStylesheet has been successfully removed from Clock.tsx. No remaining references in this file were found, confirming that the stylesheet rendering logic has been removed as intended.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to useRuntimeStylesheet

# Test 1: Search for useRuntimeStylesheet in the current file
echo "Searching for useRuntimeStylesheet in Clock.tsx:"
rg "useRuntimeStylesheet" apps/client/src/features/viewers/clock/Clock.tsx

# Test 2: Search for useRuntimeStylesheet in other files of the project
echo "Searching for useRuntimeStylesheet in other files:"
rg "useRuntimeStylesheet" --type typescript

Length of output: 371


Script:

#!/bin/bash
# Description: Check for any remaining references to useRuntimeStylesheet

# Test 1: Search for useRuntimeStylesheet in Clock.tsx
echo "Searching for useRuntimeStylesheet in Clock.tsx:"
rg "useRuntimeStylesheet" apps/client/src/features/viewers/clock/Clock.tsx

# Test 2: Search for useRuntimeStylesheet in TypeScript files using file extensions
echo "Searching for useRuntimeStylesheet in TypeScript files (.ts and .tsx):"
rg "useRuntimeStylesheet" --glob "*.ts" --glob "*.tsx"

Length of output: 1190


2-2: LGTM! Verify usage of Settings type.

The changes to the imports and ClockProps interface look good. The removal of viewSettings simplifies the component's props structure.

Let's verify the usage of the newly imported Settings type:

Also applies to: 15-19

✅ Verification successful

Settings type usage is correct.

The Settings type is properly imported from 'ontime-types' and used in the settings prop of the Clock component as Settings | undefined.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of Settings type in the Clock component

# Test: Search for usage of Settings type
rg --type typescript "Settings" apps/client/src/features/viewers/clock/Clock.tsx

Length of output: 371


Script:

#!/bin/bash
# Description: Re-verify the usage of Settings type in the Clock component with correct file types

# Test: Search for usage of Settings type in Clock.tsx using valid TypeScript file types
rg --type ts --type tsx "Settings" apps/client/src/features/viewers/clock/Clock.tsx

Length of output: 111


Script:

#!/bin/bash
# Description: Verify the usage of Settings type in the Clock component without specifying file types

# Test: Search for usage of Settings type directly in Clock.tsx
rg "Settings" apps/client/src/features/viewers/clock/Clock.tsx

Length of output: 137

apps/client/src/features/viewers/studio/StudioClock.tsx (1)

30-30: Approved: Removal of viewSettings from props destructuring

The removal of viewSettings from the props destructuring is consistent with its removal from the StudioClockProps interface. This change simplifies the component's props by eliminating an unused property, which aligns with the PR objective of refactoring.

To ensure all references to viewSettings have been removed, please run the following script:

If the script returns any results, please review and remove any remaining references to viewSettings or useRuntimeStylesheet if they are no longer needed.

✅ Verification successful

Action Required: Update Shell Scripts to Validate viewSettings Removal

The previous scripts failed due to an unrecognized file type. Please run the updated scripts below to ensure all references to viewSettings have been removed:


Action Required: Verify Complete Removal of viewSettings and useRuntimeStylesheet

The previous attempts to verify the removal of viewSettings and useRuntimeStylesheet failed due to unrecognized file types. Please run the updated scripts below, which search for these references by targeting .tsx files directly:


Verified: Complete Removal of viewSettings and useRuntimeStylesheet

The executed scripts confirmed that there are no remaining references to viewSettings or useRuntimeStylesheet in StudioClock.tsx. This ensures that the removal of these properties from the props destructuring and imports has been successfully completed, aligning with the PR objective of refactoring.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to viewSettings in the StudioClock component

# Test: Search for any remaining usage of viewSettings
rg --type typescript 'viewSettings' apps/client/src/features/viewers/studio/StudioClock.tsx

# Test: Check if useRuntimeStylesheet is still imported but unused
rg --type typescript 'import.*useRuntimeStylesheet' apps/client/src/features/viewers/studio/StudioClock.tsx

Length of output: 271


Script:

#!/bin/bash
# Description: Check for any remaining references to viewSettings in the StudioClock component

# Test: Search for any remaining usage of viewSettings
rg --type typescriptreact 'viewSettings' apps/client/src/features/viewers/studio/StudioClock.tsx

# Test: Check if useRuntimeStylesheet is still imported but unused
rg --type typescriptreact 'import.*useRuntimeStylesheet' apps/client/src/features/viewers/studio/StudioClock.tsx

Length of output: 291


Script:

#!/bin/bash
# Description: Check for any remaining references to viewSettings and useRuntimeStylesheet in the StudioClock component

# Test: Search for any remaining usage of viewSettings
rg 'viewSettings' apps/client/src/features/viewers/studio/StudioClock.tsx

# Test: Check if useRuntimeStylesheet is still imported but unused
rg 'import.*useRuntimeStylesheet' apps/client/src/features/viewers/studio/StudioClock.tsx

Length of output: 165

apps/client/src/features/viewers/ViewWrapper.tsx (1)

Line range hint 1-138: Overall component structure and functionality

Apart from the issue mentioned earlier, the overall structure and functionality of the withData HOC appear well-organized and follow good practices. The component efficiently fetches and passes various data to the wrapped component, making use of appropriate hooks and stores.

Consider adding some comments to explain the purpose of the withData HOC and its data fetching strategy, which would improve the code's maintainability and readability for future developers.

apps/client/src/features/viewers/public/Public.tsx (3)

4-4: LGTM: Import changes are consistent with prop removal.

The removal of the ViewSettings import aligns with the changes made to the BackstageProps interface. This change helps maintain code cleanliness by removing unused imports.


Line range hint 37-114: Verify impact of removing viewSettings-related code.

The removal of viewSettings-related code, including the useRuntimeStylesheet hook and conditional rendering logic, simplifies the component. However, it's crucial to ensure that this change doesn't negatively impact the component's functionality, especially regarding stylesheet loading and rendering.

Please confirm the following:

  1. The removal of useRuntimeStylesheet doesn't affect the application of necessary styles.
  2. The component renders correctly without the previous conditional logic (shouldRender).
  3. No unintended side effects occur due to the immediate rendering of the component.

Consider adding comments explaining the rationale behind these changes to improve code maintainability.


Line range hint 23-35: LGTM: BackstageProps interface updated correctly.

The removal of the viewSettings property from the BackstageProps interface is consistent with the import changes. This simplification of the component's props is likely part of a larger refactoring effort.

To ensure this change doesn't negatively impact other components, please run the following script to check for any remaining usage of viewSettings in relation to the Public component:

apps/client/src/views/timeline/timeline.utils.ts (2)

72-72: LGTM! Verify impact on consumers of makeTimelineSections.

The simplification of the makeTimelineSections function improves its focus and flexibility. It now returns raw hour indices instead of formatted time strings, which aligns with the single responsibility principle.

To ensure this change doesn't break existing functionality, please run the following script to find all usages of makeTimelineSections and verify they handle the new return type correctly:

#!/bin/bash
# Description: Find all usages of makeTimelineSections and verify they handle the new return type

# Test: Search for makeTimelineSections usage. Expect: List of files using the function.
rg --type typescript "makeTimelineSections" apps/

Please review each usage to ensure it correctly handles the new hour index return type instead of formatted time strings.


14-16: LGTM! Verify import consistency across the codebase.

The updated import paths reflect a change in the project's directory structure. This change improves code organization and is likely part of a larger refactoring effort.

To ensure consistency, please run the following script to check for any remaining occurrences of the old import paths:

✅ Verification successful

Import consistency verified. No old import paths detected.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for old import paths in the codebase

# Test: Search for old import paths. Expect: No results.
rg --type typescript "from '../../../common'" apps/

Length of output: 84


Script:

#!/bin/bash
# Description: Check for old import paths in TypeScript files within the apps directory

# Test: Search for old import paths. Expect: No results.
rg --type ts --type tsx "from '\\.\\.\\/\\.\\.\\/\\.\\.\\/common'" apps/

Length of output: 179


Script:

#!/bin/bash
# Description: Check for old import paths in TypeScript files within the apps directory

# Test: Search for old import paths. Expect: No results.
rg --type ts --type tsx 'from \.\.\/\.\.\/\.\.\/common' apps/

Length of output: 168


Script:

#!/bin/bash
# Description: Check for old import paths in TypeScript files within the apps directory

# Test: Search for old import paths. Expect: No results.
rg -F "from '../../../common'" apps/ -g "*.ts" -g "*.tsx"

Length of output: 65

apps/client/src/AppRouter.tsx (10)

87-94: LGTM: ViewLoader added to '/public' route.

The addition of ViewLoader to the '/public' route is consistent with the pattern established in the '/timer' route, maintaining a standardized approach to view loading.


95-102: LGTM: ViewLoader added to '/minimal' route.

The addition of ViewLoader to the '/minimal' route maintains consistency with the established pattern for view loading.


103-110: LGTM: ViewLoader added to '/clock' route.

The addition of ViewLoader to the '/clock' route continues the consistent application of the view loading pattern.


111-118: LGTM: ViewLoader added to '/countdown' route.

The addition of ViewLoader to the '/countdown' route maintains the consistent application of the view loading pattern across routes.


119-126: LGTM: ViewLoader added to '/backstage' route.

The addition of ViewLoader to the '/backstage' route continues the consistent application of the view loading pattern across the application's routes.


127-134: LGTM: ViewLoader added to '/studio' route.

The addition of ViewLoader to the '/studio' route maintains the consistent application of the view loading pattern established throughout the router.


137-144: LGTM: ViewLoader added to '/timeline' route and consistent with import change.

The addition of ViewLoader to the '/timeline' route completes the consistent application of the view loading pattern across all relevant routes. This change also aligns with the earlier modification to the Timeline component import path.


79-86: LGTM: ViewLoader added to '/timer' route.

The addition of ViewLoader to the '/timer' route is consistent with the new import and suggests a standardized approach to view loading.

To ensure this pattern is applied consistently across routes, please run the following script:

#!/bin/bash
# Description: Verify consistent use of ViewLoader across routes

# Test: Check if ViewLoader is used consistently in route definitions
rg --type typescript --multiline "element=\{\s*<ViewLoader>\s*<\w+\s*\/>\s*<\/ViewLoader>\s*\}" ./src/AppRouter.tsx

31-31: Verify the new location of TimelinePage component.

The import path for the Timeline component has been updated, which suggests a project structure reorganization. This change aligns with the new ViewLoader import from the 'views' directory.

Please run the following script to ensure the TimelinePage component exists in the new location:

#!/bin/bash
# Description: Verify the new location of TimelinePage component

# Test: Check if TimelinePage exists in the new location
fd --type file --full-path "./src/views/timeline/TimelinePage.tsx"

# Test: Ensure no references to the old path remain
rg --type typescript "from '\.\/features\/viewers\/timeline\/TimelinePage'" ./src

17-17: LGTM: New ViewLoader component imported.

The addition of the ViewLoader component is a good practice for managing loading states across multiple views.

To ensure the ViewLoader is implemented correctly, please run the following script:

apps/client/src/features/viewers/countdown/Countdown.tsx (3)

3-4: LGTM: Import statement improvements

The consolidation of imports from 'ontime-types' and the addition of an empty line for spacing enhance code readability and organization.


Line range hint 1-165: Summary of Countdown component changes

The changes to the Countdown component focus on simplifying its interface by removing the viewSettings prop. This aligns with the PR objective of refactoring and controlling container growth. The modifications appear to be part of a larger effort to streamline the component's functionality.

Key points:

  1. Import statements have been consolidated for better readability.
  2. The viewSettings prop has been removed from the CountdownProps interface and component logic.
  3. No other significant changes were made to the component's core functionality or rendering logic.

These changes seem to improve the component's maintainability. However, it's crucial to ensure that the removal of viewSettings doesn't inadvertently break any functionality in other parts of the application that might have depended on it.


29-29: Verify the impact of removing viewSettings

The removal of the viewSettings prop from the destructuring assignment aligns with the simplification mentioned in the summary. This change reduces complexity by removing unnecessary props.

Please run the following script to ensure that viewSettings is not used elsewhere in the component or in other parts of the codebase that might depend on it:

apps/client/src/features/viewers/backstage/Backstage.tsx (3)

5-5: LGTM: Simplified props structure

The removal of the ViewSettings import and the viewSettings prop from BackstageProps aligns with the PR objectives of refactoring. This change simplifies the component's dependencies and prop structure.

Also applies to: 42-43


Line range hint 1-165: Overall impact: Simplified component structure

The changes successfully remove the viewSettings prop and related logic, simplifying the Backstage component. This aligns with the PR objectives of refactoring and controlling container growth.

To ensure the changes don't have unintended consequences:

  1. Verify that all functionality previously dependent on viewSettings has been appropriately handled or is no longer needed.
  2. Conduct thorough testing of the Backstage component to confirm that its core functionality remains intact.
  3. Check if any other components or files need to be updated due to the removal of viewSettings.
#!/bin/bash
# Description: Check for potential impacts of removing viewSettings

# Test 1: Search for components that might have passed viewSettings to Backstage
echo "Searching for components that might have passed viewSettings to Backstage:"
rg -A 5 '<Backstage' apps/client/src/

# Test 2: Check for any ViewSettings usages in the project that might be affected
echo "Checking for ViewSettings usages in the project:"
rg 'ViewSettings' apps/client/src/

42-43: Verify removal of viewSettings functionality

The removal of viewSettings from props destructuring is consistent with the interface changes. However, please confirm that any functionality previously dependent on viewSettings has been appropriately handled or is no longer needed.

apps/client/src/views/timeline/TimelineEntry.tsx (2)

1-2: Imports are correctly added

The imports of useTimer and getProgress are appropriately added to support the new functionality in the ActiveBlock component.


98-103: ActiveBlock component correctly implements the progress bar

The ActiveBlock component uses useTimer and getProgress to calculate and display the progress bar when the status is 'live'. The implementation is correct and follows best practices.

@@ -1,4 +1,4 @@
@use '../../../theme/viewerDefs' as *;
@use '../../theme/viewerDefs' as *;
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Multiple files are still using the old import path ../../theme/viewerDefs.

Please update the import paths in the following files to ensure consistency and prevent potential issues:

  • apps/client/src/views/timeline/TimelinePage.scss
  • apps/client/src/views/timeline/Timeline.module.scss
  • apps/client/src/features/viewers/timer/Timer.scss
  • apps/client/src/features/viewers/studio/StudioClock.scss
  • apps/client/src/features/viewers/public/Public.scss
  • apps/client/src/features/viewers/countdown/Countdown.scss
  • apps/client/src/features/viewers/clock/Clock.scss
  • apps/client/src/features/viewers/backstage/Backstage.scss
  • apps/client/src/features/viewers/minimal-timer/MinimalTimer.scss
  • apps/client/src/features/control/playback/timer-display/TimerDisplay.module.scss
  • apps/client/src/common/components/schedule/Schedule.scss
  • apps/client/src/common/components/progress-bar/ProgressBar.scss
  • apps/client/src/common/components/multi-part-progress-bar/MultiPartProgressBar.scss
  • apps/client/src/common/components/title-card/TitleCard.scss
🔗 Analysis chain

Verify the impact of the import path change.

The import path for viewerDefs has been updated, which suggests a change in the project structure. Ensure that this change is consistent across the project and doesn't break any other imports.

Run the following script to verify the import usage:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the updated import path.

# Test 1: Check if there are any remaining uses of the old import path
echo "Checking for any remaining uses of the old import path:"
rg --type scss "'../../../theme/viewerDefs'"

# Test 2: Verify the existence of the new import path
echo "Verifying the existence of the new import path:"
fd --type f "viewerDefs.scss" "apps/client/src/theme"

# Test 3: Check for any other files that might need similar updates
echo "Checking for other files that might need similar updates:"
rg --type scss "'../../../theme/viewerDefs'"

Length of output: 605


Script:

#!/bin/bash
# Description: Verify the usage of the updated import path.

# Test 1: Check if there are any remaining uses of the old import path
echo "Checking for any remaining uses of the old import path:"
rg -g '*.scss' '../../theme/viewerDefs'

# Test 2: Verify the existence of the new import path
echo "Verifying the existence of the new import path:"
fd --type f "viewerDefs.scss" "apps/client/src/theme"

# Test 3: Check for any other files that might need similar updates
echo "Checking for other files that might need similar updates:"
rg -g '*.scss' '../../theme/viewerDefs'

Length of output: 3281

Comment on lines 4 to 8
import ViewParamsEditor from '../../common/components/view-params-editor/ViewParamsEditor';
import { useWindowTitle } from '../../common/hooks/useWindowTitle';
import { ViewExtendedTimer } from '../../common/models/TimeManager.type';
import { formatTime, getDefaultFormat } from '../../common/utils/time';
import SuperscriptTime from '../../features/viewers/common/superscript-time/SuperscriptTime';
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

'viewSettings' prop still referenced in the project.

The viewSettings prop has been successfully removed from TimelinePage.tsx, but it is still referenced in other parts of the codebase. Please address the following files to complete the removal:

  • packages/types/src/definitions/DataModel.type.ts
  • apps/server/src/models/demoProject.ts
  • apps/server/src/api-data/view-settings/viewSettings.router.ts
  • apps/server/src/models/dataModel.ts
  • apps/server/src/api-data/db/db.controller.ts
  • apps/server/src/api-data/db/db.validation.ts
  • apps/server/src/api-data/index.ts
  • apps/server/src/utils/parser.ts
  • apps/server/src/utils/parserFunctions.ts
  • apps/server/src/classes/data-provider/DataProvider.utils.ts
  • apps/server/src/classes/data-provider/DataProvider.ts
  • apps/server/src/classes/data-provider/__tests__/DataProvider.utils.test.ts
  • apps/server/src/utils/__tests__/parser.test.ts
  • apps/client/src/features/viewers/ViewWrapper.tsx
  • apps/client/src/features/viewers/lower-thirds/LowerThird.tsx
  • apps/client/src/features/operator/status-bar/StatusBar.tsx
  • apps/client/src/features/operator/status-bar/StatusBarProgress.tsx
  • apps/client/src/features/viewers/minimal-timer/MinimalTimer.tsx
  • apps/client/src/features/app-settings/panel/general-panel/ViewSettingsForm.tsx
  • apps/client/src/features/app-settings/panel/project-panel/ProjectMergeForm.tsx
  • apps/client/src/features/viewers/timer/Timer.tsx
  • apps/client/src/common/hooks-query/useViewSettings.ts
  • apps/client/src/common/api/constants.ts
  • apps/client/src/common/api/viewSettings.ts

Please ensure that all references to viewSettings are either removed or appropriately refactored to maintain project integrity.

🔗 Analysis chain

LGTM! Verify new import paths across the project.

The changes to import statements appear to be part of a project restructuring. The new paths look correct, but it's important to ensure consistency across the entire project.

Run the following script to verify the new import paths:


Import path verification script encountered errors. Please run the corrected script below to verify the new import paths across the project.


Please run the following script to verify the removal of the viewSettings prop from TimelinePage.tsx and ensure no lingering references exist.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the new import paths are used consistently across the project.

# Test: Search for old import paths. Expect: No results.
rg --type typescript "from '../../common/components/view-params-editor/ViewParamsEditor'" || echo "Old ViewParamsEditor import not found."
rg --type typescript "from '../../common/hooks/useWindowTitle'" || echo "Old useWindowTitle import not found."
rg --type typescript "from '../../common/models/TimeManager.type'" || echo "Old ViewExtendedTimer import not found."
rg --type typescript "from '../../common/utils/time'" || echo "Old time utils import not found."
rg --type typescript "from '../../features/viewers/common/superscript-time/SuperscriptTime'" || echo "Old SuperscriptTime import not found."

# Test: Search for new import paths. Expect: Multiple results across the project.
rg --type typescript "from '../../common/components/view-params-editor/ViewParamsEditor'"
rg --type typescript "from '../../common/hooks/useWindowTitle'"
rg --type typescript "from '../../common/models/TimeManager.type'"
rg --type typescript "from '../../common/utils/time'"
rg --type typescript "from '../../features/viewers/common/superscript-time/SuperscriptTime'"

Length of output: 267


Script:

#!/bin/bash
# Description: Verify the new import paths are used consistently across the project.

# Test: Search for old import paths. Expect: No results.
rg --type ts "from '../../common/components/view-params-editor/ViewParamsEditor'" || echo "Old ViewParamsEditor import not found."
rg --type ts "from '../../common/hooks/useWindowTitle'" || echo "Old useWindowTitle import not found."
rg --type ts "from '../../common/models/TimeManager.type'" || echo "Old ViewExtendedTimer import not found."
rg --type ts "from '../../common/utils/time'" || echo "Old time utils import not found."
rg --type ts "from '../../features/viewers/common/superscript-time/SuperscriptTime'" || echo "Old SuperscriptTime import not found."

# Test: Search for new import paths. Expect: Multiple results across the project.
rg --type ts "from '../../common/components/view-params-editor/ViewParamsEditor'"
rg --type ts "from '../../common/hooks/useWindowTitle'"
rg --type ts "from '../../common/models/TimeManager.type'"
rg --type ts "from '../../common/utils/time'"
rg --type ts "from '../../features/viewers/common/superscript-time/SuperscriptTime'"

Length of output: 3657


Script:

#!/bin/bash
# Description: Verify the removal of the `viewSettings` prop and check for any remaining references.

# Test: Ensure `viewSettings` prop is removed from TimelinePageProps interface.
if rg --type ts "viewSettings" apps/client/src/views/timeline/TimelinePage.tsx; then
  echo "Error: 'viewSettings' prop still found in TimelinePage.tsx."
else
  echo "'viewSettings' prop successfully removed from TimelinePage.tsx."
fi

# Test: Search for any remaining references to `viewSettings` across the project.
if rg --type ts "viewSettings" --ignore-file .rgignore; then
  echo "Error: 'viewSettings' prop still referenced in other parts of the project."
else
  echo "No remaining references to 'viewSettings' found in the project."
fi

Length of output: 8654

Comment on lines 89 to 92
// // prevent render until we get all the data we need
// if (!viewSettings) {
// return null;
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Issues Found: Potential Runtime Errors Due to viewSettings Usage

The removal of the safeguard for viewSettings has led to multiple instances where viewSettings is accessed directly without checking for its existence. This can cause runtime errors if viewSettings is undefined during the component's render.

Affected Areas:

  • apps/client/src/features/viewers/timer/Timer.tsx
  • apps/client/src/features/viewers/minimal-timer/MinimalTimer.tsx
  • apps/client/src/features/viewers/lower-thirds/LowerThird.tsx

Recommendations:

  1. Reintroduce the Safeguard:
    • Reinstate the conditional rendering to ensure the component only renders when viewSettings is available.
    if (!viewSettings) {
      return null;
    }
  2. Consistent Handling:
    • Ensure all accesses to viewSettings use optional chaining or include checks to handle cases where it might be undefined.
    const value = viewSettings?.property;
  3. Fallbacks and Defaults:
    • Provide default values or fallback UI elements to enhance user experience when viewSettings is not available.
🔗 Analysis chain

Potential issue: Removed safeguard for viewSettings

The commented-out code was preventing the component from rendering until viewSettings was available. Removing this check could lead to the following issues:

  1. The component might render before viewSettings is available, potentially causing runtime errors.
  2. It may affect the user experience by showing incomplete or incorrect data.
  3. Other parts of the component might rely on viewSettings being available.

Please clarify the reasoning behind this change and consider the following recommendations:

  1. Add a fallback or loading state if viewSettings is undefined.
  2. Verify that all uses of viewSettings in the component handle the possibility of it being undefined.

To help verify the impact of this change, please run the following script:

This script will help identify potential issues with viewSettings usage in the viewers feature. Please review the results to ensure that all uses of viewSettings are safe when it might be undefined.


To address the issue with the previous script, please run the following updated scripts:

These scripts search specifically for .ts and .tsx files, ensuring that rg processes the correct file types without relying on the --type flag.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for usages of viewSettings that might cause issues if undefined

# Test 1: Check for direct usage of viewSettings properties
echo "Checking for direct usage of viewSettings properties:"
rg --type typescript 'viewSettings\.' apps/client/src/features/viewers

# Test 2: Check for spread of viewSettings
echo "Checking for spread of viewSettings:"
rg --type typescript '\.\.\.\s*viewSettings' apps/client/src/features/viewers

# Test 3: Check for optional chaining on viewSettings
echo "Checking for optional chaining on viewSettings:"
rg --type typescript 'viewSettings\?\.' apps/client/src/features/viewers

Length of output: 637


Script:

# 
#!/bin/bash
# Description: Check for usages of viewSettings that might cause issues if undefined

# Test 1: Check for direct usage of viewSettings properties in .ts and .tsx files
echo "Checking for direct usage of viewSettings properties:"
rg 'viewSettings\.' apps/client/src/features/viewers --glob '*.ts' --glob '*.tsx'

# Test 2: Check for spread of viewSettings in .ts and .tsx files
echo "Checking for spread of viewSettings:"
rg '\.\.\.\s*viewSettings' apps/client/src/features/viewers --glob '*.ts' --glob '*.tsx'

# Test 3: Check for optional chaining on viewSettings in .ts and .tsx files
echo "Checking for optional chaining on viewSettings:"
rg 'viewSettings\?\.' apps/client/src/features/viewers --glob '*.ts' --glob '*.tsx'

Length of output: 2711

Comment on lines +35 to +36
let eventStatus: ProgressStatus = selectedEventId ? 'done' : 'future';
let elapsedDays = 0;
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

Refactor eventStatus logic to compute event status per event

Currently, the eventStatus variable is mutated across iterations of the rundown.map function, which can lead to unexpected behavior and reduces code clarity. It's better to compute the status for each event individually to improve maintainability.

Apply this diff to refactor the code:

@@ -35,3 +35,3 @@
 // we use selectedEventId as a signifier on whether the timeline is live
-let eventStatus: ProgressStatus = selectedEventId ? 'done' : 'future';
+let hasLiveEventOccurred = false;
@@ -47,7 +47,11 @@

-// keep track of progress of rundown
-if (eventStatus === 'live') {
-  eventStatus = 'future';
-}
-if (event.id === selectedEventId) {
-  eventStatus = 'live';
-}
+let status: ProgressStatus;
+if (event.id === selectedEventId) {
+  status = 'live';
+  hasLiveEventOccurred = true;
+} else if (hasLiveEventOccurred) {
+  status = 'future';
+} else {
+  status = 'done';
+}

@@ -82,2 +86,2 @@
   left={elementLeftPosition}
-  status={eventStatus}
+  status={status}

Also applies to: 48-53, 82-82

@@ -48,6 +49,7 @@ export function TimelineEntry(props: TimelineEntryProps) {
width: `${width}px`,
}}
>
{status === 'live' ? <ActiveBlock /> : <div data-status={status} className={style.timelineBlock} />}
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

Ensure consistent data-status attributes by passing status to ActiveBlock

In line 52, when status === 'live', the ActiveBlock component is rendered, which sets data-status='live' inside its returned div. In the else branch, a div is rendered with data-status={status}. To maintain consistency and flexibility, consider passing status as a prop to ActiveBlock and setting data-status={status} within it. This ensures that if the status logic changes in the future, ActiveBlock remains consistent with the rest of the code.

Apply the following changes:

At line 52, pass status to ActiveBlock:

- {status === 'live' ? <ActiveBlock /> : <div data-status={status} className={style.timelineBlock} />}
+ {status === 'live' ? <ActiveBlock status={status} /> : <div data-status={status} className={style.timelineBlock} />}

Modify ActiveBlock to accept status as a prop and use it:

- function ActiveBlock() {
+ function ActiveBlock({ status }: { status: ProgressStatus }) {

And in the return statement:

- return <div data-status='live' className={style.timelineBlock} style={{ '--progress': `${progress}%` }} />;
+ return <div data-status={status} className={style.timelineBlock} style={{ '--progress': `${progress}%` }} />;

Also applies to: 99-103

@cpvalente cpvalente changed the title refactor: control container growth refactor: timeline review Oct 7, 2024
@cpvalente cpvalente force-pushed the timeline-revision branch 5 times, most recently from 8f5c51d to a0913ab Compare October 12, 2024 13:16
@cpvalente cpvalente merged commit 1d4ddea into master Oct 15, 2024
4 checks passed
@cpvalente cpvalente deleted the timeline-revision branch October 15, 2024 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants