Skip to content
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

Descriptionlist in drawer demo #10229

Open
wants to merge 11 commits into
base: v5
Choose a base branch
from
25 changes: 25 additions & 0 deletions packages/react-core/src/demos/DescriptionList/DescriptionList.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
id: Description list
section: components
---

import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';
import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
import ThIcon from '@patternfly/react-icons/dist/esm/icons/th-icon';
import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-circle-icon';
import imgAvatar from '@patternfly/react-core/src/components/assets/avatarImg.svg';
import pfIcon from '../assets/pf-logo-small.svg';
import pfLogo from '../assets/pf-logo.svg';
ajaypratap003 marked this conversation as resolved.
Show resolved Hide resolved
import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon';
import { Link } from '@reach/router';
ajaypratap003 marked this conversation as resolved.
Show resolved Hide resolved
import { DashboardWrapper } from '@patternfly/react-core/dist/js/demos/DashboardWrapper';

## Demos

### In drawer

```js file='./examples/DescriptionListDrawer.tsx' isFullscreen
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
import React from 'react';
import {
Gallery,
PageSection,
GalleryItem,
Card,
CardBody,
Drawer,
DrawerPanelContent,
DrawerContent,
DrawerContentBody,
DrawerHead,
DrawerActions,
DrawerCloseButton,
PageSectionVariants,
TextContent,
Text,
DrawerPanelBody,
DescriptionList,
DescriptionListTerm,
DescriptionListGroup,
DescriptionListDescription,
Button,
Tabs,
Tab
} from '@patternfly/react-core';
import { DashboardWrapper } from '@patternfly/react-core/dist/js/demos/DashboardWrapper';
import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon';

export const DescriptionListDrawer: React.FunctionComponent = () => {
const drawerRef = React.useRef<HTMLDivElement>();
const [isExpanded, setIsExpanded] = React.useState(true);

const onExpand = () => {
drawerRef.current && drawerRef.current.focus();
};

const onCloseClick = () => {
setIsExpanded(false);
};

const onClickCard = () => {
setIsExpanded(true);
};

const panelContent = (
<DrawerPanelContent>
<DrawerHead>
<Text component="h1">ajay-test</Text>
ajaypratap003 marked this conversation as resolved.
Show resolved Hide resolved
<DrawerActions>
<DrawerCloseButton onClick={onCloseClick} />
</DrawerActions>
</DrawerHead>
<DrawerPanelBody>
<Tabs activeKey={0} variant={'default'} aria-label="Tabs in the box light variation example" role="region">
ajaypratap003 marked this conversation as resolved.
Show resolved Hide resolved
<Tab eventKey={0} title="Overview">
ajaypratap003 marked this conversation as resolved.
Show resolved Hide resolved
<DescriptionList isFillColumns columnModifier={{ default: '2Col', lg: '2Col' }}>
<DescriptionListGroup>
<DescriptionListTerm>Name</DescriptionListTerm>
<DescriptionListDescription>ajay-test</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>Namespace</DescriptionListTerm>
<DescriptionListDescription>
<a href="#">mary-test</a>
</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>Labels</DescriptionListTerm>
<DescriptionListDescription>app=ajay-test</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>Pod selector</DescriptionListTerm>
<DescriptionListDescription>Nod selector is not available at this time</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>Tolerations</DescriptionListTerm>
<DescriptionListDescription>No tolerations</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>Annotations</DescriptionListTerm>
<DescriptionListDescription>No annotaions</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>Status</DescriptionListTerm>
<DescriptionListDescription>Active</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>Created at:</DescriptionListTerm>
<DescriptionListDescription>3 minutes agot</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>Pod selector</DescriptionListTerm>
<DescriptionListDescription>
<Button variant="link" isInline icon={<PlusCircleIcon />}>
app=MyApp
</Button>
</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>Session affinity</DescriptionListTerm>
<DescriptionListDescription>None</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>Latest version</DescriptionListTerm>
<DescriptionListDescription>1.0</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>Update strategy</DescriptionListTerm>
<DescriptionListDescription>Rolling</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>Timeout</DescriptionListTerm>
<DescriptionListDescription>600 seconds</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>Max available</DescriptionListTerm>
<DescriptionListDescription>25% of 1 pod</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>Max surge</DescriptionListTerm>
<DescriptionListDescription>25% greater than 1 pod</DescriptionListDescription>
</DescriptionListGroup>
</DescriptionList>
</Tab>
<Tab eventKey={1} title="Activity" disabled>
content
</Tab>
</Tabs>
</DrawerPanelBody>
</DrawerPanelContent>
);

const drawerContent = (
<Gallery hasGutter>
{Array.from({ length: 30 }).map((_value, index) => (
<GalleryItem key={index}>
<Card key={index} onClick={onClickCard}>
<CardBody>Click here to open drawer</CardBody>
</Card>
</GalleryItem>
))}
</Gallery>
);

return (
<DashboardWrapper>
<PageSection variant={PageSectionVariants.light}>
<TextContent>
<Text component="h1">Main title</Text>
<Text component="p">This is a full page demo.</Text>
</TextContent>
</PageSection>
<PageSection>
<Drawer isExpanded={isExpanded} onExpand={onExpand}>
<DrawerContent panelContent={panelContent}>
<DrawerContentBody>{drawerContent}</DrawerContentBody>
</DrawerContent>
</Drawer>
</PageSection>
</DashboardWrapper>
);
};
Loading