-
-
Notifications
You must be signed in to change notification settings - Fork 459
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve Accessibility - captions (#957)
* Improve Accessibility - captions https://developer.mozilla.org/en-US/docs/Web/HTML/Element/caption > A caption functions like a heading for a table. Most screen readers announce the content of captions. Captions help users to find a table and understand what it’s about and decide if they want to read it. If the user uses “Tables Mode”, captions are the primary mechanism to identify tables. The caption is provided by the <caption> element. from: https://www.w3.org/WAI/tutorials/tables/caption-summary/ * renderCaption --------- Co-authored-by: Kevin Van Cott <[email protected]>
- Loading branch information
1 parent
cdb9e18
commit 1a633e9
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
packages/material-react-table/stories/styling/Caption.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { type MRT_ColumnDef, MaterialReactTable } from '../../src'; | ||
import { faker } from '@faker-js/faker'; | ||
import { type Meta } from '@storybook/react'; | ||
|
||
const meta: Meta = { | ||
title: 'Styling/Caption Examples', | ||
}; | ||
|
||
export default meta; | ||
|
||
const columns: MRT_ColumnDef<(typeof data)[0]>[] = [ | ||
{ | ||
accessorKey: 'firstName', | ||
header: 'First Name', | ||
}, | ||
{ | ||
accessorKey: 'lastName', | ||
header: 'Last Name', | ||
}, | ||
{ | ||
accessorKey: 'age', | ||
header: 'Age', | ||
}, | ||
{ | ||
accessorKey: 'address', | ||
header: 'Address', | ||
}, | ||
{ | ||
accessorKey: 'state', | ||
header: 'State', | ||
}, | ||
{ | ||
accessorKey: 'phoneNumber', | ||
header: 'Phone Number', | ||
}, | ||
]; | ||
|
||
const data = [...Array(25)].map(() => ({ | ||
address: faker.location.streetAddress(), | ||
age: faker.number.int({ max: 60, min: 20 }), | ||
firstName: faker.person.firstName(), | ||
lastName: faker.person.lastName(), | ||
phoneNumber: faker.phone.number(), | ||
state: faker.location.state(), | ||
})); | ||
|
||
export const BottomCaption = () => ( | ||
<MaterialReactTable | ||
columns={columns} | ||
data={data} | ||
renderCaption={() => 'Table Caption'} | ||
/> | ||
); | ||
|
||
export const TopCaption = () => ( | ||
<MaterialReactTable | ||
columns={columns} | ||
data={data} | ||
muiTableProps={{ | ||
sx: { | ||
captionSide: 'top', | ||
}, | ||
}} | ||
renderCaption={() => 'Table Caption'} | ||
/> | ||
); |
1a633e9
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.
Successfully deployed to the following URLs:
material-react-table-storybook – ./
material-react-table-storybook-git-v2-kevinvandy-s-team.vercel.app
material-react-table-storybook-kevinvandy-s-team.vercel.app
material-react-table-storybook.vercel.app
material-react-table.dev
www.material-react-table.dev
1a633e9
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.
Successfully deployed to the following URLs:
material-react-table – ./apps/material-react-table-docs
material-react-table.vercel.app
material-react-table-kevinvandy-s-team.vercel.app
material-react-table-git-v2-kevinvandy-s-team.vercel.app
v2.material-react-table.com
material-react-table.com
www.material-react-table.com