Skip to content

chore(page): updated examples to provide a11y labels #11740

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const PageCenteredSection: React.FunctionComponent = () => {

return (
<Page masthead={masthead} sidebar={sidebar}>
<PageSection isWidthLimited isCenterAligned>
<PageSection isWidthLimited isCenterAligned aria-label="width limited page section">
<Card>
<CardBody>
When a width limited page section is wider than the value of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,16 @@ export const PageGroupSection: React.FunctionComponent = () => {
</BreadcrumbItem>
</Breadcrumb>
</PageBreadcrumb>
<PageSection>Grouped section</PageSection>
<PageSection aria-labelledby="grouped-section">
<h2 id="grouped-section">Grouped section</h2>
</PageSection>
</PageGroup>
<PageSection>Section 1</PageSection>
<PageSection>Section 2</PageSection>
<PageSection aria-labelledby="section-1">
<h2 id="section-1">Grouped example section 1</h2>
</PageSection>
<PageSection aria-labelledby="section-2">
<h2 id="section-2">Grouped example section 2</h2>
</PageSection>
</Page>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,15 @@ export const PageHorizontalNav: React.FunctionComponent = () => {

return (
<Page masthead={masthead}>
<PageSection>Section 1</PageSection>
<PageSection variant="secondary">Section 2 with secondary variant styling</PageSection>
<PageSection>Section 3</PageSection>
<PageSection aria-labelledby="section-1">
<h2 id="section-1">Horizontal nav example section 1</h2>
</PageSection>
<PageSection variant="secondary" aria-labelledby="section-2">
<h2 id="section-2">Horizontal nav example section 2 with secondary variant styling</h2>
</PageSection>
<PageSection aria-labelledby="section-3">
<h2 id="section-3">Horizontal nav example section 3</h2>
</PageSection>
</Page>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,18 @@ export const PageMainSectionPadding: React.FunctionComponent = () => {

return (
<Page masthead={masthead} sidebar={sidebar}>
<PageSection>Section with default padding</PageSection>
<PageSection padding={{ default: 'noPadding' }}>Section with no padding</PageSection>
<PageSection padding={{ default: 'noPadding', md: 'padding' }}>Section with padding on medium</PageSection>
<PageSection padding={{ md: 'noPadding' }}>Section with no padding on medium</PageSection>
<PageSection aria-labelledby="section-1">
<h2 id="section-1">Section with default padding</h2>
</PageSection>
<PageSection padding={{ default: 'noPadding' }} aria-labelledby="section-2">
<h2 id="section-2">Section with no padding</h2>
</PageSection>
<PageSection padding={{ default: 'noPadding', md: 'padding' }} aria-labelledby="section-3">
<h2 id="section-3">Section with padding on medium</h2>
</PageSection>
<PageSection padding={{ md: 'noPadding' }} aria-labelledby="section-4">
<h2 id="section-4">Section with no padding on medium</h2>
</PageSection>
</Page>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,22 @@ export const PageMainSectionPadding: React.FunctionComponent = () => {

return (
<Page header={header} sidebar={sidebar}>
<PageSection type="subnav">
<PageSection type="subnav" aria-label="With subnav type">
Section with <code>type="subnav"</code> for horizontal subnav navigation
</PageSection>
<PageSection type="nav">
<PageSection type="nav" aria-label="With nav type">
Section with <code>type="nav"</code> for tertiary navigation
</PageSection>
<PageSection type="tabs">
<PageSection type="tabs" aria-label="With tabs type">
Section with <code>type="tabs"</code> for tabs
</PageSection>
<PageSection type="breadcrumb">
<PageSection type="breadcrumb" aria-label="With breadcrumb type">
Section with <code>type="breadcrumb"</code> for breadcrumbs
</PageSection>
<PageSection>
<PageSection aria-label="With default type">
Section without <code>type</code> prop or <code>type="default"</code> for main sections
</PageSection>
<PageSection type="wizard">
<PageSection type="wizard" aria-label="With wizard type">
Section with <code>type="wizard"</code> for wizards
</PageSection>
</Page>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,15 @@ export const PageMultipleSidebarBody: React.FunctionComponent = () => {

return (
<Page masthead={masthead} sidebar={sidebar}>
<PageSection>Section 1</PageSection>
<PageSection>Section 2</PageSection>
<PageSection>Section 3</PageSection>
<PageSection aria-labelledby="section-1">
<h2 id="section-1">Multiple sidebar body example section 1</h2>
</PageSection>
<PageSection aria-labelledby="section-2">
<h2 id="section-2">Multiple sidebar body example section 2</h2>
</PageSection>
<PageSection aria-labelledby="section-3">
<h2 id="section-3">Multiple sidebar body example section 3</h2>
</PageSection>
</Page>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,15 @@ export const PageUncontrolledNav: React.FunctionComponent = () => {

return (
<Page isManagedSidebar masthead={masthead} sidebar={sidebar}>
<PageSection>Section 1</PageSection>
<PageSection>Section 2</PageSection>
<PageSection>Section 3</PageSection>
<PageSection aria-labelledby="section-1">
<h2 id="section-1">Uncontrolled nav example section 1</h2>
</PageSection>
<PageSection aria-labelledby="section-2">
<h2 id="section-2">Uncontrolled nav example section 2</h2>
</PageSection>
<PageSection aria-labelledby="section-3">
<h2 id="section-3">Uncontrolled nav example section 3</h2>
</PageSection>
</Page>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,15 @@ export const PageVerticalNav: React.FunctionComponent = () => {

return (
<Page masthead={masthead} sidebar={sidebar}>
<PageSection>Section 1</PageSection>
<PageSection variant="secondary">Section 2 with secondary variant styling</PageSection>
<PageSection>Section 3</PageSection>
<PageSection aria-labelledby="section-1">
<h2 id="section-1">Vertical nav example section 1</h2>
</PageSection>
<PageSection variant="secondary" aria-labelledby="section-2">
<h2 id="section-2">Vertical nav example section 2 with secondary variant styling</h2>
</PageSection>
<PageSection aria-labelledby="section-3">
<h2 id="section-3">Vertical nav example section 3</h2>
</PageSection>
</Page>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,15 @@ export const PageWithOrWithoutFill: React.FunctionComponent = () => {

return (
<Page isContentFilled masthead={masthead} sidebar={sidebar}>
<PageSection>A default page section</PageSection>
<PageSection isFilled={true} variant="secondary">
This section fills the available space.
<PageSection aria-labelledby="section-1">
<h2 id="section-1">Section without fill</h2>
</PageSection>
<PageSection isFilled={true} variant="secondary" aria-labelledby="section-2">
<h2 id="section-2">Section with fill</h2>
</PageSection>
<PageSection aria-labelledby="section-3">
<h2 id="section-3">Another section without fill</h2>
</PageSection>
<PageSection>A default page section</PageSection>
</Page>
);
};
12 changes: 6 additions & 6 deletions packages/react-core/src/demos/Banner.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ class BannerDemo extends React.Component {
return (
<Fragment>
<DashboardWrapper banner={banner} breadcrumb={null}>
<PageSection>
<PageSection aria-labelledby="main-title">
<Content>
<h1>Main title</h1>
<h1 id="main-title">Main title</h1>
<p>
Body text should be Red Hat Text at 1rem(16px). It should have leading of 1.5rem(24px) because <br />
of it’s relative line height of 1.5.
</p>
</Content>
</PageSection>
<PageSection>
<PageSection aria-label='Cards gallery'>
<Gallery hasGutter>
{Array.from({ length: 30 }).map((_value, index) => (
<GalleryItem key={index}>
Expand Down Expand Up @@ -112,17 +112,17 @@ class BannerDemo extends React.Component {
</FlexItem>
<FlexItem grow={{ default: 'grow' }} style={{ minHeight: 0 }}>
<DashboardWrapper breadcrumb={null}>
<PageSection>
<PageSection aria-labelledby="main-title">
<Content>
<h1>Main title</h1>
<h1 id='main-title'>Main title</h1>
<p>
Body text should be Red Hat Text at 1rem(16px). It should have leading of 1.5rem(24px) because{' '}
<br />
of it’s relative line height of 1.5.
</p>
</Content>
</PageSection>
<PageSection>
<PageSection aria-label='Cards gallery'>
<Gallery hasGutter>
{Array.from({ length: 30 }).map((_value, index) => (
<GalleryItem key={index}>
Expand Down
13 changes: 9 additions & 4 deletions packages/react-core/src/demos/CardView/examples/CardView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -465,16 +465,16 @@ export const CardViewBasic: React.FunctionComponent = () => {
return (
<Fragment>
<DashboardWrapper mainContainerId="main-content-card-view-default-nav" breadcrumb={null}>
<PageSection>
<PageSection aria-labelledby="projects">
<Content>
<h1>Projects</h1>
<h1 id="projects">Projects</h1>
<p>This is a demo that showcases PatternFly cards.</p>
</Content>
<Toolbar id="toolbar-group-types" clearAllFilters={onDelete}>
<ToolbarContent>{toolbarItems}</ToolbarContent>
</Toolbar>
</PageSection>
<PageSection isFilled>
<PageSection isFilled aria-label="Selectable card gallery">
<Gallery hasGutter aria-label="Selectable card container">
<Card isCompact>
<Bullseye>
Expand Down Expand Up @@ -546,7 +546,12 @@ export const CardViewBasic: React.FunctionComponent = () => {
))}
</Gallery>
</PageSection>
<PageSection isFilled={false} stickyOnBreakpoint={{ default: 'bottom' }} padding={{ default: 'noPadding' }}>
<PageSection
isFilled={false}
stickyOnBreakpoint={{ default: 'bottom' }}
padding={{ default: 'noPadding' }}
aria-label="Pagination controls"
>
<Pagination
itemCount={totalItemCount}
page={page}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ export const DataListActionable: React.FunctionComponent = () => {

return (
<DashboardWrapper mainContainerId="main-content-datalist-view-actions" breadcrumb={null}>
<PageSection>
<PageSection aria-labelledby="projects">
<Content>
<Title headingLevel="h1">Projects</Title>
<Title headingLevel="h1" id="projects">
Projects
</Title>
<Content component="p">This is a demo that showcases PatternFly Data List</Content>
</Content>
</PageSection>
<PageSection>
<PageSection aria-label="Data list of projects">
<DataList aria-label="single action data list example ">
{!isDeleted && (
<DataListItem aria-labelledby="single-action-item1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ export const DataListBasic: React.FunctionComponent = () => {
return (
<Fragment>
<DashboardWrapper mainContainerId="main-content-datalist-view-default-nav" breadcrumb={null}>
<PageSection>
<PageSection aria-labelledby="projects">
<Content>
<h1>Projects</h1>
<h1 id="projects">Projects</h1>
<p>This is a demo that showcases PatternFly data list</p>
</Content>
</PageSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ export const DataListExpandableControlInToolbar: React.FunctionComponent = () =>
return (
<Fragment>
<DashboardWrapper mainContainerId="main-content-datalist-view-default-nav" breadcrumb={null}>
<PageSection>
<PageSection aria-labelledby="projects">
<Content>
<h1>Projects</h1>
<h1 id="projects">Projects</h1>
<p>This is a demo that showcases PatternFly data list</p>
</Content>
</PageSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ export const DataListStaticBottomPagination: React.FunctionComponent = () => {

return (
<DashboardWrapper mainContainerId="main-content-datalist-view-pagination" breadcrumb={null}>
<PageSection>
<PageSection aria-labelledby="projects">
<Content>
<Content component="h1">Projects</Content>
<Content component="h1" id="projects">
Projects
</Content>
<Content component="p">This is a demo that showcases PatternFly Data List</Content>
</Content>
</PageSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ import { DashboardWrapper } from '@patternfly/react-core/dist/js/demos/Dashboard

export const DescriptionListBasic: React.FunctionComponent = () => (
<DashboardWrapper>
<PageSection>
<PageSection aria-labelledby="projects">
<Content>
<Content component="h1">Projects</Content>
<h1 id="projects">Projects</h1>
<Content component="p">This is a full page demo</Content>
</Content>
</PageSection>
<PageSection>
<PageSection aria-labelledby="details">
<Card>
<CardHeader>
<Title headingLevel="h2" size="lg">
<Title headingLevel="h2" size="lg" id="details">
Details
</Title>
</CardHeader>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,15 @@ export const DescriptionListInDrawer: React.FunctionComponent = () => {
isNotificationDrawerExpanded={isExpanded}
onNotificationDrawerExpand={onExpand}
>
<PageSection>
<PageSection aria-labelledby="main-title">
<Content>
<Content component="h1">Main title</Content>
<Content component="h1" id="main-title">
Main title
</Content>
<Content component="p">This is a full page demo.</Content>
</Content>
</PageSection>
<PageSection>{drawerContent}</PageSection>
<PageSection aria-label="Drawer Content">{drawerContent}</PageSection>
</DashboardWrapper>
);
};
10 changes: 5 additions & 5 deletions packages/react-core/src/demos/JumpLinks.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ ScrollspyH2 = () => {

return (
<DashboardWrapper breadcrumb={null} mainContainerId="scrollable-element">
<PageSection>
<Title headingLevel="h1" size="2xl">
<PageSection aria-labelledby='main-title'>
<Title headingLevel="h1" size="2xl" id='main-title'>
Main title
</Title>
<Switch
Expand All @@ -90,10 +90,10 @@ ScrollspyH2 = () => {
onChange={(_event, check) => setIsVertical(check)}
/>
</PageSection>
<PageSection padding={{ default: 'noPadding' }}>
<PageSection padding={{ default: 'noPadding' }} >
<Sidebar hasGutter orientation={!isVertical && 'stack'}>
<SidebarPanel variant="sticky">
<PageSection>
<PageSection aria-label='Jump links navigation'>
<JumpLinks
isVertical={isVertical}
isCentered={!isVertical}
Expand All @@ -113,7 +113,7 @@ ScrollspyH2 = () => {
</PageSection>
</SidebarPanel>
<SidebarContent hasNoBackground>
<PageSection>
<PageSection aria-label='Main content'>
<Content>
{headings.map(i => (
<div key={i} style={{ maxWidth: '800px', marginBottom: '32px' }}>
Expand Down
Loading
Loading