PluginProbe
Extendify / 0.9.2
Extendify v0.9.2
3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 0.7.0 All 126 releases
extendify / src / Library / components / DevHelpers.js

DevHelpers.js in Extendify 0.9.2, at src/Library/components/DevHelpers.js

38 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useEffect, useState } from '@wordpress/element'
2 import { __, sprintf } from '@wordpress/i18n'
3 import { CopyToClipboard } from 'react-copy-to-clipboard'
4
5 /** Overlay for pattern import button */
6 export const DevButtonOverlay = ({ template }) => {
7 const basePatternId = template?.fields?.basePattern?.length
8 ? template?.fields?.basePattern[0]
9 : ''
10 const [idText, setIdText] = useState(basePatternId)
11
12 useEffect(() => {
13 if (!basePatternId?.length || idText === basePatternId) return
14 setTimeout(() => setIdText(basePatternId), 1000)
15 }, [idText, basePatternId])
16
17 if (!basePatternId) return null
18
19 return (
20 <div className="absolute bottom-0 left-0 z-50 mb-4 ml-4 flex items-center space-x-2 opacity-0 transition duration-100 group-hover:opacity-100 space-x-0.5">
21 <CopyToClipboard
22 text={template?.fields?.basePattern}
23 onCopy={() => setIdText(__('Copied!', 'extendify'))}>
24 <button className="text-sm rounded-md border border-black bg-white py-1 px-2.5 font-medium text-black no-underline m-0 cursor-pointer">
25 {sprintf(__('Base: %s', 'extendify'), idText)}
26 </button>
27 </CopyToClipboard>
28 <a
29 target="_blank"
30 className="text-sm rounded-md border border-black bg-white py-1 px-2.5 font-medium text-black no-underline m-0"
31 href={template?.fields?.editURL}
32 rel="noreferrer">
33 {__('Edit', 'extendify')}
34 </a>
35 </div>
36 )
37 }
38