-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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: set primary field styles #57846
Changes from all commits
4c0c0b9
3da669a
9e7c4fd
ad49d6a
268e536
2a7ae88
553af7e
2af1de8
19fdc9e
16e85b0
6b3b92c
2502f57
8b6a78d
ed93d63
68c46ea
2b4e995
6c3bdb7
9ef0dc1
8260891
96a7448
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
import { | ||
__experimentalHStack as HStack, | ||
Button, | ||
__experimentalHeading as Heading, | ||
Tooltip, | ||
Flex, | ||
} from '@wordpress/components'; | ||
|
@@ -197,24 +196,24 @@ function Title( { item, categoryId } ) { | |
/> | ||
</Tooltip> | ||
) } | ||
<Flex as="span" gap={ 0 } justify="left"> | ||
<Flex | ||
as="div" | ||
gap={ 0 } | ||
justify="left" | ||
className="edit-site-patterns__pattern-title" | ||
> | ||
{ item.type === PATTERN_TYPES.theme ? ( | ||
<span className="dataviews-view-grid__title-field"> | ||
{ item.title } | ||
</span> | ||
item.title | ||
) : ( | ||
<Heading level={ 5 }> | ||
<Button | ||
variant="link" | ||
onClick={ onClick } | ||
// Required for the grid's roving tab index system. | ||
// See https://github.com/WordPress/gutenberg/pull/51898#discussion_r1243399243. | ||
tabIndex="-1" | ||
className="dataviews-view-grid__title-field" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should not use internal dataviews classes in the consumer code. |
||
> | ||
{ item.title || item.name } | ||
</Button> | ||
</Heading> | ||
<Button | ||
variant="link" | ||
onClick={ onClick } | ||
// Required for the grid's roving tab index system. | ||
// See https://github.com/WordPress/gutenberg/pull/51898#discussion_r1243399243. | ||
tabIndex="-1" | ||
> | ||
{ item.title || item.name } | ||
</Button> | ||
) } | ||
</Flex> | ||
</HStack> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,10 +8,8 @@ import removeAccents from 'remove-accents'; | |
*/ | ||
import { | ||
Icon, | ||
__experimentalView as View, | ||
__experimentalText as Text, | ||
__experimentalHStack as HStack, | ||
__experimentalVStack as VStack, | ||
VisuallyHidden, | ||
} from '@wordpress/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
@@ -96,28 +94,19 @@ function normalizeSearchInput( input = '' ) { | |
|
||
function TemplateTitle( { item, viewType } ) { | ||
if ( viewType === LAYOUT_LIST ) { | ||
return ( | ||
<> | ||
{ decodeEntities( item.title?.rendered ) || __( '(no title)' ) } | ||
</> | ||
); | ||
return decodeEntities( item.title?.rendered ) || __( '(no title)' ); | ||
} | ||
|
||
return ( | ||
<VStack spacing={ 1 }> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removes extra divs (VStack/View) that were no longer necessary. |
||
<View as="span" className="dataviews-view-grid__title-field"> | ||
<Link | ||
params={ { | ||
postId: item.id, | ||
postType: item.type, | ||
canvas: 'edit', | ||
} } | ||
> | ||
{ decodeEntities( item.title?.rendered ) || | ||
__( '(no title)' ) } | ||
</Link> | ||
</View> | ||
</VStack> | ||
<Link | ||
params={ { | ||
postId: item.id, | ||
postType: item.type, | ||
canvas: 'edit', | ||
} } | ||
> | ||
{ decodeEntities( item.title?.rendered ) || __( '(no title)' ) } | ||
</Link> | ||
); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,9 @@ import { | |
} from '../../utils/constants'; | ||
|
||
export const DEFAULT_CONFIG_PER_VIEW_TYPE = { | ||
[ LAYOUT_TABLE ]: {}, | ||
[ LAYOUT_TABLE ]: { | ||
primaryField: 'title', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The table layout wasn't defining what's the primary field. This is necessary for the primary field class to be serialized into the HTML. |
||
}, | ||
[ LAYOUT_GRID ]: { | ||
mediaField: 'featured-image', | ||
primaryField: 'title', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removes extra divs (VStack/View) that were no longer necessary.