Skip to content

Commit

Permalink
feat: options to CopyContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Jul 21, 2021
1 parent 2c8ee72 commit e3750e6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion ui/components/src/CopyContainer/CopyContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ export interface CopyContainerProps {
* value to copy
*/
value: string;
/**
* maximum length of string to be displayed in copied tooltip
*/
maxLength?: number;
/**
* copy-to-clipboard options
*/
options?: Parameters<typeof copy>[1];
}

/**
Expand All @@ -21,6 +29,7 @@ export interface CopyContainerProps {
export const CopyContainer: FC<CopyContainerProps> = ({
name,
value,
maxLength = 50,
children,
...rest
}) => {
Expand Down Expand Up @@ -58,7 +67,11 @@ export const CopyContainer: FC<CopyContainerProps> = ({
<CheckIcon size={16} sx={{ color: 'green' }} />
<Box sx={{ ml: 2, fontSize: 2 }}>{`${
name && name !== value ? `${name} ` : ''
}copied ${value}`}</Box>
}copied ${
value.length > maxLength
? `${value.substring(0, maxLength)}...`
: value
}`}</Box>
</Box>
)}
>
Expand Down

0 comments on commit e3750e6

Please sign in to comment.