API / Minn\Blocks / States

States final class

Minn\Blocks\States · public/minn/src/Minn/Blocks/States.php · 160 lines

Block state styles (a block's style[":hover"] and the like, probe block-supports): the selector arithmetic and the fallbacks the reference applies when it writes a state's rules. Pure: styles and selectors in, styles, groups and declarations out.

Constants and properties

privateSIDES = array ( 0 => 'top', 1 => 'right', 2 => 'bottom', 3 => 'left', )

Public

staticsplit(string $selector): array#

A selector list split at its top-level commas (none inside parentheses counts), each part as written.

@return list<string>
staticselector(string $base, string $selectors, string $state): string#

A state on each selector of a block's list, its leading compound selector swapped for the base; the base alone for an empty list.

staticpresetVars(mixed $value): mixed#

Presets (var:preset|{kind}|{slug}) as their custom properties, through arrays; anything else as it is.

staticbackgroundResets(array $declarations): array#

Declarations with a background image unset under a background colour that sets neither a background nor an image of its own.

$declarationsarray<string, string>
@return array<string, string>
staticborderFallbacks(array $declarations): array#

Declarations with a solid border style for a border (or a side of one) given a width or a colour and no style.

$declarationsarray<string, string>
@return array<string, string>
staticdimensionFallbacks(array $style): array#

A state's style with an explicit aspect ratio unsetting the height and minimum height, or a height or minimum height unsetting the aspect ratio.

$stylearray<string, mixed>
@return array<string, mixed>
staticgroups(array $style, array $selectors): array#

A state's style split by the selectors a block gives its features: a feature (or one of its properties) with a selector of its own goes there, a feature's other properties to its root selector, the rest to the block's root. Groups keep the order they are first met in.

$stylearray<string, mixed>
$selectorsarray<string, mixed>the block's selectors, root among them
@return list<array{selector: ?string, style: array<string, mixed>}>
staticaddGroup(array $groups, ?string $selector, array $style): void#

Adds a style to the group of a selector, merged into what it holds.

$groupsarray<string, array{selector: ?string, style: array<string, mixed>}>
$stylearray<string, mixed>