-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add Tabs component #73
Conversation
dgca
commented
Dec 3, 2024
•
edited
Loading
edited
function List({ children }: ListProps) { | ||
return ( | ||
<HStack justifyContent="center" borderBottomWidth={1} borderColor="divider"> | ||
{children} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to make things more accessible, we should have the children here be a ul
and then we can wrap the trigger elements in an li
.
The ul
can then also have the role of tablist
and each li
can have a role of tab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Man, this would be so much easier with polymorphic components :(
function Content({ children, value }: ContentProps) { | ||
const context = useTabsContext(); | ||
|
||
return context.activeTab === value ? <>{children}</> : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the content of a tab content area should have a role of tabpanel
|
||
return ( | ||
<html.button | ||
onClick={() => context.setActiveTab(value)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if active we can add an aria-selected
value here so it reads out as the active tab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only thoughts are around a11y
Talked on Slack and decided to fix the a11y stuff as a follow up after trying to make polymorphic |