Skip to content

Commit

Permalink
Merge pull request #5720 from WordPress/update/add-reusable-block-ind…
Browse files Browse the repository at this point in the history
…icator

Update UI to better indicate that a block is reusable
  • Loading branch information
noisysocks authored Mar 23, 2018
2 parents 8d77d9e + 7164afb commit 0fa6c7e
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 16 deletions.
4 changes: 3 additions & 1 deletion blocks/library/block/edit-panel/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
font-family: $default-font;
font-size: $default-font-size;
justify-content: flex-end;
margin: $block-padding (-$block-padding) (-$block-padding);
margin: 0 (-$block-padding);
padding: 10px $block-padding;
position: relative;
top: $block-padding;

.reusable-block-edit-panel__spinner {
margin: 0 5px;
Expand Down
2 changes: 2 additions & 0 deletions blocks/library/block/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { __ } from '@wordpress/i18n';
*/
import BlockEdit from '../../block-edit';
import ReusableBlockEditPanel from './edit-panel';
import ReusableBlockIndicator from './indicator';

class ReusableBlockEdit extends Component {
constructor( { reusableBlock } ) {
Expand Down Expand Up @@ -118,6 +119,7 @@ class ReusableBlockEdit extends Component {
onCancel={ this.stopEditing }
/>
) }
{ ! isSelected && ! isEditing && <ReusableBlockIndicator title={ reusableBlock.title } /> }
</Fragment>
);
}
Expand Down
22 changes: 22 additions & 0 deletions blocks/library/block/indicator/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* WordPress dependencies
*/
import { Tooltip, Dashicon } from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import './style.scss';

function ReusableBlockIndicator( { title } ) {
return (
<Tooltip text={ sprintf( __( 'Shared Block: %s' ), title ) }>
<span className="reusable-block-indicator">
<Dashicon icon="controls-repeat" />
</span>
</Tooltip>
);
}

export default ReusableBlockIndicator;
12 changes: 12 additions & 0 deletions blocks/library/block/indicator/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.reusable-block-indicator {
background: $white;
border-left: 1px dashed $light-gray-500;
color: $dark-gray-500;
border-top: 1px dashed $light-gray-500;
bottom: -$block-padding;
height: 30px;
padding: 5px;
position: absolute;
right: -$block-padding;
width: 30px;
}
30 changes: 15 additions & 15 deletions editor/components/block-list/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,12 @@
transition: opacity 0.2s;
}

&.is-reusable.is-selected > .editor-block-mover:before {
border-right: none;
}

&.is-selected > .editor-block-settings-menu:before,
&.is-hovered > .editor-block-settings-menu:before {
border-left: 1px solid $light-gray-500;
left: 6px;
}

&.is-reusable.is-selected > .editor-block-settings-menu:before {
border-left: none;
}


/**
* Selected Block style
*/
Expand All @@ -132,12 +123,6 @@
outline: 1px solid $light-gray-500;
}

// give reusable blocks a dashed outline
&.is-reusable.is-selected > .editor-block-list__block-edit:before {
outline: 1px dashed $light-gray-500;
}


/**
* Selection Style
*/
Expand All @@ -159,6 +144,21 @@
background: $blue-medium-highlight;
}

/**
* Reusable Block style
*/

&.is-reusable > .editor-block-mover:before {
border-right: none;
}

&.is-reusable > .editor-block-settings-menu:before {
border-left: none;
}

&.is-reusable > .editor-block-list__block-edit:before {
outline: 1px dashed $light-gray-500;
}

// @todo, this appears to be unused
.iframe-overlay {
Expand Down

0 comments on commit 0fa6c7e

Please sign in to comment.