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

Use table layout in templates list screen #36707

Merged
merged 3 commits into from Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 13 additions & 10 deletions packages/edit-site/src/components/list/style.scss
Expand Up @@ -66,7 +66,7 @@
margin: 0;
overflow: hidden;

li {
tr {
display: flex;
align-items: center;
padding: $grid-unit-20;
Expand All @@ -78,36 +78,39 @@
padding: $grid-unit-30 $grid-unit-40;
}

// Template.
.edit-site-list-table-column:nth-child(1) {
width: calc(60% - 36px);
flex-grow: 1;
display: flex;
flex-direction: column;
align-items: flex-start;

a {
display: block;
display: inline-block;
text-decoration: none;
font-weight: 500;
margin-bottom: $grid-unit-05;
}
}

// Added by.
.edit-site-list-table-column:nth-child(2) {
width: calc(40% - 36px);
}

// Actions.
.edit-site-list-table-column:nth-child(3) {
min-width: $button-size;
flex-shrink: 0;
}
}

li.edit-site-list-table-head {
border-bottom: $border-width solid $gray-200;
tr.edit-site-list-table-head {
font-size: 16px;
font-weight: 500;
font-weight: 600;
text-align: left;
color: $black;
color: #050505;
border-top: none;

& + li {
border-top: 0;
}
}
}
68 changes: 40 additions & 28 deletions packages/edit-site/src/components/list/table.js
Expand Up @@ -6,9 +6,6 @@ import { store as coreStore } from '@wordpress/core-data';
import { __, sprintf } from '@wordpress/i18n';
import {
VisuallyHidden,
FlexItem,
__experimentalHStack as HStack,
__experimentalHeading as Heading,
DropdownMenu,
MenuGroup,
MenuItem,
Expand Down Expand Up @@ -77,23 +74,38 @@ export default function Table( { templateType } ) {
}

return (
<ul className="edit-site-list-table">
<HStack className="edit-site-list-table-head" as="li">
<FlexItem className="edit-site-list-table-column">
<Heading level={ 4 }>{ __( 'Template' ) }</Heading>
</FlexItem>
<FlexItem className="edit-site-list-table-column">
<Heading level={ 4 }>{ __( 'Added by' ) }</Heading>
</FlexItem>
<FlexItem className="edit-site-list-table-column">
<VisuallyHidden>{ __( 'Actions' ) }</VisuallyHidden>
</FlexItem>
</HStack>
<table className="edit-site-list-table" role="table">
<thead>
<tr className="edit-site-list-table-head" role="row">
<th
className="edit-site-list-table-column"
role="columnheader"
>
{ __( 'Template' ) }
</th>
<th
className="edit-site-list-table-column"
role="columnheader"
>
{ __( 'Added by' ) }
</th>
<th
className="edit-site-list-table-column"
role="columnheader"
>
<VisuallyHidden>{ __( 'Actions' ) }</VisuallyHidden>
</th>
</tr>
</thead>

{ templates.map( ( template ) => (
<li key={ template.id }>
<HStack className="edit-site-list-table-row">
<FlexItem className="edit-site-list-table-column">
<tbody>
{ templates.map( ( template ) => (
<tr
key={ template.id }
className="edit-site-list-table-row"
role="row"
>
<td className="edit-site-list-table-column" role="cell">
<a
href={ addQueryArgs( '', {
page: 'gutenberg-edit-site',
Expand All @@ -104,12 +116,12 @@ export default function Table( { templateType } ) {
{ template.title.rendered }
</a>
{ template.description }
</FlexItem>
</td>

<FlexItem className="edit-site-list-table-column">
<td className="edit-site-list-table-column" role="cell">
{ template.theme }
</FlexItem>
<FlexItem className="edit-site-list-table-column">
</td>
<td className="edit-site-list-table-column" role="cell">
{ isTemplateRemovable( template ) && (
<DropdownMenu
icon={ moreVertical }
Expand All @@ -124,10 +136,10 @@ export default function Table( { templateType } ) {
) }
</DropdownMenu>
) }
</FlexItem>
</HStack>
</li>
) ) }
</ul>
</td>
</tr>
) ) }
</tbody>
</table>
);
}