@gov-cy/govcy-frontend-renderer 1.13.0 → 1.14.1

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/README.md CHANGED
@@ -359,6 +359,7 @@ let inputString =
359
359
 
360
360
  If your using the `pageData.layout`, you can render html in each of the following [gov.cy page template](https://gov-cy.github.io/govcy-design-system-docs/getting-started/page-template/) blocks:
361
361
  - **bodyStart**: the start of the body
362
+ - **userName**: the section where the username and logout links are rendered
362
363
  - **header**: the header section (where the gov.cy logo and service name are rendered)
363
364
  - **beforeMain**: the section before the main content
364
365
  - **main**: the main content
@@ -414,6 +415,7 @@ let inputJson =
414
415
 
415
416
  If your using the `pageData.layout`, you can render html in each of the following [gov.cy page template](https://gov-cy.github.io/govcy-design-system-docs/getting-started/page-template/) blocks, by using the `sections` array (in a similar way `blocks` is use ) :
416
417
  - **bodyStart**: the start of the body
418
+ - **userName**: the section where the username and logout links are rendered
417
419
  - **header**: the header section (where the gov.cy logo and service name are rendered)
418
420
  - **beforeMain**: the section before the main content
419
421
  - **main**: the main content
@@ -7115,6 +7115,110 @@ root: root
7115
7115
  })();
7116
7116
  })();
7117
7117
 
7118
+ (function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["elements/userName.njk"] = (function() {
7119
+ function root(env, context, frame, runtime, cb) {
7120
+ var lineno = 0;
7121
+ var colno = 0;
7122
+ var output = "";
7123
+ try {
7124
+ var parentTemplate = null;
7125
+ output += "\r\n";
7126
+ var macro_t_1 = runtime.makeMacro(
7127
+ ["params"],
7128
+ [],
7129
+ function (l_params, kwargs) {
7130
+ var callerFrame = frame;
7131
+ frame = new runtime.Frame();
7132
+ kwargs = kwargs || {};
7133
+ if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {
7134
+ frame.set("caller", kwargs.caller); }
7135
+ frame.set("params", l_params);
7136
+ var t_2 = "";env.getTemplate("utilities/govcyUtilities.njk", false, "elements/userName.njk", false, function(t_4,t_3) {
7137
+ if(t_4) { cb(t_4); return; }
7138
+ t_3.getExported(function(t_5,t_3) {
7139
+ if(t_5) { cb(t_5); return; }
7140
+ if(Object.prototype.hasOwnProperty.call(t_3, "govcyLocalizeContent")) {
7141
+ var t_6 = t_3.govcyLocalizeContent;
7142
+ } else {
7143
+ cb(new Error("cannot import 'govcyLocalizeContent'")); return;
7144
+ }
7145
+ context.setVariable("govcyLocalizeContent", t_6);
7146
+ if(Object.prototype.hasOwnProperty.call(t_3, "govcyLangAttribute")) {
7147
+ var t_7 = t_3.govcyLangAttribute;
7148
+ } else {
7149
+ cb(new Error("cannot import 'govcyLangAttribute'")); return;
7150
+ }
7151
+ context.setVariable("govcyLangAttribute", t_7);
7152
+ var t_8;
7153
+ t_8 = (lineno = 12, colno = 38, runtime.callWrap(t_6, "govcyLocalizeContent", context, [{"en": "Sign out","el": "Αποσύνδεση"},runtime.memberLookup((l_params),"lang")]));
7154
+ frame.set("signOut", t_8, true);
7155
+ if(frame.topLevel) {
7156
+ context.setVariable("signOut", t_8);
7157
+ }
7158
+ if(frame.topLevel) {
7159
+ context.addExport("signOut", t_8);
7160
+ }
7161
+ var t_9;
7162
+ t_9 = (lineno = 13, colno = 49, runtime.callWrap(t_6, "govcyLocalizeContent", context, [{"en": "from user","el": "από το χρήστη"},runtime.memberLookup((l_params),"lang")]));
7163
+ frame.set("userVisuallyHidden", t_9, true);
7164
+ if(frame.topLevel) {
7165
+ context.setVariable("userVisuallyHidden", t_9);
7166
+ }
7167
+ if(frame.topLevel) {
7168
+ context.addExport("userVisuallyHidden", t_9);
7169
+ }
7170
+ if(runtime.memberLookup((l_params),"name") && runtime.memberLookup((l_params),"signOutLink")) {
7171
+ t_2 += "\r\n <div ";
7172
+ if(runtime.memberLookup((l_params),"id")) {
7173
+ t_2 += "id=\"";
7174
+ t_2 += runtime.suppressValue(runtime.memberLookup((l_params),"id"), env.opts.autoescape);
7175
+ t_2 += "\" ";
7176
+ ;
7177
+ }
7178
+ t_2 += "class=\"govcy-header-top-area";
7179
+ if(runtime.memberLookup((l_params),"classes")) {
7180
+ t_2 += " ";
7181
+ t_2 += runtime.suppressValue(runtime.memberLookup((l_params),"classes"), env.opts.autoescape);
7182
+ ;
7183
+ }
7184
+ t_2 += "\"";
7185
+ t_2 += runtime.suppressValue((lineno = 15, colno = 164, runtime.callWrap(t_7, "govcyLangAttribute", context, [runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
7186
+ t_2 += ">\r\n <div class=\"govcy-container\">\r\n <div class=\"govcy-header-top-area-wrapper\">\r\n <ul class=\"govcy-sign-in\">\r\n <li>";
7187
+ t_2 += runtime.suppressValue((lineno = 19, colno = 47, runtime.callWrap(t_6, "govcyLocalizeContent", context, [runtime.memberLookup((l_params),"name"),runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
7188
+ t_2 += "</li>\r\n <li><span>|</span></li>\r\n <li><a href=\"";
7189
+ t_2 += runtime.suppressValue(runtime.memberLookup((l_params),"signOutLink"), env.opts.autoescape);
7190
+ t_2 += "\">";
7191
+ t_2 += runtime.suppressValue(runtime.contextOrFrameLookup(context, frame, "signOut"), env.opts.autoescape);
7192
+ t_2 += "<span class=\"govcy-visually-hidden-error\"> ";
7193
+ t_2 += runtime.suppressValue(runtime.contextOrFrameLookup(context, frame, "userVisuallyHidden"), env.opts.autoescape);
7194
+ t_2 += " ";
7195
+ t_2 += runtime.suppressValue((lineno = 21, colno = 163, runtime.callWrap(t_6, "govcyLocalizeContent", context, [runtime.memberLookup((l_params),"name"),runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
7196
+ t_2 += "</span></a></li>\r\n </ul>\r\n </div>\r\n </div>\r\n </div>";
7197
+ ;
7198
+ }
7199
+ })});
7200
+ frame = callerFrame;
7201
+ return new runtime.SafeString(t_2);
7202
+ });
7203
+ context.addExport("userName");
7204
+ context.setVariable("userName", macro_t_1);
7205
+ if(parentTemplate) {
7206
+ parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);
7207
+ } else {
7208
+ cb(null, output);
7209
+ }
7210
+ ;
7211
+ } catch (e) {
7212
+ cb(runtime.handleError(e, lineno, colno));
7213
+ }
7214
+ }
7215
+ return {
7216
+ root: root
7217
+ };
7218
+
7219
+ })();
7220
+ })();
7221
+
7118
7222
  (function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["govcyElement.njk"] = (function() {
7119
7223
  function root(env, context, frame, runtime, cb) {
7120
7224
  var lineno = 0;
@@ -7123,7 +7227,7 @@ var output = "";
7123
7227
  try {
7124
7228
  var parentTemplate = null;
7125
7229
  var t_1;
7126
- t_1 = ["label","legend","hint","button","errorMessage","select","textElement","htmlElement","textInput","radios","checkboxes","fileInput","fileView","backLink","tag","table","summaryList","textArea","markdown","panel","datePicker","dateInput","taskList","errorSummary","details","stepByStepStatic","progressList"];
7230
+ t_1 = ["label","legend","hint","button","errorMessage","select","textElement","htmlElement","textInput","radios","checkboxes","fileInput","fileView","backLink","tag","table","summaryList","textArea","markdown","panel","datePicker","dateInput","taskList","errorSummary","details","stepByStepStatic","progressList","userName"];
7127
7231
  frame.set("macroSimpleBlocks", t_1, true);
7128
7232
  if(frame.topLevel) {
7129
7233
  context.setVariable("macroSimpleBlocks", t_1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gov-cy/govcy-frontend-renderer",
3
- "version": "1.13.0",
3
+ "version": "1.14.1",
4
4
  "description": "Render html for design elements of the Unified design system using njk or json template.",
5
5
  "author": "DMRID - DSF Team",
6
6
  "license": "MIT",
@@ -0,0 +1,28 @@
1
+ {# error userName
2
+ @param {object} name The name text. Will escape text. Example `{en:"George Smith",el:"Γιώργος Σμιθ"}`
3
+ @param {string} signOutLink The sign out url. Will escape text.
4
+ @param {string} id The id attribute. Will escape text. Optional
5
+ @param {string} lang The language used. Can be 'en','el'. Optional, default is 'el'.
6
+ @param {string} classes Additional classes to add to the outer div. Optional
7
+ @returns govcy user name html
8
+ #}
9
+ {% macro userName(params) -%}
10
+ {#- Import localizer from utilities -#}
11
+ {%- from "../utilities/govcyUtilities.njk" import govcyLocalizeContent, govcyLangAttribute -%}
12
+ {#- set localizations -#}
13
+ {%- set signOut = govcyLocalizeContent({en:'Sign out',el:'Αποσύνδεση'} , params.lang) -%}
14
+ {%- set userVisuallyHidden = govcyLocalizeContent({en:'from user',el:'από το χρήστη'} , params.lang) -%}
15
+ {%- if params.name and params.signOutLink %}
16
+ <div {% if params.id %}id="{{ params.id }}" {% endif %}class="govcy-header-top-area{% if params.classes %} {{ params.classes }}{% endif %}"{{ govcyLangAttribute(params.lang) }}>
17
+ <div class="govcy-container">
18
+ <div class="govcy-header-top-area-wrapper">
19
+ <ul class="govcy-sign-in">
20
+ <li>{{ govcyLocalizeContent(params.name , params.lang) }}</li>
21
+ <li><span>|</span></li>
22
+ <li><a href="{{ params.signOutLink }}">{{ signOut }}<span class="govcy-visually-hidden-error"> {{ userVisuallyHidden }} {{ govcyLocalizeContent(params.name , params.lang) }}</span></a></li>
23
+ </ul>
24
+ </div>
25
+ </div>
26
+ </div>
27
+ {%- endif %}
28
+ {%- endmacro %}
@@ -26,7 +26,7 @@ To use:
26
26
  'errorMessage','select','textElement','htmlElement','textInput','radios','checkboxes',
27
27
  'fileInput','fileView','backLink','tag','table', 'summaryList', 'textArea','markdown',
28
28
  'panel', 'datePicker','dateInput', 'taskList', 'errorSummary', 'details', 'stepByStepStatic',
29
- 'progressList'] -%}
29
+ 'progressList', 'userName'] -%}
30
30
  {%- set macroCallerBlocks = ['formControl','form','fieldset'] -%}
31
31
  {%- macro govcyElement(component, params) -%}
32
32
  {#- Simple blocks -#}
@@ -87,6 +87,7 @@ To use this template you need to pass the following data:
87
87
 
88
88
  <!--Header-->
89
89
  <header class="govcy-header govcy-d-print-none" id="headerContainer">
90
+ {% block userName %}{% endblock %}
90
91
  {% block header %}
91
92
  <div class="govcy-header-main-area">
92
93
  <div class="govcy-container govcy-main-area-items">