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

Site: editor: Add view site link to site editor nav #50420

Merged
merged 14 commits into from
May 28, 2023
Merged
12 changes: 11 additions & 1 deletion packages/edit-site/src/components/site-hub/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
__unstableMotion as motion,
__unstableAnimatePresence as AnimatePresence,
__experimentalHStack as HStack,
ExternalLink,
Tooltip,
} from '@wordpress/components';
import { useReducedMotion } from '@wordpress/compose';
import { __ } from '@wordpress/i18n';
Expand All @@ -34,15 +36,20 @@ const { store: commandsStore } = unlock( commandsPrivateApis );
const HUB_ANIMATION_DURATION = 0.3;

const SiteHub = forwardRef( ( props, ref ) => {
const { canvasMode, dashboardLink } = useSelect( ( select ) => {
const { canvasMode, dashboardLink, homeUrl } = useSelect( ( select ) => {
const { getCanvasMode, getSettings } = unlock(
select( editSiteStore )
);

const {
getUnstableBase, // Site index.
} = select( coreStore );

return {
canvasMode: getCanvasMode(),
dashboardLink:
getSettings().__experimentalDashboardLink || 'index.php',
homeUrl: getUnstableBase()?.home,
};
}, [] );
const { open: openCommandCenter } = useDispatch( commandsStore );
Expand Down Expand Up @@ -149,6 +156,9 @@ const SiteHub = forwardRef( ( props, ref ) => {
{ decodeEntities( siteTitle ) }
</motion.div>
</AnimatePresence>
<Tooltip text={ __( 'View site' ) }>
<ExternalLink href={ homeUrl } />
</Tooltip>
</HStack>
{ window?.__experimentalEnableCommandCenter &&
canvasMode === 'view' && (
Expand Down
23 changes: 23 additions & 0 deletions packages/edit-site/src/components/site-hub/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,28 @@
.edit-site-site-hub__text-content {
// Necessary for the ellipsis to work.
overflow: hidden;
.components-external-link {
flex-grow: 0;
@include break-mobile() {
opacity: 0;
transition: opacity 0.2s ease-in-out;
}
&:focus {
outline: none;
box-shadow: none;
}
.components-external-link__icon {
fill: $white;
height: initial;
width: initial;
}
}
&:hover {
.components-external-link {
display: inline-block;
opacity: 1;
}
}
}

.edit-site-site-hub__title {
Expand All @@ -29,6 +51,7 @@

.edit-site-site-hub__site-title {
margin-left: $grid-unit-05;
flex-grow: 1;
}

.edit-site-site-hub_toggle-command-center {
Expand Down