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

Clearer handling of expandable list steps #2333

Merged
merged 6 commits into from
Oct 18, 2024

Conversation

rohitpaulk
Copy link
Member

@rohitpaulk rohitpaulk commented Oct 18, 2024

  • fix dark mode hover effect
  • Add NonExpandableStep component and refactor ExpandableStepList logic.

Summary by CodeRabbit

  • New Features

    • Introduced a new NonExpandableStep component to enhance the user experience in the expandable step list.
    • Added a hover overlay on non-expandable steps to inform users about completion requirements.
    • Expanded Tailwind CSS theme with a new amber color for enhanced styling options.
  • Bug Fixes

    • Updated hover background color for improved visibility in dark mode.
  • Style

    • Enhanced responsive and adaptive styles for light and dark themes in the new component.
    • Adjusted hover effects in dark mode for better user experience.

Copy link
Contributor

coderabbitai bot commented Oct 18, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request introduces a new NonExpandableStep component within the ExpandableStepList, designed to visually represent non-expandable steps. It includes a hover overlay that informs users about the completion requirements of previous steps. Additionally, minor updates to the hover styling for dark mode in the Step component are included, along with enhancements to the Tailwind CSS configuration, adding new color definitions and customization options.

Changes

File Path Change Summary
app/components/expandable-step-list/non-expandable-step.hbs Introduced non-expandable-step component with a hover overlay and responsive styles.
app/components/expandable-step-list/non-expandable-step.ts Added NonExpandableStepComponent, defined its signature, and registered it in the Glint environment.
app/components/expandable-step-list/step.hbs Updated hover background color class for dark mode styling.
app/components/expandable-step-list/step.ts Modified logic in handleDidUpdateIsComplete to allow broader conditions for previous step completion.
tailwind.config.js Added amber color to the theme and expanded customization options for colors and variants.

Possibly related PRs

🐰 In the garden of code, we hop and play,
New steps emerge, brightening the way.
With overlays and styles, we dance in delight,
Expanding our list, making everything right!
So let’s celebrate, with a joyful cheer,
For every new change brings us closer, my dear! 🌼✨


🪧 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

🧹 Outside diff range and nitpick comments (5)
app/components/expandable-step-list/non-expandable-step.ts (1)

13-13: LGTM: Component class is correctly defined.

The NonExpandableStepComponent class is properly set up, extending Component with the Signature interface. This ensures type safety for the component's props and element type.

Consider adding JSDoc comments to describe the component's purpose and usage. For example:

/**
 * Represents a non-expandable step in the ExpandableStepList.
 * This component is used for rendering steps that don't require expansion.
 */
export default class NonExpandableStepComponent extends Component<Signature> {}
app/components/expandable-step-list/non-expandable-step.hbs (1)

1-15: Styling approach looks good, with a minor suggestion for consistency.

The use of utility classes provides great flexibility and covers both light and dark modes effectively. The hover effect and overlay styling are well-implemented.

For consistency, consider using the same text color class for both the title and the overlay message in dark mode. Currently, the title uses dark:prose-invert (which typically results in white text), while the overlay message uses dark:text-yellow-500. You might want to choose one approach:

  1. Keep the yellow color for emphasis:

    <h3 class="prose dark:prose-invert dark:text-yellow-500" data-test-step-title>
  2. Use the default dark mode text color for both:

    <div class="text-sm text-gray-500 dark:text-gray-200 font-semibold shadow-sm" data-test-step-title>

Choose the option that best fits your design system and user experience goals.

app/components/expandable-step-list.hbs (3)

9-26: Approve the introduction of conditional rendering for steps

The new conditional rendering logic enhances the component's flexibility by introducing the NonExpandableStep for steps that are not complete and not the first incomplete step. This change likely improves the user experience by providing a clear visual distinction between expandable and non-expandable steps.

Consider extracting the condition into a named helper or computed property for improved readability:

{{#if (should-render-non-expandable-step step)}}
  <ExpandableStepList::NonExpandableStep @number={{add stepIndex 1}} @step={{step}} />
{{else}}
  <ExpandableStepList::Step
    ...
  >
    ...
  </ExpandableStepList::Step>
{{/if}}

This would make the template more declarative and easier to understand at a glance.


11-26: Approve the Step component usage with a suggestion for consistency

The properties and event handlers passed to the ExpandableStepList::Step component are comprehensive and well-structured. The use of the eq helper for comparisons and the fn helper for event binding is appropriate.

For consistency with the NonExpandableStep component, consider moving the @number attribute to the first position in the list of attributes:

<ExpandableStepList::Step
  @number={{add stepIndex 1}}
  @isExpanded={{eq this.expandedStepId step.id}}
  @isFirstIncompleteStep={{eq step.id this.firstIncompleteStep.id}}
  ...
>
  ...
</ExpandableStepList::Step>

This minor change would align the attribute order with the NonExpandableStep component, potentially making the code easier to scan and maintain.


9-26: Summary: Improved flexibility and user experience in ExpandableStepList

The changes introduced in this pull request significantly enhance the ExpandableStepList component by:

  1. Adding conditional rendering to differentiate between expandable and non-expandable steps.
  2. Introducing a new NonExpandableStep component for improved visual distinction.
  3. Maintaining the existing Step component with comprehensive properties and event handlers.

These modifications align well with the PR objectives, potentially improving the user interface and experience, especially in scenarios involving incomplete steps. The implementation appears sound and maintains the overall structure of the component while adding new functionality.

As the component grows in complexity, consider breaking it down into smaller, more focused components if it hasn't been done already. This could improve maintainability and make it easier to test individual parts of the expandable step list functionality.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c9ae492 and d4ba6eb.

📒 Files selected for processing (4)
  • app/components/expandable-step-list.hbs (1 hunks)
  • app/components/expandable-step-list/non-expandable-step.hbs (1 hunks)
  • app/components/expandable-step-list/non-expandable-step.ts (1 hunks)
  • app/components/expandable-step-list/step.hbs (1 hunks)
🧰 Additional context used
🔇 Additional comments (6)
app/components/expandable-step-list/non-expandable-step.ts (4)

1-2: LGTM: Imports are correct and necessary.

The imports are appropriate for defining a Glimmer component and using the Step type from the parent directory.


4-11: LGTM: Interface definition is well-structured.

The Signature interface correctly defines the component's structure:

  • Element as HTMLDivElement indicates the component will render as a div.
  • Args properly defines the expected props: number and step.

This structure ensures type safety when using the component.


15-19: LGTM: Glint module declaration is correct.

The component is properly registered in the Glint environment:

  • The naming convention 'ExpandableStepList::NonExpandableStep' correctly indicates a nested component structure.
  • This declaration ensures proper type checking when using the component in templates.

1-19: Overall implementation aligns well with PR objectives.

The new NonExpandableStepComponent is well-structured and implements the necessary TypeScript and Glimmer component patterns. It aligns with the PR objectives of refactoring the ExpandableStepList logic by introducing a new component for non-expandable steps.

Key points:

  1. Proper use of TypeScript for type safety.
  2. Clear component structure with a well-defined signature.
  3. Correct Glint environment registration for template type checking.

This implementation provides a solid foundation for rendering non-expandable steps within the ExpandableStepList, enhancing the overall functionality as described in the PR objectives.

app/components/expandable-step-list/non-expandable-step.hbs (1)

1-15: 🛠️ Refactor suggestion

Consider additional functionality enhancements and edge cases.

The current implementation of the non-expandable step component looks functional, but there are a few areas where we could enhance the user experience and handle potential edge cases:

  1. Keyboard accessibility: Although the step is not expandable, consider adding keyboard focus styles for better accessibility. This can be done by adding focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 classes to the main container.

  2. Screen reader support: Add an aria-describedby attribute to the main container and create a hidden description to explain why the step is not expandable.

  3. Error handling: Add a fallback for cases where @step.titleMarkdown might be undefined or empty.

  4. Customizable messaging: Consider making the overlay message customizable through an attribute.

Here's an example of how you could implement these enhancements:

<article 
  class="py-2 px-1 cursor-not-allowed group/non-expandable-step relative focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" 
  aria-label="Non-expandable step {{@number}}" 
  aria-describedby="step-{{@number}}-description"
  tabindex="0"
  data-test-expandable-step-list-non-expandable-step 
  ...attributes
>
  <div class="flex items-center justify-between gap-2">
    <h3 class="prose dark:prose-invert" data-test-step-title>
      {{markdown-to-html (concat "**Step " @number "**: " (or @step.titleMarkdown "Untitled Step"))}}
    </h3>
  </div>
  <div
    class="absolute inset-0 flex gap-1 items-center justify-center bg-gray-50/80 dark:bg-gray-800/80 backdrop-blur-[3px] opacity-0 group-hover/non-expandable-step:opacity-100 group-focus/non-expandable-step:opacity-100 transition-opacity"
    aria-hidden="true"
  >
    {{svg-jar "information-circle" class="w-5 h-5 fill-current text-yellow-500 shadow-sm" aria-hidden="true"}}
    <div class="text-sm text-gray-500 dark:text-yellow-500 font-semibold shadow-sm" data-test-step-title>
      {{or @overlayMessage "Complete previous step to expand this step"}}
    </div>
  </div>
  <div id="step-{{@number}}-description" class="sr-only">
    This step cannot be expanded until the previous step is completed.
  </div>
</article>

These changes would improve accessibility, handle potential edge cases, and allow for more customization of the component.

To ensure that the markdown-to-html helper is properly imported and used across the project, we can run the following verification:

This will help us confirm that the markdown-to-html helper is consistently used and properly defined in the project.

app/components/expandable-step-list/step.hbs (1)

2-2: Improved dark mode hover effect

The change from dark:hover:bg-gray-800 to dark:hover:bg-gray-700/60 enhances the dark mode hover effect. The slightly lighter gray with 60% opacity should provide a more subtle and visually appealing hover state, improving the overall user experience in dark mode.

This modification aligns well with modern design trends and addresses the PR objective of fixing the dark mode hover effect.

Comment on lines 1 to 15
<div class="py-2 px-1 cursor-not-allowed group/non-expandable-step relative" data-test-expandable-step-list-non-expandable-step ...attributes>
<div class="flex items-center justify-between gap-2">
<div class="prose dark:prose-invert" data-test-step-title>
{{markdown-to-html (concat "**Step " @number "**: " @step.titleMarkdown)}}
</div>
</div>
<div
class="absolute inset-0 flex gap-1 items-center justify-center bg-gray-50/80 dark:bg-gray-800/80 backdrop-blur-[3px] opacity-0 group-hover/non-expandable-step:opacity-100 transition-opacity"
>
{{svg-jar "information-circle" class="w-5 h-5 fill-current text-yellow-500 shadow-sm"}}
<div class="text-sm text-gray-500 dark:text-yellow-500 font-semibold shadow-sm" data-test-step-title>
Complete previous step to expand this step
</div>
</div>
</div>
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

Consider using semantic HTML elements and enhancing accessibility.

The overall structure of the component is well-organized, but it could benefit from using more semantic HTML elements and improving accessibility. Here are some suggestions:

  1. Use <article> or <section> instead of the outermost <div> to better represent the step content semantically.
  2. Add an aria-label to the main container to describe its purpose.
  3. Use a heading element (e.g., <h3>) for the step title instead of a <div>.
  4. Add appropriate ARIA attributes to the overlay to improve screen reader experience.

Here's an example of how you could refactor the component:

<article class="py-2 px-1 cursor-not-allowed group/non-expandable-step relative" aria-label="Non-expandable step {{@number}}" data-test-expandable-step-list-non-expandable-step ...attributes>
  <div class="flex items-center justify-between gap-2">
    <h3 class="prose dark:prose-invert" data-test-step-title>
      {{markdown-to-html (concat "**Step " @number "**: " @step.titleMarkdown)}}
    </h3>
  </div>
  <div
    class="absolute inset-0 flex gap-1 items-center justify-center bg-gray-50/80 dark:bg-gray-800/80 backdrop-blur-[3px] opacity-0 group-hover/non-expandable-step:opacity-100 transition-opacity"
    aria-hidden="true"
    role="tooltip"
  >
    {{svg-jar "information-circle" class="w-5 h-5 fill-current text-yellow-500 shadow-sm" aria-hidden="true"}}
    <div class="text-sm text-gray-500 dark:text-yellow-500 font-semibold shadow-sm" data-test-step-title>
      Complete previous step to expand this step
    </div>
  </div>
</article>

These changes would improve the semantic structure and accessibility of the component.

Copy link

codecov bot commented Oct 18, 2024

Bundle Report

Changes will increase total bundle size by 3.04kB (0.01%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
client-array-push 35.76MB 3.04kB (0.01%) ⬆️

Copy link

github-actions bot commented Oct 18, 2024

Test Results

  1 files  ±0    1 suites  ±0   6m 26s ⏱️ -7s
574 tests ±0  537 ✅  - 1  36 💤 ±0  0 ❌ ±0  1 🔥 +1 
589 runs  ±0  551 ✅  - 2  36 💤 ±0  1 ❌ +1  1 🔥 +1 

For more details on these errors, see this check.

Results for commit 9106a9c. ± Comparison against base commit c9ae492.

♻️ This comment has been updated with latest results.

Copy link

codecov bot commented Oct 18, 2024

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
574 1 573 0
View the top 1 failed tests by shortest run time
Chrome 129.0 Acceptance | concepts-test: tracked progress is rendered properly on page visit
Stack Traces | 0.394s run time
No failure message available

To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard

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 (1)
tailwind.config.js (1)

30-30: LGTM! Consider updating documentation.

The addition of the amber color to the Tailwind configuration is appropriate and aligns with the PR objectives. This new color can be used for the hover effect mentioned in the PR summary.

Consider updating any relevant documentation or style guides to reflect the availability of the amber color palette in your project. This will help other developers be aware of and correctly use the new color option.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 3b52212 and 6a2ab5c.

📒 Files selected for processing (2)
  • app/components/expandable-step-list/non-expandable-step.hbs (1 hunks)
  • tailwind.config.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/components/expandable-step-list/non-expandable-step.hbs
🧰 Additional context used

@rohitpaulk rohitpaulk changed the title expandable list hover effect Clearer handling of expandable list steps Oct 18, 2024
@rohitpaulk rohitpaulk merged commit 023efa7 into main Oct 18, 2024
5 of 7 checks passed
@rohitpaulk rohitpaulk deleted the expandable-list-hover-effect branch October 18, 2024 03:04
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.

1 participant