diff --git a/packages/module/patternfly-docs/content/extensions/chatbot/examples/UI/Settings.tsx b/packages/module/patternfly-docs/content/extensions/chatbot/examples/UI/Settings.tsx index 9b12e1a5..56a73897 100644 --- a/packages/module/patternfly-docs/content/extensions/chatbot/examples/UI/Settings.tsx +++ b/packages/module/patternfly-docs/content/extensions/chatbot/examples/UI/Settings.tsx @@ -1,18 +1,29 @@ import React from 'react'; -import Settings from '@patternfly/chatbot/dist/dynamic/Settings'; +import SettingsForm from '@patternfly/chatbot/dist/dynamic/Settings'; import { Button, + Divider, Dropdown, + DropdownGroup, DropdownItem, DropdownList, FormGroup, MenuToggle, MenuToggleElement, Radio, - Switch + Switch, + Title } from '@patternfly/react-core'; -import { ChatbotDisplayMode } from '@patternfly/chatbot/dist/dynamic/Chatbot'; +import Chatbot, { ChatbotDisplayMode } from '@patternfly/chatbot/dist/dynamic/Chatbot'; +import ChatbotHeader, { + ChatbotHeaderActions, + ChatbotHeaderCloseButton, + ChatbotHeaderMain, + ChatbotHeaderOptionsDropdown, + ChatbotHeaderTitle +} from '@patternfly/chatbot/dist/dynamic/ChatbotHeader'; +import { CogIcon, ExpandIcon, OpenDrawerRightIcon, OutlinedWindowRestoreIcon } from '@patternfly/react-icons'; export const SettingsDemo: React.FunctionComponent = () => { const [isChecked, setIsChecked] = React.useState(true); @@ -20,33 +31,14 @@ export const SettingsDemo: React.FunctionComponent = () => { const [isLanguageOpen, setIsLanguageOpen] = React.useState(false); const [isVoiceOpen, setIsVoiceOpen] = React.useState(false); const [displayMode, setDisplayMode] = React.useState(ChatbotDisplayMode.default); - const [isModalOpen, setIsModalOpen] = React.useState(true); + const [areSettingsOpen, setAreSettingsOpen] = React.useState(true); + const chatbotVisible = true; const onFocus = (id: string) => { const element = document.getElementById(id); (element as HTMLElement).focus(); }; - const onEscapePress = (event: KeyboardEvent) => { - const target = event.target as Element; - if (target?.id === 'voice') { - setIsVoiceOpen(!isVoiceOpen); - onFocus('voice'); - return; - } - if (target?.id === 'language') { - setIsLanguageOpen(!isLanguageOpen); - onFocus('language'); - return; - } - if (target?.id === 'theme') { - setIsThemeOpen(!isThemeOpen); - onFocus('theme'); - return; - } - setIsModalOpen(!isModalOpen); - }; - const onThemeToggleClick = () => { setIsThemeOpen(!isThemeOpen); }; @@ -219,6 +211,60 @@ export const SettingsDemo: React.FunctionComponent = () => { } ]; + const onSelectDropdownItem = ( + _event: React.MouseEvent | undefined, + value: string | number | undefined + ) => { + if (value === 'Settings') { + setAreSettingsOpen(true); + } else { + setDisplayMode(value as ChatbotDisplayMode); + } + }; + + const regularChatbot = ( + + + + + + } + isSelected={displayMode === ChatbotDisplayMode.default} + > + Overlay + + } + isSelected={displayMode === ChatbotDisplayMode.docked} + > + Dock to window + + } + isSelected={displayMode === ChatbotDisplayMode.fullscreen} + > + Fullscreen + + + + + + }> + Settings + + + + + + ); + return ( <>
{ position: 'fixed', padding: 'var(--pf-t--global--spacer--lg)', zIndex: '601', - boxShadow: 'var(--pf-t--global--box-shadow--lg)' + boxShadow: 'var(--pf-t--global--box-shadow--lg)', + left: 0, + bottom: 120 }} > @@ -259,15 +307,27 @@ export const SettingsDemo: React.FunctionComponent = () => { id="embedded" /> - +
- setIsModalOpen(!isModalOpen)} - fields={children} - > + + {areSettingsOpen ? ( + <> + + + + + Settings + + + + setAreSettingsOpen(false)} /> + + + + ) : ( + <>{regularChatbot} + )} + ); }; diff --git a/packages/module/patternfly-docs/content/extensions/chatbot/examples/UI/UI.md b/packages/module/patternfly-docs/content/extensions/chatbot/examples/UI/UI.md index 05acf98d..0e1ae2d4 100644 --- a/packages/module/patternfly-docs/content/extensions/chatbot/examples/UI/UI.md +++ b/packages/module/patternfly-docs/content/extensions/chatbot/examples/UI/UI.md @@ -54,6 +54,7 @@ import { PreviewAttachment } from '@patternfly/chatbot/dist/dynamic/PreviewAttac import ChatbotAlert from '@patternfly/chatbot/dist/dynamic/ChatbotAlert'; import { ChatbotHeader, +ChatbotHeaderCloseButton, ChatbotHeaderMain, ChatbotHeaderMenu, ChatbotHeaderActions, @@ -65,7 +66,7 @@ import { ChatbotFooter, ChatbotFootnote } from '@patternfly/chatbot/dist/dynamic import { MessageBar } from '@patternfly/chatbot/dist/dynamic/MessageBar'; import SourceDetailsMenuItem from '@patternfly/chatbot/dist/dynamic/SourceDetailsMenuItem'; import { ChatbotModal } from '@patternfly/chatbot/dist/dynamic/ChatbotModal'; -import Settings from '@patternfly/chatbot/dist/dynamic/Settings'; +import SettingsForm from '@patternfly/chatbot/dist/dynamic/Settings'; import { BellIcon, CalendarAltIcon, ClipboardIcon, CodeIcon, UploadIcon } from '@patternfly/react-icons'; import { useDropzone } from 'react-dropzone'; @@ -75,10 +76,12 @@ import { DropdownItem, DropdownList, Checkbox } from '@patternfly/react-core'; import OutlinedWindowRestoreIcon from '@patternfly/react-icons/dist/esm/icons/outlined-window-restore-icon'; import ExpandIcon from '@patternfly/react-icons/dist/esm/icons/expand-icon'; import OpenDrawerRightIcon from '@patternfly/react-icons/dist/esm/icons/open-drawer-right-icon'; +import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon'; import PFHorizontalLogoColor from './PF-HorizontalLogo-Color.svg'; import PFHorizontalLogoReverse from './PF-HorizontalLogo-Reverse.svg'; import userAvatar from '../Messages/user_avatar.svg'; import patternflyAvatar from '../Messages/patternfly_avatar.jpg'; +import { CloseIcon } from '@patternfly/react-icons'; ## Structure @@ -346,6 +349,8 @@ Based on the [PatternFly modal](/components/modal), this modal adapts to the Cha ### Settings +A settings layout can be substituted for other components within the chatbot. It should accept any number of buttons, dropdowns, toggles, etc. and labels, and render them appropriately within all four display modes. + ```js file="./Settings.tsx" isFullscreen ``` diff --git a/packages/module/src/ChatbotHeader/ChatbotHeaderCloseButton.tsx b/packages/module/src/ChatbotHeader/ChatbotHeaderCloseButton.tsx new file mode 100644 index 00000000..b9383860 --- /dev/null +++ b/packages/module/src/ChatbotHeader/ChatbotHeaderCloseButton.tsx @@ -0,0 +1,51 @@ +import React from 'react'; + +import { Button, Icon, Tooltip, TooltipProps } from '@patternfly/react-core'; +import { CloseIcon } from '@patternfly/react-icons'; + +export interface ChatbotHeaderCloseButtonProps { + /** Callback function for when button is clicked */ + onClick: () => void; + /** Custom classname for the header component */ + className?: string; + /** Props spread to the PF Tooltip component wrapping the display mode dropdown */ + tooltipProps?: TooltipProps; + /** Aria label for menu */ + menuAriaLabel?: string; + /** Ref applied to menu */ + innerRef?: React.Ref; + /** Content used in tooltip */ + tooltipContent?: string; +} + +const ChatbotHeaderCloseButtonBase: React.FunctionComponent = ({ + className, + onClick, + tooltipProps, + menuAriaLabel = 'Close', + innerRef, + tooltipContent = 'Close' +}: ChatbotHeaderCloseButtonProps) => ( +
+ +
+); + +export const ChatbotHeaderCloseButton = React.forwardRef( + (props: ChatbotHeaderCloseButtonProps, ref: React.Ref) => ( + + ) +); diff --git a/packages/module/src/ChatbotHeader/ChatbotHeaderMenu.tsx b/packages/module/src/ChatbotHeader/ChatbotHeaderMenu.tsx index 4ac5be10..16b1925a 100644 --- a/packages/module/src/ChatbotHeader/ChatbotHeaderMenu.tsx +++ b/packages/module/src/ChatbotHeader/ChatbotHeaderMenu.tsx @@ -14,6 +14,8 @@ export interface ChatbotHeaderMenuProps { menuAriaLabel?: string; /** Ref applied to menu */ innerRef?: React.Ref; + /** Content used in tooltip */ + tooltipContent?: string; } const ChatbotHeaderMenuBase: React.FunctionComponent = ({ @@ -21,10 +23,11 @@ const ChatbotHeaderMenuBase: React.FunctionComponent = ( onMenuToggle, tooltipProps, menuAriaLabel = 'Toggle menu', - innerRef + innerRef, + tooltipContent = 'Menu' }: ChatbotHeaderMenuProps) => (
- +