Skip to content

Commit

Permalink
Site Editor: Use site title as a link (#61258)
Browse files Browse the repository at this point in the history
* Try using site title as a link

* Proper ellipsis

* ensure ↗ renders on long site titles

* focus tweaks

* use unicode

Unlinked contributors: jarekmorawski.

Co-authored-by: richtabor <richtabor@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: bgardner <bgardner@git.wordpress.org>
  • Loading branch information
5 people authored May 31, 2024
1 parent 9d0f32f commit 277a689
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 21 deletions.
23 changes: 11 additions & 12 deletions packages/edit-site/src/components/site-hub/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { store as coreStore } from '@wordpress/core-data';
import { store as editorStore } from '@wordpress/editor';
import { decodeEntities } from '@wordpress/html-entities';
import { memo } from '@wordpress/element';
import { search, external } from '@wordpress/icons';
import { search } from '@wordpress/icons';
import { store as commandsStore } from '@wordpress/commands';
import { displayShortcut } from '@wordpress/keycodes';
import { filterURLForDisplay } from '@wordpress/url';
Expand Down Expand Up @@ -158,14 +158,8 @@ const SiteHub = memo( ( { isTransparent, className } ) => {
} }
>
<div className="edit-site-site-hub__title">
{ decodeEntities( siteTitle ) }
</div>
<HStack
spacing={ 0 }
expanded={ false }
className="edit-site-site-hub__actions"
>
<Button
variant="link"
href={ homeUrl }
target="_blank"
label={ __(
Expand All @@ -174,10 +168,15 @@ const SiteHub = memo( ( { isTransparent, className } ) => {
aria-label={ __(
'View site (opens in a new tab)'
) }
icon={ external }
className="edit-site-site-hub__site-view-link"
/>

>
{ decodeEntities( siteTitle ) }
</Button>
</div>
<HStack
spacing={ 0 }
expanded={ false }
className="edit-site-site-hub__actions"
>
<Button
className="edit-site-site-hub_toggle-command-center"
icon={ search }
Expand Down
55 changes: 46 additions & 9 deletions packages/edit-site/src/components/site-hub/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,55 @@
}
}

.edit-site-site-hub__title {
.edit-site-site-hub__title .components-button {
color: $gray-200;
display: block;
flex-grow: 1;
font-size: 15px;
font-weight: 500;
overflow: hidden;
// Add space for the ↗ to render.
padding-right: $grid-unit-20;
position: relative;
text-decoration: none;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
flex-grow: 1;
color: $gray-200;
}

.edit-site-site-hub__site-view-link {
margin-right: var(--wp-admin-border-width-focus);
svg {
fill: $gray-200;
&:hover,
&:focus,
&:active {
color: $gray-200;
}

&:focus {
// Defer to :focus-visible below.
box-shadow: none;
outline: none;
}

&:focus-visible {
// Push the shadow away from the title.
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) $gray-900, 0 0 0 calc(2 * var(--wp-admin-border-width-focus)) var(--wp-admin-theme-color);

// Windows High Contrast mode will show this outline, but not the box-shadow.
outline: 2px solid transparent;
outline-offset: 2px;
}

&::after {
content: "\2197";
font-weight: 400;
opacity: 0;
position: absolute;
right: 0;
transition: opacity 0.1s linear;
@include reduce-motion("transition");
}

&:hover::after,
&:focus::after,
&:active::after {
opacity: 1;
}
}

Expand Down

0 comments on commit 277a689

Please sign in to comment.