|
| 1 | +import React from 'react'; |
| 2 | +import { Button, FormGroup, Radio, SkipToContent } from '@patternfly/react-core'; |
| 3 | +import TermsOfUse from '@patternfly/chatbot/dist/dynamic/TermsOfUse'; |
| 4 | +import Chatbot, { ChatbotDisplayMode } from '@patternfly/chatbot/dist/dynamic/Chatbot'; |
| 5 | + |
| 6 | +export const TermsOfUseCompactExample: React.FunctionComponent = () => { |
| 7 | + const [isModalOpen, setIsModalOpen] = React.useState(true); |
| 8 | + const [displayMode, setDisplayMode] = React.useState(ChatbotDisplayMode.default); |
| 9 | + const chatbotRef = React.useRef<HTMLDivElement>(null); |
| 10 | + const termsRef = React.useRef<HTMLDivElement>(null); |
| 11 | + |
| 12 | + const handleSkipToContent = (e) => { |
| 13 | + e.preventDefault(); |
| 14 | + if (!isModalOpen && chatbotRef.current) { |
| 15 | + chatbotRef.current.focus(); |
| 16 | + } |
| 17 | + if (isModalOpen && termsRef.current) { |
| 18 | + termsRef.current.focus(); |
| 19 | + } |
| 20 | + }; |
| 21 | + |
| 22 | + const handleModalToggle = (_event: React.MouseEvent | MouseEvent | KeyboardEvent) => { |
| 23 | + setIsModalOpen(!isModalOpen); |
| 24 | + }; |
| 25 | + |
| 26 | + const onPrimaryAction = () => { |
| 27 | + // eslint-disable-next-line no-console |
| 28 | + console.log('Clicked primary action'); |
| 29 | + }; |
| 30 | + |
| 31 | + const onSecondaryAction = () => { |
| 32 | + // eslint-disable-next-line no-console |
| 33 | + console.log('Clicked secondary action'); |
| 34 | + }; |
| 35 | + |
| 36 | + const introduction = ( |
| 37 | + <> |
| 38 | + <p> |
| 39 | + Welcome to PatternFly! These terms and conditions outline the rules and regulations for the use of PatternFly's |
| 40 | + website, located at <a href="https://patternfly.org">www.patternfly.org.</a> |
| 41 | + </p> |
| 42 | + <p> |
| 43 | + By accessing this website, you are agreeing with our terms and conditions. If you do not agree to all of these |
| 44 | + terms and conditions, do not continue to use PatternFly. |
| 45 | + </p> |
| 46 | + </> |
| 47 | + ); |
| 48 | + |
| 49 | + const terminology = ( |
| 50 | + <> |
| 51 | + <p> |
| 52 | + The following terminology applies to these Terms and Conditions, Privacy Statement, Disclaimer Notice, and all |
| 53 | + Agreements: |
| 54 | + </p> |
| 55 | + <ul> |
| 56 | + <li> |
| 57 | + "Client", "You", and "Your" refer to you, the person using this website who is compliant with the Company's |
| 58 | + terms and conditions. |
| 59 | + </li> |
| 60 | + <li> |
| 61 | + "The Company", "Ourselves", "We", "Our", and "Us", refer to our Company. "Party", "Parties", or "Us", refers |
| 62 | + to both the Client and ourselves. |
| 63 | + </li> |
| 64 | + </ul> |
| 65 | + </> |
| 66 | + ); |
| 67 | + |
| 68 | + const body = ( |
| 69 | + <> |
| 70 | + <h2>Introduction</h2> |
| 71 | + {introduction} |
| 72 | + <h2>Terminology</h2> |
| 73 | + {terminology} |
| 74 | + </> |
| 75 | + ); |
| 76 | + |
| 77 | + return ( |
| 78 | + <> |
| 79 | + <SkipToContent style={{ zIndex: '999' }} onClick={handleSkipToContent} href="#"> |
| 80 | + Skip to chatbot |
| 81 | + </SkipToContent> |
| 82 | + <div |
| 83 | + style={{ |
| 84 | + position: 'fixed', |
| 85 | + padding: 'var(--pf-t--global--spacer--lg)', |
| 86 | + zIndex: '601', |
| 87 | + boxShadow: 'var(--pf-t--global--box-shadow--lg)' |
| 88 | + }} |
| 89 | + > |
| 90 | + <FormGroup role="radiogroup" isInline fieldId="basic-form-radio-group" label="Display mode"> |
| 91 | + <Radio |
| 92 | + isChecked={displayMode === ChatbotDisplayMode.default} |
| 93 | + onChange={() => setDisplayMode(ChatbotDisplayMode.default)} |
| 94 | + name="basic-inline-radio" |
| 95 | + label="Default" |
| 96 | + id="default" |
| 97 | + /> |
| 98 | + <Radio |
| 99 | + isChecked={displayMode === ChatbotDisplayMode.docked} |
| 100 | + onChange={() => setDisplayMode(ChatbotDisplayMode.docked)} |
| 101 | + name="basic-inline-radio" |
| 102 | + label="Docked" |
| 103 | + id="docked" |
| 104 | + /> |
| 105 | + <Radio |
| 106 | + isChecked={displayMode === ChatbotDisplayMode.fullscreen} |
| 107 | + onChange={() => setDisplayMode(ChatbotDisplayMode.fullscreen)} |
| 108 | + name="basic-inline-radio" |
| 109 | + label="Fullscreen" |
| 110 | + id="fullscreen" |
| 111 | + /> |
| 112 | + <Radio |
| 113 | + isChecked={displayMode === ChatbotDisplayMode.embedded} |
| 114 | + onChange={() => setDisplayMode(ChatbotDisplayMode.embedded)} |
| 115 | + name="basic-inline-radio" |
| 116 | + label="Embedded" |
| 117 | + id="embedded" |
| 118 | + /> |
| 119 | + </FormGroup> |
| 120 | + <Button onClick={handleModalToggle}>Launch modal</Button> |
| 121 | + </div> |
| 122 | + <Chatbot ref={chatbotRef} displayMode={displayMode} isVisible></Chatbot> |
| 123 | + <TermsOfUse |
| 124 | + ref={termsRef} |
| 125 | + displayMode={displayMode} |
| 126 | + isModalOpen={isModalOpen} |
| 127 | + handleModalToggle={handleModalToggle} |
| 128 | + onPrimaryAction={onPrimaryAction} |
| 129 | + onSecondaryAction={onSecondaryAction} |
| 130 | + isCompact |
| 131 | + > |
| 132 | + {body} |
| 133 | + </TermsOfUse> |
| 134 | + </> |
| 135 | + ); |
| 136 | +}; |
0 commit comments