Skip to content

Commit

Permalink
Fix missing book instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
ax committed Apr 27, 2024
1 parent 3c1be5f commit 004df20
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 10 deletions.
12 changes: 5 additions & 7 deletions web/themes/custom/alps_trips/alps_trips.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ libraries-extend:
- alps_trips/progress
core_version_requirement: ^10
generator: "starterkit_theme:10.1.1"

components:
namespaces:
atoms: ../../../../storybook/stories/01-atoms
molecules: ../../../../storybook/stories/02-molecules
organisms: ../../../../storybook/stories/03-organisms

regions:
header: Header
breadcrumb: Breadcrumb
Expand All @@ -36,3 +29,8 @@ regions:
footer: Footer
page_top: Page top
page_bottom: Page bottom
components:
namespaces:
atoms: ../../../../storybook/stories/01-atoms
molecules: ../../../../storybook/stories/02-molecules
organisms: ../../../../storybook/stories/03-organisms
30 changes: 27 additions & 3 deletions web/themes/custom/alps_trips/alps_trips.theme
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* Functions to support theming.
*/

use Drupal\block\Entity\Block;

/**
* Implements hook_preprocess_image_widget().
*/
Expand All @@ -21,16 +23,38 @@ function alps_trips_preprocess_image_widget(array &$variables) {
}

/**
* Implements hook_preprocess_region_alter().
* Implements hook_theme_suggestions_HOOK().
*/
function alps_trips_theme_suggestions_region_alter(array &$suggestions, array $variables): void {
if (!empty($variables['elements']['#region'])) {
if (\Drupal::service('path.matcher')->isFrontPage()) {
$suggestions[] = 'region__' . $variables['elements']['#region'] . '__front';

// Add a suggestion if we are on the front page.
if (Drupal::service('path.matcher')->isFrontPage()) {
$suggestions[] =
'region__' . $variables['elements']['#region'] . '__front';
}
}
}

/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function alps_trips_theme_suggestions_block_alter(array &$suggestions, array $variables): void {
// Add a suggestion with the block region.
$elements = $variables['elements'];
if (array_key_exists('#id', $elements)) {
$block = Block::load($elements['#id']);
$suggestions[] = 'block__' . $block->getRegion();
}

if (array_key_exists('#block_content', $elements['content'])) {
/** @var \Drupal\block_content\Entity\BlockContent $block_content */
$block_content = $elements['content']['#block_content'];
$block_bundle = $block_content->bundle();
$suggestions[] = 'block__type_' . $block_bundle;
}
}

/**
* Implements hook_preprocess_region().
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{#
/**
* @file
* Theme override for a menu block.
*
* Available variables:
* - plugin_id: The ID of the block implementation.
* - label: The configured label of the block if visible.
* - configuration: A list of the block's configuration values.
* - label: The configured label for the block.
* - label_display: The display settings for the label.
* - provider: The module or other provider that provided this block plugin.
* - Block plugin specific settings will also be stored here.
* - in_preview: Whether the plugin is being rendered in preview mode.
* - content: The content of this block.
* - attributes: HTML attributes for the containing element.
* - id: A valid HTML ID and guaranteed unique.
* - title_attributes: HTML attributes for the title element.
* - content_attributes: HTML attributes for the content element.
* - title_prefix: Additional output populated by modules, intended to be
* displayed in front of the main title tag that appears in the template.
* - title_suffix: Additional output populated by modules, intended to be
* displayed after the main title tag that appears in the template.
*
* Headings should be used on navigation menus that consistently appear on
* multiple pages. When this menu block's label is configured to not be
* displayed, it is automatically made invisible using the 'visually-hidden' CSS
* class, which still keeps it visible for screen-readers and assistive
* technology. Headings allow screen-reader and keyboard only users to navigate
* to or skip the links.
* See http://juicystudio.com/article/screen-readers-display-none.php and
* http://www.w3.org/TR/WCAG-TECHS/H42.html for more information.
*/
#}
{{ include('@molecules/menu-block.html.twig',
{
'title': label,
'menu': content,
})
}}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ include('@organisms/header.html.twig',
{
'blocks': content,
'attributes': attributes.setAttribute('role', 'banner'),
'background': true,
})
}}

0 comments on commit 004df20

Please sign in to comment.