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

Dataviews List: Update item layout #63299

Merged
merged 2 commits into from
Jul 10, 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
53 changes: 39 additions & 14 deletions packages/dataviews/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -421,27 +421,47 @@
}

.dataviews-view-list__item-actions {
position: absolute;
top: $grid-unit-20;
right: 0;


> div {
height: $button-size-small;
}

.components-button {
opacity: 0;
position: fixed;
right: 0;
}
}

&:has(.dataviews-view-list__fields:empty) {
.dataviews-view-list__item-actions {
top: 50%;
transform: translateY(-50%);
}
}

&.is-selected,
&.is-hovered,
&:focus-within {
.dataviews-view-list__item-actions {
padding-right: $grid-unit-30;
background: #f8f8f8;
padding-left: $grid-unit-10;
margin-right: $grid-unit-30;
box-shadow: -12px 0 8px 0 #f8f8f8;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we substitute a few variables here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have an outstanding todo item for this gray. It will mean expanding the existing scale a bit, so needs a dedicated PR.

I'm not sure variables really necessary for shadows.


.components-button {
opacity: 1;
position: static;
}
}
}

.dataviews-view-list__item {
padding-right: 0;
&.is-selected {
.dataviews-view-list__item-actions {
background-color: rgb(247 248 255);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a 'solid' version of rgba(var(--wp-admin-theme-color--rgb), 0.04), which should probably be a variable too given it's increasing use. I'd lean towards tackling this together, separately.

box-shadow: -12px 0 8px 0 rgb(247 248 255);
}
}

Expand Down Expand Up @@ -477,7 +497,7 @@
}

.dataviews-view-list__item {
padding: $grid-unit-20 0 $grid-unit-20 $grid-unit-30;
padding: $grid-unit-20 $grid-unit-30;
width: 100%;
scroll-margin: $grid-unit-10 0;

Expand All @@ -494,15 +514,15 @@
}
}
.dataviews-view-list__primary-field {
min-height: $grid-unit-05 * 5;
line-height: $grid-unit-05 * 5;
min-height: $grid-unit-30;
line-height: $grid-unit-30;
overflow: hidden;
}
}

.dataviews-view-list__media-wrapper {
width: $grid-unit-50;
height: $grid-unit-50;
width: $grid-unit-05 * 13;
height: $grid-unit-05 * 13;
overflow: hidden;
position: relative;
flex-shrink: 0;
Expand Down Expand Up @@ -533,13 +553,22 @@
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
}

.dataviews-view-list__fields {
color: $gray-700;
display: flex;
gap: $grid-unit-10;
row-gap: $grid-unit-05;
flex-wrap: wrap;
font-size: 12px;

&:empty {
display: none;
}

.dataviews-view-list__field {
&:has(.dataviews-view-list__field-value:empty) {
display: none;
Expand All @@ -548,12 +577,8 @@

.dataviews-view-list__field-value {
line-height: $grid-unit-05 * 6;
display: inline-flex;
}
}
.dataviews-view-list__item-actions {
padding-right: $grid-unit-30;
}

& + .dataviews-pagination {
justify-content: space-between;
Expand Down
13 changes: 8 additions & 5 deletions packages/dataviews/src/view-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ function ListItem< Item >( {
<div className="dataviews-view-list__media-placeholder"></div>
) }
</div>
<VStack spacing={ 0 }>
<VStack
spacing={ 1 }
className="dataviews-view-list__field-wrapper"
>
<span
className="dataviews-view-list__primary-field"
id={ labelId }
Expand Down Expand Up @@ -186,7 +189,7 @@ function ListItem< Item >( {
</div>
{ eligibleActions?.length > 0 && (
<HStack
spacing={ 1 }
spacing={ 3 }
justify="flex-end"
className="dataviews-view-list__item-actions"
style={ {
Expand All @@ -205,7 +208,7 @@ function ListItem< Item >( {
isDestructive={
primaryAction.isDestructive
}
size="compact"
size="small"
onClick={ () =>
setIsModalOpen( true )
}
Expand Down Expand Up @@ -236,7 +239,7 @@ function ListItem< Item >( {
isDestructive={
primaryAction.isDestructive
}
size="compact"
size="small"
onClick={ () => {
primaryAction.callback(
[ item ],
Expand All @@ -255,7 +258,7 @@ function ListItem< Item >( {
store={ store }
render={
<Button
size="compact"
size="small"
icon={ moreVertical }
label={ __( 'Actions' ) }
accessibleWhenDisabled
Expand Down
Loading