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 field display in grid layout #60083

Merged
merged 3 commits into from Mar 27, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 18 additions & 1 deletion packages/dataviews/src/style.scss
Expand Up @@ -327,7 +327,24 @@
}

.dataviews-view-grid__field {
.dataviews-view-grid__field-value {
align-items: flex-start;

&:not(.is-column) {
align-items: center;

.dataviews-view-grid__field-name {
width: 35%;
}

.dataviews-view-grid__field-value {
width: 65%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}

.dataviews-view-grid__field-name {
color: $gray-700;
}
}
Expand Down
42 changes: 32 additions & 10 deletions packages/dataviews/src/view-grid.js
Expand Up @@ -10,8 +10,9 @@ import {
__experimentalGrid as Grid,
__experimentalHStack as HStack,
__experimentalVStack as VStack,
Tooltip,
Spinner,
Flex,
FlexItem,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { useAsyncList } from '@wordpress/compose';
Expand All @@ -34,6 +35,7 @@ function GridItem( {
mediaField,
primaryField,
visibleFields,
displayAsColumnFields,
} ) {
const hasBulkAction = useHasAPossibleBulkAction( actions, item );
const id = getItemId( item );
Expand Down Expand Up @@ -107,17 +109,34 @@ function GridItem( {
return null;
}
return (
<VStack
className="dataviews-view-grid__field"
<Flex
className={ classnames(
'dataviews-view-grid__field',
displayAsColumnFields?.includes( field.id )
? 'is-column'
: 'is-row'
) }
key={ field.id }
spacing={ 1 }
gap={ 1 }
justify="flex-start"
expanded
style={ { height: 'auto' } }
ntsekouras marked this conversation as resolved.
Show resolved Hide resolved
direction={
displayAsColumnFields?.includes( field.id )
? 'column'
: 'row'
}
>
<Tooltip text={ field.header } placement="left">
<div className="dataviews-view-grid__field-value">
{ renderedValue }
</div>
</Tooltip>
</VStack>
<FlexItem className="dataviews-view-grid__field-name">
{ field.header }
</FlexItem>
<FlexItem
className="dataviews-view-grid__field-value"
style={ { maxHeight: 'none' } }
>
{ renderedValue }
</FlexItem>
</Flex>
);
} ) }
</VStack>
Expand Down Expand Up @@ -175,6 +194,9 @@ export default function ViewGrid( {
mediaField={ mediaField }
primaryField={ primaryField }
visibleFields={ visibleFields }
displayAsColumnFields={
view.layout.displayAsColumnFields
}
/>
);
} ) }
Expand Down
Expand Up @@ -70,6 +70,7 @@ const defaultConfigPerViewType = {
[ LAYOUT_GRID ]: {
mediaField: 'preview',
primaryField: 'title',
displayAsColumnFields: [ 'description' ],
},
[ LAYOUT_LIST ]: {
primaryField: 'title',
Expand Down Expand Up @@ -148,7 +149,7 @@ function AuthorField( { item, viewType } ) {
<Icon icon={ icon } />
</div>
) }
<span>{ text }</span>
<span className="page-templates-author-field__name">{ text }</span>
</HStack>
);
}
Expand Down
Expand Up @@ -103,6 +103,11 @@
}
}

.page-templates-author-field__name {
text-overflow: ellipsis;
overflow: hidden;
}

.edit-site-list__rename-modal {
// The rename dropdown popover is open at the same time as the rename modal. The latter has to be higher.
z-index: z-index(".edit-site-list__rename-modal");
Expand Down