Skip to content

Commit

Permalink
refactor: set typography variant
Browse files Browse the repository at this point in the history
  • Loading branch information
NiclasNorin committed Feb 16, 2024
1 parent c983c2d commit d6fd3b3
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions source/php/Component/Typography/Typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,13 @@ public function init() {

private function getVariant($variant) {
$element = $this->data['element'];
$headings = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];

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, $headings) && !in_array($variant, $headings)) {
trigger_error(
sprintf(
'Element "%s" and variant "%s" cannot be combined. Heading elements must use a heading variant.',
Expand All @@ -63,7 +61,7 @@ private function getVariant($variant) {
return $element;
}

return 'p';
return $variant;
}

private function setMaxHeading($element) {
Expand Down

0 comments on commit d6fd3b3

Please sign in to comment.