Skip to content

Commit f76da1b

Browse files
authored
Fix accessibility issues on dashboard examples (#5866)
1 parent 750bcb7 commit f76da1b

File tree

3 files changed

+71
-66
lines changed

3 files changed

+71
-66
lines changed

apps/docs/src/examples/templates/dashboards/DashboardExample.js

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useContext, useMemo, useState } from 'react';
2-
import { Box, Button, Text, Page, PageContent } from 'grommet';
2+
import { Box, Button, Text, Page, PageContent, Main } from 'grommet';
33
import { defaultUser, GlobalHeader, UserContext } from '../global-header';
44
import { DashboardGrid, DashboardFooter, Greeting } from '.';
55

@@ -17,23 +17,25 @@ export const DashboardExample = () => {
1717
return (
1818
<UserContext.Provider value={contextValue}>
1919
<GlobalHeader />
20-
<Page background="background-back">
21-
<Box overflow="auto">
22-
<PageContent>
23-
<Box flex={false}>
24-
{user ? (
25-
<Box gap="xlarge">
26-
<Greeting />
27-
<DashboardGrid />
28-
</Box>
29-
) : (
30-
<DemoPageContent />
31-
)}
32-
</Box>
33-
{user && <DashboardFooter />}
34-
</PageContent>
35-
</Box>
36-
</Page>
20+
<Main>
21+
<Page background="background-back">
22+
<Box overflow="auto">
23+
<PageContent>
24+
<Box flex={false}>
25+
{user ? (
26+
<Box gap="xlarge">
27+
<Greeting />
28+
<DashboardGrid />
29+
</Box>
30+
) : (
31+
<DemoPageContent />
32+
)}
33+
</Box>
34+
{user && <DashboardFooter />}
35+
</PageContent>
36+
</Box>
37+
</Page>
38+
</Main>
3739
</UserContext.Provider>
3840
);
3941
};

apps/docs/src/examples/templates/dashboards/ThreeColumnDashboard.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useContext, useState } from 'react';
22
import {
33
Grid,
4-
// Main,
4+
Main,
55
ResponsiveContext,
66
Page,
77
PageContent,
@@ -14,12 +14,14 @@ import { CostByMonth, CostByService, CostByYear, RulesAudit } from './content';
1414
export const ThreeColumnDashboard = () => (
1515
<AppContainer background="background-back">
1616
<ContentArea title="Global Header" />
17-
<Page pad={{ bottom: '3xlarge' }}>
18-
<PageContent gap="xlarge">
19-
<PageHeader title="Dashboard" />
20-
<Content />
21-
</PageContent>
22-
</Page>
17+
<Main>
18+
<Page pad={{ bottom: '3xlarge' }}>
19+
<PageContent gap="xlarge">
20+
<PageHeader title="Dashboard" />
21+
<Content />
22+
</PageContent>
23+
</Page>
24+
</Main>
2325
<ContentArea title="Global Footer" />
2426
</AppContainer>
2527
);

apps/docs/src/examples/templates/dashboards/TwoColumnDashboard.js

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
Box,
55
Grid,
66
Heading,
7-
// Main,
7+
Main,
88
ResponsiveContext,
99
Page,
1010
PageContent,
@@ -94,48 +94,49 @@ const Content = () => {
9494
const size = useContext(ResponsiveContext);
9595

9696
return (
97-
// Main is commented out for this example, but should be used in a
98-
// real application.
99-
// <Main>
100-
<Grid columns={parentGrid.columns[size]} gap={parentGrid.gap[size]}>
101-
{/* RecentActivity is top priority content. At narrow breakpoints,
97+
<Main>
98+
<Grid columns={parentGrid.columns[size]} gap={parentGrid.gap[size]}>
99+
{/* RecentActivity is top priority content. At narrow breakpoints,
102100
place as first content element. Otherwise, place in second column. */}
103-
{['xsmall', 'small'].includes(size) && <RecentActivity />}
104-
<Box gap="xlarge">
105-
<Box gap="xsmall">
106-
<Heading level={2} margin="none">
107-
Servers
108-
</Heading>
109-
<Grid columns={firstChildGrid.columns[size]} gap={firstChildGrid.gap}>
110-
<ServerHealth />
111-
<ServerAttention />
112-
</Grid>
113-
</Box>
114-
<Box gap="xsmall">
115-
<Heading level={2} margin="none">
116-
Firmware
117-
</Heading>
118-
<Grid
119-
columns={secondChildGrid.columns[size]}
120-
rows={secondChildGrid.rows}
121-
areas={secondChildGrid.areas[size]}
122-
gap={secondChildGrid.gap}
123-
>
124-
<FirmwareStatus gridArea="firmwareStatus" />
125-
<UpdatesAvaliable gridArea="firmwareUpdates" />
126-
<FirmwareBaselines gridArea="firmwareBaselines" />
127-
</Grid>
128-
</Box>
129-
</Box>
130-
{!['xsmall', 'small'].includes(size) && (
101+
{['xsmall', 'small'].includes(size) && <RecentActivity />}
131102
<Box gap="xlarge">
132-
{/* fragment is used to create a gap spacing element
133-
for alignment to column 1 */}
134-
<></>
135-
<RecentActivity />
103+
<Box gap="xsmall">
104+
<Heading level={2} margin="none">
105+
Servers
106+
</Heading>
107+
<Grid
108+
columns={firstChildGrid.columns[size]}
109+
gap={firstChildGrid.gap}
110+
>
111+
<ServerHealth />
112+
<ServerAttention />
113+
</Grid>
114+
</Box>
115+
<Box gap="xsmall">
116+
<Heading level={2} margin="none">
117+
Firmware
118+
</Heading>
119+
<Grid
120+
columns={secondChildGrid.columns[size]}
121+
rows={secondChildGrid.rows}
122+
areas={secondChildGrid.areas[size]}
123+
gap={secondChildGrid.gap}
124+
>
125+
<FirmwareStatus gridArea="firmwareStatus" />
126+
<UpdatesAvaliable gridArea="firmwareUpdates" />
127+
<FirmwareBaselines gridArea="firmwareBaselines" />
128+
</Grid>
129+
</Box>
136130
</Box>
137-
)}
138-
</Grid>
139-
// </Main>
131+
{!['xsmall', 'small'].includes(size) && (
132+
<Box gap="xlarge">
133+
{/* fragment is used to create a gap spacing element
134+
for alignment to column 1 */}
135+
<></>
136+
<RecentActivity />
137+
</Box>
138+
)}
139+
</Grid>
140+
</Main>
140141
);
141142
};

0 commit comments

Comments
 (0)