-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Blocks: Automatically generate a wrapper classname for blocks #1381
Conversation
blocks/api/serializer.js
Outdated
if ( ! element || ! isObject( element ) ) { | ||
return element; | ||
} | ||
const className = classnames( element.props.className, `wp-block-${ kebabCase( blockName ) }` ); |
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.
Can we drop core
from the classes?
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.
What about plugin blocks with other namespaces? this could create ambiguity.
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.
How so? Core blocks would have no namespace and plugin blocks will have the plugin namespace.
@@ -37,8 +39,18 @@ export function getSaveContent( save, attributes ) { | |||
} | |||
} | |||
|
|||
// Adding a generic classname | |||
const addClassnameToElement = ( element ) => { |
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'd be nice to have a list of blocks where we don't want to apply the class (p
and heading
, to start).
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.
what about a block setting className
that can be nullable and if not set we default to wp-block-core-quote
6c73d48
to
7240717
Compare
@youknowriad why do we drop the Alternative suggestion: From
|
We had a discussion in Slack (should have reported this here), and we decided to drop the namespace for core blocks to shorten the classname (and we'll forbid the |
I think we should revisit this decision. It's a definitive way in which core blocks are not equal to plugin blocks; it imposes additional cognitive load; and anything related to how we handle block names should be super simple, consistent, and explicit. This breaks down a bit if, for example, a plugin registers a block named |
try to close #1362
Glitches:
Notes:
We may need the same thing on the backend for dynamically rendered blocks but it's harder to implement because we only have strings (and not element) in the backend.