Skip to content

Commit

Permalink
fix(shs-5692): refactor spotlight style field class assignation
Browse files Browse the repository at this point in the history
  • Loading branch information
cienvaras committed Aug 8, 2024
1 parent 3d781e3 commit 90456b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type: list_string
settings:
allowed_values:
-
value: hb-spotlight--expanded
value: expanded
label: Expanded
allowed_values_function: ''
module: options
Expand Down
16 changes: 6 additions & 10 deletions docroot/modules/humsci/hs_layouts/hs_layouts.module
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,12 @@ function hs_layouts_preprocess_pattern_spotlight(&$variables) {
$bgValue = $paragraph->get('field_hs_spotlight_bg')->getString();
$variables['attributes']->addClass(Html::cleanCssIdentifier($bgValue));
}
if ($paragraph instanceof ParagraphInterface) {
if (
$paragraph->hasField('field_spotlight_style') &&
$paragraph->get('field_spotlight_style')->getString()
) {
$spotlightStyle = $paragraph->get('field_spotlight_style')->getString();
$variables['attributes']->addClass(Html::cleanCssIdentifier($spotlightStyle));
} else {
$variables['attributes']->addClass(Html::cleanCssIdentifier('hb-spotlight--classic'));
}
if (
$paragraph instanceof ParagraphInterface &&
$paragraph->hasField('field_spotlight_style')
) {
$className = $paragraph->get('field_spotlight_style')->isEmpty() ? 'classic' : $paragraph->get('field_spotlight_style')->getString();
$variables['attributes']->addClass(Html::cleanCssIdentifier('hb-spotlight--' . $className));
}
}

Expand Down

0 comments on commit 90456b7

Please sign in to comment.