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

Tabs component #169

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

Conversation

Shivareddy-Aluri
Copy link

implemented tabs component
Screenshot 2022-11-13 at 11 19 14 PM

@@ -0,0 +1,5 @@
<div data-test-ember-headlessui-tabs-wrapper ...attributes>
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we have to have this wrapping div?

</div>
<div class="mx-auto w-full max-w-md shadow-md px-4 py-4 rounded-xl bg-white mt-4">
{{#each this.contents as |content index|}}
<tabs.Content class="content" @content-index={{index}}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we remove the index? and compare via object identity or some other way? using indexes makes looping inefficient / invalidate more frequently than we need it to

@@ -0,0 +1,22 @@
<div class='w-full max-w-md px-2 py-16 mx-auto'>
<TabsGroup class="flex flex-col space-x-1 rounded-xl p-1" @onChange = {{this.onChange}} as |tabs|>
Copy link
Collaborator

Choose a reason for hiding this comment

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

What are your thoughts on internalizing the onChange behavior by default?

can we abstract away the need for the consumer to configure this? (I think so!)

@tracked currentTab = null;
@action
registerTabNames(e) {
this.tabNames = [...this.tabNames, e];
Copy link
Collaborator

Choose a reason for hiding this comment

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

instead of using immutability patterns, can we switch to a TrackedArray? that will provide more optimal updates and not invalidate the whole collection

@@ -0,0 +1,7 @@
<div class="{{if this.renderContent '' 'hidden'}}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we can assume a "hidden" class exists

get renderContent() {
return this.element === this.args.selectedContent;
}
registerContent = modifier((e) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we not have this side-effect here? I know this pattern is common in headlessui, but it's a problematic pattern, and we don't want to propagate it.

Derived data will be more performant, have fewer layout shifts, and will in general be way easier to debug.

id={{guid}}
disabled={{if @disable true false}}
{{on 'click' this.selectTab}}
{{this.registerTabs}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove this modifier please <3

Copy link
Collaborator

@NullVoxPopuli NullVoxPopuli left a comment

Choose a reason for hiding this comment

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

First off, thanks for submitting this!!! It's a huge help!

Only got part way through so far, but some general notes:

  • don't have effects, instead, favor derived data patterns
    • no registerItem/tab/whatever helpers/modifiers/etc
  • I think we can reduce the amount of glue code consumers need to use

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