-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update organisation switcher link logic
Only display the organisation switcher link if a link object is passed to the component. This prevents an empty link tag being output to the source if there is no link destination. This change still supports the fallback text as long as a link `href` is supplied. It also updates the example to show how the component will look without a change link and with the fallback link text.
- Loading branch information
1 parent
334d7d2
commit 993b2f4
Showing
2 changed files
with
18 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |