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

fix(templates): don't show section when all items are hidden #2219

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mtdvlpr
Copy link

@mtdvlpr mtdvlpr commented Feb 21, 2025

Summary by CodeRabbit

  • Refactor
    • Refined the display logic for content sections so that only sections containing visible items are rendered. This update improves the consistency of the interface by ensuring that sections without any visible content remain hidden.

Copy link

coderabbitai bot commented Feb 21, 2025

📝 Walkthrough

Walkthrough

The changes update the rendering logic in multiple files by modifying the conditional check in the Section component. Each update now filters the section.items array to include only items marked as visible, and the component returns null if the section is not visible or if there are no visible items. This adjustment refines the component's control flow to ensure that only sections with visible items are rendered.

Changes

File(s) Change Summary
apps/artboard/.../azurill.tsx, apps/artboard/.../bronzor.tsx, apps/artboard/.../chikorita.tsx, apps/artboard/.../ditto.tsx, apps/artboard/.../gengar.tsx, apps/artboard/.../glalie.tsx, apps/artboard/.../kakuna.tsx, apps/artboard/.../leafish.tsx, apps/artboard/.../nosepass.tsx, apps/artboard/.../onyx.tsx, apps/artboard/.../pikachu.tsx, apps/artboard/.../rhyhorn.tsx Updated the conditional check in the Section component to filter for visible items before counting them. The component now returns null only if the section is not visible or if no visible items are present.

Sequence Diagram(s)

sequenceDiagram
    participant Section as Section Component
    participant Filter as Item Filter
    participant Render as Render Decision

    Section->>Filter: Filter section.items by item.visible
    Filter-->>Section: Return list of visible items
    Section->>Render: Check if section is visible and list length > 0
    Render-->>Section: Return decision (render or null)
Loading

Poem

I'm a rabbit of code, with a burrow so neat,
Hopping over booleans on nimble, bouncy feet.
Filtering out the shadows, letting only light in view,
Ensuring each section shines with items fresh and true.
In fields of code I frolic, where visibility is key,
Celebrating each change with a joyful, swift spree! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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

@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

🧹 Nitpick comments (1)
apps/artboard/src/templates/chikorita.tsx (1)

185-185: LGTM! Consider reducing code duplication across templates.

The visibility check implementation is correct and consistent with other templates.

Consider moving the Section component to a shared location since it's identical across all templates. This would:

  • Reduce code duplication
  • Make future maintenance easier
  • Ensure consistency in behavior

Example structure:

// src/components/section.tsx
export const Section = <T,>({ section, children, ...props }: SectionProps<T>) => {
  if (!section.visible || section.items.filter((item) => item.visible).length === 0) return null;
  // ... rest of the implementation
};

// templates/onyx.tsx, rhyhorn.tsx, etc.
import { Section } from "../components/section";
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cd21860 and 8efc243.

📒 Files selected for processing (12)
  • apps/artboard/src/templates/azurill.tsx (1 hunks)
  • apps/artboard/src/templates/bronzor.tsx (1 hunks)
  • apps/artboard/src/templates/chikorita.tsx (1 hunks)
  • apps/artboard/src/templates/ditto.tsx (1 hunks)
  • apps/artboard/src/templates/gengar.tsx (1 hunks)
  • apps/artboard/src/templates/glalie.tsx (1 hunks)
  • apps/artboard/src/templates/kakuna.tsx (1 hunks)
  • apps/artboard/src/templates/leafish.tsx (1 hunks)
  • apps/artboard/src/templates/nosepass.tsx (1 hunks)
  • apps/artboard/src/templates/onyx.tsx (1 hunks)
  • apps/artboard/src/templates/pikachu.tsx (1 hunks)
  • apps/artboard/src/templates/rhyhorn.tsx (1 hunks)
🔇 Additional comments (11)
apps/artboard/src/templates/kakuna.tsx (1)

199-199: LGTM! Improved section visibility logic.

The updated condition correctly filters out hidden items before checking the section's length, ensuring sections with only hidden items are not displayed. This change aligns well with the PR objective.

apps/artboard/src/templates/leafish.tsx (1)

194-194: LGTM! Consistent implementation across templates.

The visibility check update matches the implementation in other templates, maintaining consistency in how hidden items are handled.

apps/artboard/src/templates/azurill.tsx (1)

189-189: LGTM! Maintains consistent behavior.

The visibility check update aligns with other templates, ensuring consistent handling of hidden items across the application.

apps/artboard/src/templates/bronzor.tsx (1)

180-180: LGTM! Completes the consistent implementation.

The visibility check update matches other templates, completing the consistent implementation of this feature across all templates.

apps/artboard/src/templates/onyx.tsx (1)

200-200: LGTM! The visibility check enhancement improves the rendering logic.

The updated condition ensures that sections with only hidden items are not rendered, which aligns with the PR objective and improves the user experience.

apps/artboard/src/templates/rhyhorn.tsx (1)

181-181: LGTM! Consistent implementation across templates.

The visibility check matches the implementation in other templates, maintaining consistency in the codebase.

apps/artboard/src/templates/nosepass.tsx (1)

183-183: LGTM! Visibility check is consistent with other templates.

The implementation maintains consistency with other templates while improving section visibility logic.

apps/artboard/src/templates/glalie.tsx (1)

195-195: LGTM! The visibility check is now more consistent and efficient.

The change improves the component by:

  1. Moving the visibility check earlier in the component lifecycle
  2. Ensuring consistency with the filtering in the render method
  3. Preventing unnecessary component initialization when no items are visible
apps/artboard/src/templates/gengar.tsx (1)

187-187: LGTM! The visibility check is consistent with other templates.

The change ensures consistent behavior across templates by applying the same visibility logic improvement.

apps/artboard/src/templates/pikachu.tsx (1)

215-215: LGTM! The visibility check is consistent with other templates.

The change ensures consistent behavior across templates by applying the same visibility logic improvement.

apps/artboard/src/templates/ditto.tsx (1)

200-200: LGTM! The visibility check is consistent with other templates.

The change ensures consistent behavior across templates by applying the same visibility logic improvement.

@DemaPy
Copy link
Contributor

DemaPy commented Mar 8, 2025

@mtdvlpr isn't would be better to move it into utils folder?
This is clearly duplicated logic.

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