-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathAscendingNavigationExample.js
More file actions
45 lines (41 loc) · 1.46 KB
/
AscendingNavigationExample.js
File metadata and controls
45 lines (41 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* eslint-disable react/prop-types */
import React, { useState } from 'react';
import { Anchor, Box, Button, PageContent, PageHeader } from 'grommet';
import { Left } from '@hpe-design/icons-grommet';
import { HomeContent } from './components/HomeContent';
import { PageOneContent } from './components/PageOneContent';
import { PageTwoContent } from './components/PageTwoContent';
import { sectionConfig } from './data/sections';
export const AscendingNavigationExample = () => {
const [activePage, setActivePage] = useState('pageOne');
const page = sectionConfig[activePage];
const sectionContent = {
home: <HomeContent onNavigate={setActivePage} />,
pageOne: <PageOneContent onNavigate={setActivePage} />,
pageTwo: <PageTwoContent onNavigate={setActivePage} />,
};
return (
<PageContent gap="xsmall" kind="full">
<Box width="xlarge" pad={{ bottom: 'xxlarge' }}>
<PageHeader
title={page.label}
subtitle={page.subtitle}
size="large"
parent={
activePage !== 'home' ? (
<Anchor
label={sectionConfig.home.label}
icon={<Left />}
onClick={() => setActivePage('home')}
/>
) : undefined
}
actions={
activePage !== 'home' && <Button label={page.action} primary />
}
/>
<Box gap="small">{sectionContent[activePage]}</Box>
</Box>
</PageContent>
);
};