forked from patternfly/patternfly-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClipboardCopyToggle.tsx
More file actions
37 lines (35 loc) · 1.09 KB
/
ClipboardCopyToggle.tsx
File metadata and controls
37 lines (35 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import * as React from 'react';
import AngleRightIcon from '@patternfly/react-icons/dist/esm/icons/angle-right-icon';
import AngleDownIcon from '@patternfly/react-icons/dist/esm/icons/angle-down-icon';
import { Button } from '../Button';
export interface ClipboardCopyToggleProps
extends Omit<React.HTMLProps<HTMLButtonElement>, 'ref' | 'type' | 'size' | 'tabIndex' | 'aria-label'> {
onClick: (event: React.MouseEvent) => void;
id: string;
textId: string;
contentId: string;
isExpanded?: boolean;
className?: string;
}
export const ClipboardCopyToggle: React.FunctionComponent<ClipboardCopyToggleProps> = ({
onClick,
id,
textId,
contentId,
isExpanded = false,
...props
}: ClipboardCopyToggleProps) => (
<Button
type="button"
variant="control"
onClick={onClick}
id={id}
aria-labelledby={`${id} ${textId}`}
aria-controls={`${id} ${contentId}`}
aria-expanded={isExpanded}
{...props}
>
{isExpanded ? <AngleDownIcon aria-hidden="true" /> : <AngleRightIcon aria-hidden="true" />}
</Button>
);
ClipboardCopyToggle.displayName = 'ClipboardCopyToggle';