-
Notifications
You must be signed in to change notification settings - Fork 808
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Components: Update Toolbar and ClipboardInput components to prevent d…
…eprecation notices (#39960)
- Loading branch information
1 parent
f1111d7
commit 0c2f195
Showing
8 changed files
with
81 additions
and
75 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
projects/plugins/jetpack/changelog/fix-wp-compat-issues-prior-versions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: compat | ||
|
||
Components: Shortlink and Toolbar related components have been updated to ensure compatibility. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 19 additions & 42 deletions
61
projects/plugins/jetpack/extensions/shared/clipboard-input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,24 @@ | ||
import { ClipboardButton, TextControl } from '@wordpress/components'; | ||
import { Component } from '@wordpress/element'; | ||
import { __, _x } from '@wordpress/i18n'; | ||
import { CopyToClipboard } from '@automattic/jetpack-components'; | ||
import { TextControl } from '@wordpress/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
import './clipboard-input.scss'; | ||
|
||
class ClipboardInput extends Component { | ||
state = { | ||
hasCopied: false, | ||
}; | ||
|
||
onCopy = () => this.setState( { hasCopied: true } ); | ||
|
||
onFinishCopy = () => this.setState( { hasCopied: false } ); | ||
|
||
onFocus = event => event.target.select(); | ||
|
||
render() { | ||
const { link } = this.props; | ||
const { hasCopied } = this.state; | ||
|
||
if ( ! link ) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div className="jetpack-clipboard-input"> | ||
<TextControl | ||
readOnly | ||
onFocus={ this.onFocus } | ||
value={ link } | ||
__nextHasNoMarginBottom={ true } | ||
/> | ||
<ClipboardButton | ||
variant="secondary" | ||
onCopy={ this.onCopy } | ||
onFinishCopy={ this.onFinishCopy } | ||
text={ link } | ||
> | ||
{ hasCopied ? __( 'Copied!', 'jetpack' ) : _x( 'Copy', 'verb', 'jetpack' ) } | ||
</ClipboardButton> | ||
</div> | ||
); | ||
} | ||
} | ||
const ClipboardInput = ( { link } ) => { | ||
return ( | ||
<div className="jetpack-clipboard-input"> | ||
<TextControl readOnly value={ link } __nextHasNoMarginBottom={ true } /> | ||
<CopyToClipboard | ||
buttonStyle="icon-text" | ||
className="components-clipboard-button" | ||
textToCopy={ link } | ||
variant="secondary" | ||
weight="regular" | ||
> | ||
{ __( 'Copy', 'jetpack' ) } | ||
</CopyToClipboard> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ClipboardInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
import { Button } from '@wordpress/components'; | ||
import { ToolbarButton } from '@wordpress/components'; | ||
|
||
export default ( { label, onClick } ) => ( | ||
<Button className="components-toolbar__control" label={ label } icon="edit" onClick={ onClick } /> | ||
<ToolbarButton | ||
className="components-toolbar__control" | ||
onClick={ onClick } | ||
icon="edit" | ||
title={ label } | ||
showTooltip | ||
></ToolbarButton> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters