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

Feature: Title and description for tabs #3442

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

Conversation

Nevelito
Copy link
Contributor

Description

  • Refactor tab_groups to have title and description

Fixes # (issue) #3421

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

Screenshots & recording

image

Copy link

codeclimate bot commented Nov 19, 2024

Code Climate has analyzed commit 45318a0 and detected 0 issues on this pull request.

View more on Code Climate.

@Nevelito
Copy link
Contributor Author

I think I mede it as I should, but I do not know what can I put into title and description of tabs. Also I don't know why tab_group_component_spec and tab_swicher_component_spec are empty.

@Paul-Bob Paul-Bob added the Enhancement Not necessarily a feature, but something has improved label Nov 19, 2024
Copy link
Contributor

@Paul-Bob Paul-Bob left a comment

Choose a reason for hiding this comment

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

Looking good already, @Nevelito. Thank you!

Let's make two minor changes:

  1. Use the instance variable directly in the component instead of defining a public reader. Instance variable access is faster than reader access.
  2. In the tab header component, let's add the def render? method, and inside it, define the logic as (@title || @description).present?. This way, we avoid rendering an empty div if there is neither a title nor a description.

Otherwise, it's looking good! 👍

app/components/avo/tab_header_component.rb Outdated Show resolved Hide resolved
app/components/avo/tab_header_component.html.erb Outdated Show resolved Hide resolved
Copy link
Contributor

@Paul-Bob Paul-Bob left a comment

Choose a reason for hiding this comment

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

While manually testing this I noticed something, title and description would look nicer outside of the tabs border:

image

And let's try to extract the header section from app/components/avo/panel_component.html.erb and reuse it for tabs instead of creating a new component.

Copy link
Contributor

@Paul-Bob Paul-Bob left a comment

Choose a reason for hiding this comment

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

Seems a bit to much to render the whole Avo::PanelComponent when we only want to render the header section. Le'ts create a new component, extract the header section into that component and use the new Avo::PanelHeaderComponent

app/components/avo/tab_group_component.html.erb Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Not necessarily a feature, but something has improved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants