Skip to content

Commit e7a5a29

Browse files
committed
main 🧊 add landing header, add new demo
1 parent 62c188c commit e7a5a29

20 files changed

Lines changed: 344 additions & 1042 deletions

File tree

‎packages/core/src/hooks/useClipboard/useClipboard.demo.tsx‎

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,59 @@
1-
import { useClipboard, useField } from '@siberiacancode/reactuse';
1+
import { useClipboard } from '@siberiacancode/reactuse';
2+
import { CheckIcon, CopyIcon } from 'lucide-react';
3+
import { useState } from 'react';
4+
5+
const SHARE_URL = 'https://reactuse.org';
26

37
const Demo = () => {
48
const clipboard = useClipboard();
5-
const textField = useField();
9+
const [copied, setCopied] = useState(false);
10+
11+
const onShare = () => {
12+
clipboard.copy(SHARE_URL);
13+
setCopied(true);
14+
setTimeout(() => {
15+
setCopied(false);
16+
}, 1500);
17+
};
618

719
return (
8-
<>
9-
<p>
10-
Copied value: <code>{clipboard.value || 'Nothing is copied yet!'}</code>
11-
</p>
12-
<input {...textField.register()} />
20+
<section className='flex max-w-sm flex-col gap-5'>
21+
<div className='flex flex-col items-center gap-2'>
22+
<h3>Share with friends</h3>
23+
<p className='text-muted-foreground text-center text-sm'>
24+
Spread the word about reactuse. Click the button below to copy the link to your clipboard
25+
and share it with anyone.
26+
</p>
27+
</div>
1328

14-
<button type='button' onClick={() => clipboard.copy(textField.getValue())}>
15-
Copy
16-
</button>
17-
</>
29+
<div className='relative mt-2 flex items-center gap-2'>
30+
<input readOnly className='text-md! h-12! rounded-full! px-3!' value={SHARE_URL} />
31+
32+
<button className='absolute top-2 right-2 h-8!' type='button' onClick={onShare}>
33+
{copied ? (
34+
<>
35+
<CheckIcon className='size-4' /> Copied
36+
</>
37+
) : (
38+
<>
39+
<CopyIcon className='size-4' /> Share
40+
</>
41+
)}
42+
</button>
43+
</div>
44+
45+
<p className='text-muted-foreground text-center text-xs'>
46+
Star us on{' '}
47+
<a
48+
className='underline'
49+
href='https://github.com/siberiacancode/reactuse'
50+
rel='noreferrer'
51+
target='_blank'
52+
>
53+
GitHub
54+
</a>
55+
</p>
56+
</section>
1857
);
1958
};
2059

0 commit comments

Comments
 (0)