Skip to content

Commit

Permalink
Merge pull request #376 from helsingborg-stad/refactor/typography-var…
Browse files Browse the repository at this point in the history
…iants

Refactor/typography variants
  • Loading branch information
NiclasNorin authored Feb 16, 2024
2 parents ef7db26 + a7a9b4e commit 84d71f1
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions source/php/Component/Typography/Typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +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 @@ -64,7 +61,7 @@ private function getVariant($variant) {
return $element;
}

return 'p';
return $variant;
}

private function setMaxHeading($element) {
Expand Down

0 comments on commit 84d71f1

Please sign in to comment.