You are here

webform-progress-tracker.html.twig in Webform 6.x

Same filename and directory in other branches
  1. 8.5 templates/webform-progress-tracker.html.twig

Default theme implementation for webform wizard progress tracker.

Available variables:

  • webform: A webform.
  • pages: Associative array of wizard pages.
  • progress: Array of wizard progress containing page titles.
  • current_page: Current wizard page key.
  • current_index: The current wizard page index.
  • max_pages: Maximum number of pages that progress text should be displayed on.

File

templates/webform-progress-tracker.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation for webform wizard progress tracker.
  5. *
  6. * Available variables:
  7. * - webform: A webform.
  8. * - pages: Associative array of wizard pages.
  9. * - progress: Array of wizard progress containing page titles.
  10. * - current_page: Current wizard page key.
  11. * - current_index: The current wizard page index.
  12. * - max_pages: Maximum number of pages that progress text should be displayed on.
  13. *
  14. * @see template_preprocess_webform_progress_tracker()
  15. * @see https://www.w3.org/WAI/tutorials/forms/multi-page/
  16. *
  17. * @ingroup themeable
  18. */
  19. #}
  20. {{ attach_library('webform/webform.progress.tracker') }}
  21. <ul class="webform-progress-tracker progress-tracker progress-tracker--center" data-webform-progress-steps>
  22. {% for index, page in progress %}
  23. {% set is_completed = index < current_index %}
  24. {% set is_active = index == current_index %}
  25. {%
  26. set classes = [
  27. 'progress-step',
  28. is_completed ? 'is-complete',
  29. is_active ? 'is-active',
  30. ]
  31. %}
  32. {%
  33. set attributes = create_attribute()
  34. .setAttribute('data-webform-' ~ page.type, page.name)
  35. .setAttribute('title', page.title)
  36. .setAttribute('class', '')
  37. .addClass(classes)
  38. %}
  39. <li{{ attributes }}>
  40. <div class="progress-marker" data-webform-progress-step data-webform-progress-link data-text="{{ index + 1 }}"></div>
  41. {% if progress|length < max_pages %}
  42. <div class="progress-text">
  43. <div class="progress-title" data-webform-progress-link>
  44. <span class="visually-hidden" data-webform-progress-state>{% if is_active or is_completed %}{{ is_active ? 'Current'|t : 'Completed'|t }}{% endif %}</span>
  45. {{ page.title }}
  46. </div>
  47. </div>
  48. {% endif %}
  49. </li>
  50. {% endfor %}
  51. </ul>