@companieshouse/ch-node-utils 1.3.1 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@companieshouse/ch-node-utils",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "author": "companieshouse",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -14,11 +14,15 @@ It receives:
14
14
  <ul class="govuk-language-select__list">
15
15
  {% if languageEnabled %}
16
16
  {% for l in languages %}
17
- <li class="govuk-language-select__list-item">
18
- <a href="{{lang2url.addLangToUrl(currentUrl, l.IsoCode, true)}}" lang={{l.IsoCode}} rel="alternate" class="govuk-link" >
19
- <span>{{l.Name}}</span>
20
- </a>
21
- </li>
17
+ <li class="govuk-language-select__list-item">
18
+ {% if lang and lang == l.IsoCode %}
19
+ <span class="govuk-body-s govuk-!-margin-2">{{l.Name}}</span>
20
+ {% else %}
21
+ <a href="{{lang2url.addLangToUrl(currentUrl, l.IsoCode, true)}}" lang={{l.IsoCode}} rel="alternate" class="govuk-link govuk-!-margin-2" >
22
+ <span>{{l.Name}}</span>
23
+ </a>
24
+ {% endif %}
25
+ </li>
22
26
  {% endfor %}
23
27
  {% endif %}
24
28
  </ul>
@@ -0,0 +1,74 @@
1
+ {#
2
+ GENERAL NOTES:
3
+ The navbar requires importing language files from the locales folder in ch-node-utils
4
+ and making them available to all Nunjuck templates using the addGlobal() function in app.ts.
5
+ It also requires a flag displayAuthorisedAgent set the same way for displaying the 'Authorised agent'
6
+ menu item. If the logged user has ACSP membership, this flag should be set to 'yes'.
7
+
8
+ It also requires the use of styles provided in the following stylesheet
9
+ (you can either add the provided link to the head section or include specific
10
+ styles in your own stylesheet)
11
+
12
+ <link href="{{ cdnHost }}/stylesheets/ch.gov.uk.css" rel="stylesheet"/>
13
+
14
+ It also requires the following script to be added to the footer
15
+
16
+ <script src="{{ cdnHost }}/javascripts/lib/navbar.js"></script>
17
+ #}
18
+
19
+ {#
20
+ A macro that adds a menu navigation bar with the provided items.
21
+ It receives:
22
+ - signInHref: the URL of the sign in / register page
23
+ - menuItems: a collection of objects representing individual menu items.
24
+ Each object must contain properties with the following keys to build an anchor:
25
+ - id: it's the anchor element id
26
+ - href: the URL of the page the menu item will point to
27
+ - displayText: the text to display in the anchor
28
+ - userDisplayText: a text identifying the logged user, e.g. email address or name
29
+ #}
30
+ {% macro addNavbar(signInHref, menuItems, userDisplayText) %}
31
+ <div class="js-toggle-nav" id="global-nav">
32
+ <nav role="navigation" class="content" aria-label="{{ lang.mainNavbar or 'The main navigation bar' }}">
33
+ {% if userDisplayText %}
34
+ <a href="#navigation" class="js-header-toggle menu">{{ userDisplayText }}
35
+ <span class="govuk-visually-hidden">{{ lang.clickToExpandOrCollapse or 'Click to expand or collapse' }}</span>
36
+ </a>
37
+ {% else %}
38
+ <a id="user-signin-mobile" href="{{ signInHref }}" class="sign-in govuk-link">{{ lang.signInOrRegister or 'Sign in / Register' }}</a>
39
+ {% endif %}
40
+
41
+ <ul id="navigation">
42
+ <li id="signed-in-user" class="user">
43
+ {{ userDisplayText }}
44
+ </li>
45
+ {% for item in menuItems %}
46
+ <li>
47
+ <a class="govuk-link" id="{{ item.id }}" href="{{ item.href }}">{{ item.displayText }}</a>
48
+ </li>
49
+ {% endfor %}
50
+ </ul>
51
+ </nav>
52
+ </div>
53
+ {% endmacro %}
54
+
55
+ {#
56
+ A macro that adds a menu navigation bar with predefined items.
57
+ It receives:
58
+ - userDisplayText: a text identifying the logged user, e.g. email address or name
59
+ - chsMonitorGuiUrl: the URL for the 'Companies you follow' link
60
+ #}
61
+ {% macro addPredefinedNavbar(userDisplayText, chsMonitorGuiUrl) %}
62
+ {% set menuItems = [
63
+ { id: "authorised-agent", href: "/authorised-agent", displayText: lang.authorisedAgent or "Authorised agent" } if displayAuthorisedAgent === "yes",
64
+ { id: "your-companies", href: "/your-companies", displayText: lang.yourCompanies or "Your companies" },
65
+ { id: "your-filings", href: "/user/transactions", displayText: lang.yourFilings or "Your filings" },
66
+ { id: "companies-you-follow", href: chsMonitorGuiUrl, displayText: lang.companiesYouFollow or "Companies you follow" },
67
+ { id: "basket", href: "/basket", displayText: lang.basket or "Basket" },
68
+ { id: "your-details", href: "/user/account", displayText: lang.manageAccount or "Manage account" },
69
+ { id: "user-signout", href: "/signout", displayText: lang.signOut or "Sign out" }
70
+ ] | reject("falsy") %}
71
+
72
+ {{ addNavbar("/signin", menuItems, userDisplayText) }}
73
+
74
+ {% endmacro %}