-
Notifications
You must be signed in to change notification settings - Fork 36
feat(Onboarding): Add modal #732
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
11 commits
Select commit
Hold shift + click to select a range
d785ac0
feat(Onboarding): Add modal
rebeccaalpert 431d2ff
Add high-contrast modal style
rebeccaalpert 6ddb39d
Add compact example
rebeccaalpert 83ed697
Add close button
rebeccaalpert b3b2789
Add compact test and adjust styles a bit - needs more work
rebeccaalpert 63eabf9
Add styles
rebeccaalpert 7cfa36e
Update packages/module/patternfly-docs/content/extensions/chatbot/exa…
rebeccaalpert 28be9bb
Move examples under modals
rebeccaalpert 48d68d2
Address PR feedback
rebeccaalpert 5daa65c
Fix a11y isssue
rebeccaalpert a49167d
Update screenshots
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
141 changes: 141 additions & 0 deletions
141
packages/module/patternfly-docs/content/extensions/chatbot/examples/UI/CompactOnboarding.tsx
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,141 @@ | ||
| import { | ||
| useRef, | ||
| useState, | ||
| FunctionComponent, | ||
| MouseEvent, | ||
| CSSProperties, | ||
| Ref, | ||
| MouseEvent as ReactMouseEvent | ||
| } from 'react'; | ||
| import { | ||
| Button, | ||
| SkipToContent, | ||
| MenuToggle, | ||
| MenuToggleElement, | ||
| Select, | ||
| SelectList, | ||
| SelectOption, | ||
| Stack | ||
| } from '@patternfly/react-core'; | ||
| import Onboarding from '@patternfly/chatbot/dist/dynamic/Onboarding'; | ||
| import Chatbot, { ChatbotDisplayMode } from '@patternfly/chatbot/dist/dynamic/Chatbot'; | ||
|
|
||
| export const OnboardingExample: FunctionComponent = () => { | ||
| const [isModalOpen, setIsModalOpen] = useState(true); | ||
| const [displayMode, setDisplayMode] = useState(ChatbotDisplayMode.default); | ||
| const chatbotRef = useRef<HTMLDivElement>(null); | ||
| const termsRef = useRef<HTMLDivElement>(null); | ||
| const [isOpen, setIsOpen] = useState(false); | ||
| const [selected, setSelected] = useState<string>('Select display mode'); | ||
|
|
||
| const handleSkipToContent = (e) => { | ||
| e.preventDefault(); | ||
| if (!isModalOpen && chatbotRef.current) { | ||
| chatbotRef.current.focus(); | ||
| } | ||
| if (isModalOpen && termsRef.current) { | ||
| termsRef.current.focus(); | ||
| } | ||
| }; | ||
|
|
||
| const handleModalToggle = (_event: MouseEvent | MouseEvent | KeyboardEvent) => { | ||
| setIsModalOpen(!isModalOpen); | ||
| }; | ||
|
|
||
| const onPrimaryAction = () => { | ||
| // eslint-disable-next-line no-console | ||
| console.log('Clicked primary action'); | ||
| }; | ||
|
|
||
| const onSecondaryAction = () => { | ||
| // eslint-disable-next-line no-console | ||
| console.log('Clicked secondary action'); | ||
| }; | ||
| const onSelect = (_event: ReactMouseEvent<Element, MouseEvent> | undefined, value: string | number | undefined) => { | ||
| setSelected(value as string); | ||
| setIsOpen(false); | ||
| if (value === 'Default') { | ||
| setDisplayMode(ChatbotDisplayMode.default); | ||
| } | ||
| if (value === 'Docked') { | ||
| setDisplayMode(ChatbotDisplayMode.docked); | ||
| } | ||
| if (value === 'Fullscreen') { | ||
| setDisplayMode(ChatbotDisplayMode.fullscreen); | ||
| } | ||
| if (value === 'Embedded') { | ||
| setDisplayMode(ChatbotDisplayMode.embedded); | ||
| } | ||
| }; | ||
|
|
||
| const onToggleClick = () => { | ||
| setIsOpen(!isOpen); | ||
| }; | ||
|
|
||
| const toggle = (toggleRef: Ref<MenuToggleElement>) => ( | ||
| <MenuToggle | ||
| ref={toggleRef} | ||
| onClick={onToggleClick} | ||
| isExpanded={isOpen} | ||
| style={ | ||
| { | ||
| width: '200px' | ||
| } as CSSProperties | ||
| } | ||
| aria-label={selected === 'Select display mode' ? 'Select display mode' : `Display mode, ${selected}`} | ||
| > | ||
| {selected} | ||
| </MenuToggle> | ||
| ); | ||
|
|
||
| const body = 'Simplify your Red Hat journey with personalized assistance and seamless problem-solving.'; | ||
|
|
||
| return ( | ||
| <> | ||
| <SkipToContent style={{ zIndex: '999' }} onClick={handleSkipToContent} href="#"> | ||
| Skip to chatbot | ||
| </SkipToContent> | ||
| <div | ||
| style={{ | ||
| position: 'fixed', | ||
| padding: 'var(--pf-t--global--spacer--lg)', | ||
| zIndex: '601', | ||
| boxShadow: 'var(--pf-t--global--box-shadow--lg)' | ||
| }} | ||
| > | ||
| <Stack hasGutter> | ||
| <Select | ||
| id="single-select" | ||
| isOpen={isOpen} | ||
| selected={selected} | ||
| onSelect={onSelect} | ||
| onOpenChange={(isOpen) => setIsOpen(isOpen)} | ||
| toggle={toggle} | ||
| shouldFocusToggleOnSelect | ||
| > | ||
| <SelectList> | ||
| <SelectOption value="Default">Default</SelectOption> | ||
| <SelectOption value="Docked">Docked</SelectOption> | ||
| <SelectOption value="Fullscreen">Fullscreen</SelectOption> | ||
| <SelectOption value="Embedded">Embedded</SelectOption> | ||
| </SelectList> | ||
| </Select> | ||
| <Button onClick={handleModalToggle}>Toggle modal</Button> | ||
| </Stack> | ||
| </div> | ||
| <Chatbot ref={chatbotRef} displayMode={displayMode} isVisible isCompact></Chatbot> | ||
| <Onboarding | ||
| ref={termsRef} | ||
| displayMode={displayMode} | ||
| isModalOpen={isModalOpen} | ||
| handleModalToggle={handleModalToggle} | ||
| onPrimaryAction={onPrimaryAction} | ||
| onSecondaryAction={onSecondaryAction} | ||
| title="Redefine work in the age of AI" | ||
| isCompact | ||
| > | ||
| {body} | ||
| </Onboarding> | ||
| </> | ||
| ); | ||
| }; | ||
151 changes: 151 additions & 0 deletions
151
packages/module/patternfly-docs/content/extensions/chatbot/examples/UI/Onboarding.tsx
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,151 @@ | ||
| import { | ||
| useRef, | ||
| useState, | ||
| FunctionComponent, | ||
| MouseEvent, | ||
| CSSProperties, | ||
| Ref, | ||
| MouseEvent as ReactMouseEvent | ||
| } from 'react'; | ||
| import { | ||
| Button, | ||
| Checkbox, | ||
| SkipToContent, | ||
| MenuToggle, | ||
| MenuToggleElement, | ||
| Select, | ||
| SelectList, | ||
| SelectOption, | ||
| Stack | ||
| } from '@patternfly/react-core'; | ||
| import Onboarding from '@patternfly/chatbot/dist/dynamic/Onboarding'; | ||
| import Chatbot, { ChatbotDisplayMode } from '@patternfly/chatbot/dist/dynamic/Chatbot'; | ||
| import onboardingHeader from './RH-Hat-Image.svg'; | ||
|
|
||
| export const OnboardingExample: FunctionComponent = () => { | ||
| const [isModalOpen, setIsModalOpen] = useState(true); | ||
| const [displayMode, setDisplayMode] = useState(ChatbotDisplayMode.default); | ||
| const [hasImage, setHasImage] = useState(true); | ||
| const chatbotRef = useRef<HTMLDivElement>(null); | ||
| const termsRef = useRef<HTMLDivElement>(null); | ||
| const [isOpen, setIsOpen] = useState(false); | ||
| const [selected, setSelected] = useState<string>('Select display mode'); | ||
|
|
||
| const handleSkipToContent = (e) => { | ||
| e.preventDefault(); | ||
| if (!isModalOpen && chatbotRef.current) { | ||
| chatbotRef.current.focus(); | ||
| } | ||
| if (isModalOpen && termsRef.current) { | ||
| termsRef.current.focus(); | ||
| } | ||
| }; | ||
|
|
||
| const handleModalToggle = (_event: MouseEvent | MouseEvent | KeyboardEvent) => { | ||
| setIsModalOpen(!isModalOpen); | ||
| }; | ||
|
|
||
| const onPrimaryAction = () => { | ||
| // eslint-disable-next-line no-console | ||
| console.log('Clicked primary action'); | ||
| }; | ||
|
|
||
| const onSecondaryAction = () => { | ||
| // eslint-disable-next-line no-console | ||
| console.log('Clicked secondary action'); | ||
| }; | ||
| const onSelect = (_event: ReactMouseEvent<Element, MouseEvent> | undefined, value: string | number | undefined) => { | ||
| setSelected(value as string); | ||
| setIsOpen(false); | ||
| if (value === 'Default') { | ||
| setDisplayMode(ChatbotDisplayMode.default); | ||
| } | ||
| if (value === 'Docked') { | ||
| setDisplayMode(ChatbotDisplayMode.docked); | ||
| } | ||
| if (value === 'Fullscreen') { | ||
| setDisplayMode(ChatbotDisplayMode.fullscreen); | ||
| } | ||
| if (value === 'Embedded') { | ||
| setDisplayMode(ChatbotDisplayMode.embedded); | ||
| } | ||
| }; | ||
|
|
||
| const onToggleClick = () => { | ||
| setIsOpen(!isOpen); | ||
| }; | ||
|
|
||
| const toggle = (toggleRef: Ref<MenuToggleElement>) => ( | ||
| <MenuToggle | ||
| ref={toggleRef} | ||
| onClick={onToggleClick} | ||
| isExpanded={isOpen} | ||
| style={ | ||
| { | ||
| width: '200px' | ||
| } as CSSProperties | ||
| } | ||
| aria-label={selected === 'Select display mode' ? 'Select display mode' : `Display mode, ${selected}`} | ||
| > | ||
| {selected} | ||
| </MenuToggle> | ||
| ); | ||
|
|
||
| const body = 'Simplify your Red Hat journey with personalized assistance and seamless problem-solving.'; | ||
|
|
||
| return ( | ||
| <> | ||
| <SkipToContent style={{ zIndex: '999' }} onClick={handleSkipToContent} href="#"> | ||
| Skip to chatbot | ||
| </SkipToContent> | ||
| <div | ||
| style={{ | ||
| position: 'fixed', | ||
| padding: 'var(--pf-t--global--spacer--lg)', | ||
| zIndex: '601', | ||
| boxShadow: 'var(--pf-t--global--box-shadow--lg)' | ||
| }} | ||
| > | ||
| <Stack hasGutter> | ||
| <Select | ||
| id="single-select" | ||
| isOpen={isOpen} | ||
| selected={selected} | ||
| onSelect={onSelect} | ||
| onOpenChange={(isOpen) => setIsOpen(isOpen)} | ||
| toggle={toggle} | ||
| shouldFocusToggleOnSelect | ||
| > | ||
| <SelectList> | ||
| <SelectOption value="Default">Default</SelectOption> | ||
| <SelectOption value="Docked">Docked</SelectOption> | ||
| <SelectOption value="Fullscreen">Fullscreen</SelectOption> | ||
| <SelectOption value="Embedded">Embedded</SelectOption> | ||
| </SelectList> | ||
| </Select> | ||
| <Checkbox | ||
| isChecked={hasImage} | ||
| id="toggle-header-image" | ||
| name="toggle-header-image" | ||
| label="Has image in header" | ||
| onChange={(_event, checked) => setHasImage(checked)} | ||
| ></Checkbox> | ||
| <Button onClick={handleModalToggle}>Toggle modal</Button> | ||
| </Stack> | ||
| </div> | ||
| <Chatbot ref={chatbotRef} displayMode={displayMode} isVisible></Chatbot> | ||
| <Onboarding | ||
| ref={termsRef} | ||
| displayMode={displayMode} | ||
| isModalOpen={isModalOpen} | ||
| handleModalToggle={handleModalToggle} | ||
| onPrimaryAction={onPrimaryAction} | ||
| onSecondaryAction={onSecondaryAction} | ||
| headerImage={hasImage ? onboardingHeader : undefined} | ||
| title="Redefine work in the age of AI" | ||
| > | ||
| {body} | ||
| </Onboarding> | ||
| </> | ||
| ); | ||
| }; |
9 changes: 9 additions & 0 deletions
9
.../module/patternfly-docs/content/extensions/chatbot/examples/UI/RH-Hat-Image.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Binary file added
BIN
+22.1 KB
.../extensions/chatbot/messages/demo/attach-via-menu-of-options-in-message-bar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+29 KB
...ed/extensions/chatbot/messages/demo/attach-via-upload-button-in-message-bar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+29.7 KB
...nfly-docs/generated/extensions/chatbot/messages/demo/message-auto-scrolling.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+29.7 KB
...le/patternfly-docs/generated/extensions/chatbot/overview/demo/basic-chatbot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+29.7 KB
...patternfly-docs/generated/extensions/chatbot/overview/demo/chat-transcripts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+36.4 KB
.../patternfly-docs/generated/extensions/chatbot/overview/demo/compact-chatbot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.5 KB
...tternfly-docs/generated/extensions/chatbot/overview/demo/comparing-chatbots.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+27.4 KB
...rnfly-docs/generated/extensions/chatbot/overview/demo/display-mode-switcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+46.6 KB
...patternfly-docs/generated/extensions/chatbot/overview/demo/embedded-chatbot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+38.6 KB
...rnfly-docs/generated/extensions/chatbot/overview/demo/inline-drawer-chatbot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+43.8 KB
...ly-docs/generated/extensions/chatbot/overview/demo/primary-color-background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.2 KB
...s/module/patternfly-docs/generated/extensions/chatbot/ui/react/basic-toggle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+19.5 KB
...le/patternfly-docs/generated/extensions/chatbot/ui/react/compact-onboarding.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+16.2 KB
...dule/patternfly-docs/generated/extensions/chatbot/ui/react/compact-settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+49.7 KB
.../patternfly-docs/generated/extensions/chatbot/ui/react/compact-terms-of-use.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.02 KB
...ages/module/patternfly-docs/generated/extensions/chatbot/ui/react/container.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.47 KB
...le/patternfly-docs/generated/extensions/chatbot/ui/react/custom-toggle-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.82 KB
...e/patternfly-docs/generated/extensions/chatbot/ui/react/custom-toggle-shape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.29 KB
packages/module/patternfly-docs/generated/extensions/chatbot/ui/react/modal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+51.8 KB
...ges/module/patternfly-docs/generated/extensions/chatbot/ui/react/onboarding.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.8 KB
packages/module/patternfly-docs/generated/extensions/chatbot/ui/react/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.66 KB
...odule/patternfly-docs/generated/extensions/chatbot/ui/react/skip-to-content.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+46.3 KB
...s/module/patternfly-docs/generated/extensions/chatbot/ui/react/terms-of-use.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12.5 KB
...odule/patternfly-docs/generated/extensions/chatbot/ui/react/welcome-message.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+19.5 KB
...patternfly-docs/generated/patternfly-ai/chatbot/ui/react/compact-onboarding.png
Oops, something went wrong.
Binary file added
BIN
+51.8 KB
.../module/patternfly-docs/generated/patternfly-ai/chatbot/ui/react/onboarding.png
Oops, something went wrong.
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
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.