API / Minn\Blocks / Elements

Elements final class

Minn\Blocks\Elements · public/minn/src/Minn/Blocks/Elements.php · 121 lines

Per-block element styles (style.elements in a block's attributes, the link colour most often; probe block-supports). A block whose element styles set a colour gets a numbered wp-elements-N class and a rule per element and state, recorded with the page's block-support styles in render order: links (their text colour, plain or on hover), headings, each heading level and buttons (text, background or gradient). A block type whose colour support skips serialization, whole or for links, headings or buttons, writes none for those.

Used by 1

Constants and properties

privateSELECTORS = array ( 'link' => 'a:where(:not(.wp-element-button))', 'heading' => 'h1, h2, h3, h4, h5, h6', 'h1' => 'h1', 'h2' => 'h2', 'h3' => 'h3', 'h4' => 'h4', 'h5' => 'h5', 'h6' => 'h6', 'button' => '.wp-element-button, .wp-block-button__link', )
privateKINDS = array ( 'link' => 'link', 'heading' => 'heading', 'h1' => 'heading', 'h2' => 'heading', 'h3' => 'heading', 'h4' => 'heading', 'h5' => 'heading', 'h6' => 'heading', 'button' => 'button', )

The kind each element's skip answers to: every heading level is a heading.

Public

staticclassName(array $attrs, array $supports): ?string#

The block's wp-elements-N class, recording its rules; null when its element styles earn none.

$supportsarray<string, mixed>the block type's supports
staticshouldAdd(array $elements, array $skip): bool#

Whether element styles earn a class: a link's text colour (or its hover's), a heading's, a heading level's or a button's text, background or gradient, for a kind not skipped.

$elementsarray<string, mixed>
$skiparray<string, bool>by kind: link, heading, button
staticskips(array $supports): array#

The kinds a block type's colour support skips serializing.

$supportsarray<string, mixed>
@return array<string, bool>

Internals 2

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privaterules(string $class, array $elements, array $skip): array#
$elementsarray<string, mixed>
$skiparray<string, bool>
@return list<array{selector: string, declarations: array<string, string>}>
privatedeclarations(array $styles): array#
@return array<string, string>