Skip to content

Commit

Permalink
Add option to override icon and href
Browse files Browse the repository at this point in the history
  • Loading branch information
vindl committed Nov 24, 2020
1 parent 4740032 commit c3e7c54
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { close } from '@wordpress/icons';

const MainDashboardButtonIconTest = () => (
<MainDashboardButton>
<FullscreenModeClose icon={ close } />
<FullscreenModeClose icon={ close } href="http://wordpress.org" />
</MainDashboardButton>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { __ } from '@wordpress/i18n';
import { addQueryArgs } from '@wordpress/url';
import { wordpress } from '@wordpress/icons';

function FullscreenModeClose( { showTooltip } ) {
function FullscreenModeClose( { showTooltip, icon, href } ) {
const { isActive, isRequestingSiteIcon, postType, siteIconUrl } = useSelect(
( select ) => {
const { getCurrentPostType } = select( 'core/editor' );
Expand Down Expand Up @@ -50,16 +50,26 @@ function FullscreenModeClose( { showTooltip } ) {
src={ siteIconUrl }
/>
);
} else if ( isRequestingSiteIcon ) {
}

if ( isRequestingSiteIcon ) {
buttonIcon = null;
}

// Override default icon if custom icon is provided via props.
if ( icon ) {
buttonIcon = <Icon size="36px" icon={ icon } />;
}

return (
<Button
className="edit-post-fullscreen-mode-close has-icon"
href={ addQueryArgs( 'edit.php', {
post_type: postType.slug,
} ) }
href={
href ??
addQueryArgs( 'edit.php', {
post_type: postType.slug,
} )
}
label={ get( postType, [ 'labels', 'view_items' ], __( 'Back' ) ) }
showTooltip={ showTooltip }
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
background: #23282e; // WP-admin gray.
color: $white;
border-radius: 0;
height: auto;
height: $header-height;
width: $header-height;

&:hover {
Expand All @@ -31,4 +31,3 @@
.edit-post-fullscreen-mode-close_site-icon {
width: 36px;
}

0 comments on commit c3e7c54

Please sign in to comment.