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

Improve accessibility and consistency of the 'Last modified' Revisions button. #66606

Merged
merged 6 commits into from
Nov 26, 2024
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
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
/**
* WordPress dependencies
*/
import { __, sprintf } from '@wordpress/i18n';
import { humanTimeDiff } from '@wordpress/date';
import { createInterpolateElement } from '@wordpress/element';
import { _n, sprintf } from '@wordpress/i18n';
import { addQueryArgs } from '@wordpress/url';
import {
Icon,
__experimentalItemGroup as ItemGroup,
} from '@wordpress/components';
import { __experimentalItemGroup as ItemGroup } from '@wordpress/components';
import { backup } from '@wordpress/icons';

/**
* Internal dependencies
*/
import {
SidebarNavigationScreenDetailsPanelRow,
SidebarNavigationScreenDetailsPanelLabel,
SidebarNavigationScreenDetailsPanelValue,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the SidebarNavigationScreenDetailsPanelValue component isn't being used anywhere anymore, we should be able to delete the component itself.

packages/edit-site/src/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-value.js

} from '../sidebar-navigation-screen-details-panel';
import SidebarNavigationItem from '../sidebar-navigation-item';

export default function SidebarNavigationScreenDetailsFooter( {
Expand Down Expand Up @@ -56,33 +46,20 @@ export default function SidebarNavigationScreenDetailsFooter( {
hrefProps.as = 'a';
}
return (
<ItemGroup className="edit-site-sidebar-navigation-screen-details-footer">
<ItemGroup
size="large"
className="edit-site-sidebar-navigation-screen-details-footer"
>
<SidebarNavigationItem
aria-label={ __( 'Revisions' ) }
icon={ backup }
{ ...hrefProps }
{ ...otherProps }
>
<SidebarNavigationScreenDetailsPanelRow justify="space-between">
<SidebarNavigationScreenDetailsPanelLabel>
{ __( 'Last modified' ) }
</SidebarNavigationScreenDetailsPanelLabel>
<SidebarNavigationScreenDetailsPanelValue>
{ createInterpolateElement(
sprintf(
/* translators: %s: is the relative time when the post was last modified. */
__( '<time>%s</time>' ),
humanTimeDiff( record.modified )
),
{
time: <time dateTime={ record.modified } />,
}
) }
</SidebarNavigationScreenDetailsPanelValue>
<Icon
className="edit-site-sidebar-navigation-screen-details-footer__icon"
icon={ backup }
/>
</SidebarNavigationScreenDetailsPanelRow>
{ sprintf(
/* translators: %d: Number of Styles revisions. */
_n( '%d Revision', '%d Revisions', revisionsCount ),
revisionsCount
) }
</SidebarNavigationItem>
</ItemGroup>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,4 @@
div.edit-site-sidebar-navigation-item.components-item[aria-current] {
background: none;
}
.edit-site-sidebar-navigation-screen-details-footer__icon {
margin-left: auto;
fill: $gray-600;
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ export default function SidebarNavigationScreenGlobalStyles() {
}, [ openGlobalStyles, setEditorCanvasContainerView ] );

// If there are no revisions, do not render a footer.
const modifiedDateTime = revisions?.[ 0 ]?.modified;
const shouldShowGlobalStylesFooter =
revisionsCount > 0 && ! isLoadingRevisions && modifiedDateTime;
!! revisionsCount && ! isLoadingRevisions;

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
.edit-site-sidebar-navigation-screen__content {
padding: 0 $grid-unit-20;

.components-item-group {
.edit-site-sidebar-navigation-screen-details-footer {
margin-left: -$grid-unit-20;
margin-right: -$grid-unit-20;
}
Expand Down Expand Up @@ -127,9 +127,14 @@
bottom: 0;
background-color: $gray-900;
gap: 0;
padding: $grid-unit-20 0;
padding: $grid-unit-10 $grid-unit-20;
margin: $grid-unit-20 0 0;
border-top: 1px solid $gray-800;

.components-item-group {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.components-item-group {
.edit-site-sidebar-navigation-screen-details-footer {

Let's avoid using .components-prefixed CSS classes whenever possible.

margin-left: -$grid-unit-20;
margin-right: -$grid-unit-20;
}
}

/* In general style overrides are discouraged.
Expand Down
1 change: 0 additions & 1 deletion packages/edit-site/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
@import "./components/sidebar-navigation-screen/style.scss";
@import "./components/sidebar-navigation-screen-details-footer/style.scss";
@import "./components/sidebar-navigation-screen-navigation-menu/style.scss";
@import "components/sidebar-navigation-screen-details-panel/style.scss";
@import "./components/sidebar-navigation-screen-patterns/style.scss";
@import "./components/sidebar-dataviews/style.scss";
@import "./components/site-hub/style.scss";
Expand Down
Loading