WordPress/gutenberg

Allow custom style variation classNames

Open

#11,763 opened on 2018年11月12日

GitHub で見る
 (16 comments) (21 reactions) (0 assignees)JavaScript (9,607 stars) (3,893 forks)batch import
Good First Issue[Feature] Block Style Variations[Type] Enhancement

説明

Is your feature request related to a problem? Please describe.

The block styles variations API introduced in #7362 uses an is-style-{styleName} className to the block for style variants. This works well for core blocks and new blocks, but may be overly opinionated for converting existing content that has an established approach to styling variants (see https://github.com/WordPress/gutenberg/pull/7362#issuecomment-398342742). For example, a pattern library that uses BEM conventions might use .element for a default element, and .element.element--variant for a variant of that element. I'd advocate for a solution that does not require changing an existing naming convention if one exists.

Describe the solution you'd like

A className attribute could be added to each style variation which, if supplied, would be used instead of the default generated className. Here's some pseudocode:

styles: [
    { 
        name: 'default', 
        label: __( 'Rounded' ), 
        isDefault: true 
    },
    { 
        name: 'outline', 
        label: __( 'Outline' ),
        className: 'button--outline' 
    },
    { 
        name: 'squared', 
        label: __( 'Squared' ) 
        className: 'button--squared' 
    },
],

Describe alternatives you've considered

The only alternative at present is to use the opinionated is-style-{styleName} naming convention.

コントリビューターガイド

Allow custom style variation classNames · WordPress/gutenberg#11763 | Good First Issue