playbook_ui_docs 14.17.0.pre.alpha.play2065passphrasewithselect7273 → 14.17.0.pre.alpha.play2065passphrasewithselect7295

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8530513aa746090107a2187ee40cb98bd0782ce48810e4ca6dcd7af786ad778
4
- data.tar.gz: 454e294a1b24802bcabecbb29d2adb0c5e4be1a94450f241c09b7fda3d395453
3
+ metadata.gz: c3fd7e2bc6f3ddbca137ddf0f76fe34479d3bc585ac7478f3616a127d3deaad7
4
+ data.tar.gz: c89143e2b1a3a18228ff7b50242ac163dc13caea72187f9ca21530dc557d4530
5
5
  SHA512:
6
- metadata.gz: a4a328355b46a405fe5328e6204457ff51707cd1a91f2f9f264a7f562a79063eba666d1c1bf14f2f784e6b130e216d6a90e9a4ba6ce7e9f9ec4157b4456c2fda
7
- data.tar.gz: 2cd3943908636eed42d4221aaf2140284b42b9d0569593599149b0ab87e8a94872e19f1d9ded2e84f4884878331dd24d9588d7554ff954241ae16ef544d776ef
6
+ metadata.gz: 8f5d631aa25edabb18a89eb7b53304d99ed69ae12c827010aabc3058e525219af09cd5c10e4f4cb07429f6a9b4fb7f58afc1023a53805b61d57ab99060e5cc56
7
+ data.tar.gz: dbbc538c71f446bc5c95ff14204de4e63da9355f404737169b1589d34205d26d321f5486c770437949f0cf0373c18ef4d0eb22a6f31d44fc3eeb290dd2845ed9
@@ -0,0 +1,54 @@
1
+ import React, { useEffect, useState } from 'react'
2
+ import usePBCopy from '../../pb_copy_button/usePBCopy'
3
+ import Body from '../../pb_body/_body'
4
+ import Textarea from '../../pb_textarea/_textarea'
5
+ import Tooltip from '../../pb_tooltip/_tooltip'
6
+
7
+ const CopyButtonHook = ({...props}) => {
8
+ // This is how you can use the copy button hook to copy text to the clipboard
9
+ // eslint-disable-next-line no-unused-vars
10
+ const [copied, copyToClipboard] = usePBCopy({ from: 'hookbody' })
11
+ // I added a tooltip so it looks better in the ui
12
+ const [showTooltip, setShowTooltip] = useState(false)
13
+
14
+ const handleCopy = () => {
15
+ copyToClipboard()
16
+ setShowTooltip(true)
17
+ setTimeout(() => setShowTooltip(false), 1500)
18
+ }
19
+
20
+ useEffect(() => {
21
+ const el = document.getElementById('hookbody')
22
+ if (!el) return
23
+
24
+ el.addEventListener('click', handleCopy)
25
+ return () => {
26
+ el.removeEventListener('click', handleCopy)
27
+ }
28
+ }, [copyToClipboard])
29
+
30
+ return (
31
+ <div>
32
+ <Tooltip
33
+ delay={{ close: 1000 }}
34
+ forceOpenTooltip={showTooltip}
35
+ placement="top"
36
+ showTooltip={false}
37
+ text="Copied!"
38
+ >
39
+ <Body
40
+ cursor="pointer"
41
+ id="hookbody"
42
+ text="I'm a custom copy hook! Click this body to copy this text!"
43
+ />
44
+ </Tooltip>
45
+
46
+ <Textarea
47
+ {...props}
48
+ placeholder="Paste here"
49
+ />
50
+ </div>
51
+ )
52
+ }
53
+
54
+ export default CopyButtonHook
@@ -0,0 +1,3 @@
1
+ We provide a `usePBCopy` hook that you can import to your project. This hook will return a function that you can call to copy the text to the clipboard.
2
+
3
+ `usePBCopy({ from: 'your_id' })` will grab the `innerText` from `your_id` element, or `value` if it is an input element.
@@ -6,3 +6,4 @@ examples:
6
6
  react:
7
7
  - copy_button_default: Default
8
8
  - copy_button_from: Copy From
9
+ - copy_button_hook: Copy Hook
@@ -1,2 +1,3 @@
1
1
  export { default as CopyButtonDefault } from './_copy_button_default.jsx'
2
- export { default as CopyButtonFrom } from './_copy_button_from.jsx'
2
+ export { default as CopyButtonFrom } from './_copy_button_from.jsx'
3
+ export { default as CopyButtonHook } from './_copy_button_hook.jsx'