-
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: Add preview and grid view in templates list #56382
Conversation
Size Change: +370 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
Thank you for polishing @jameskoster !
I think that's something we can handle separately. In general the main take away here, is that we will probably need a way to have different fields per view type(we don't have it right now). This is probably going to be useful for mobile. |
I pushed some changes to the preview dimensions in grid view. It's tricky to get the dimensions right accounting for different 'length' templates (note the visible white space at the bottom of the 'Product search results template' in the screenshot below) but this feels like a reasonable starting point from which to refine. @ntsekouras I don't know if it's feasible, but if we could apply the theme background color to |
Flaky tests detected in 3979ca5d7d28eef291c9cc38c5ddfc3b14d19396. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6959311088
|
I think we have a good starting point and we could refine in this PR. |
packages/edit-site/src/components/page-templates/dataviews-templates.js
Outdated
Show resolved
Hide resolved
As it is now, the grid layout I felt it was a bit too confusing (perhaps a side effect of my testing theme being based on a white/black palette): Gravacao.do.ecra.2023-11-23.as.11.21.17.movSo I merged 56441 into this one to test whether those changes would help in separating visually the cards. The end result looks like this: Gravacao.do.ecra.2023-11-23.as.11.14.15.movI just thought I'd bring it up, no sure what the action steps would be. I think we should have a grid for templates, though more visual order/hierarchy (specially for white/black based themes) would be helpful. |
const DEFAULT_VIEW = { | ||
type: 'list', | ||
search: '', | ||
page: 1, | ||
perPage: 20, | ||
// All fields are visible by default, so it's | ||
// better to keep track of the hidden ones. | ||
hiddenFields: [], | ||
hiddenFields: [ 'preview' ], |
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.
I still consider a bug that the preview field cannot be hidden in the grid layout :/ Not to fix in this PR, though.
Gravacao.do.ecra.2023-11-23.as.11.25.43.mov
1a93330
to
eeb8fd9
Compare
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.
This is looking good to me code wise.
@@ -94,6 +110,32 @@ function AuthorField( { item } ) { | |||
); | |||
} | |||
|
|||
function TemplatePreview( { content, viewType } ) { | |||
const settings = usePatternSettings(); |
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's a bit weird that we use this hook when this page is unrelated to patterns. Looking at the data the hook provides, it sounds like we'd only need the settings from the site editor (everything else is related to patterns). Can we pull those settings directly here?
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.
This hook is misnamed I think. It's about providing the block editor with the settings it needs to render anything (with all the patterns, styles...)
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.
Actually this hook loads the patterns are needed here too, in order to render previews with patterns inside. These patterns are loaded within a Block Editor instance and in our case we don't load one.
packages/edit-site/src/components/page-templates/dataviews-templates.js
Outdated
Show resolved
Hide resolved
/> | ||
); | ||
}, | ||
minWidth: 120, |
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.
I mentioned elsewhere, but this data is only for one of the layouts (list). We should find a different way to provide this. Either by making it explicit in the field API (e.g.: scope it under layout.list.minWidth
, for example) or by absorbing it in the view config (in principle, I'd prefer this option, as it relates to controlling layout).
Not to fix in this PR, but important to figure out before stabilizing/creating a package for dataviews.
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.
Agreed, but let's explore this separately. Probably it should be enough by just adding specific css on each field, per view type.
@oandregal I think some styles are missing there, the template previews should have a static height to avoid breaking the grid and 'longer' templates causing excessive scrolling. |
Is something more needed to land this? 🤔 |
Looks good to me.
|
You mean in the view type menu on top? Or for the author? Probably the latter, right? |
for the author, sorry. |
If we hide it we'll have the issue we were discussing about ambiguity. I'll try the smaller icon and we can discuss in that new PR. |
What?
Part of: #55083
This PR add the
grid
view support to templates list. By default(inlist
view) the field is hidden. I'm not sure how we can make it more performant, since the previews are expensive and block the UI. Aside of this PR, we need a better solution to handle the previews and I think folks are exploring some approaches.Testing Instructions
grid
view and inlist
view make the field visible and do the sameScreenshots or screencast
Screen.Recording.2023-11-21.at.3.17.12.PM.mov
Notes
I've added some
TODOs
in the code that could be done in followups. I think that's fine for now, that the feature is experimental and is heavily iterated.