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

feat(DeleteModal): first version #3

Merged
merged 11 commits into from
Oct 9, 2024
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ coverage
.cache
.tmp
.eslintcache
generated

# package managers
yarn-error.log
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
# Sidenav top-level section
# should be the same for all markdown files for each extension
section: extensions
section: AI-infra-ui-components
# Sidenav secondary level section
# should be the same for all markdown files for each extension
id: AI-infra-ui-components
id: DeleteModal
# Tab (react | react-demos | html | html-demos | design-guidelines | accessibility)
source: design-guidelines
---
Expand Down
4 changes: 0 additions & 4 deletions packages/module/patternfly-docs/content/examples/Basic.tsx

This file was deleted.

23 changes: 23 additions & 0 deletions packages/module/patternfly-docs/content/examples/DeleteModal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
# Sidenav top-level section
# should be the same for all markdown files
section: AI-infra-ui-components
# Sidenav secondary level section
# should be the same for all markdown files
id: DeleteModal
# Tab (react | react-demos | html | html-demos | design-guidelines | accessibility)
source: react
# If you use typescript, the name of the interface to display props for
# These are found through the sourceProps function provided in patternfly-docs.source.js
propComponents: ['DeleteModal']
---

import { DeleteModal } from "@patternfly/ai-infra-ui-components";

Note: this component documents the API and enhances the [existing DeleteModal](https://github.com/opendatahub-io/odh-dashboard/blob/main/frontend/src/pages/projects/components/DeleteModal.tsx) component from odh-dashboard. It can be imported from [@patternfly/ai-infra-ui-components](https://www.npmjs.com/package/@patternfly/AI-infra-ui-components). Alternatively, it can be used within the odh-dashboard via the import: `~/pages/projects/components/DeleteModal`

### Example

```js file="./DeleteModalBasic.tsx"

```
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React from 'react';
import { Button, Stack, StackItem } from '@patternfly/react-core';
import { DeleteModal } from '@patternfly/ai-infra-ui-components';

export const DeleteModalBasic: React.FunctionComponent = () => {
const [isModalRecoverableOpen, setIsModalRecoverableOpen] = React.useState(false);
const [isModalDestructiveOpen, setIsModalDestructiveOpen] = React.useState(false);
const [isModalExtraDestructiveOpen, setIsModalExtraDestructiveOpen] = React.useState(false);

return (
<>
<Stack hasGutter style={{ marginBottom: '2rem' }}>
<StackItem>
<Button variant="primary" onClick={() => setIsModalRecoverableOpen(true)}>
Show delete modal (Easily recoverable)
</Button>
</StackItem>
<StackItem>
<Button variant="primary" onClick={() => setIsModalDestructiveOpen(true)}>
Show delete modal (Destructive)
</Button>
</StackItem>
<StackItem>
<Button variant="primary" onClick={() => setIsModalExtraDestructiveOpen(true)}>
Show delete modal (Extra destructive)
</Button>
</StackItem>
</Stack>

{isModalRecoverableOpen && (
<DeleteModal
title="Delete [item]?"
deleteName="item-name"
onDelete={() => {}}
deleteVariant="easily-recoverable"
onClose={() => setIsModalRecoverableOpen(false)}
>
The <strong>item-name</strong> item will be deleted.
</DeleteModal>
)}

{isModalDestructiveOpen && (
<DeleteModal
title="Delete [item]?"
deleteName="item-name"
onDelete={() => {}}
deleteVariant="destructive"
onClose={() => setIsModalDestructiveOpen(false)}
>
The <strong>item-name</strong> item will be deleted. [Brief sentence describing consequence of action].
</DeleteModal>
)}

{isModalExtraDestructiveOpen && (
<DeleteModal
title="Delete [item]?"
deleteName="item-name"
onDelete={() => {}}
deleteVariant="extra-destructive"
onClose={() => setIsModalExtraDestructiveOpen(false)}
>
The <strong>item-name</strong> item will be deleted. [Brief sentence describing consequence of action].
</DeleteModal>
)}
</>
);
};
29 changes: 0 additions & 29 deletions packages/module/patternfly-docs/content/examples/basic.md

This file was deleted.

51 changes: 0 additions & 51 deletions packages/module/patternfly-docs/generated/design-guidelines.js

This file was deleted.

This file was deleted.

This file was deleted.

24 changes: 0 additions & 24 deletions packages/module/patternfly-docs/generated/index.js

This file was deleted.

Loading