carbon-design-system / carbon

A design system built by IBM
https://www.carbondesignsystem.com
Apache License 2.0
7.87k stars 1.82k forks source link

Content Switcher refactor #9519

Open joshblack opened 3 years ago

joshblack commented 3 years ago

The ContentSwitcher component effectively uses the tab pattern under-the-hood in order to be operable. Unfortunately, the current API does not wire up everything that is needed for this pattern to function. In particular, it does not connect the currently selected "tab" with its corresponding "tabpanel".

This issue is to update the ContentSwitcher API to correctly implement the ARIA Design Pattern for Tab: https://w3c.github.io/aria-practices/#tabpanel behind the enable-v11-release feature flag. This work can optionally include refactoring the class-based component to a hook-based one, in an earlier stage, if it's helpful.

Some potential APIs to consider:

joshblack commented 3 years ago

API Design

// Sample code snippet

Props

Name Type Description

Links & Resources

joshblack commented 3 years ago

Question, how would we relate switchers like in this example:

image

joshblack commented 3 years ago

ContentSwitcher checklist

GA

joshblack commented 3 years ago

Next steps

Use cases

kingtraceyj commented 3 years ago

Here are some high level thoughts for our Monday discussion:

Content switcher let users toggle between different formatting, like with a grid view and a table view. They are also often used to narrow content groups of closely related information. The role of tabs in information hierarchy is to separate content. Tabs follow the metaphor for sections in a filing cabinet and two tabs wouldn’t contain the same sheet of paper. When it comes to content, tabs play a bigger part in information hierarchy while content switchers are more precise in the content/component they are paired with.

There are a few similar use cases. For instance, you could use both tabs or a content switcher within a card but it depends on the specific content being organized:

different view of same info: content switcher

different category of same thing: content switcheror tabs, depends on the visual hierarchy of the components and content around it

separate but related info: tabs (see this a lot with multiple data tables)

high level differences:

tabs content switcher
distinct but still related content alternate views of same content
no overlapping content (sometimes can happen but if so, it's very specific to workflow) usually has overlapping content or is the same content
organizes a broader range content organize specific content in context
first hierarchically, can be more broad, stand alone usually paired with other content or components
organizes content to reduce cognitive load narrow down choices or options to make a better decision
kingtraceyj commented 3 years ago

ai apps icon switcher: https://pages.github.ibm.com/ai-applications/design/components/iconcontentswitcher/usage/

sstrubberg commented 1 year ago

Backlog cleaning:

It currently fails the "tab pattern"