Re-enabled copy feedback and extracted it to it's own component. Still WIP, but further work is still waiting on better InkScape
This commit is contained in:
parent
951760b619
commit
92a63d0a7f
7 changed files with 24 additions and 39 deletions
17
src/app/[...file]/components/copy.tsx
Normal file
17
src/app/[...file]/components/copy.tsx
Normal file
|
@ -0,0 +1,17 @@
|
|||
'use client'
|
||||
|
||||
import { useState } from 'react';
|
||||
|
||||
import * as style from './copy.css';
|
||||
|
||||
export default function Copy({ className, text, children }: { className?: string, text: string, children: React.ReactNode }) {
|
||||
const [copied, set_copied ] = useState(false);
|
||||
function make_copy_text(text: string) {
|
||||
return () => {
|
||||
navigator.clipboard.writeText(text);
|
||||
set_copied(true);
|
||||
setTimeout(() => { set_copied(false); }, 2000);
|
||||
};
|
||||
}
|
||||
return <button onClick={make_copy_text(text)} className={`${style.copy} ${className ?? ''}`}>{copied ? '[ Copied ]' : '[ Copy ]'} {children}</button>
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue