Skip to content

Commit

Permalink
updates linkViewer to match the button style
Browse files Browse the repository at this point in the history
  • Loading branch information
draganescu committed Feb 4, 2020
1 parent 3b00abf commit d41f1e3
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 25 deletions.
37 changes: 16 additions & 21 deletions packages/block-editor/src/components/media-replace-flow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const MediaReplaceFlow = ( {
onError,
name = __( 'Replace' ),
} ) => {
const [ showURLInput, setShowURLInput ] = useState( false );
const [ showEditURLInput, setShowEditURLInput ] = useState( false );
const [ mediaURLValue, setMediaURLValue ] = useState( mediaURL );
const mediaUpload = useSelect( ( select ) => {
Expand Down Expand Up @@ -94,6 +93,7 @@ const MediaReplaceFlow = ( {
if ( showEditURLInput ) {
urlInputUIContent = (
<LinkEditor
className="block-editor-media-replace-flow__link-editor"
onKeyDown={ stopPropagationRelevantKeys }
onKeyPress={ stopPropagation }
value={ mediaURLValue }
Expand All @@ -109,14 +109,20 @@ const MediaReplaceFlow = ( {
);
} else {
urlInputUIContent = (
<LinkViewer
isFullWidth={ true }
className="block-editor-media-replace-flow__link-viewer"
url={ mediaURLValue }
onEditLinkClick={ () =>
setShowEditURLInput( ! showEditURLInput )
}
/>
<>
<span className="block-editor-media-replace-flow__image-url-label">
{ __( ' Current media URL:' ) }
</span>
<LinkViewer
isFullWidth={ true }
iconButton={ false }
className="block-editor-media-replace-flow__link-viewer"
url={ mediaURLValue }
onEditLinkClick={ () =>
setShowEditURLInput( ! showEditURLInput )
}
/>
</>
);
}

Expand Down Expand Up @@ -168,19 +174,8 @@ const MediaReplaceFlow = ( {
} }
/>
</MediaUploadCheck>
{ onSelectURL && (
<MenuItem
icon="admin-links"
onClick={ () =>
setShowURLInput( ! showURLInput )
}
aria-expanded={ showURLInput }
>
<div> { __( 'Insert from URL' ) } </div>
</MenuItem>
) }
</NavigableMenu>
{ showURLInput && (
{ onSelectURL && (
<div className="block-editor-media-flow__url-input">
{ urlInputUIContent }
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,28 @@

.block-editor-media-flow__url-input {
padding: 0 15px;
max-width: 255px;
max-width: 258px;
padding-bottom: 10px;
border-top: 1px solid $light-gray-800;
margin-top: 5px;
padding-top: 15px;

input {
max-width: 180px;
}
}

.block-editor-media-replace-flow__image-url-label {
color: $dark-gray-300;
font-size: $default-font-size;
padding-left: 4px;
margin-bottom: -8px;
display: block;
}

.block-editor-media-replace-flow__link-viewer {
margin-left: -3px;

// Overflow is not working properly if we show the icon.
.components-external-link__icon {
display: none;
Expand All @@ -34,4 +47,15 @@
.components-button {
flex-shrink: 0;
}

button {
position: relative;
top: -8px;
}
}

.block-editor-media-replace-flow__link-editor {
.block-editor-url-input .components-base-control__field input[type="text"] {
border: 1px solid $dark-gray-200;
}
}
10 changes: 7 additions & 3 deletions packages/block-editor/src/components/url-popover/link-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default function LinkViewer( {
onEditLinkClick,
url,
urlLabel,
iconButton = true,
...props
} ) {
return (
Expand All @@ -50,10 +51,13 @@ export default function LinkViewer( {
/>
{ onEditLinkClick && (
<Button
icon="edit"
label={ __( 'Edit' ) }
icon={ iconButton ? 'edit' : false }
isSecondary={ iconButton ? false : true }
onClick={ onEditLinkClick }
/>
className="block-editor-link-control__search-item-action block-editor-link-control__search-item-action--edit"
>
{ iconButton ? '' : __( 'Edit' ) }
</Button>
) }
</div>
);
Expand Down

0 comments on commit d41f1e3

Please sign in to comment.