Skip to content

Commit

Permalink
D8CORE-5828 If home page starts with a wysiwyg, add some space at the…
Browse files Browse the repository at this point in the history
… top
  • Loading branch information
pookmish committed Nov 6, 2024
1 parent 8a596db commit 58b7f31
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion themes/stanford_basic/dist/css/layout.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion themes/stanford_basic/dist/js/behaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ window.Drupal.behaviors.stanford_basic = {
}
$('.su-masthead .su-skipnav--content', context).attr('href', '#' + $title.attr('id'));
} else {
if ($('#main-content', context).length === 0) {
if (!$('#main-content', context).length) {
$('.su-skipnav--content', context).attr('href', '#page-content');
}
}
Expand Down
4 changes: 4 additions & 0 deletions themes/stanford_basic/src/scss/layout/_page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ body {
[data-island] {
width: 100%;
}

.add-more-space-to-top {
@include margin(8rem 0 0);
}
20 changes: 20 additions & 0 deletions themes/stanford_basic/stanford_basic.theme
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,26 @@ function stanford_basic_preprocess_node(&$variables) {
$node_bundle = $variables['node']->bundle();
$variables['#attached']['library'][] = 'stanford_basic/content.' . $node_bundle;
unset($variables['content']['book_navigation']);

// If the home page (no page title) has a wysiwyg as the first component, and
// it does not have a page banner, at a class that will create a little space
// at the top of the page.
if (
$variables['page'] &&
$node_bundle == 'stanford_page' &&
\Drupal::service('path.matcher')->isFrontPage()
) {
/** @var \Drupal\node\NodeInterface $node */
$node = $variables['node'];
if (
!$node->get('su_page_banner')->count() &&
$node->get('su_page_components')->count() >= 2 &&
$node->get('su_page_components')
->get(1)->entity->bundle() == 'stanford_wysiwyg'
) {
$variables['attributes']['class'][] = 'add-more-space-to-top';
}
}
}

/**
Expand Down

0 comments on commit 58b7f31

Please sign in to comment.