PluginProbe
Code Snippets / trunk
Code Snippets vtrunk
4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 All 65 releases
code-snippets / js / components / FeedbackReporter / FeedbackReporter.tsx

FeedbackReporter.tsx in Code Snippets trunk, at js/components/FeedbackReporter/FeedbackReporter.tsx

33 lines 993 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React, { useState } from 'react'
2 import { __ } from '@wordpress/i18n'
3 import { WithRestAPIContext } from '../../hooks/useRestAPI'
4 import { FeedbackPanel } from './FeedbackPanel'
5 import { HeadingBadge } from './HeadingBadge'
6
7 export const FeedbackReporter: React.FC = () => {
8 const [isOpen, setIsOpen] = useState(false)
9 const config = window.CODE_SNIPPETS_FEEDBACK
10
11 if (!config) {
12 return null
13 }
14
15 // The provider registers a heartbeat listener without cleanup, so it is mounted once
16 // for the page rather than on each open.
17 return <WithRestAPIContext>
18 <HeadingBadge label={config.badge} />
19
20 <button
21 type="button"
22 className="code-snippets-feedback-launcher"
23 aria-expanded={isOpen}
24 onClick={() => setIsOpen(true)}
25 >
26 <span className="code-snippets-feedback-launcher__dot" aria-hidden="true"></span>
27 {__('Send feedback', 'code-snippets')}
28 </button>
29
30 {isOpen && <FeedbackPanel config={config} onClose={() => setIsOpen(false)} />}
31 </WithRestAPIContext>
32 }
33