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

Update Templates table layout #57930

Merged
merged 4 commits into from
Jan 18, 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
15 changes: 14 additions & 1 deletion packages/dataviews/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
margin: $grid-unit-40 0 $grid-unit-20;
}

.dataviews-view-table-wrapper {
overflow-x: scroll;
}

.dataviews-view-table {
width: 100%;
text-indent: 0;
Expand All @@ -81,7 +85,12 @@
td,
th {
padding: $grid-unit-15;
min-width: 160px;
white-space: nowrap;

@include break-huge() {
min-width: 200px;
}

&[data-field-id="actions"] {
text-align: right;
}
Expand Down Expand Up @@ -200,6 +209,10 @@
.dataviews-view-table-header {
padding-left: $grid-unit-05;
}

.dataviews-view-table__actions-column {
width: 1%;
}
}

.dataviews-view-list__primary-field,
Expand Down
9 changes: 6 additions & 3 deletions packages/dataviews/src/view-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ function ViewTable( {
);

return (
<div>
<div className="dataviews-view-table-wrapper">
<table
className="dataviews-view-table"
aria-busy={ isLoading }
Expand Down Expand Up @@ -506,7 +506,10 @@ function ViewTable( {
</th>
) ) }
{ !! actions?.length && (
<th data-field-id="actions">
<th
data-field-id="actions"
className="dataviews-view-table__actions-column"
>
<span className="dataviews-view-table-header">
{ __( 'Actions' ) }
</span>
Expand Down Expand Up @@ -581,7 +584,7 @@ function ViewTable( {
</td>
) ) }
{ !! actions?.length && (
<td>
<td className="dataviews-view-table__actions-column">
<ItemActions
item={ item }
actions={ actions }
Expand Down
32 changes: 19 additions & 13 deletions packages/edit-site/src/components/page-templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,20 +216,25 @@ export default function DataviewsTemplates() {
id: 'description',
getValue: ( { item } ) => item.description,
render: ( { item } ) => {
return item.description
? decodeEntities( item.description )
: view.type === LAYOUT_TABLE && (
<>
<Text variant="muted" aria-hidden="true">
&#8212;
</Text>
<VisuallyHidden>
{ __( 'No description.' ) }
</VisuallyHidden>
</>
);
return item.description ? (
<span className="page-templates-description">
{ decodeEntities( item.description ) }
</span>
) : (
view.type === LAYOUT_TABLE && (
<>
<Text variant="muted" aria-hidden="true">
&#8212;
</Text>
<VisuallyHidden>
{ __( 'No description.' ) }
</VisuallyHidden>
</>
)
);
},
maxWidth: 200,
maxWidth: 400,
minWidth: 320,
enableSorting: false,
},
{
Expand All @@ -242,6 +247,7 @@ export default function DataviewsTemplates() {
enableHiding: false,
type: ENUMERATION_TYPE,
elements: authors,
width: '1%',
},
],
[ authors, view.type ]
Expand Down
4 changes: 4 additions & 0 deletions packages/edit-site/src/components/page-templates/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@
}
}
}

.page-templates-description {
white-space: normal;
}
Loading