-
Notifications
You must be signed in to change notification settings - Fork 6
Try moving blocks to their own modular directories #170
Conversation
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.
Hi @johnstonphilip,
Good idea to move block functions to their own directory.
The Pattern Block works the same as before.
wp-modules/editor/js/src/index.ts
Outdated
'blocks.registerBlockType', | ||
'pattern-manager/registerPatternBlock', | ||
registerPatternBlock | ||
); |
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.
Moving addFilter()
out of this file is the only part of this PR I don't like.
The idea of this file was to run all of the side-effects of the editor/
module.
So importing another file shouldn't run side-effects.
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.
Still, it's just my opinion 😄
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.
Yeah I can see the argument for both ways. My preference is to be able to remove the whole block by simply deleting a directory. But I'd be alright with putting it back.
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.
Sounds good, it's a minor issue 😄 Whatever you'd like.
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 moved it back :)
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.
Thanks a lot!
'blocks.registerBlockType', | ||
'pattern-manager/registerPatternBlock', | ||
registerPatternBlock | ||
); | ||
|
||
export default function registerPatternBlock( |
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.
Good idea to move the block-related functions to blocks/
return () => ( {} ); | ||
} ); | ||
|
||
jest.mock( '../../../../../app/js/src/components/PatternPreview', () => { | ||
jest.mock( '../../../../../../app/js/src/components/PatternPreview', () => { |
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.
Mocking for React components is so messy 🤣
…into try/move-blocks-to-their-own-files
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 looks good, @johnstonphilip!
The structure is a bit easier to follow this way — it's nice cleanup.
Tasks
Summary of changes
This PR refactors the Pattern Block's (aka Patternception's) code into its own dedicated directory.
How to test