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

Templates: hide media field in list view #66573

Merged
merged 2 commits into from
Oct 30, 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
12 changes: 5 additions & 7 deletions packages/dataviews/src/dataviews-layouts/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ function ListItem< Item >( {
}, [ actions, item ] );

const renderedMediaField = mediaField?.render ? (
<mediaField.render item={ item } />
) : (
<div className="dataviews-view-list__media-placeholder"></div>
);
<div className="dataviews-view-list__media-wrapper">
Copy link
Contributor

Choose a reason for hiding this comment

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

This removes the placeholder in all lists, right?

I'm wondering why we needed an empty placeholder before though, because it would only be rendered if we hadn't provided mediaField and wouldn't check if the result of the render. 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it removes it when the consumer doesn't provide a mediaField, while before we'd render a placeholder.

<mediaField.render item={ item } />
</div>
) : null;

const renderedPrimaryField = primaryField?.render ? (
<primaryField.render item={ item } />
Expand Down Expand Up @@ -248,9 +248,7 @@ function ListItem< Item >( {
/>
</div>
<HStack spacing={ 3 } justify="start" alignment="flex-start">
<div className="dataviews-view-list__media-wrapper">
{ renderedMediaField }
</div>
{ renderedMediaField }
<VStack
spacing={ 1 }
className="dataviews-view-list__field-wrapper"
Expand Down
6 changes: 0 additions & 6 deletions packages/dataviews/src/dataviews-layouts/list/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,6 @@ ul.dataviews-view-list {
}
}

.dataviews-view-list__media-placeholder {
width: $grid-unit-05 * 13;
height: $grid-unit-05 * 13;
background-color: $gray-200;
}

.dataviews-view-list__field-wrapper {
min-height: $grid-unit-05 * 13; // Ensures title is centrally aligned when all fields are hidden
flex-grow: 1;
Expand Down
1 change: 0 additions & 1 deletion packages/edit-site/src/components/page-templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ const defaultLayouts = {
fields: [ 'title', 'description', 'author' ],
layout: {
primaryField: 'title',
mediaField: 'preview',
},
},
};
Expand Down
Loading