Download wp-calypso/client/blocks/post-likes/docs/example.jsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.52 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/blocks/post-likes/docs/example.jsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/blocks/post-likes/docs/example.jsx
-
curl -L -o example.jsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/blocks/post-likes/docs/example.jsx
1.52 kB
| import { Button, FormLabel } from '@automattic/components'; | |
| import { createRef, PureComponent } from 'react'; | |
| import FormCheckbox from 'calypso/components/forms/form-checkbox'; | |
| import PostLikes from '../'; | |
| import PostLikesPopover from '../popover'; | |
| class PostLikesExample extends PureComponent { | |
| popoverContext = createRef(); | |
| state = { | |
| showDisplayNames: false, | |
| showPopover: false, | |
| }; | |
| toggleDisplayNames = () => { | |
| this.setState( { | |
| showDisplayNames: ! this.state.showDisplayNames, | |
| } ); | |
| }; | |
| togglePopover = () => { | |
| this.setState( { | |
| showPopover: ! this.state.showPopover, | |
| } ); | |
| }; | |
| closePopover = () => { | |
| this.setState( { | |
| showPopover: false, | |
| } ); | |
| }; | |
| render() { | |
| return ( | |
| <div> | |
| <FormLabel> | |
| <FormCheckbox | |
| onChange={ this.toggleDisplayNames } | |
| checked={ this.state.showDisplayNames } | |
| /> | |
| <span>Show display names</span> | |
| </FormLabel> | |
| <PostLikes | |
| siteId={ 3584907 } | |
| postId={ 37769 } | |
| showDisplayNames={ this.state.showDisplayNames } | |
| /> | |
| <Button ref={ this.popoverContext } onClick={ this.togglePopover }> | |
| Toggle likes popover | |
| </Button> | |
| { this.state.showPopover && ( | |
| <PostLikesPopover | |
| siteId={ 3584907 } | |
| postId={ 39717 } | |
| showDisplayNames={ this.state.showDisplayNames } | |
| context={ this.popoverContext.current } | |
| position="bottom" | |
| onClose={ this.closePopover } | |
| /> | |
| ) } | |
| </div> | |
| ); | |
| } | |
| } | |
| PostLikesExample.displayName = 'PostLikes'; | |
| export default PostLikesExample; | |