@ons/design-system 46.1.2 → 47.0.0

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.
Files changed (33) hide show
  1. package/components/document-list/_macro.njk +114 -0
  2. package/components/document-list/document-list.scss +182 -0
  3. package/components/download-resources/_download-resources.scss +2 -9
  4. package/components/download-resources/download-resources.js +2 -2
  5. package/components/input/_macro.njk +1 -2
  6. package/components/select/_macro.njk +1 -2
  7. package/components/textarea/_macro.njk +0 -1
  8. package/components/timeout-modal/timeout-modal.js +31 -6
  9. package/components/upload/_macro.njk +0 -1
  10. package/css/census.css +1 -1
  11. package/css/main.css +1 -1
  12. package/img/large/alison-pritchard-featured.jpg +0 -0
  13. package/img/large/alison-pritchard.jpg +0 -0
  14. package/img/large/census-monuments-lights-featured.jpg +0 -0
  15. package/img/large/census-monuments-lights.jpg +0 -0
  16. package/img/large/ons-award-winners.jpg +0 -0
  17. package/img/small/alison-pritchard-featured.jpg +0 -0
  18. package/img/small/alison-pritchard.jpg +0 -0
  19. package/img/small/census-monuments-lights-featured.jpg +0 -0
  20. package/img/small/census-monuments-lights.jpg +0 -0
  21. package/img/small/ons-award-winners.jpg +0 -0
  22. package/img/small/placeholder-portrait.png +0 -0
  23. package/js/timeout.js +5 -32
  24. package/layout/_template.njk +1 -1
  25. package/package.json +4 -4
  26. package/scripts/main.es5.js +2 -2
  27. package/scripts/main.js +1 -1
  28. package/scss/main.scss +1 -2
  29. package/scss/vars/_colors.scss +9 -3
  30. package/components/articles/_articles.scss +0 -86
  31. package/components/articles/_macro.njk +0 -81
  32. package/components/downloads/_downloads.scss +0 -39
  33. package/components/downloads/_macro.njk +0 -66
@@ -0,0 +1,114 @@
1
+ {% macro onsDocumentList(params) %}
2
+ <ul{% if params.id is defined and params.id %} id="{{ params.id }}"{% endif %} class="ons-document-list{{ ' ' + params.classes if params.classes is defined and params.classes else '' }}"{% if params.attributes is defined and params.attributes %}{% for attribute, value in (params.attributes.items() if params.attributes is mapping and params.attributes.items else params.attributes) %} {{attribute}}="{{value}}"{% endfor %}{% endif %}>
3
+ {% for document in (params.documents if params.documents is iterable else params.documents.items()) %}
4
+
5
+ <li class="ons-document-list__item{{ ' ons-document-list__item--featured' if document.featured is defined and document.featured }}{{ ' ons-document-list__item--full-width' if document.fullWidth is defined and document.fullWidth == true }}{{ ' ' + document.classes if document.classes is defined and document.classes else '' }}"{% if document.attributes is defined and document.attributes %}{% for attribute, value in (document.attributes.items() if document.attributes is mapping and document.attributes.items else document.attributes) %} {{attribute}}="{{value}}"{% endfor %}{% endif %}>
6
+
7
+ {% if document.fullWidth is defined and document.fullWidth == true %}
8
+
9
+ <div class="ons-container{{ ' ons-container--wide' if document.wide is defined and document.wide == true }}">
10
+
11
+ {% endif %}
12
+
13
+ {% if document.thumbnail is defined or document.thumbnail == true %}
14
+
15
+ <div class="ons-document-list__item-image{%- if document.metadata.file is defined and document.metadata.file %} ons-document-list__item-image--file{% endif %}" aria-hidden="true">
16
+ <a class="ons-document-list__image-link{{ ' ons-document-list__image-link--placeholder' if not document.thumbnail.smallSrc }}" href="{{ document.url }}" tabindex="-1">
17
+ {% if document.thumbnail.smallSrc is defined and document.thumbnail.smallSrc and document.thumbnail.largeSrc is defined and document.thumbnail.largeSrc %}
18
+ <img srcset="{{ document.thumbnail.smallSrc }} 1x, {{ document.thumbnail.largeSrc }} 2x" src="{{ document.thumbnail.smallSrc }}" alt="" loading="lazy">
19
+ {% endif %}
20
+ </a>
21
+ </div>
22
+
23
+ {% endif %}
24
+
25
+ <div class="ons-document-list__item-content">
26
+
27
+ <div class="ons-document-list__item-header{{ ' ons-document-list__item-header--reverse' if document.showMetadataFirst is defined and document.showMetadataFirst == true }}">
28
+
29
+ {% set titleTag = params.titleTag | default("h2") %}
30
+
31
+ <{{ titleTag }} class="ons-document-list__item-title ons-u-fs-m ons-u-mt-no ons-u-mb-xs">
32
+ <a href="{{ document.url }}">{{ document.title }}
33
+ {%- if document.metadata is defined and document.metadata and document.metadata.file is defined and document.metadata.file %}
34
+ <span class="ons-u-vh">,
35
+
36
+ {% set fileMetadataItems = [] %}
37
+
38
+ {% if document.metadata.file.fileType is defined and document.metadata.file.fileType %}{% set fileMetadataItems = (fileMetadataItems.push(document.metadata.file.fileType + ' document download'), fileMetadataItems) %}{% endif %}
39
+ {% if document.metadata.file.fileSize is defined and document.metadata.file.fileSize %}{% set fileMetadataItems = (fileMetadataItems.push(document.metadata.file.fileSize), fileMetadataItems) %}{% endif %}
40
+ {% if document.metadata.file.filePages is defined and document.metadata.file.filePages %}{% set fileMetadataItems = (fileMetadataItems.push(document.metadata.file.filePages), fileMetadataItems) %}{% endif %}
41
+
42
+ {{ fileMetadataItems | join(', ') }}
43
+
44
+ {% endif -%}
45
+
46
+ </span></a>
47
+ </{{ titleTag }}>
48
+
49
+ {%- if document.metadata is defined and document.metadata %}
50
+
51
+ <ul class="ons-document-list__item-metadata{% if document.description is defined and document.description %} ons-u-mb-xs{% else %} ons-u-mb-no{% endif %}">
52
+
53
+ {%- if document.metadata.date is defined and document.metadata.date %}
54
+ <li class="ons-document-list__item-attribute">
55
+ {% if document.metadata.date -%}
56
+ {% set prefixClasses = "ons-u-fw-b" if document.metadata.date.showPrefix is defined and document.metadata.date.showPrefix == true else "ons-u-vh" %}
57
+ <span class="{{ prefixClasses }}">{{ document.metadata.date.prefix | default("Published") }}: </span>
58
+ {%- endif -%}
59
+ {% if document.metadata.date.iso is defined and document.metadata.date.iso -%}
60
+ <time datetime="{{ document.metadata.date.iso }}">{{ document.metadata.date.short }}</time>
61
+ {%- endif %}
62
+ </li>
63
+ {% endif %}
64
+
65
+ {%- if document.metadata.type is defined and document.metadata.type and document.metadata.type.text is defined and document.metadata.type.text %}
66
+ <li class="ons-document-list__item-attribute{%- if document.metadata.file is defined and document.metadata.file %} ons-u-mr-no{% endif %}">
67
+ {%- if document.metadata.type.url is defined and document.metadata.type.url %}
68
+ <a class="ons-document-list__attribute-link" href="{{ document.metadata.type.url }}">
69
+ {% endif %}
70
+ <span {% if not document.metadata.file and not document.metadata.type.url %}class="ons-u-fw-b"{% endif %}>{{ document.metadata.type.text }}{%- if document.metadata.type.ref is defined and document.metadata.type.ref %}: {% elif document.metadata.file is defined and document.metadata.file %},{% endif %}</span>
71
+ {%- if document.metadata.type.url is defined and document.metadata.type.url %}
72
+ </a>
73
+ {% endif %}
74
+ {%- if document.metadata.type.ref is defined and document.metadata.type.ref %}
75
+ <span>{{ document.metadata.type.ref }}</span>
76
+ {% endif %}
77
+ </li>
78
+ {% endif %}
79
+
80
+ {%- if document.metadata.file is defined and document.metadata.file and document.metadata.file.fileType is defined and document.metadata.file.fileType %}
81
+
82
+ <li class="ons-document-list__item-attribute" aria-hidden="true">
83
+ {% set fileMetadataItems = [] %}
84
+
85
+ {% if document.metadata.file.fileType is defined and document.metadata.file.fileType %}{% set fileMetadataItems = (fileMetadataItems.push(document.metadata.file.fileType), fileMetadataItems) %}{% endif %}
86
+ {% if document.metadata.file.fileSize is defined and document.metadata.file.fileSize %}{% set fileMetadataItems = (fileMetadataItems.push(document.metadata.file.fileSize), fileMetadataItems) %}{% endif %}
87
+ {% if document.metadata.file.filePages is defined and document.metadata.file.filePages %}{% set fileMetadataItems = (fileMetadataItems.push(document.metadata.file.filePages), fileMetadataItems) %}{% endif %}
88
+
89
+ {{ fileMetadataItems | join(', ') }}
90
+ </li>
91
+
92
+ {% endif -%}
93
+ </ul>
94
+
95
+ {% endif %}
96
+ </div>
97
+
98
+ {% if document.description is defined and document.description %}
99
+ <div class="ons-document-list__item-description">{{ document.description | safe }}</div>
100
+ {% endif %}
101
+
102
+ </div>
103
+
104
+ {% if document.fullWidth is defined and document.fullWidth == true %}
105
+
106
+ </div>
107
+
108
+ {% endif %}
109
+
110
+ </li>
111
+ {% endfor %}
112
+ </ul>
113
+
114
+ {% endmacro %}
@@ -0,0 +1,182 @@
1
+ .ons-document-list {
2
+ @extend .ons-list--bare;
3
+
4
+ margin-bottom: 0;
5
+
6
+ &__item {
7
+ border-bottom: 1px solid $color-borders-list;
8
+ margin: 0 0 1.5rem;
9
+ padding: 0 0 1.5rem;
10
+
11
+ @include mq(xs) {
12
+ align-items: flex-start;
13
+ display: flex;
14
+ }
15
+
16
+ &:last-of-type {
17
+ border-bottom: 0;
18
+ margin: 0;
19
+ }
20
+ }
21
+
22
+ &__item-image {
23
+ flex: 0 0 auto;
24
+ margin-bottom: 1rem;
25
+ width: 136px;
26
+
27
+ @include mq(xs) {
28
+ margin-right: 1.5rem;
29
+ }
30
+
31
+ @include mq(m) {
32
+ margin-bottom: 0;
33
+ }
34
+ }
35
+
36
+ &__item-image & {
37
+ &__image-link {
38
+ &--placeholder {
39
+ height: 96px;
40
+ }
41
+ }
42
+ }
43
+
44
+ &__item-image--file {
45
+ width: 96px;
46
+ }
47
+
48
+ &__item-image--file & {
49
+ &__image-link {
50
+ border-color: $color-borders-document-image;
51
+
52
+ &--placeholder {
53
+ height: 136px;
54
+ }
55
+ }
56
+ }
57
+
58
+ &__image-link {
59
+ border: 2px solid transparent;
60
+ box-sizing: content-box;
61
+ display: block;
62
+ width: 100%;
63
+
64
+ &:focus {
65
+ background-color: $color-placeholder !important;
66
+ border: 2px solid $color-borders-document-image-focus;
67
+ box-shadow: none;
68
+ outline: 4px solid $color-focus !important;
69
+ outline-offset: 0;
70
+ }
71
+
72
+ &--placeholder {
73
+ background-clip: padding-box;
74
+ background-color: $color-borders-document-image;
75
+ background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3e%3cpath fill='%23fff' d='M0 19.39c.49-1 1-2 1.55-2.93A31.59 31.59 0 0 1 0 11.72v7.67ZM3 0S0 0 0 3.7v2a34.85 34.85 0 0 0 2.17 9.76A31.2 31.2 0 0 1 8.3 8.3c4.84-4.16 11.36-7 20.21-8.29Zm28.84 2c-10.11 1-17 3.86-22 8.1a29.78 29.78 0 0 0-6.49 8C7.26 25.65 14.66 31.19 27 32h1.21A3.71 3.71 0 0 0 32 27.91V2a.41.41 0 0 1-.16 0Zm-26 21.49a25.94 25.94 0 0 1-3-4.4A48 48 0 0 0 0 25.71V32h20.23a26.41 26.41 0 0 1-14.39-8.49Z'/%3e%3c/svg%3e");
76
+ background-position: center;
77
+ background-repeat: no-repeat;
78
+ background-size: 32px 32px;
79
+ height: 100%;
80
+ }
81
+ }
82
+
83
+ &__item-metadata {
84
+ @extend .ons-list--bare;
85
+
86
+ line-height: 1.2 !important;
87
+ }
88
+
89
+ &__item-attribute {
90
+ color: $color-text-metadata;
91
+ display: inline-block;
92
+ margin: 0 1rem 0 0;
93
+
94
+ @extend .ons-u-fs-s;
95
+ }
96
+
97
+ &__attribute-link {
98
+ color: inherit;
99
+
100
+ &:hover {
101
+ color: $color-text-metadata;
102
+ text-decoration: underline solid $color-text-metadata 2px;
103
+ }
104
+ }
105
+
106
+ &__item-description {
107
+ margin-bottom: 0;
108
+ max-width: 660px; // Equivalent to 8 Columns
109
+
110
+ p:last-of-type {
111
+ margin-bottom: 0;
112
+ }
113
+ }
114
+ }
115
+
116
+ // Featured document
117
+ .ons-document-list {
118
+ &__item {
119
+ &--featured {
120
+ background-color: $color-banner-bg;
121
+ border-bottom: none;
122
+ display: block;
123
+ padding: 2rem;
124
+
125
+ @include mq(m) {
126
+ align-items: flex-start;
127
+ display: flex;
128
+
129
+ .ons-container {
130
+ display: flex;
131
+ }
132
+ }
133
+
134
+ // Increase thumbnail image size
135
+ .ons-document-list__item-image {
136
+ width: 248px;
137
+
138
+ & &__image-link {
139
+ &--placeholder {
140
+ height: 96px;
141
+ }
142
+ }
143
+
144
+ @include mq(m) {
145
+ margin-right: 2.5rem;
146
+ width: 379px;
147
+
148
+ & &__image-link {
149
+ &--placeholder {
150
+ height: 248px;
151
+ }
152
+ }
153
+ }
154
+ }
155
+
156
+ // Show metadata above title
157
+ .ons-document-list__item-header {
158
+ &--reverse {
159
+ display: flex;
160
+ flex-direction: column-reverse;
161
+ margin-bottom: 0.5rem;
162
+ }
163
+ }
164
+
165
+ // Increase font size
166
+ .ons-document-list__item-title {
167
+ @extend .ons-u-fs-l;
168
+ }
169
+
170
+ // If featured item is first in same list
171
+ & + .ons-document-list__item {
172
+ border-top: none;
173
+ margin-top: 0;
174
+ }
175
+ }
176
+
177
+ // If featured item is full width
178
+ &--full-width {
179
+ padding: 2rem 0;
180
+ }
181
+ }
182
+ }
@@ -1,8 +1,9 @@
1
1
  .ons-adv-filter {
2
2
  &__gallery {
3
- border-top: 1px solid $color-grey-15;
3
+ border-top: 1px solid $color-borders-list;
4
4
  margin-left: 0;
5
5
  padding-left: 0;
6
+ padding-top: 1.5rem;
6
7
  }
7
8
 
8
9
  &__item {
@@ -137,14 +138,6 @@ body:not(.ons-js-enabled) {
137
138
  }
138
139
  }
139
140
 
140
- .ons-filter__item {
141
- border-bottom: 1px solid $color-grey-15;
142
- display: block; // Accessible way of removing bullets (don’t use list-style-type: none; https://github.com/jensimmons/cssremedy/issues/15#issuecomment-462174177)
143
- margin-bottom: 0; // Reset default margin bottom on list items
144
- padding-bottom: 1.5rem;
145
- padding-top: 1.5rem;
146
- }
147
-
148
141
  // Prevent scrollbars on body
149
142
  .ons-no-scroll {
150
143
  overflow-y: hidden;
@@ -920,8 +920,8 @@ Math.easeInOutQuad = function(t, b, c, d) {
920
920
  }
921
921
 
922
922
  function getInputListLabel(section, inputs) {
923
- let counter = 0;
924
- label = '';
923
+ let counter = 0,
924
+ label = '';
925
925
  for (let i = 0; i < inputs.length; i++) {
926
926
  if (inputs[i].checked) {
927
927
  let labelElement = inputs[i].parentNode.getElementsByTagName('label');
@@ -153,9 +153,8 @@
153
153
  "id": params.fieldId,
154
154
  "classes": params.fieldClasses,
155
155
  "dontWrap": params.dontWrap,
156
- "legendIsQuestionTitle": params.legendIsQuestionTitle,
157
156
  "error": params.error,
158
- "inline": params.label.inline
157
+ "inline": params.label.inline if params.label is defined and params.label else ''
159
158
  }) %}
160
159
  {% if charCheckField is defined and charCheckField %}
161
160
  {{ charCheckField | safe }}
@@ -7,9 +7,8 @@
7
7
  "classes": params.fieldClases,
8
8
  "legendClasses": params.legendClasses,
9
9
  "dontWrap": params.dontWrap,
10
- "legendIsQuestionTitle": params.legendIsQuestionTitle,
11
10
  "error": params.error,
12
- "inline": params.label.inline
11
+ "inline": params.label.inline if params.label is defined and params.label else ''
13
12
  }) %}
14
13
  {{
15
14
  onsLabel({
@@ -68,7 +68,6 @@
68
68
  "id": params.fieldId,
69
69
  "classes": params.fieldClasses,
70
70
  "dontWrap": params.dontWrap,
71
- "legendIsQuestionTitle": params.legendIsQuestionTitle,
72
71
  "error": params.error
73
72
  }) %}
74
73
  {{ field | safe }}
@@ -8,6 +8,9 @@ export default class TimeoutModal {
8
8
  this.initialExpiryTime = initialExpiryTime;
9
9
  this.continueButton = context.querySelector('.ons-js-modal-btn');
10
10
  this.modalVisibleInMilliseconds = context.getAttribute('data-show-modal-time') * 1000;
11
+ this.expiryTime = '';
12
+ this.expiryTimeInMilliseconds = 0;
13
+ this.shouldRestartCheck = false;
11
14
 
12
15
  // Create modal instance
13
16
  this.modal = new Modal(this.context);
@@ -27,30 +30,52 @@ export default class TimeoutModal {
27
30
  startTimeout() {
28
31
  clearTimeout(this.showModalTimeout);
29
32
  if (this.initialExpiryTime) {
30
- this.totalMilliseconds = this.timeout.expiryTimeInMilliseconds;
33
+ this.expiryTime = this.timeout.expiryTime;
34
+ this.expiryTimeInMilliseconds = this.timeout.convertTimeToMilliSeconds(this.expiryTime);
31
35
  } else {
32
36
  // For demo purposes
33
- this.totalMilliseconds = 60000;
37
+ this.expiryTimeInMilliseconds = 60000;
34
38
  }
35
39
  this.showModalTimeout = setTimeout(
36
40
  this.openModalAndStartCountdown.bind(this),
37
- this.totalMilliseconds - this.modalVisibleInMilliseconds,
41
+ this.expiryTimeInMilliseconds - this.modalVisibleInMilliseconds,
38
42
  );
39
43
  }
40
44
 
41
45
  async openModalAndStartCountdown() {
42
- const modalWillOpen = await this.timeout.hasExpiryTimeResetInAnotherTab();
46
+ const modalWillOpen = await this.hasExpiryTimeResetInAnotherTab();
43
47
  if (modalWillOpen && !this.modal.isDialogOpen()) {
44
48
  this.modal.openDialog();
45
49
  this.timeout.startUiCountdown();
50
+
51
+ this.shouldRestartCheck = setInterval(async () => {
52
+ await this.hasExpiryTimeResetInAnotherTab();
53
+ }, 20000);
46
54
  }
47
55
  }
48
56
 
49
- closeModalAndRestartTimeout() {
57
+ async hasExpiryTimeResetInAnotherTab() {
58
+ const checkExpiryTime = await this.timeout.getExpiryTime();
59
+ if (checkExpiryTime.substring(0, 19) != this.timeout.expiryTime.substring(0, 19)) {
60
+ // Substring is required as endpoint can at random return milliseconds with expiry time
61
+ this.expiryTime = checkExpiryTime;
62
+ this.expiryTimeInMilliseconds = this.timeout.convertTimeToMilliSeconds(checkExpiryTime);
63
+ this.closeModalAndRestartTimeout(this.expiryTimeInMilliseconds);
64
+ } else {
65
+ return true;
66
+ }
67
+ }
68
+
69
+ async closeModalAndRestartTimeout(time) {
70
+ clearInterval(this.shouldRestartCheck);
71
+
72
+ if (typeof timeInMilliSeconds !== 'string') {
73
+ time = false;
74
+ }
50
75
  if (this.modal.isDialogOpen()) {
51
76
  this.modal.closeDialog();
52
77
  }
53
- this.timeout.restartTimeout();
78
+ await this.timeout.restartTimeout(time);
54
79
  this.startTimeout();
55
80
  }
56
81
 
@@ -19,7 +19,6 @@
19
19
  "id": params.fieldId,
20
20
  "classes": params.fieldClasses,
21
21
  "dontWrap": params.dontWrap,
22
- "legendIsQuestionTitle": params.legendIsQuestionTitle,
23
22
  "error": params.error
24
23
  }) %}
25
24
  {{ field | safe }}