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

📑 @tournant/tabs #62

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

marcus-herrmann
Copy link
Collaborator

What has been added

How can this be tested

In which screen readers have these additions been tested

  • NVDA
  • JAWS
  • VoiceOver

In which browsers have these additions been tested

Mobile

  • Firefox
  • Chrome (Android)
  • Safari (iOS)
  • Samsung Internet

Desktop

  • Firefox (recent)
  • Edge (recent)
  • Chrome (recent)
  • Safari (recent)

Additonal remarks

@marcus-herrmann marcus-herrmann changed the title feat(switch button): add to homepage feat(tab): add tabpanel Jan 20, 2020
@marcus-herrmann marcus-herrmann self-assigned this Jan 20, 2020
@marcus-herrmann marcus-herrmann added the component:tabs Issues regarding @tournant/tabs label Jan 20, 2020
@marcus-herrmann marcus-herrmann force-pushed the feature/component/add-tab-component branch from 3b1889d to 259922c Compare January 20, 2020 13:09
@ovlb ovlb changed the title feat(tab): add tabpanel 📑 @tournant/tabs Jan 30, 2020
Copy link
Member

@ovlb ovlb left a comment

Choose a reason for hiding this comment

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

Some remarks.

Also, I added a more complex example and Safari does not send focus inside of the tab with a link.

@@ -0,0 +1,7 @@
Copyright 2019 Oscar Braunert <[email protected]>
Copy link
Member

Choose a reason for hiding this comment

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

Note to self: Need to update the license header in communard.

</tournant-tabs-widget>
```
Finally, decide on the initial tab. Pass the tab/panel name into `<TournantTabsWidget>`'s initial prop.

Copy link
Member

Choose a reason for hiding this comment

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

I would love to have examples that got deeper than this. What happens if there is interactive contents, headline structure etc. Also, we should avoid foo, bar, baz as variable names. Rather come up with a simple real life example. Maybe cooking related?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

First Course, Second Course, Third Course, Dessert. I like it.

@click="clickHandler"
@keydown="keydownHandler"
>
<slot name="tabs"></slot>
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we could simplify the implementation by using a prop instead of a slot here. Would probably also reduce the amount of code we would have to write in the event handlers down here. At the moment it seems like we miss to leverage most of the benefits Vue provides us for modifying attributes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Reasoning behind using <tournant-tab> was that that way, people could place more than just text in Tabs, for example an icon. This wouldn't be possible if tabs were an array, e.g. ["Foo", "Bar", "Baz"]. I know what you mean regarding this approach not being vue-ish, though. I'm wondering for quite some while now: is there a third way?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm … good point. Let me think about this. Of the top of my head: When using an array of objects we could provide some level of customisation (e.g. class names and text). If we change Tab.vue into a functional component we might(!) be able to provide an option to render child components through it (say you want to add an icon that is a component). Either way, we should be very clear what is and what is not usable (e.g. don’t put complex structures in there as the button will likely eat its semantics). Locking this down has some advantages, as keeping it open.

If we keep TournantTab, we have to make sure that the name for the ID is slugified. A random ID wouldn’t work here as Tab and Tabpanel need to have the same name, right?

In the end: It depends. Need to get those stickers now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If we keep TournantTab, we have to make sure that the name for the ID is slugified. A random ID wouldn’t work here as Tab and Tabpanel need to have the same name, right?

Correct.

<slot name="tabs"></slot>
</div>
<div ref="panellist">
<slot name="panels"></slot>
Copy link
Member

Choose a reason for hiding this comment

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

Slot here makes sense to provide a mechanism for implementors to add any kind of content.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is this actionable or rather thinking out loud? If the latter: Yes, that's what I was thinking.

Copy link
Member

Choose a reason for hiding this comment

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

This was thinking out loud agreement :)

Comment on lines +84 to +110
keydownHandler: function(e) {
const activeElem = this.$refs.tablist.querySelector(`#${this.activeTab}`)
const activeIndex = Array.from(this.$refs.tablist.children).indexOf(
activeElem
)
let targetTab
switch (e.keyCode) {
case 37:
if (activeIndex - 1 < 0) {
targetTab = this.tabs[this.tabs.length - 1]
} else {
targetTab = this.tabs[activeIndex - 1]
}
this.changeTab(targetTab.id)
break
case 39:
if (activeIndex + 1 > this.tabs.length - 1) {
targetTab = this.tabs[0]
} else {
targetTab = this.tabs[activeIndex + 1]
}
this.changeTab(targetTab.id)
break
default:
return
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Can we break this up into multiple methods for the single events?

@ovlb
Copy link
Member

ovlb commented Mar 6, 2020

A case we probably also need to think about: How does it collapse in a «server side rendering but JS fails to run»-environment?

@marcus-herrmann
Copy link
Collaborator Author

A case we probably also need to think about: How does it collapse in a «server side rendering but JS fails to run»-environment?

This concern is valid for all of tournant, I'm afraid

@ovlb
Copy link
Member

ovlb commented Mar 6, 2020

This concern is valid for all of tournant, I'm afraid

It indeed is. I’ll open an issue to explore the robustness of the components once implemented. Building the project website could help with this. 🙈

@ovlb
Copy link
Member

ovlb commented Mar 6, 2020

See #71

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:tabs Issues regarding @tournant/tabs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants