From e7345057eb5667dbc4ab34f2dbe6540a423af8f2 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Wed, 26 Jun 2024 16:46:00 +0200 Subject: [PATCH 1/3] =?UTF-8?q?1712:=20Added=20=E2=80=9CExpand=20all=20ste?= =?UTF-8?q?ps=E2=80=9D=20link=20on=20step=20by=20step?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ .../os2loop/themes/os2loop_theme/assets/app.scss | 8 ++++++++ .../os2loop/themes/os2loop_theme/os2loop_theme.theme | 5 +++++ ...paragraph--os2loop-documents-step-by-step.html.twig | 9 ++++++++- .../paragraph--os2loop-documents-step.html.twig | 10 +++++++--- 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73df22d34..711593a02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +- [PR-354](https://github.com/itk-dev/os2loop/pull/354) + 1712: Added “Expand all steps” link on step by step - [PR-353](https://github.com/itk-dev/os2loop/pull/353): Security update - [PR-352](https://github.com/itk-dev/os2loop/pull/352): diff --git a/web/profiles/custom/os2loop/themes/os2loop_theme/assets/app.scss b/web/profiles/custom/os2loop/themes/os2loop_theme/assets/app.scss index 8b9ac6d14..b71ffce34 100644 --- a/web/profiles/custom/os2loop/themes/os2loop_theme/assets/app.scss +++ b/web/profiles/custom/os2loop/themes/os2loop_theme/assets/app.scss @@ -113,3 +113,11 @@ img { // } // } // } + +// Offset used for (trying to) prevent topbar from overlapping content when using URL fragment identifier. +$target-offset: 64px; + +:target { + margin-top: -$target-offset; + padding-top: $target-offset; +} diff --git a/web/profiles/custom/os2loop/themes/os2loop_theme/os2loop_theme.theme b/web/profiles/custom/os2loop/themes/os2loop_theme/os2loop_theme.theme index 5a8d6320b..31ef48df0 100644 --- a/web/profiles/custom/os2loop/themes/os2loop_theme/os2loop_theme.theme +++ b/web/profiles/custom/os2loop/themes/os2loop_theme/os2loop_theme.theme @@ -18,6 +18,11 @@ use Drupal\user\Entity\User; function os2loop_theme_preprocess(&$variables) { $variables['logopath'] = \Drupal::service('file_url_generator')->generateString(theme_get_setting('logo.url')); $variables['os2loop_container_class'] = theme_get_setting('container_class') ?: 'container-fluid'; + // Poor man's App Global Variable + // (https://symfony.com/doc/current/templates.html#the-app-global-variable). + $variables['app'] = [ + 'request' => \Drupal::request(), + ]; } /** diff --git a/web/profiles/custom/os2loop/themes/os2loop_theme/templates/content-entities/paragraph--os2loop-documents-step-by-step.html.twig b/web/profiles/custom/os2loop/themes/os2loop_theme/templates/content-entities/paragraph--os2loop-documents-step-by-step.html.twig index 8439f6e26..02d9c618c 100644 --- a/web/profiles/custom/os2loop/themes/os2loop_theme/templates/content-entities/paragraph--os2loop-documents-step-by-step.html.twig +++ b/web/profiles/custom/os2loop/themes/os2loop_theme/templates/content-entities/paragraph--os2loop-documents-step-by-step.html.twig @@ -47,10 +47,17 @@ ] %} {% block paragraph %} - + {% set paragraph_id = 'p-' ~ paragraph.id.value %} + {% set expanded = app.request.query.get('expanded') %} + {{ content.contextual_links }} {{ include('@os2loop_theme/content-entities/os2loop_documents_title.html.twig') }} {{ content.os2loop_documents_description }} + + {% if not expanded %} + {{ 'Expand all steps'|trans }} + {% endif %} +
    {{ content.os2loop_documents_steps }}
diff --git a/web/profiles/custom/os2loop/themes/os2loop_theme/templates/content-entities/paragraph--os2loop-documents-step.html.twig b/web/profiles/custom/os2loop/themes/os2loop_theme/templates/content-entities/paragraph--os2loop-documents-step.html.twig index 95dc12d10..218b60d3b 100644 --- a/web/profiles/custom/os2loop/themes/os2loop_theme/templates/content-entities/paragraph--os2loop-documents-step.html.twig +++ b/web/profiles/custom/os2loop/themes/os2loop_theme/templates/content-entities/paragraph--os2loop-documents-step.html.twig @@ -51,24 +51,28 @@ {% set has_title = content.os2loop_documents_step_title['#title'] is not null %} +{% set expanded = app.request.query.get('expanded') %} +{% set class_collapsed = not expanded ? 'collapsed' %} +{% set class_collapse = not expanded ? 'collapse' %} + {% block paragraph %} {% block content %}
  • {# A hack to check if we're rendering content for pdf generation #} {% if 'print/pdf' in url('')['#markup'] %} -