File size: 1,763 Bytes
1e92f2d |
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# Post Likes
`<PostLikes />` is a connected React component for rendering a list of users
who liked a given post. If the user has a primary site set on WP.com, the
user's avatar (and display name, if shown) will link to that site in the
Calypso Reader.
## Usage
Render the component passing a `siteId` and a `postId`.
```jsx
function MyAwesomeComponent() {
return <PostLikes siteId={ 10 } postId={ 1143 } />;
}
```
## Props
### `siteId`
<table>
<tr><th>Type</th><td>Number</td></tr>
<tr><th>Required</th><td>Yes</td></tr>
</table>
The site ID for which the post likes should be displayed.
### `postId`
<table>
<tr><th>Type</th><td>Number</td></tr>
<tr><th>Required</th><td>Yes</td></tr>
</table>
The post ID for which the post likes should be displayed.
### `showDisplayNames`
<table>
<tr><th>Type</th><td>Boolean</td></tr>
<tr><th>Required</th><td>No</td></tr>
</table>
Whether or not to show display names for users who liked the post (and show one
user per line). Defaults to `false`.
## Popover
There is also a version of this component that displays using a `Popover`. The
show/hide logic for this popover must be managed externally: if the popover is
rendered with a valid `context` prop, it will be shown.
```js
import PostLikesPopover from 'calypso/blocks/post-likes/popover';
export default function SomeComponent() {
return (
<PostLikesPopover
context={ context /* Element to render the Popover next to */ }
onClose={ onClose /* Callback for Esc keypresses, click-outside */ }
position={ 'bottom' /* optional, and/or any other Popover props */ }
siteId={ 1234 /* Numeric site ID */ }
postId={ 1234 /* Numeric post ID */ }
/>
);
}
```
See [`docs/example.jsx`](docs/example.jsx) for a full-featured example.
|