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

Minor improvements for the permalink Copy to clipboard button #6472

Merged
merged 2 commits into from
Apr 30, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions components/button/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
opacity: 0.3;
}

&:not( :disabled ) {
&:not( :disabled ):not( [aria-disabled="true"] ) {
cursor: pointer;
}

&:focus {
&:not( :disabled ):not( [aria-disabled="true"] ):focus {
@include button-style__focus-active;
}

Expand Down
6 changes: 3 additions & 3 deletions components/clipboard-button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Component } from '@wordpress/element';
/**
* Internal dependencies
*/
import { Button } from '../';
import IconButton from '../icon-button';

class ClipboardButton extends Component {
constructor() {
Expand Down Expand Up @@ -82,9 +82,9 @@ class ClipboardButton extends Component {

return (
<span ref={ this.bindContainer }>
<Button { ...buttonProps } className={ classes }>
<IconButton { ...buttonProps } icon="admin-links" className={ classes }>
Copy link
Member

Choose a reason for hiding this comment

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

Should this have been applied to ClipboardButton broadly, or is it specific to PostPermalink ?

It's affecting other usage, such as the ClipboardButtons shown in the editor crash prompt:

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I missed that sorry :(

{ children }
</Button>
</IconButton>
</span>
);
}
Expand Down
29 changes: 16 additions & 13 deletions editor/components/post-permalink/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
/**
* External dependencies
*/
import classnames from 'classnames';

/**
* WordPress dependencies
*/
import { withDispatch, withSelect } from '@wordpress/data';
import { Component, compose } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { Dashicon, ClipboardButton, Button, Tooltip } from '@wordpress/components';
import { ClipboardButton, Button } from '@wordpress/components';

/**
* Internal Dependencies
Expand All @@ -21,7 +26,7 @@ class PostPermalink extends Component {
this.onVisibilityChange = this.onVisibilityChange.bind( this );

this.state = {
iconClass: '',
isCopied: false,
isEditingPermalink: false,
};
}
Expand Down Expand Up @@ -52,23 +57,22 @@ class PostPermalink extends Component {

render() {
const { isNew, previewLink, isEditable, samplePermalink, isPublished } = this.props;
const { iconClass, isEditingPermalink } = this.state;
const { isCopied, isEditingPermalink } = this.state;
const ariaLabel = isCopied ? __( 'Permalink copied' ) : __( 'Copy the permalink' );

if ( isNew || ! previewLink ) {
return null;
}

return (
<div className="editor-post-permalink">
<Tooltip text={ __( 'Copy the permalink to your clipboard' ) }>
<ClipboardButton
className="editor-post-permalink__copy"
text={ samplePermalink }
onCopy={ () => this.setState( { iconClass: 'is-copied' } ) }
>
<Dashicon icon="admin-links" className={ iconClass } />
</ClipboardButton>
</Tooltip>
<ClipboardButton
className={ classnames( 'editor-post-permalink__copy', { 'is-copied': isCopied } ) }
text={ samplePermalink }
label={ ariaLabel }
onCopy={ () => this.setState( { isCopied: true } ) }
aria-disabled={ isCopied }
/>

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

Expand Down Expand Up @@ -132,4 +136,3 @@ export default compose( [
return { refreshPost };
} ),
] )( PostPermalink );

7 changes: 4 additions & 3 deletions editor/components/post-permalink/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
}

.editor-post-permalink__copy {
margin-top: 4px;
border-radius: 4px;
padding: 6px;
}

.editor-post-permalink__copy .is-copied {
.editor-post-permalink__copy.is-copied {
opacity: 0.3;
}

.editor-post-permalink__label {
margin: 0 10px;
margin: 0 10px 0 5px;
}

.editor-post-permalink__link {
Expand Down