Skip to content

Commit

Permalink
Update field display in grid layout (WordPress#60083)
Browse files Browse the repository at this point in the history
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
  • Loading branch information
4 people authored and cbravobernal committed Apr 9, 2024
1 parent ce78682 commit 66f8809
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 12 deletions.
19 changes: 18 additions & 1 deletion packages/dataviews/src/style.scss
Expand Up @@ -333,7 +333,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' } }
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 @@ -64,6 +64,7 @@ const defaultConfigPerViewType = {
[ LAYOUT_GRID ]: {
mediaField: 'preview',
primaryField: 'title',
displayAsColumnFields: [ 'description' ],
},
[ LAYOUT_LIST ]: {
primaryField: 'title',
Expand Down Expand Up @@ -138,7 +139,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

0 comments on commit 66f8809

Please sign in to comment.