Skip to content
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

Enable user-specified CSS classes via Inspector field #1889

Merged
merged 5 commits into from
Jul 14, 2017

Conversation

aduth
Copy link
Member

@aduth aduth commented Jul 13, 2017

Related: #887

This pull request seeks to add an "Additional CSS Class" field to the Block Inspector for all blocks which do not explicitly opt out from the className block type field. If the user provides a value fro this field, it is automatically applied to the serialized content for that block.

Additional CSS Class

Testing instructions:

Verify that the "Additional CSS Class" field shows in the Block Inspector for all applicable block types, and that the value is included in the serialized content.

  1. Insert a new block
  2. In Settings > Block, note that...
    • If the block type opts out of the className field (e.g. text block), the "Additional CSS Class" field is not shown
    • Otherwise, the "Additional CSS Class" field is shown
  3. Enter a value in "Additional CSS Class"
  4. Change to Text editing mode
  5. Note that the class value is included in the serialized content

Caveats:

The behavior of block description is such that the "Additional CSS Class" field is shown before the description in the inspector. Per feedback at #1555 (comment), I'd like to separately explore refactoring description to be a property of the block type itself.

@aduth aduth added the General Interface Parts of the UI which don't fall neatly under other labels. label Jul 13, 2017
@@ -34,8 +35,7 @@ const BlockInspector = ( { selectedBlock } ) => {
export default connect(
( state ) => {
return {
selectedBlock: getSelectedBlock( state ),
hasSelectedBlock: !! getSelectedBlock( state ),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to include the block name somewhere in the UI.

Copy link
Member Author

@aduth aduth Jul 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to include the block name somewhere in the UI.

Can always change it back with your changes 😉

return <span className="editor-block-inspector__no-blocks">{ __( 'No block selected.' ) }</span>;
}

return (
<Panel>
<PanelBody>
<BlockInspectorClassName />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be rendered after the slot, and probably include a separator (hr).

@aduth aduth force-pushed the add/inspector-class-name branch from 3d17c86 to 3f84d6c Compare July 14, 2017 12:35
@aduth aduth merged commit 7ba1516 into master Jul 14, 2017
@mtias mtias deleted the add/inspector-class-name branch July 14, 2017 12:45
@lkraav
Copy link

lkraav commented Jul 14, 2017

@mtias is something similar planned for allowing inline css style? Would be useful for Headers and elsewhere.

@mtias
Copy link
Member

mtias commented Jul 24, 2017

@lkraav nothing planned for it. The point being you would add the class and style separately. What was the use case you had in mind? Inline styles would make further modifications more difficult, make theme switches potentially harder, and affect context like feeds, readers, email in ways the user cannot anticipate.

@lkraav
Copy link

lkraav commented Jul 24, 2017

nothing planned for it. The point being you would add the class and style separately. What was the use case you had in mind?
Inline styles would make further modifications more difficult, make theme switches potentially harder, and affect context like feeds, readers, email in ways the user cannot anticipate.

Use case is mainly landing/sales pages. One can template (aka try to generalize how content should look) all one wants, but when copywriting across products is going to be different length, different concepts presented, etc, adjusting specific things quickly per-page/product via inline styling is the fastest and most productive workflow.

It doesn't necessarily have to be in core, if we are really looking to save people from shooting themselves in the foot and are thinking that not making some basic html/css level tools available would help it. As long as there's an interface for a plugin to hook in and provide this ability, that would probably work for people handling "Advanced" cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
General Interface Parts of the UI which don't fall neatly under other labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants