From 4413fe377cdef5cd71c66eaafe38b8e0c3c0cbcd Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Sun, 28 Jun 2026 07:52:25 -0400 Subject: [PATCH] Consolidate button style resolution into StyleAttributeMapper ButtonStyleResolver independently re-parsed the same CSS color/typography/ spacing/border declarations that the shared StyleAttributeMapper (#261) already resolves for every block (parseBorderShorthand was byte-for-byte identical; border/backgroundColor/boxSides/cssColor were near-duplicates). Delegate that generic CSS->attribute mechanic to StyleAttributeMapper and keep only the button-specific presentation policy in ButtonStyleResolver: background-before-text color shape, no gradient fill, padding-not-margin spacing, and the curated typography subset. Behavior-preserving: the emitted style object (and its key order) is byte-identical, so all 144 parity fixtures pass unchanged. Refs #242 Co-Authored-By: Claude Opus 4.8 --- .../Patterns/ButtonStyleResolver.php | 224 ++++-------------- 1 file changed, 48 insertions(+), 176 deletions(-) diff --git a/php-transformer/src/HtmlToBlocks/Patterns/ButtonStyleResolver.php b/php-transformer/src/HtmlToBlocks/Patterns/ButtonStyleResolver.php index 3e3d2a93..15f0ea5d 100644 --- a/php-transformer/src/HtmlToBlocks/Patterns/ButtonStyleResolver.php +++ b/php-transformer/src/HtmlToBlocks/Patterns/ButtonStyleResolver.php @@ -3,6 +3,8 @@ namespace Automattic\BlocksEngine\PhpTransformer\HtmlToBlocks\Patterns; +use Automattic\BlocksEngine\PhpTransformer\HtmlToBlocks\Style\StyleAttributeMapper; + /** * Translates a button's resolved CSS declarations (from inline style plus the * `