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
14 changes: 14 additions & 0 deletions packages/react-core/src/demos/DescriptionList/DescriptionList.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
id: Description list
section: components
---

import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon';
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,169 @@
import React from 'react';
import {
Gallery,
PageSection,
GalleryItem,
Card,
CardBody,
Drawer,
DrawerPanelContent,
DrawerContent,
DrawerHead,
DrawerActions,
DrawerCloseButton,
PageSectionVariants,
TextContent,
Text,
DrawerPanelBody,
DescriptionList,
DescriptionListTerm,
DescriptionListGroup,
DescriptionListDescription,
Button,
Page,
Title
} 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>(null);
const [isExpanded, setIsExpanded] = React.useState(true);

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

const onCloseClick = () => {
setIsExpanded(false);
drawerRef.current && drawerRef.current.focus();
ajaypratap003 marked this conversation as resolved.
Show resolved Hide resolved
};

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

const panelContent = (
<DrawerPanelContent>
<DrawerHead>
<Title headingLevel="h2" tabIndex={isExpanded ? 0 : -1} ref={drawerRef}>
ajaypratap003 marked this conversation as resolved.
Show resolved Hide resolved
test
</Title>
<DrawerActions>
<DrawerCloseButton onClick={onCloseClick} />
</DrawerActions>
</DrawerHead>
<DrawerPanelBody>
<DescriptionList isFillColumns columnModifier={{ default: '2Col', lg: '2Col' }}>
<DescriptionListGroup>
<DescriptionListTerm>Name</DescriptionListTerm>
<DescriptionListDescription>test</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>Namespace</DescriptionListTerm>
<DescriptionListDescription>
<a href="#">mary-test</a>
</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>Labels</DescriptionListTerm>
<DescriptionListDescription>app=test</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>Pod selector</DescriptionListTerm>
<DescriptionListDescription>Node 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>
</DrawerPanelBody>
</DrawerPanelContent>
);

const drawerContent = (
<Gallery hasGutter>
<GalleryItem key={0}>
<Card>
<CardBody>
<Button variant="link" isInline onClick={onOpenDrawer}>
Open drawer
</Button>
</CardBody>
</Card>
</GalleryItem>
{Array.from({ length: 30 }).map((_value, index) => (
<GalleryItem key={index + 1}>
<Card>
<CardBody>{`Card-${index + 1}`}</CardBody>
</Card>
</GalleryItem>
))}
</Gallery>
);

const buildDrawer = (
<Drawer isExpanded={isExpanded} onExpand={onExpand}>
ajaypratap003 marked this conversation as resolved.
Show resolved Hide resolved
<DrawerContent panelContent={panelContent}></DrawerContent>
</Drawer>
);

return (
<DashboardWrapper notificationDrawer={buildDrawer} isNotificationDrawerExpanded={isExpanded}>
<Page>
<PageSection variant={PageSectionVariants.light}>
<TextContent>
<Text component="h1">Main title</Text>
<Text component="p">This is a full page demo.</Text>
</TextContent>
</PageSection>
<PageSection>{drawerContent}</PageSection>
</Page>
</DashboardWrapper>
);
};
Loading