Style book: make the style book slot generic#49973
Conversation
|
Size Change: +3.59 kB (0%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
| * | ||
| * @return {string} Translated string corresponding to value of view. Default is ''. | ||
| */ | ||
| export function getEditorCanvasContainerTitle( view ) { |
There was a problem hiding this comment.
Not sure where this should go. Oh the agony.
I want a central place where we can match the current value of store.editorCanvasContainerView to a translated string.
Something like this is needed to get the string across the app, e.g., header-edit-mode/index.js
?
There was a problem hiding this comment.
Good question — personally I'd probably leave it in this module for now, since it's close to where it's being used? It could always be moved around later.
andrewserong
left a comment
There was a problem hiding this comment.
Nice abstraction! This is testing well for me, and the Style Book appears to behave exactly the same as on trunk, including keyboard behaviour (tabbing around, and closing via the Escape key when the top buttons are focused). I like the abstraction, it feels like it could be quite useful for other future features, too.
It might be worth also getting a review from @youknowriad or @ntsekouras just when it comes to naming for the slot. EditorCanvasContainer makes sense to me, but I'm wondering if for someone passing by if getCanvasMode and getEditorCanvasContainerView might sound like similar kinds of things?
| const { Slot: EditorCanvasContainerSlot, Fill: EditorCanvasContainerFill } = | ||
| createSlotFill( SLOT_FILL_NAME ); | ||
|
|
||
| function EditorCanvasContainer( { |
There was a problem hiding this comment.
Nice, I like this abstraction — should make it easier building subsequent screens (which I'm sure is why you made it like this 😄)
| * | ||
| * @return {string} Translated string corresponding to value of view. Default is ''. | ||
| */ | ||
| export function getEditorCanvasContainerTitle( view ) { |
There was a problem hiding this comment.
Good question — personally I'd probably leave it in this module for now, since it's close to where it's being used? It could always be moved around later.
Excellent point. I spent more time trying to come up with a name. ChatGPT was no help Thank you for testing this @andrewserong! 🙇 |
packages/edit-site/src/components/editor-canvas-container/index.js
Outdated
Show resolved
Hide resolved
- create new component slot to house style book and other editor views
- forwarding refs to first child
… close functionality
53903e4 to
b2a2a70
Compare
apeatling
left a comment
There was a problem hiding this comment.
All testing well!
✅ Check that keyboard navigation is not affected.
✅ The close button should be focussed
✅ You should be able to arrow key through the style engine tags
✅ Does the close button still work?
✅ Can you toggle the Style Book on and off and on and off and on and off.
|
Just checking in with @noisysocks before I hit the big green button. I didn't move |
noisysocks
left a comment
There was a problem hiding this comment.
It'd be nice to figure out a way to pass title along with the fill (add an additional slot for the title?) so that we don't need the extra redux state. Ideally consumers could just set a title prop on EditorCanvasContainerFill and have everything "just work".
Worth exploring if this API is ever made public but since right now it's all internal to edit-site this is fine.
100% I'll add it as a follow up task. Thanks again, everyone! |
Parent issue:
What?
Genericize the Style Book slot, which allows alternative Editor Canvas views in the site editor.
Plucked from the experimental branch:
Also makes the slot private.
Why?
@noisysocks first had the idea to make the Style Book a generic slot:
Then I came along and found a use case for it: to display revision items.
So there you are.
How?
By turning the slot into a wrapper that can house a resizable editor instance. Add your
<Iframe>,<BlockList />or<EditorStyles />... whatever you like!AND! By adding a new item to the edit-site store
editorCanvasContainerView, e.g.,AND making the new slot private thanks to the work in #49819
Testing Instructions
Ensure I haven't broken the Style Book (compare with trunk)
For more fun, see the test comments on the original PR: