-
Notifications
You must be signed in to change notification settings - Fork 37
chore(docs): Add demo for canvas #901
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c399988
chore(docs): Add demo for canvas
rebeccaalpert 696402a
Address feedback
rebeccaalpert a39c52f
Update packages/module/patternfly-docs/content/extensions/chatbot/exa…
rebeccaalpert c67dd22
Address focus, etc
rebeccaalpert a6fb78c
Address CSS classes
rebeccaalpert 5b05fbe
Address feedback
rebeccaalpert a0a3407
Remove isClickable
rebeccaalpert 5a8ea7e
Update packages/module/patternfly-docs/content/extensions/chatbot/exa…
rebeccaalpert fbb78bf
Address feedback
rebeccaalpert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
...ages/module/patternfly-docs/content/extensions/chatbot/examples/demos/Canvas.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| --- | ||
| id: Canvas | ||
| section: patterns | ||
| source: demo | ||
| --- | ||
|
|
||
| import { useState, useRef, useCallback, useEffect, FunctionComponent, ReactNode } from 'react'; | ||
| import { | ||
| Brand, | ||
| Divider, | ||
| Drawer, | ||
| DrawerActions, | ||
| DrawerCloseButton, | ||
| DrawerContent, | ||
| DrawerContentBody, | ||
| DrawerHead, | ||
| DrawerPanelContent, | ||
| DropdownItem, | ||
| DropdownList, | ||
| Flex, | ||
| FlexItem, | ||
| Label, | ||
| MenuToggle, | ||
| Popover, | ||
| Select, | ||
| SelectList, | ||
| SelectOption, | ||
| Title, | ||
| Tooltip | ||
| } from '@patternfly/react-core'; | ||
| import { CodeEditor, CodeEditorControl, Language } from '@patternfly/react-code-editor'; | ||
| import Chatbot, { ChatbotDisplayMode } from '@patternfly/chatbot/dist/dynamic/Chatbot'; | ||
| import ChatbotContent from '@patternfly/chatbot/dist/dynamic/ChatbotContent'; | ||
| import ChatbotFooter, { ChatbotFootnote } from '@patternfly/chatbot/dist/dynamic/ChatbotFooter'; | ||
| import MessageBar from '@patternfly/chatbot/dist/dynamic/MessageBar'; | ||
| import MessageBox from '@patternfly/chatbot/dist/dynamic/MessageBox'; | ||
| import Message from '@patternfly/chatbot/dist/dynamic/Message'; | ||
| import ChatbotConversationHistoryNav from '@patternfly/chatbot/dist/dynamic/ChatbotConversationHistoryNav'; | ||
| import ChatbotHeader, { | ||
| ChatbotHeaderActions, | ||
| ChatbotHeaderCloseButton, | ||
| ChatbotHeaderMain, | ||
| ChatbotHeaderMenu, | ||
| ChatbotHeaderTitle | ||
| } from '@patternfly/chatbot/dist/dynamic/ChatbotHeader'; | ||
| import RhUiImageFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-image-fill-icon'; | ||
| import RhUiAddIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-add-icon'; | ||
| import RhUiTaskFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-task-fill-icon'; | ||
| import RhUiNotificationFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-notification-fill-icon'; | ||
| import RhUiCalendarFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-calendar-fill-icon'; | ||
| import RhUiExportIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-export-icon'; | ||
| import RhUiRedoIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-redo-icon'; | ||
| import RhUiUndoIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-undo-icon'; | ||
| import RhUiServerUploadFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-server-upload-fill-icon'; | ||
| import RhUiAiEditIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-ai-edit-icon'; | ||
| import RhUiAiInfoIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-ai-info-icon'; | ||
| import { useDropzone } from 'react-dropzone'; | ||
| import PFIconLogoColor from '../UI/PF-IconLogo-Color.svg'; | ||
| import PFIconLogoReverse from '../UI/PF-IconLogo-Reverse.svg'; | ||
| import userAvatar from '../Messages/user_avatar.svg'; | ||
|
|
||
| **Canvas** lets users work with generated or editable content alongside a conversation. Canvas content is fully flexible, allowing you to render any content suitable for your use case. It is recommended to only utilize canvas mode with a fullscreen Chatbot. | ||
|
|
||
| ## Composable structure | ||
|
|
||
| When utilizing a canvas layout, it's recommended to use a PatternFly [drawer](/components/drawer). You must apply the `pf-chatbot__canvas*` classes from `@patternfly/chatbot` so the drawer matches ChatBot backgrounds and fills the fullscreen layout. | ||
|
|
||
| The general recommended structure is as follows: | ||
|
|
||
| ```noLive | ||
| <Chatbot displayMode={ChatbotDisplayMode.fullscreen}> | ||
| <div className="pf-chatbot__canvas"> | ||
| <Drawer className="pf-chatbot__canvas-drawer" isExpanded={...} isInline position="end"> | ||
| <DrawerContent panelContent={/* CodeEditor or other canvas content */}> | ||
| <DrawerContentBody className="pf-chatbot__canvas-body"> | ||
| <div className="pf-chatbot__canvas-column"> | ||
| <ChatbotHeader .../> | ||
| <ChatbotContent ... /> | ||
| <ChatbotFooter ... > | ||
| </div> | ||
| </DrawerContentBody> | ||
| </DrawerContent> | ||
| </Drawer> | ||
| </div> | ||
| </Chatbot> | ||
| ``` | ||
|
|
||
| ## Class names | ||
|
|
||
| | Class name | Purpose | | ||
| | --- | --- | | ||
| | `pf-chatbot__canvas` | Container for the fullscreen canvas layout and its background. | | ||
| | `pf-chatbot__canvas-drawer` | Styles the drawer that contains the canvas panel. | | ||
| | `pf-chatbot__canvas-section` | Styles the section used within the drawer for focus. | | ||
| | `pf-chatbot__canvas-body` | Ensures the drawer content body fills the available height. | | ||
| | `pf-chatbot__canvas-column` | Arranges the canvas header, content, and footer vertically. | | ||
| | `pf-chatbot__canvas-panel` | Styles the canvas drawer panel and removes the default panel spacing. | | ||
| | `pf-chatbot__canvas-panel-body` | Provides the canvas panel content area and its spacing. | | ||
| | `pf-chatbot__canvas-head` | Styles and positions the canvas panel header and close action. | | ||
| | `pf-chatbot__canvas-editor` | Makes the code editor fill the available canvas space. | | ||
|
|
||
| ## Demos | ||
|
|
||
| ### With code editor | ||
|
|
||
| This demo shows canvas mode being used to render a PatternFly [code editor](/components/code-editor). Canvas mode is launched by clicking a file chip below a message or the "Canvas" label below the message bar. You can also enable or disable canvas mode from the attach menu and dismiss the label to exit canvas mode. | ||
|
|
||
| ```js file="./Canvas.tsx" isFullscreen | ||
|
|
||
| ``` | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.