-
Notifications
You must be signed in to change notification settings - Fork 450
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
feat(core): document layout #5340
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
No changes to documentation |
d334e80
to
75669ab
Compare
Component Testing Report Updated Dec 15, 2023 11:13 AM (UTC)
|
75669ab
to
89aad79
Compare
422af38
to
9a68ef9
Compare
9a68ef9
to
d2bbeac
Compare
7f240fa
to
96955f8
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.
I really like this API. It follows the same conventions for the studio.components
API and enables a lot of cool plugins. I think this API could pair well with the changes I proposed in #4938 a while back.
I'd like to I think about refactoring the component resolution of all component API into the config resolver for consistency's sake but that's a different thing. This is a very solid API addition! Looking forward to discussing this in our Studio DX sync tomorrow!
packages/sanity/src/desk/comments/plugin/document-layout/CommentsDocumentLayout.tsx
Outdated
Show resolved
Hide resolved
packages/sanity/src/desk/comments/src/hooks/useResolveCommentsEnabled.ts
Outdated
Show resolved
Hide resolved
packages/sanity/src/desk/comments/src/hooks/useResolveCommentsEnabled.ts
Show resolved
Hide resolved
89456e9
to
48a2442
Compare
48a2442
to
67434db
Compare
67434db
to
a3dbcb0
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.
very nice! love the refactors you did too!
packages/sanity/src/desk/panes/document/document-layout/DocumentLayout.tsx
Show resolved
Hide resolved
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.
Excellent work! Thanks for taking the time to add documentation and tests as well.
Description
This pull request introduces
document.components.layout
to the Components API, enabling the customization of the document layout. The pull request also refactors the comments plugin to utilize this new capability within the Components API. As a result, all comments-specific logic that was previously implemented directly indesk
is now removed and is instead configured in the comments plugin. That is, the comments feature is now entirely implemented as a plugin, utilizing existing APIs.Things to keep in mind:
core
and made available universally across all tools, thedocument.components.layout
requires resolution within each individual tool. This is because there is no predefined concept of a specific document layout. That is, it is the responsibility of each individual tool to resolve the document layout component from the Components API middleware chain. To accomplish this, theuseMiddlewareComponents
hook can be used, which is exported from thesanity
package (see example here indesk
).document.components.layout
component receives thedocumentId
anddocumentType
in props, modifying these props passed torenderDefault
will have no effect. This is because thedocumentId
anddocumentType
used indesk
are resolved from the URL. That is, these props are currently being used as ‘read-only’ props in order to know which context you’re in.desk
, which uses an advanced pane system layout, customizing the UI aspects of the document layout might lead to unexpected results and is not recommended. Instead, the API is best used as a way to add context providers to the document layout.What to review
document.components.layout
are properly appliedcomments
plugin fromdeskTool
should remove the feature entirely and no errors should appearNotes for release
N/A