Skip to content

Commit

Permalink
Fix the clipboard button as IconButton usage. (#6532)
Browse files Browse the repository at this point in the history
* Fix the clipboard button as IconButton usage.

* Better fix for the ClipboardButton.

* Let the icon be passed via additional props.

* No need to explicitly pass the icon prop.
  • Loading branch information
afercia authored May 3, 2018
1 parent 150c185 commit 56f2956
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions components/clipboard-button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Component } from '@wordpress/element';
* Internal dependencies
*/
import IconButton from '../icon-button';
import Button from '../button';

class ClipboardButton extends Component {
constructor() {
Expand Down Expand Up @@ -78,13 +79,15 @@ class ClipboardButton extends Component {
// Disable reason: Exclude from spread props passed to Button
// eslint-disable-next-line no-unused-vars
const { className, children, onCopy, onFinishCopy, text, ...buttonProps } = this.props;
const { icon } = buttonProps;
const classes = classnames( 'components-clipboard-button', className );
const ComponentToUse = icon ? IconButton : Button;

return (
<span ref={ this.bindContainer }>
<IconButton { ...buttonProps } icon="admin-links" className={ classes }>
<ComponentToUse { ...buttonProps } className={ classes }>
{ children }
</IconButton>
</ComponentToUse>
</span>
);
}
Expand Down
1 change: 1 addition & 0 deletions editor/components/post-permalink/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class PostPermalink extends Component {
label={ ariaLabel }
onCopy={ () => this.setState( { isCopied: true } ) }
aria-disabled={ isCopied }
icon="admin-links"
/>

<span className="editor-post-permalink__label">{ __( 'Permalink:' ) }</span>
Expand Down

0 comments on commit 56f2956

Please sign in to comment.