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 sidebar: add page details #50767

Merged
merged 12 commits into from
May 26, 2023
27 changes: 15 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion packages/date/src/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ describe( 'Moment.js Localization', () => {
} );

describe( 'humanTimeDiff', () => {
it( 'should return human readable time differences', () => {
it( 'should return human readable time differences in the past', () => {
expect(
humanTimeDiff(
'2023-04-28T11:00:00.000Z',
Expand All @@ -643,5 +643,20 @@ describe( 'Moment.js Localization', () => {
)
).toBe( '2 days ago' );
} );

it( 'should return human readable time differences in the future', () => {
Copy link
Member

Choose a reason for hiding this comment

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

I just added some tests to make sure it can handle future dates.

// Future.
const now = new Date();
const twoHoursLater = new Date(
now.getTime() + 2 * 60 * 60 * 1000
);
expect( humanTimeDiff( twoHoursLater ) ).toBe( 'in 2 hours' );

const twoDaysLater = new Date(
now.getTime() + 2 * 24 * 60 * 60 * 1000
); // Adding 2 days in milliseconds

expect( humanTimeDiff( twoDaysLater ) ).toBe( 'in 2 days' );
} );
} );
} );
3 changes: 3 additions & 0 deletions packages/edit-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"@wordpress/dom": "file:../dom",
"@wordpress/editor": "file:../editor",
"@wordpress/element": "file:../element",
"@wordpress/escape-html": "file:../escape-html",
"@wordpress/hooks": "file:../hooks",
"@wordpress/html-entities": "file:../html-entities",
"@wordpress/i18n": "file:../i18n",
Expand All @@ -54,13 +55,15 @@
"@wordpress/notices": "file:../notices",
"@wordpress/plugins": "file:../plugins",
"@wordpress/preferences": "file:../preferences",
"@wordpress/primitives": "file:../primitives",
"@wordpress/private-apis": "file:../private-apis",
"@wordpress/reusable-blocks": "file:../reusable-blocks",
"@wordpress/router": "file:../router",
"@wordpress/style-engine": "file:../style-engine",
"@wordpress/url": "file:../url",
"@wordpress/viewport": "file:../viewport",
"@wordpress/widgets": "file:../widgets",
"@wordpress/wordcount": "file:../wordcount",
"classnames": "^2.3.1",
"colord": "^2.9.2",
"downloadjs": "^1.4.7",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* WordPress dependencies
*/
import {
__experimentalHStack as HStack,
__experimentalText as Text,
} from '@wordpress/components';

export default function DataListItem( { label, value } ) {
return (
<HStack
className="edit-site-sidebar-navigation_data-list__item"
key={ label }
spacing={ 5 }
alignment="left"
>
<Text className="edit-site-sidebar-navigation_data-list__label">
{ label }
</Text>
<Text className="edit-site-sidebar-navigation_data-list__value">
{ value }
</Text>
</HStack>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* WordPress dependencies
*/
import { __experimentalVStack as VStack } from '@wordpress/components';
/**
* Internal dependencies
*/
ramonjd marked this conversation as resolved.
Show resolved Hide resolved
import DataListItem from './data-list-item';

export default function SidebarDetails( { details } ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The naming of the file and the above DataListItem component feel a bit ambiguous to me. Are we going to reuse them elsewhere? Should we move them internally to SidebarNavigationScreenPage?

Copy link
Member

Choose a reason for hiding this comment

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

Agree. I suspect it's specific to display individual entity properties, e.g., page/template. @SaxonF can confirm.

We can rename in a follow up if so.

return (
<VStack
className="edit-site-sidebar-navigation_data-list"
spacing={ 5 }
>
{ details.map( ( detail ) => (
<DataListItem
key={ detail.label }
label={ detail.label }
value={ detail.value }
/>
) ) }
</VStack>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@


.edit-site-sidebar-navigation_data-list__item {
.edit-site-sidebar-navigation_data-list__label {
color: $gray-600;
width: 100px;
}

.edit-site-sidebar-navigation_data-list__value.edit-site-sidebar-navigation_data-list__value {
color: $gray-200;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.edit-site-sidebar-navigation-screen__description {
margin: 0 0 $grid-unit-40 $grid-unit-20;
margin: 0 0 $grid-unit-40 0;
}

.edit-site-sidebar-navigation-screen-navigation-menus__content {
Expand Down
Loading