-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Update: Document and Remove experimental mark from URLPopover "subcomponents" #16566
Merged
draganescu
merged 1 commit into
master
from
update/document-link-edit-components-and-remove-experimental-mark
Jul 29, 2019
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
42 changes: 42 additions & 0 deletions
42
packages/block-editor/src/components/url-popover/link-editor.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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import classnames from 'classnames'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { | ||
IconButton, | ||
} from '@wordpress/components'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import URLInput from '../url-input'; | ||
|
||
export default function LinkEditor( { | ||
autocompleteRef, | ||
className, | ||
onChangeInputValue, | ||
value, | ||
...props | ||
} ) { | ||
return ( | ||
<form | ||
className={ classnames( | ||
'block-editor-url-popover__link-editor', | ||
className | ||
) } | ||
{ ...props } | ||
> | ||
<URLInput | ||
value={ value } | ||
onChange={ onChangeInputValue } | ||
autocompleteRef={ autocompleteRef } | ||
/> | ||
<IconButton icon="editor-break" label={ __( 'Apply' ) } type="submit" /> | ||
</form> | ||
); | ||
} |
56 changes: 56 additions & 0 deletions
56
packages/block-editor/src/components/url-popover/link-viewer.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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import classnames from 'classnames'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { | ||
ExternalLink, | ||
IconButton, | ||
} from '@wordpress/components'; | ||
import { safeDecodeURI, filterURLForDisplay } from '@wordpress/url'; | ||
|
||
function LinkViewerUrl( { url, urlLabel, className } ) { | ||
const linkClassName = classnames( | ||
className, | ||
'block-editor-url-popover__link-viewer-url' | ||
); | ||
|
||
if ( ! url ) { | ||
return <span className={ linkClassName }></span>; | ||
} | ||
|
||
return ( | ||
<ExternalLink | ||
className={ linkClassName } | ||
href={ url } | ||
> | ||
{ urlLabel || filterURLForDisplay( safeDecodeURI( url ) ) } | ||
</ExternalLink> | ||
); | ||
} | ||
|
||
export default function LinkViewer( { | ||
className, | ||
linkClassName, | ||
onEditLinkClick, | ||
url, | ||
urlLabel, | ||
...props | ||
} ) { | ||
return ( | ||
<div | ||
className={ classnames( | ||
'block-editor-url-popover__link-viewer', | ||
className | ||
) } | ||
{ ...props } | ||
> | ||
<LinkViewerUrl url={ url } urlLabel={ urlLabel } className={ linkClassName } /> | ||
{ onEditLinkClick && <IconButton icon="edit" label={ __( 'Edit' ) } onClick={ onEditLinkClick } /> } | ||
</div> | ||
); | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the file name, this probably should have been named
LinkViewer
. In any case, this specific naming doesn't adhere to capitalization guidelines, and it should at the very least beLinkViewerURL
. Thankfully it doesn't seem to be part of the public API?https://make.wordpress.org/core/handbook/best-practices/coding-standards/javascript/#abbreviations-and-acronyms
Edit: Oh, I see this file contains multiple components. In that case, I might have suggested each component get its own file.