-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(SkipToContent): Add direct example
- Loading branch information
1 parent
c5830f5
commit bd11d21
Showing
4 changed files
with
54 additions
and
1 deletion.
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