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

WIP Give themes control of visual styles for core blocks #6721

Closed
wants to merge 7 commits into from

Conversation

brandonpayton
Copy link
Member

@brandonpayton brandonpayton commented May 11, 2018

Description

This is a PR to:

  • Separate core block visual styles from structural styles.
  • Give themes the ability opt-into visual styles provided with core blocks.
  • Make it easy for themes to augment core block styles.

Contributes to #5360.

How has this been tested?

This has been tested manually with a parent theme. It needs to be tested with a child theme where both parent and child specify styles for the same block types. It would also be good to add unit tests.

Types of changes

  • Split visual styles into a theme.css for each core block.
  • Update the build to produce an aggregate build/theme.css file.
  • Enqueue build/theme.css when themes enable support for wp_block_styles.
  • Support themes augmenting block styles by creating a blocks/ directory and a CSS file per block styled by the theme. Example: <theme-dir>/blocks/core.quote.css.
  • Read augmented block styles from both child and parent theme. If both specify augmented styles for a given block type, use the styles provided by the child theme.
  • Documentation
  • Unit tests
  • Take steps to reduce surprise and interruption when developers and users discover visual block styles are no longer added by default.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

@brandonpayton brandonpayton self-assigned this May 16, 2018
@brandonpayton brandonpayton requested a review from mtias May 17, 2018 18:08
@brandonpayton
Copy link
Member Author

brandonpayton commented May 17, 2018

Questions for review:

  • What would be a PHP/WP-idiomatic way of unit testing something like this?
  • Any suggestions on how we can reduce the developer and tester impact of landing this?
  • It seems like it would be clearer to split out theme styles for core blocks under a follow-up PR. Does that sound reasonable?
  • Right now, this PR will enqueue each <theme>/blocks/<block-name>.css file found for registered and core blocks. I believe this will lead to too many resource requests on the front end. Should we read the files and add them inline instead?
  • You mentioned SCSS files in your description of this feature. Is that something we should be supporting here? I don't think so but want to be sure.

@brandonpayton brandonpayton force-pushed the add/separate-block-visual-styles branch from 5553e15 to 3881478 Compare May 18, 2018 06:34

## Styling blocks

### Default theme styles
Copy link
Member

Choose a reason for hiding this comment

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

"Default block styles"


### Adding block styles

Themes may add styles for individual block types. You can do this by adding a `blocks` folder and filling it will files named after the blocks you want to style.
Copy link
Member

Choose a reason for hiding this comment

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

type "will"

/**
* Enqueues block styles provided by the theme.
*
* @since 2.9.0
Copy link
Member

Choose a reason for hiding this comment

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

todo, fix version number

@brandonpayton
Copy link
Member Author

brandonpayton commented May 21, 2018

Thanks for your review, @mtias. I pushed fixes to address your comments.

@mtias mtias added this to the 3.0 milestone May 22, 2018
@mtias mtias added [Feature] Block API API that allows to express the block paradigm. Customization Issues related to Phase 2: Customization efforts labels May 22, 2018
@rchipka
Copy link

rchipka commented May 23, 2018

Related to #6651

The addition of configurable CSS attributes should be standardized as a special prop on each component so that Gutenberg can take care of injecting the styles/classes in an automated, consistent, and maintainable way.

Also see the notes about how we should be doing class names and class injection to properly support extensibility.

@brandonpayton
Copy link
Member Author

Closing this in favor of a simpler PR for block style separation (#6947) and likely another in support of theme overrides for specific block types.

@brandonpayton brandonpayton deleted the add/separate-block-visual-styles branch July 19, 2018 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Customization Issues related to Phase 2: Customization efforts [Feature] Block API API that allows to express the block paradigm.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants