-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react): add CopyButton component (#1603)
- Loading branch information
Showing
21 changed files
with
633 additions
and
122 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
--- | ||
title: CopyButton | ||
description: An interactive component that copies the provided value to the user's clipboard when clicked. | ||
source: https://github.com/dequelabs/cauldron/tree/develop/packages/react/src/components/CopyButton/index.tsx | ||
--- | ||
|
||
import { CopyButton } from '@deque/cauldron-react' | ||
|
||
```js | ||
import { CopyButton } from '@deque/cauldron-react' | ||
``` | ||
|
||
## Examples | ||
|
||
### Default | ||
|
||
```jsx example | ||
<CopyButton value="text to copy" /> | ||
``` | ||
|
||
### Label | ||
|
||
Both the accessible name and the notification label can be customized. | ||
|
||
```jsx example | ||
<CopyButton | ||
value="body { color: green; }" | ||
notificationLabel="CSS Selector Copied!" | ||
> | ||
Copy CSS Selector | ||
</CopyButton> | ||
``` | ||
|
||
### Hide Visible Label | ||
|
||
When space is limited, the visible label of the button can be optionally hidden, with the label show on hover or focus with a tooltip. | ||
|
||
```jsx example | ||
<CopyButton | ||
value="text to copy" | ||
hideVisibleLabel | ||
/> | ||
``` | ||
|
||
### Variants | ||
|
||
`CopyButton` is an extension of `Button` and limited variants are available to be used: | ||
|
||
```jsx example | ||
<CopyButton variant="primary" value="text to copy" /> | ||
<CopyButton variant="secondary" value="text to copy" thin /> | ||
``` | ||
|
||
## Props | ||
|
||
Unless otherwise noted, prop types are inherited from [Button](./Button). | ||
|
||
<ComponentProps | ||
children={{ | ||
type: 'ContentNode', | ||
description: 'The accessible name of the button. Defaults to "Copy".' | ||
}} | ||
refType="HTMLButtonElement" | ||
props={[ | ||
{ | ||
name: 'value', | ||
required: true, | ||
description: 'The text to copy upon activation of the button.' | ||
}, | ||
{ | ||
name: 'variant', | ||
type: ['primary', 'secondary', 'tertiary'], | ||
defaultValue: 'tertiary', | ||
description: 'Visual style of the button.' | ||
}, | ||
{ | ||
name: 'notificationLabel', | ||
type: 'ContentNode', | ||
defaultValue: '"Copied"', | ||
description: 'The status notification that appears after the text has been copied.' | ||
}, | ||
{ | ||
name: 'tooltipPlacement', | ||
type: 'string', | ||
defaultValue: 'auto', | ||
description: 'The placement of the tooltip relative to the button.' | ||
}, | ||
{ | ||
name: 'onCopy', | ||
type: 'function', | ||
description: 'Callback function invoked with the value of the copied text after the text has been copied.' | ||
} | ||
|
||
]} | ||
/> | ||
|
||
## Related Components | ||
|
||
- [Button](./Button) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,7 +93,8 @@ | |
"exclude": [ | ||
"lib", | ||
"coverage", | ||
"test/**/*.js" | ||
"test/**/*.js", | ||
"test/**/*.e2e.tsx" | ||
] | ||
} | ||
} |
Oops, something went wrong.