Skip to content

Commit

Permalink
Merge pull request #67 from ministryofjustice/component/organisation-…
Browse files Browse the repository at this point in the history
…switcher

 Update organisation switcher link logic
  • Loading branch information
adamsilver authored Aug 8, 2019
2 parents 334d7d2 + 993b2f4 commit 72b77df
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
12 changes: 9 additions & 3 deletions app/views/components/organisation-switcher/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,24 @@ <h2 class="govuk-heading-l">Example 1</h2>
href: '#'
}
}) }}

<br>

<h2 class="govuk-heading-l">Example 2</h2>
{{ mojOrganisationSwitcher({
text: 'HMP Brixton, HMP/YOI Feltham, HMP/YOI Isis, HMP Pentonville, HMP Thameside, HMP Wandsworth, HMP Wormwood Scrubs',
link: {
text: "Change prisons",
href: '#'
}
}) }}

<br>

<h2 class="govuk-heading-l">Example 3</h2>
{{ mojOrganisationSwitcher({
text: 'HMP Brixton'
}) }}

</div>

</div>
Expand Down
14 changes: 9 additions & 5 deletions src/moj/components/organisation-switcher/template.njk
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<div {% if params.id %}id="{{ params.id }}"{% endif -%} class="moj-organisation-nav {{- ' ' + params.classes if params.classes}}" aria-label="{{ params.label | default('Organisation switcher') }}" {%- for attribute, value in params.attributes -%} {{ attribute }}="{{ value }}"{% endfor %}>
<div {%- if params.id %} id="{{ params.id }}"{% endif %} class="moj-organisation-nav {{- ' ' + params.classes if params.classes }}" aria-label="{{ params.label | default('Organisation switcher') }}" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
<div class="moj-organisation-nav__title">
{{- params.html | safe if params.html else params.text -}}
</div>
<a {% if params.link.id %}id="{{ params.link.id }}"{% endif -%} href="{{ params.link.href }}" class="moj-organisation-nav__link {{- ' ' + params.link.classes if params.link.classes}}" {%- for attribute, value in params.link.attributes -%} {{ attribute }}="{{ value }}"{% endfor %}>
{{- params.link.html | safe if params.link.html else params.link.text | default('Change organisation') -}}
</a>
</div>

{% if params.link %}
{%- set linkText = params.link.text | default('Change organisation') -%}
<a {%- if params.link.id %} id="{{ params.link.id }}"{% endif %} href="{{ params.link.href }}" class="moj-organisation-nav__link {{- ' ' + params.link.classes if params.link.classes }}" {%- for attribute, value in params.link.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
{{- linkText -}}
</a>
{% endif %}
</div>

0 comments on commit 72b77df

Please sign in to comment.