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

Try: Small chevron icon for breadcrumb separators. #33042

Merged
merged 2 commits into from
Jul 1, 2021
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
35 changes: 23 additions & 12 deletions packages/block-editor/src/components/block-breadcrumb/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { Button } from '@wordpress/components';
import { useSelect, useDispatch } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { chevronRightSmall, Icon } from '@wordpress/icons';

/**
* Internal dependencies
Expand All @@ -14,9 +15,9 @@ import { store as blockEditorStore } from '../../store';
/**
* Block breadcrumb component, displaying the hierarchy of the current block selection as a breadcrumb.
*
* @param {Object} props Component props.
* @param {string} props.rootLabelText Translated label for the root element of the breadcrumb trail.
* @return {WPElement} Block Breadcrumb.
* @param {Object} props Component props.
* @param {string} props.rootLabelText Translated label for the root element of the breadcrumb trail.
* @return {WPElement} Block Breadcrumb.
*/
function BlockBreadcrumb( { rootLabelText } ) {
const { selectBlock, clearSelectedBlock } = useDispatch( blockEditorStore );
Expand Down Expand Up @@ -65,16 +66,26 @@ function BlockBreadcrumb( { rootLabelText } ) {
) }
{ ! hasSelection && rootLabel }
</li>
<Icon
icon={ chevronRightSmall }
className="block-editor-block-breadcrumb__separator"
/>
{ parents.map( ( parentClientId ) => (
<li key={ parentClientId }>
<Button
className="block-editor-block-breadcrumb__button"
variant="tertiary"
onClick={ () => selectBlock( parentClientId ) }
>
<BlockTitle clientId={ parentClientId } />
</Button>
</li>
<>
<li key={ parentClientId }>
<Button
className="block-editor-block-breadcrumb__button"
variant="tertiary"
onClick={ () => selectBlock( parentClientId ) }
>
<BlockTitle clientId={ parentClientId } />
</Button>
</li>
<Icon
icon={ chevronRightSmall }
className="block-editor-block-breadcrumb__separator"
/>
</>
) ) }
{ !! clientId && (
<li
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,18 @@
li {
display: inline-block;
margin: 0;
}

.block-editor-block-breadcrumb__separator {
fill: currentColor;
margin-left: -$grid-unit-05;
margin-right: -$grid-unit-05;

// Flip for RTL.
transform: scaleX(1) #{"/*rtl:scaleX(-1);*/"}; // This points the chevron right for LTR and left for RTL.

&:not(:last-child)::after {
content: "\2192" #{'/*rtl:"\2190"*/'}; // This becomes → for LTR and ← for RTL.
&:last-child {
display: none;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,19 @@ exports[`BlockBreadcrumb should render correctly 1`] = `
>
Document
</li>
<svg
aria-hidden="true"
class="block-editor-block-breadcrumb__separator"
focusable="false"
height="24"
role="img"
viewBox="0 0 24 24"
width="24"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M10.8622 8.04053L14.2805 12.0286L10.8622 16.0167L9.72327 15.0405L12.3049 12.0286L9.72327 9.01672L10.8622 8.04053Z"
/>
</svg>
</ul>
`;