-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #296 from rebeccaalpert/skip
feat(SkipToContent): Add SkipToContent to demos
- Loading branch information
Showing
15 changed files
with
225 additions
and
29 deletions.
There are no files selected for viewing
This file contains 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
40 changes: 40 additions & 0 deletions
40
...e/patternfly-docs/content/extensions/virtual-assistant/examples/Chatbot/SkipToContent.tsx
This file contains 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,40 @@ | ||
import React from 'react'; | ||
|
||
import { SkipToContent } from '@patternfly/react-core'; | ||
import ChatbotToggle from '@patternfly/virtual-assistant/dist/dynamic/ChatbotToggle'; | ||
import Chatbot, { ChatbotDisplayMode } from '@patternfly/virtual-assistant/dist/dynamic/Chatbot'; | ||
|
||
export const ChatbotDemo: React.FunctionComponent = () => { | ||
const [chatbotVisible, setChatbotVisible] = React.useState<boolean>(true); | ||
const toggleRef = React.useRef<HTMLButtonElement>(null); | ||
const chatbotRef = React.useRef<HTMLDivElement>(null); | ||
const displayMode = ChatbotDisplayMode.default; | ||
|
||
const handleSkipToContent = (e) => { | ||
e.preventDefault(); | ||
if (!chatbotVisible && toggleRef.current) { | ||
toggleRef.current.focus(); | ||
} | ||
if (chatbotVisible && chatbotRef.current) { | ||
chatbotRef.current.focus(); | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
<SkipToContent onClick={handleSkipToContent} href="#"> | ||
Skip to chatbot | ||
</SkipToContent> | ||
<ChatbotToggle | ||
toolTipLabel="Chatbot" | ||
isChatbotVisible={chatbotVisible} | ||
onToggleChatbot={() => setChatbotVisible(!chatbotVisible)} | ||
id="chatbot-toggle" | ||
ref={toggleRef} | ||
/> | ||
<Chatbot isVisible={chatbotVisible} displayMode={displayMode} ref={chatbotRef}> | ||
| ||
</Chatbot> | ||
</> | ||
); | ||
}; |
This file contains 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
This file contains 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
This file contains 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
+7.21 KB
...ocs/generated/patternfly-ai/chatbot/chatbot-container/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.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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.