Skip to content

Commit

Permalink
fix: headings variant (#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
NiclasNorin authored Feb 16, 2024
1 parent 912778f commit 4d94f06
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions source/php/Component/Typography/Typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ public function init() {

private function getVariant($variant) {
$element = $this->data['element'];

if (!$variant) {
return $element;
}


if (in_array($element, ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'])) {
if (in_array($variant, ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'])) {
return $variant;
}

if (in_array($element, ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']) && !in_array($variant, ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'])) {
trigger_error(
sprintf(
'Element "%s" and variant "%s" cannot be combined. Heading elements must use a heading variant.',
Expand All @@ -56,6 +60,7 @@ private function getVariant($variant) {
),
E_USER_WARNING
);

return $element;
}

Expand Down

0 comments on commit 4d94f06

Please sign in to comment.