-
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
Data views: Add ability to display fields as a badge in grid layout #60284
Changes from 9 commits
f2a20f5
6415a4b
50a3721
1a4c96a
9d14dd5
0e2fc17
89f8a80
4998c22
8097196
8b79460
4926501
1c038c5
4fc6e50
ef9a806
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 |
---|---|---|
|
@@ -68,6 +68,7 @@ const defaultConfigPerViewType = { | |
[ LAYOUT_GRID ]: { | ||
mediaField: 'preview', | ||
primaryField: 'title', | ||
badgeFields: [ 'sync-status' ], | ||
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're starting to have several kind of displays for fields: primary, media, badge (maybe others in other layouts). It would be good to check if we can consolidate somehow. Maybe 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. I also wonder if want to show the "badge" in the same way in other views. Meaning maybe the field itself (sync status) display as a badge in its render function rather than this begin a config. 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. Yes I think so too. I'll create an issue to track this. |
||
}, | ||
}; | ||
const DEFAULT_VIEW = { | ||
|
@@ -300,19 +301,23 @@ export default function DataviewsPatterns() { | |
]; | ||
if ( type === PATTERN_TYPES.theme ) { | ||
_fields.push( { | ||
header: __( 'Sync Status' ), | ||
header: __( 'Sync status' ), | ||
id: 'sync-status', | ||
render: ( { item } ) => { | ||
// User patterns can have their sync statuses checked directly. | ||
// Non-user patterns are all unsynced for the time being. | ||
return ( | ||
SYNC_FILTERS.find( | ||
( { value } ) => value === item.syncStatus | ||
)?.label || | ||
SYNC_FILTERS.find( | ||
( { value } ) => | ||
value === PATTERN_SYNC_TYPES.unsynced | ||
).label | ||
<span | ||
className={ `edit-site-patterns__field-sync-status-${ item.syncStatus }` } | ||
> | ||
{ SYNC_FILTERS.find( | ||
( { value } ) => value === item.syncStatus | ||
)?.label || | ||
SYNC_FILTERS.find( | ||
( { value } ) => | ||
value === PATTERN_SYNC_TYPES.unsynced | ||
).label } | ||
</span> | ||
); | ||
}, | ||
type: ENUMERATION_TYPE, | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -111,6 +111,11 @@ | |||||
.dataviews-pagination { | ||||||
z-index: z-index(".edit-site-patterns__dataviews-list-pagination"); | ||||||
} | ||||||
|
||||||
.is-badge:has(.edit-site-patterns__field-sync-status-fully) { | ||||||
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. Wouldn't this work?
Suggested change
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. |
||||||
background: rgba(var(--wp-block-synced-color--rgb), 0.04); | ||||||
color: var(--wp-block-synced-color); | ||||||
} | ||||||
} | ||||||
|
||||||
.dataviews-action-modal__duplicate-pattern { | ||||||
|
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.
It sounds like we may remove the
is-badge
class? It's only used inpackages/edit-site/src/components/page-patterns/style.scss
but it seems to be unnecessary?