mirror of
https://github.com/Ravinou/borgwarehouse
synced 2026-03-14 14:25:46 +01:00
refactor: ⚡ copybutton component
This commit is contained in:
parent
4f175114ff
commit
d9500df622
1 changed files with 11 additions and 3 deletions
|
|
@ -1,14 +1,22 @@
|
|||
//Lib
|
||||
import classes from './CopyButton.module.css';
|
||||
import { useState } from 'react';
|
||||
import { useState, ReactNode } from 'react';
|
||||
import { IconChecks, IconCopy } from '@tabler/icons-react';
|
||||
|
||||
export default function CopyButton(props) {
|
||||
type CopyButtonProps = {
|
||||
dataToCopy: string;
|
||||
children?: ReactNode;
|
||||
displayIconConfirmation?: boolean;
|
||||
size?: number;
|
||||
stroke?: number;
|
||||
};
|
||||
|
||||
export default function CopyButton(props: CopyButtonProps) {
|
||||
//State
|
||||
const [isCopied, setIsCopied] = useState(false);
|
||||
|
||||
//Function
|
||||
const handleCopy = async (data) => {
|
||||
const handleCopy = async (data: string) => {
|
||||
navigator.clipboard
|
||||
.writeText(data)
|
||||
.then(() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue