diff --git a/components/content/content-types/.gitkeep b/components/content/content-types/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/components/content/displays/display-full/display-full.component.yml b/components/content/displays/display-full/display-full.component.yml new file mode 100644 index 00000000..e69de29b diff --git a/components/content/displays/display-full/display-full.twig b/components/content/displays/display-full/display-full.twig new file mode 100644 index 00000000..4227c565 --- /dev/null +++ b/components/content/displays/display-full/display-full.twig @@ -0,0 +1,66 @@ +{# + @file Fallback content template to be used for full view mode when no other + more specific template is available. +#} + +{% if not localgov_base_remove_css %} + {{ attach_library('localgov_base/full') }} + {% if content_type == 'localgov_directories_venue' + or content_type == 'localgov_directories_page' + or content_type == 'localgov_directory' %} + {{ attach_library('localgov_base/directories') }} + {% endif %} + + {% if content_type == 'localgov_step_by_step_overview' + or content_type == 'localgov_step_by_step_page' %} + {{ attach_library('localgov_base/step-by-step') }} + {% endif %} +{% endif %} + +{% + set classes = [ + content_type|clean_class, + 'node', + restricted_width_content_type ? 'node--with-restricted-width', + display_full_promoted ? 'node--promoted', + display_full_sticky ? 'node--sticky', + display_full_unpublished ? 'node--unpublished', + view_mode ? 'node--view-mode-' ~ view_mode|clean_class, + ] +%} + + + +
+ {{ title_prefix }} + {{ title_suffix }} + + {% if display_submitted %} +
+ {{ author_picture }} + + {% trans %}Submitted by {{ author_name }} on {{ date }}{% endtrans %} + {{ metadata }} +
+ + {% endif %} + + {% if content_type in restricted_width_content_types %} +
+ {% endif %} + + + {{ display_full_content }} +
+ + + {% if localgov_subsites_content %} + {{ localgov_subsites_content }} + {% endif %} + + + {% if content_type in restricted_width_content_types %} + + {% endif %} + + diff --git a/config/install/localgov_base.settings.yml b/config/install/localgov_base.settings.yml index 6d9345c0..ee804895 100644 --- a/config/install/localgov_base.settings.yml +++ b/config/install/localgov_base.settings.yml @@ -2,6 +2,7 @@ localgov_base_remove_css: FALSE localgov_base_remove_js: FALSE localgov_base_add_unpublished_background_colour: TRUE localgov_base_add_draft_note_to_unpublished_content: FALSE +localgov_base_add_archived_note_to_archived_content: FALSE localgov_base_header_behaviour: 'default' localgov_base_localgov_guides_stacked_heading: FALSE localgov_base_localgov_guides_vertical_navigation: TRUE diff --git a/config/schema/localgov_base.schema.yml b/config/schema/localgov_base.schema.yml index 50b4bc6c..b007c508 100644 --- a/config/schema/localgov_base.schema.yml +++ b/config/schema/localgov_base.schema.yml @@ -14,6 +14,9 @@ localgov_base.settings: localgov_base_add_draft_note_to_unpublished_content: type: boolean label: 'Add "[Draft]" to title of unpublished content.' + localgov_base_add_archived_note_to_archived_content: + type: boolean + label: 'Add "[Archived]" to title of archived content.' localgov_base_header_behaviour: type: string label: 'Header behaviour' diff --git a/localgov_base.theme b/localgov_base.theme index 2e94ef46..2eb3773e 100644 --- a/localgov_base.theme +++ b/localgov_base.theme @@ -8,6 +8,7 @@ use Drupal\Component\Utility\Crypt; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; +use Drupal\node\NodeInterface; use Drupal\views\ViewExecutable; /** @@ -42,9 +43,16 @@ function localgov_base_form_system_theme_settings_alter(&$form, FormStateInterfa $form['localgov_base_add_draft_note_to_unpublished_content'] = [ '#type' => 'checkbox', - '#title' => t('Add "Draft" to title of unpublished content.'), + '#title' => t('Add "Draft" to title of draft unpublished content.'), '#default_value' => theme_get_setting('localgov_base_add_draft_note_to_unpublished_content'), - '#description' => t('This adds the word "Draft" to the title of any unpublished content. This is useful if you have removed the pink background from unpublished content.'), + '#description' => t('This adds the word "Draft" to the title of any draft unpublished content. This is useful if you have removed the pink background from unpublished content.'), + ]; + + $form['localgov_base_add_archived_note_to_archived_content'] = [ + '#type' => 'checkbox', + '#title' => t('Add "Archived" to title of archived content.'), + '#default_value' => theme_get_setting('localgov_base_add_archived_note_to_archived_content'), + '#description' => t('This adds the word "Archived" to the title of any content with the "archived" moderation state.'), ]; $form['localgov_base_show_back_to_top_link'] = [ @@ -190,14 +198,55 @@ function localgov_base_preprocess_page(&$variables): void { } +/** + * Get the restricted width content types. + * + * @return array + * An array of restricted width content types. + */ +function _localgov_get_restricted_width_content_types() { + return [ + 'localgov_services_page', + 'localgov_event', + 'localgov_services_status', + 'localgov_step_by_step_overview', + 'localgov_publication_cover_page' + ]; +} + /** * Implements hook_preprocess_HOOK(). */ function localgov_base_preprocess_node(&$variables): void { + $node = $variables['node']; $node_status = $variables['node']->isPublished(); + + if ($node instanceof NodeInterface && $variables['view_mode'] === 'full') { + // Restrict width of the content area to two-thirds of the screen for + // some content types. This is helpful to reduce the line-length for + // better readability. + $variables['restricted_width_content_types'] = []; + if (in_array($node->bundle(), _localgov_get_restricted_width_content_types(), TRUE)) { + $variables['restricted_width_content_types'][] = $node->bundle(); + } + + } + if ($node_status === FALSE) { if (theme_get_setting('localgov_base_add_draft_note_to_unpublished_content') === TRUE) { - $variables['label'] = t('[Draft]') . " " . $variables['node']->label(); + $state = $variables['node']->get('moderation_state')->getString(); + if ($state == 'draft') { + $variables['label'] = t('[Draft]') . " " . $variables['node']->label(); + } + } + } + // We have a theme setting to prepend 'archived' to the title of + // archived content, but we don't mind whether it is published or not. + // An archived state does not have to always be unpubilshed. + if (theme_get_setting('localgov_base_add_archived_note_to_archived_content') === TRUE) { + $state = $variables['node']->get('moderation_state')->getString(); + if ($state == 'archived') { + $variables['label'] = t('[Archived]') . " " . $variables['node']->label(); } } @@ -224,7 +273,21 @@ function localgov_base_preprocess_block(&$variables): void { if ($node_status === FALSE) { if (theme_get_setting('localgov_base_add_draft_note_to_unpublished_content') === TRUE) { $current_title = $variables['content'][0]['#title']; - $variables['content'][0]['#title'] = t('[Draft]') . " " . $current_title; + $state = $node->get('moderation_state')->getString(); + if ($state == 'draft') { + $variables['content'][0]['#title'] = t('[Draft]') . " " . $current_title; + } + } + } + + // We have a theme setting to prepend 'archived' to the title of + // archived content, but we don't mind whether it is published or not. + // An archived state does not have to always be unpubilshed. + if (theme_get_setting('localgov_base_add_archived_note_to_archived_content') === TRUE) { + $current_title = $variables['content'][0]['#title']; + $state = $node->get('moderation_state')->getString(); + if ($state == 'archived') { + $variables['content'][0]['#title'] = t('[Archived]') . " " . $current_title; } } @@ -302,18 +365,22 @@ function localgov_base_views_pre_render(ViewExecutable $view): void { * Implements hook_preprocess_container(). */ function localgov_base_preprocess_container(&$variables): void { - - // Randomize form container IDs for accessibility. // See https://www.drupal.org/project/drupal/issues/1852090 + // Ensure the container has an ID. if (isset($variables['element']['#id'])) { - $id = $variables['element']['#id']; - if ($id === 'edit-actions') { - $id .= '--' . Crypt::randomBytesBase64(8); + $original_id = $variables['element']['#id']; + + // Check if the ID starts with 'edit-actions'. + if (strpos($original_id, 'edit-actions') === 0) { + $random_suffix = Crypt::randomBytesBase64(8); + $random_id = $original_id . '--' . $random_suffix; + + // Keep a stable selector but allow ID randomization. + $variables['attributes']['id'] = $random_id; + $variables['attributes']['data-drupal-selector'] = $original_id; + $variables['element']['#attributes']['data-drupal-selector'] = $original_id; + $variables['element']['#id'] = $random_id; } - $variables['attributes']['id'] = $id; - $variables['attributes']['data-drupal-selector'] = $id; - $variables['element']['#attributes']['data-drupal-selector'] = $id; - $variables['element']['#id'] = $id; } } diff --git a/scripts/subtheme-items/assets/images/favicons/safari-pinned-tab.svg b/scripts/subtheme-items/assets/images/favicons/safari-pinned-tab.svg new file mode 100644 index 00000000..ee382952 --- /dev/null +++ b/scripts/subtheme-items/assets/images/favicons/safari-pinned-tab.svg @@ -0,0 +1,13 @@ + + + + +Created by potrace 1.14, written by Peter Selinger 2001-2017 + + + + diff --git a/templates/content/node--full.html.twig b/templates/content/node--full.html.twig index 0915c9bd..052e2609 100644 --- a/templates/content/node--full.html.twig +++ b/templates/content/node--full.html.twig @@ -71,90 +71,24 @@ */ #} -{# - Restrict width of the content area to two-thirds of the screen for - some content types. This is helpful to reduce the line-length for - better readability. -#} -{% set restricted_width_content_types = [ - 'localgov_services_page', - 'localgov_event', - 'localgov_step_by_step_overview', - 'localgov_services_status', - 'localgov_publication_cover_page' - ] -%} - {% set content_type = node.bundle %} -{% if not localgov_base_remove_css %} - {{ attach_library('localgov_base/full') }} - {% if content_type == 'localgov_directories_venue' - or content_type == 'localgov_directories_page' - or content_type == 'localgov_directory' %} - {{ attach_library('localgov_base/directories') }} - {% endif %} - - {% if content_type == 'localgov_event' %} - {{ attach_library('localgov_base/events') }} - {% endif %} - - {% if content_type == 'localgov_step_by_step_overview' - or content_type == 'localgov_step_by_step_page' %} - {{ attach_library('localgov_base/step-by-step') }} - {% endif %} +{% if node.isPromoted() %} + {% set display_full_promoted = TRUE %} {% endif %} -{% - set classes = [ - content_type|clean_class, - 'node', - 'node--type-' ~ node.bundle|clean_class, - content_type in restricted_width_content_types ? 'node--with-restricted-width', - node.isPromoted() ? 'node--promoted', - node.isSticky() ? 'node--sticky', - not node.isPublished() ? 'node--unpublished', - view_mode ? 'node--view-mode-' ~ view_mode|clean_class, - ] -%} - - - -
- {{ title_prefix }} - {% if label and not page %} - - {{ label }} - - {% endif %} - {{ title_suffix }} - - {% if display_submitted %} -
- {{ author_picture }} - - {% trans %}Submitted by {{ author_name }} on {{ date }}{% endtrans %} - {{ metadata }} -
- - {% endif %} - - {% if content_type in restricted_width_content_types %} -
- {% endif %} +{% if node.isSticky() %} + {% set display_full_sticky = TRUE %} +{% endif %} - - {{ content|without('localgov_subsites_content') }} -
- +{% if not node.isPublished() %} + {% set display_full_unpublished = TRUE %} +{% endif %} - {% if node.localgov_subsites_content.value or content.localgov_subsites_content['#type'] == 'layout_paragraphs_builder' %} - {{ content.localgov_subsites_content }} - {% endif %} - +{% set display_full_content = content|without('localgov_subsites_content') %} - {% if content_type in restricted_width_content_types %} - - {% endif %} +{% if node.localgov_subsites_content.value or content.localgov_subsites_content['#type'] == 'layout_paragraphs_builder' %} + {% set localgov_subsites_content = content.localgov_subsites_content %} +{% endif %} - +{% include "localgov_base:display-full" %}