Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions php-transformer/src/HtmlToBlocks/HtmlTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ private function presentationAttributes(DOMElement $element): array
return array_filter(array(
'className' => $this->promotedClassName($this->attr($element, 'class')),
'style' => $style,
'layout' => $this->layoutAttribute($element),
'layout' => $this->layoutAttribute($element, $style),
), static fn ($value): bool => is_array($value) ? array() !== $value : '' !== trim((string) $value));
}

Expand Down Expand Up @@ -1137,7 +1137,7 @@ private function isHighValueStyledElement(DOMElement $element): bool
$this->attr($element, 'role'),
))));

if ( preg_match('/(?:^|[^a-z0-9])(?:btn|button|cta|action|nav|menu|card|tile|panel|pricing|price|product|grid|columns|layout|stack|cluster|row|wrap)(?:[^a-z0-9]|$)/', $tokens) ) {
if ( preg_match('/(?:^|[^a-z0-9])(?:btn|button|cta|action|nav|menu|cards?|tile|panel|pricing|price|product|grid|columns|layout|stack|cluster|row|wrap)(?:[^a-z0-9]|$)/', $tokens) ) {
return true;
}

Expand Down Expand Up @@ -1403,7 +1403,7 @@ private function promotedClassName(string $className): string
/**
* @return array<string, string>
*/
private function layoutAttribute(DOMElement $element): array
private function layoutAttribute(DOMElement $element, string $mergedStyle = ''): array
{
$declared = trim($this->attr($element, 'data-layout'));
if ( '' === $declared ) {
Expand All @@ -1418,7 +1418,7 @@ private function layoutAttribute(DOMElement $element): array
}
}

$style = strtolower($this->attr($element, 'style'));
$style = strtolower('' !== trim($mergedStyle) ? $mergedStyle : $this->attr($element, 'style'));
if ( preg_match('/(?:^|;)\s*display\s*:\s*(inline-)?flex\b/', $style) ) {
return array( 'type' => 'flex' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
{
"path": "index.html",
"kind": "html",
"content": "<!doctype html><html><head><title>Layout wrappers</title><link rel=\"stylesheet\" href=\"assets/site.css\"></head><body><main><section class=\"hero-grid\"><div><h1>Plan the work</h1><p>Keep the lead and aside aligned.</p></div><aside><p>Side note</p></aside></section><section class=\"shift-card\"><span>1</span><div><h2>First shift</h2><p>Flexible card row.</p></div></section></main></body></html>"
"content": "<!doctype html><html><head><title>Layout wrappers</title><link rel=\"stylesheet\" href=\"assets/site.css\"></head><body><main><section class=\"hero-grid\"><div><h1>Plan the work</h1><p>Keep the lead and aside aligned.</p></div><aside><p>Side note</p></aside></section><section class=\"shift-card\"><span>1</span><div><h2>First shift</h2><p>Flexible card row.</p></div></section><section class=\"services-cards\"><article><h2>One</h2><p>First service.</p></article><article><h2>Two</h2><p>Second service.</p></article><article><h2>Three</h2><p>Third service.</p></article></section></main></body></html>"
},
{
"path": "assets/site.css",
"kind": "css",
"content": ".hero-grid{display:grid;grid-template-columns:1fr 420px;gap:clamp(24px,4vw,64px);align-items:center}.shift-card{display:grid;grid-template-columns:auto 1fr;gap:16px;align-items:start}"
"content": ".hero-grid{display:grid;grid-template-columns:1fr 420px;gap:clamp(24px,4vw,64px);align-items:center}.shift-card{display:grid;grid-template-columns:auto 1fr;gap:16px;align-items:start}.services-cards{display:flex;gap:24px;align-items:stretch}"
}
]
}
Expand All @@ -34,6 +34,7 @@
{ "path": "serialized_blocks", "assert": "contains", "value": "display:grid;grid-template-columns:1fr 420px;gap:clamp(24px,4vw,64px);align-items:center" },
{ "path": "serialized_blocks", "assert": "contains", "value": "shift-card" },
{ "path": "serialized_blocks", "assert": "contains", "value": "display:grid;grid-template-columns:auto 1fr;gap:16px;align-items:start" },
{ "path": "serialized_blocks", "assert": "contains", "value": "<!-- wp:group {\"className\":\"services-cards\",\"style\":\"display:flex;gap:24px;align-items:stretch\",\"layout\":{\"type\":\"flex\"}} -->" },
{ "path": "fallbacks", "assert": "count", "count": 0 }
]
}
Loading