Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs for ClipboardButton component #34711

Merged
merged 8 commits into from
Sep 15, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion packages/components/src/clipboard-button/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ With a clipboard button, users copy text (or other elements) with a single click

```jsx
import { ClipboardButton } from '@wordpress/components';
import { useState } from '@wordpress/compose';
import { useState } from '@wordpress/element';
ciampo marked this conversation as resolved.
Show resolved Hide resolved

const MyClipboardButton = () => {
const [ hasCopied, setHasCopied ] = useState( false );
Expand All @@ -24,3 +24,35 @@ const MyClipboardButton = () => {
);
};
```

## Props

The component accepts the following props:
ciampo marked this conversation as resolved.
Show resolved Hide resolved

### className

The class that will be added to the classes of the underlying `<Button>` component.

- Type: `string`
- Required: no

### text

The text that will be copied to the clipboard.

- Type: `string`
- Required: no
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a quick look at the code, it seems like text would be required — WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This totally makes sense to be marked as required. I checked this and it doesn't fire errors but I think the idea of it being required to use the component rather than required to not break it is a good distinction.


### onCopy

The function that will be called when the text is copied.

-- Type: `() => void`
-- Required: no
ciampo marked this conversation as resolved.
Show resolved Hide resolved

### onFinishCopy

The function that will be called when the text is copied and the copy animation is finished.

-- Type: `() => void`
-- Required: no
ciampo marked this conversation as resolved.
Show resolved Hide resolved