diff --git a/core/themes/olivero/config/schema/olivero.schema.yml b/core/themes/olivero/config/schema/olivero.schema.yml index e37bf66d2f..563b9a52c9 100644 --- a/core/themes/olivero/config/schema/olivero.schema.yml +++ b/core/themes/olivero/config/schema/olivero.schema.yml @@ -4,47 +4,6 @@ olivero.settings: type: theme_settings label: 'olivero settings' mapping: - third_party_settings: - type: mapping - label: 'Third party settings' - mapping: - shortcut: - type: mapping - label: 'Shortcut' - mapping: - module_link: - type: boolean - label: 'Module Link' - features: - type: mapping - label: 'Features' - mapping: - node_user_picture: - type: boolean - label: "User picture" - comment_user_picture: - type: boolean - label: "Comment user picture" - comment_user_verification: - type: boolean - label: "Comment user verification" - favicon: - type: boolean - label: "Favicon" - logo: - type: mapping - label: 'Features' - mapping: - use_default: - type: boolean - label: "Use default" - favicon: - type: mapping - label: 'Features' - mapping: - use_default: - type: boolean - label: "Use default" mobile_menu_all_widths: type: integer label: "Mobile menu all widths" diff --git a/core/themes/olivero/olivero.info.yml b/core/themes/olivero/olivero.info.yml index da4fbeef9d..14ceed7389 100644 --- a/core/themes/olivero/olivero.info.yml +++ b/core/themes/olivero/olivero.info.yml @@ -1,8 +1,8 @@ # This theme is marked as @internal. It is intended to evolve and change over # minor releases. -# As the UI of Drupal improves between minor versions, the mark up and assets -# in the Olivero theme will change. The Olivero theme is not backwards -# compatible. If you wish to modify the output or assets of Olivero you can: +# As the UI of Drupal improves between minor versions, the markup and assets in +# the Olivero theme will change. The Olivero theme is not backwards compatible +# If you wish to modify the output or assets of Olivero you can: # 1. Copy the whole of Olivero and rename it as your own theme. You will need to # manually manage your own updates if you want to stay up to date with Olivero's # bug fixes and feature support. diff --git a/core/themes/olivero/olivero.theme b/core/themes/olivero/olivero.theme index 14ce021ac0..7cb0ff6da1 100644 --- a/core/themes/olivero/olivero.theme +++ b/core/themes/olivero/olivero.theme @@ -11,6 +11,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Template\Attribute; use Drupal\Core\Render\Element; +use Drupal\user\UserInterface; /** * Implements hook_preprocess_HOOK() for HTML document templates. @@ -104,29 +105,30 @@ function olivero_preprocess_block(&$variables) { if ($block) { $region = $block->getRegion(); if ($region == 'primary_menu') { - if ($variables['base_plugin_id'] == 'system_menu_block') { + if ($variables['base_plugin_id'] === 'system_menu_block') { $variables['content']['#attributes']['region'] = $region; } - elseif ($variables['base_plugin_id'] == 'search_form_block') { + elseif ($variables['base_plugin_id'] === 'search_form_block') { // Attaching library for search block if present at primary menu // region. $variables['#attached']['library'][] = 'olivero/search-narrow'; } } - elseif ($region == 'secondary_menu' && $variables['base_plugin_id'] == 'search_form_block') { + elseif ($region === 'secondary_menu' && $variables['base_plugin_id'] === 'search_form_block') { // Attaching library for search block if present at secondary menu // region. $variables['#attached']['library'][] = 'olivero/search-wide'; } - if ($variables['base_plugin_id'] == 'search_form_block' && in_array($region, ['primary_menu', 'secondary_menu'])) { - $variables['content']['actions']['submit']['#olivero_is_header_search_submit'] = TRUE; + if ($variables['base_plugin_id'] === 'search_form_block' && in_array($region, ['primary_menu', 'secondary_menu'], TRUE)) { + $variables['content']['actions']['submit']['#theme_wrappers'] = ['input__submit__header_search']; } } } - if ($variables['plugin_id'] == 'system_branding_block') { - if (theme_get_setting('site_branding_bg_color') && theme_get_setting('site_branding_bg_color') !== 'default') { - $variables['attributes']['class'][] = 'site-branding--bg-' . theme_get_setting('site_branding_bg_color'); + if ($variables['plugin_id'] === 'system_branding_block') { + $site_branding_color = theme_get_setting('site_branding_bg_color'); + if ($site_branding_color && $site_branding_color !== 'default') { + $variables['attributes']['class'][] = 'site-branding--bg-' . $site_branding_color; } } } @@ -135,7 +137,7 @@ function olivero_preprocess_block(&$variables) { * Implements hook_theme_suggestions_HOOK_alter() for menu. */ function olivero_theme_suggestions_menu_alter(&$suggestions, array $variables) { - if (isset($variables['attributes']['region']) && $variables['attributes']['region'] == 'primary_menu') { + if (isset($variables['attributes']['region']) && $variables['attributes']['region'] === 'primary_menu') { $suggestions[] = 'menu__' . $variables['attributes']['region']; } } @@ -144,7 +146,7 @@ function olivero_theme_suggestions_menu_alter(&$suggestions, array $variables) { * Implements hook_theme_suggestions_HOOK_alter() for form templates. */ function olivero_theme_suggestions_form_alter(array &$suggestions, array $variables) { - if ($variables['element']['#form_id'] == 'search_block_form') { + if ($variables['element']['#form_id'] === 'search_block_form') { $suggestions[] = 'form__search_block_form'; } } @@ -153,7 +155,7 @@ function olivero_theme_suggestions_form_alter(array &$suggestions, array $variab * Implements hook_theme_suggestions_HOOK_alter() for field templates. */ function olivero_theme_suggestions_field_alter(array &$suggestions, array $variables) { - if ($variables["element"]["#field_type"] == 'entity_reference' && $variables["element"]["#formatter"] == "entity_reference_label") { + if ($variables['element']['#field_type'] == 'entity_reference' && $variables['element']['#formatter'] == 'entity_reference_label') { $suggestions[] = 'field__type_entity_reference__formatter_entity_reference_label'; } } @@ -206,15 +208,6 @@ function olivero_theme_suggestions_block_alter(&$suggestions, array $variables) } } -/** - * Implements hook_theme_suggestions_HOOK_alter() for input(). - */ -function olivero_theme_suggestions_input_alter(&$suggestions, array $variables) { - if ($variables['element']['#olivero_is_header_search_submit'] ?? FALSE) { - $suggestions[] = $variables['theme_hook_original'] . '__header_search'; - } -} - /** * Implements hook_preprocess_HOOK() for menu-local-tasks templates. * @@ -235,7 +228,7 @@ function olivero_preprocess_menu_local_tasks(&$variables) { * Implements hook_preprocess_form_element(). */ function olivero_preprocess_form_element(&$variables) { - if (!empty($variables['element']['#type']) && ($variables['element']['#type'] === 'radio' || $variables['element']['#type'] === 'checkbox')) { + if (in_array($variables['element']['#type'] ?? FALSE, ['checkbox', 'radio'], TRUE)) { $variables['attributes']['class'][] = 'form-type--boolean'; } @@ -286,7 +279,7 @@ function olivero_preprocess_input(&$variables) { 'week', ]; - if (in_array($type_html, $text_types_html)) { + if (in_array($type_html, $text_types_html, TRUE)) { $variables['attributes']['class'][] = 'form-element'; $variables['attributes']['class'][] = Html::getClass('form-element--type-' . $type_html); $variables['attributes']['class'][] = Html::getClass('form-element--api-' . $type_api); @@ -296,7 +289,7 @@ function olivero_preprocess_input(&$variables) { } } - if (in_array($type_html, ['checkbox', 'radio'])) { + if (in_array($type_html, ['checkbox', 'radio'], TRUE)) { $variables['attributes']['class'][] = 'form-boolean'; $variables['attributes']['class'][] = Html::getClass('form-boolean--type-' . $type_html); } @@ -341,7 +334,7 @@ function olivero_preprocess_radios(&$variables) { function olivero_preprocess_field(&$variables) { $rich_field_types = ['text_with_summary', 'text', 'text_long']; - if (in_array($variables['field_type'], $rich_field_types)) { + if (in_array($variables['field_type'], $rich_field_types, TRUE)) { $variables['attributes']['class'][] = 'text-content'; } } @@ -532,10 +525,9 @@ function olivero_preprocess_field__comment(&$variables) { // Add user.compact to field-comment if profile's avatar of current user // exist. - $uid = \Drupal::currentUser()->id(); - if ($uid) { - $user = User::load($uid); - if (!empty($user->user_picture) && $user->user_picture->isEmpty() === FALSE) { + $user = \Drupal::currentUser(); + if ($user->isAuthenticated() && $user instanceof UserInterface) { + if ($user->hasField('user_picture') && !$user->get('user_picture')->isEmpty()) { $variables['user_picture'] = \Drupal::entityTypeManager() ->getViewBuilder('user') ->view($user, 'compact'); diff --git a/core/themes/olivero/templates/block/block--secondary-menu.html.twig b/core/themes/olivero/templates/block/block--secondary-menu.html.twig index 078a4ce083..624fa44498 100644 --- a/core/themes/olivero/templates/block/block--secondary-menu.html.twig +++ b/core/themes/olivero/templates/block/block--secondary-menu.html.twig @@ -41,7 +41,7 @@ ] %} {% set heading_id = attributes.id ~ '-menu'|clean_id %} -