@ons/design-system 43.0.0 → 44.1.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.
Files changed (71) hide show
  1. package/components/checkboxes/_checkbox.scss +1 -1
  2. package/components/checkboxes/_macro.njk +3 -3
  3. package/components/collapsible/_collapsible.scss +1 -1
  4. package/components/field/_field-group.scss +0 -1
  5. package/components/fieldset/_macro.njk +1 -1
  6. package/components/header/_header.scss +3 -3
  7. package/components/header/_macro.njk +2 -2
  8. package/components/input/_input.scss +6 -2
  9. package/components/input/_macro.njk +1 -1
  10. package/components/message/_message.scss +3 -1
  11. package/components/modal/_macro.njk +23 -0
  12. package/components/modal/_modal.scss +32 -0
  13. package/components/modal/modal.dom.js +14 -0
  14. package/components/modal/modal.js +104 -0
  15. package/components/question/_macro.njk +2 -2
  16. package/components/radios/_macro.njk +6 -2
  17. package/components/summary/_summary.scss +4 -2
  18. package/components/table/_table.scss +1 -1
  19. package/components/timeout-modal/_macro.njk +26 -0
  20. package/components/timeout-modal/timeout.dom.js +16 -0
  21. package/components/timeout-modal/timeout.js +289 -0
  22. package/css/census.css +1 -1
  23. package/css/error.css +1 -1
  24. package/css/main.css +1 -1
  25. package/favicons/census/cy/android-chrome-192x192.png +0 -0
  26. package/favicons/census/cy/android-chrome-512x512.png +0 -0
  27. package/favicons/census/cy/apple-touch-icon.png +0 -0
  28. package/favicons/census/cy/browserconfig.xml +12 -0
  29. package/favicons/census/cy/favicon-16x16.png +0 -0
  30. package/favicons/census/cy/favicon-32x32.png +0 -0
  31. package/favicons/census/cy/favicon.ico +0 -0
  32. package/favicons/census/cy/manifest.json +20 -0
  33. package/favicons/census/cy/mstitle-150x150.png +0 -0
  34. package/favicons/census/cy/mstitle-310x150.png +0 -0
  35. package/favicons/census/cy/mstitle-310x310.png +0 -0
  36. package/favicons/census/cy/mstitle-70x70.png +0 -0
  37. package/favicons/census/cy/opengraph.png +0 -0
  38. package/favicons/census/cy/safari-pinned-tab.svg +3 -0
  39. package/favicons/census/cy/site.webmanifest +19 -0
  40. package/favicons/census/cy/twitter.png +0 -0
  41. package/favicons/census/en/android-chrome-192x192.png +0 -0
  42. package/favicons/census/en/android-chrome-512x512.png +0 -0
  43. package/favicons/census/en/apple-touch-icon.png +0 -0
  44. package/favicons/census/en/browserconfig.xml +12 -0
  45. package/favicons/census/en/favicon-16x16.png +0 -0
  46. package/favicons/census/en/favicon-32x32.png +0 -0
  47. package/favicons/census/en/favicon.ico +0 -0
  48. package/favicons/census/en/manifest.json +20 -0
  49. package/favicons/census/en/mstitle-150x150.png +0 -0
  50. package/favicons/census/en/mstitle-310x150.png +0 -0
  51. package/favicons/census/en/mstitle-310x310.png +0 -0
  52. package/favicons/census/en/mstitle-70x70.png +0 -0
  53. package/favicons/census/en/opengraph.png +0 -0
  54. package/favicons/census/en/safari-pinned-tab.svg +3 -0
  55. package/favicons/census/en/site.webmanifest +19 -0
  56. package/favicons/census/en/twitter.png +0 -0
  57. package/favicons/census/ni/favicon.ico +0 -0
  58. package/package.json +8 -11
  59. package/scripts/main.es5.js +2 -2
  60. package/scripts/main.js +1 -1
  61. package/scss/base/_global.scss +9 -5
  62. package/scss/error.scss +0 -2
  63. package/scss/helpers/_functions.scss +4 -2
  64. package/scss/main.scss +64 -8
  65. package/scss/overrides/rtl.scss +4 -2
  66. package/scss/patternlib.scss +3 -2
  67. package/scss/utilities/_colors.scss +4 -4
  68. package/scss/utilities/_grid.scss +7 -5
  69. package/src/js/domready.js +17 -0
  70. package/components/related-links/_macro.njk +0 -14
  71. package/components/related-links/_related-links.scss +0 -6
@@ -124,7 +124,7 @@ $checkbox-padding: 11px;
124
124
  }
125
125
 
126
126
  &__input:focus + &__label::before {
127
- @extend .ons-input:focus;
127
+ @extend %ons-input-focus;
128
128
  }
129
129
 
130
130
  &__input:not(:checked) ~ &__other {
@@ -40,9 +40,9 @@
40
40
  {% endif %}
41
41
  {% if checkbox.other is defined and checkbox.other %}
42
42
  {% set otherClass = " ons-js-other" %}
43
- {% endif %}
44
- {% if checkbox.other.selectAllChildren is defined and checkbox.other.selectAllChildren == true %}
45
- {% set otherClass = otherClass + " ons-js-select-all-children" %}
43
+ {% if checkbox.other.selectAllChildren is defined and checkbox.other.selectAllChildren == true %}
44
+ {% set otherClass = otherClass + " ons-js-select-all-children" %}
45
+ {% endif %}
46
46
  {% endif %}
47
47
  <span class="ons-checkboxes__item{{ " ons-checkboxes__item--no-border" if params.borderless }}">
48
48
  {% set config = {
@@ -17,7 +17,7 @@ $collapsible-caret-width: 1.5rem;
17
17
 
18
18
  &:focus {
19
19
  .ons-collapsible__title {
20
- @extend a:focus;
20
+ @extend %a-focus;
21
21
  // extend collapsible focus background behind caret
22
22
  margin-left: -$collapsible-caret-width;
23
23
  padding-left: $collapsible-caret-width;
@@ -4,7 +4,6 @@
4
4
  .ons-field {
5
5
  display: inline-block;
6
6
  font-size: 1rem;
7
- margin-bottom: 1.5rem;
8
7
  margin-top: 0;
9
8
  vertical-align: top;
10
9
 
@@ -21,7 +21,7 @@
21
21
  {{- params.legend | safe -}}
22
22
  {% endif %}
23
23
  {% if params.description is defined and params.description %}
24
- <span class="ons-fieldset__description {% if params.legendIsQuestionTitle %}ons-fieldset__description--title{% endif %}">{{ params.description | safe }}</span>
24
+ <div class="ons-fieldset__description {% if params.legendIsQuestionTitle %}ons-fieldset__description--title{% endif %}">{{ params.description | safe }}</div>
25
25
  {% endif %}
26
26
  </legend>
27
27
  {{ caller() }}
@@ -5,6 +5,7 @@
5
5
  -moz-osx-font-smoothing: grayscale;
6
6
  margin: 0;
7
7
  position: relative;
8
+
8
9
  & &__title--svg-logo {
9
10
  display: block;
10
11
  fill: $color-white;
@@ -38,9 +39,6 @@
38
39
  background: $color-header;
39
40
  padding: 0.56rem 0;
40
41
 
41
- @include mq(m) {
42
- height: 95px;
43
- }
44
42
  &--border {
45
43
  border-bottom: 3px solid $color-header;
46
44
  border-top: 3px solid $color-header;
@@ -57,12 +55,14 @@
57
55
  color: $color-white;
58
56
 
59
57
  @include mq(m) {
58
+ margin-bottom: 1rem;
60
59
  margin-top: 0.8rem;
61
60
  }
62
61
 
63
62
  &--with-description,
64
63
  &--with-button {
65
64
  @include mq(m) {
65
+ margin-bottom: 0;
66
66
  margin-top: 0.45rem;
67
67
  }
68
68
  }
@@ -87,7 +87,7 @@
87
87
  })
88
88
  }}
89
89
  {% else %}
90
- <{{ title_tag }} class="ons-header__title{% if params.desc is defined and params.desc %} header__title--with-description{% endif %}{% if params.button is defined and params.button %} header__title--with-button{% endif %}">{{ params.title }}</{{ title_tag }}>
90
+ <{{ title_tag }} class="ons-header__title{% if params.desc is defined and params.desc %} ons-header__title--with-description{% endif %}{% if params.button is defined and params.button %} ons-header__title--with-button{% endif %}">{{ params.title }}</{{ title_tag }}>
91
91
  {% endif %}
92
92
  {% if params.titleLogoHref is defined and params.titleLogoHref %}</a>{% endif %}
93
93
  </div>
@@ -95,7 +95,7 @@
95
95
  <div class="ons-grid__col ons-col-auto ons-u-flex-no-shrink ons-u-d-no@xxs@m">
96
96
  {{ onsButton({
97
97
  "text": params.button.text,
98
- "classes": "ons-u-d-no@xxs@m ons-u-mt-xs@m",
98
+ "classes": "ons-u-d-no@xxs@m",
99
99
  "variants": "ghost",
100
100
  "name": params.button.name,
101
101
  "attributes": params.button.attributes,
@@ -1,3 +1,8 @@
1
+ %ons-input-focus {
2
+ box-shadow: 0 0 0 3px $color-focus, inset 0 0 0 1px $color-input;
3
+ outline: none;
4
+ }
5
+
1
6
  .ons-input {
2
7
  border: $input-border-width solid $color-input;
3
8
  border-radius: $input-radius;
@@ -31,8 +36,7 @@
31
36
  }
32
37
 
33
38
  &:focus {
34
- box-shadow: 0 0 0 3px $color-focus, inset 0 0 0 1px $color-input;
35
- outline: none;
39
+ @extend %ons-input-focus;
36
40
  }
37
41
 
38
42
  &:disabled {
@@ -127,7 +127,7 @@
127
127
  {% call onsMutuallyExclusive({
128
128
  "id": params.fieldId,
129
129
  "legend": params.legend,
130
- "legendClasses": params.legendClasses ~ "ons-js-input-legend",
130
+ "legendClasses": params.legendClasses ~ " ons-js-input-legend",
131
131
  "description": params.description,
132
132
  "dontWrap": params.dontWrap,
133
133
  "legendIsQuestionTitle": params.legendIsQuestionTitle,
@@ -1,5 +1,7 @@
1
+ @use 'sass:math';
2
+
1
3
  .ons-message {
2
- border-radius: $grid-gutters / 2;
4
+ border-radius: math.div($grid-gutters, 2);
3
5
  margin-bottom: 2rem;
4
6
 
5
7
  &--sent {
@@ -0,0 +1,23 @@
1
+ {% macro onsModal(params) %}
2
+ {% set modalID = params.id | default('dialog') %}
3
+ <dialog class="ons-modal ons-js-modal {{ params.classes }}"
4
+ id="{{ modalID }}"
5
+ role="dialog"
6
+ aria-labelledby="ons-modal-title"
7
+ {% 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 %}
8
+ >
9
+ <h1 id="ons-modal-title" class="ons-modal__title">
10
+ {{ params.title }}
11
+ </h1>
12
+ <div class="ons-modal__body">
13
+ {{ (params.body if params else "") | safe }}{{ caller() if caller }}
14
+ </div>
15
+ {% if params.btnText %}
16
+ {% from "components/button/_macro.njk" import onsButton %}
17
+ {{ onsButton({
18
+ "text": params.btnText,
19
+ "classes": "ons-js-modal-btn ons-u-mt-s"
20
+ }) }}
21
+ {% endif %}
22
+ </dialog>
23
+ {% endmacro %}
@@ -0,0 +1,32 @@
1
+ $backdrop-colour: rgba(0, 0, 0, 0.8);
2
+
3
+ .ons-modal {
4
+ border: none;
5
+ border-radius: 0.4rem;
6
+ box-shadow: 0 0 7px 0 #000;
7
+ display: none;
8
+ margin-left: 2rem;
9
+ margin-right: 2rem;
10
+ max-width: 500px;
11
+ padding: 2rem;
12
+ width: auto;
13
+
14
+ @media screen and (min-width: 600px) {
15
+ margin-left: auto;
16
+ margin-right: auto;
17
+ width: 100%;
18
+ }
19
+
20
+ &::backdrop {
21
+ backdrop-filter: blur(3px);
22
+ background: $backdrop-colour;
23
+ }
24
+
25
+ & + .backdrop {
26
+ background: $backdrop-colour;
27
+ }
28
+ }
29
+
30
+ .ons-modal-overlay {
31
+ overflow: hidden;
32
+ }
@@ -0,0 +1,14 @@
1
+ import domready from '../../js/domready';
2
+
3
+ async function modals() {
4
+ const modals = [...document.querySelectorAll('.ons-js-modal')];
5
+ const timeouts = [...document.querySelectorAll('.ons-js-timeout-modal')];
6
+
7
+ if (modals.length && !timeouts.length) {
8
+ const Modal = (await import('./modal')).default;
9
+
10
+ modals.forEach(component => new Modal(component));
11
+ }
12
+ }
13
+
14
+ domready(modals);
@@ -0,0 +1,104 @@
1
+ import dialogPolyfill from 'dialog-polyfill';
2
+
3
+ const overLayClass = 'ons-modal-overlay';
4
+
5
+ export default class Modal {
6
+ constructor(component) {
7
+ this.component = component;
8
+ this.launcher = document.querySelector(`[data-modal-id=${component.id}]`);
9
+ this.closeButton = component.querySelector('.ons-js-modal-btn');
10
+ this.lastFocusedEl = null;
11
+
12
+ this.initialise();
13
+ }
14
+
15
+ initialise() {
16
+ if (!this.dialogSupported()) {
17
+ /* istanbul ignore next */
18
+ return;
19
+ }
20
+
21
+ if (this.launcher) {
22
+ this.launcher.addEventListener('click', this.openDialog.bind(this));
23
+ }
24
+
25
+ if (this.closeButton) {
26
+ this.closeButton.addEventListener('click', this.closeDialog.bind(this));
27
+ }
28
+ }
29
+
30
+ dialogSupported() {
31
+ if (typeof HTMLDialogElement === 'function') {
32
+ return true;
33
+ } else {
34
+ try {
35
+ dialogPolyfill.registerDialog(this.component);
36
+ return true;
37
+ } catch (error) {
38
+ /* istanbul ignore next */
39
+ return false;
40
+ }
41
+ }
42
+ }
43
+
44
+ openDialog(event) {
45
+ if (!this.isDialogOpen()) {
46
+ this.component.classList.add('ons-u-db');
47
+ document.querySelector('body').className += ' ' + overLayClass;
48
+ this.makePageContentInert();
49
+ this.saveLastFocusedEl();
50
+ if (event) {
51
+ const modal = document.getElementById(event.target.getAttribute('data-modal-id'));
52
+ modal.showModal();
53
+ } else {
54
+ this.component.showModal();
55
+ }
56
+ }
57
+ }
58
+
59
+ saveLastFocusedEl() {
60
+ this.lastFocusedEl = document.activeElement;
61
+ if (!this.lastFocusedEl || this.lastFocusedEl === document.body) {
62
+ this.lastFocusedEl = null;
63
+ } else if (document.querySelector) {
64
+ this.lastFocusedEl = document.querySelector(':focus');
65
+ }
66
+ }
67
+
68
+ setFocusOnLastFocusedEl(lastFocusedEl) {
69
+ if (lastFocusedEl) {
70
+ lastFocusedEl.focus();
71
+ }
72
+ }
73
+
74
+ makePageContentInert() {
75
+ if (document.querySelector('.ons-page')) {
76
+ document.querySelector('.ons-page').inert = true;
77
+ document.querySelector('.ons-page').setAttribute('aria-hidden', 'true');
78
+ }
79
+ }
80
+
81
+ removeInertFromPageContent() {
82
+ if (document.querySelector('.ons-page')) {
83
+ document.querySelector('.ons-page').inert = false;
84
+ document.querySelector('.ons-page').setAttribute('aria-hidden', 'false');
85
+ }
86
+ }
87
+
88
+ isDialogOpen() {
89
+ return this.component['open'];
90
+ }
91
+
92
+ closeDialog(event) {
93
+ if (this.isDialogOpen()) {
94
+ if (event) {
95
+ event.preventDefault();
96
+ }
97
+ this.component.classList.remove('ons-u-db');
98
+ document.querySelector('body').classList.remove(overLayClass);
99
+ this.component.close();
100
+ this.setFocusOnLastFocusedEl(this.lastFocusedEl);
101
+ this.removeInertFromPageContent();
102
+ }
103
+ }
104
+ }
@@ -9,9 +9,9 @@
9
9
 
10
10
  {% set descHtml %}
11
11
  {% if params.readDescriptionFirst is defined and params.readDescriptionFirst == true %}
12
- <span aria-hidden="true" {% if params.legendIsQuestionTitle is not defined %}class="ons-question__description"{% endif %}>{{ params.description | safe }}</span>
12
+ <div aria-hidden="true" {% if params.legendIsQuestionTitle is not defined %}class="ons-question__description"{% endif %}>{{ params.description | safe }}</div>
13
13
  {% elif params.legendIsQuestionTitle is not defined %}
14
- <span class="ons-question__description">{{ params.description | safe }}</span>
14
+ <div class="ons-question__description">{{ params.description | safe }}</div>
15
15
  {% else %}
16
16
  {{ params.description | safe }}
17
17
  {% endif %}
@@ -21,10 +21,15 @@
21
21
  {% endif %}
22
22
  <span class="ons-radios__item{{ " ons-radios__item--no-border" if params.borderless }}">
23
23
  <span class="ons-radio{{ " ons-radio--no-border" if params.borderless }}">
24
+ {% if radio.other is defined and radio.other and radio.other.selectAllChildren is defined and radio.other.selectAllChildren == true %}
25
+ {% set selectAllClass = ' ons-js-select-all-children' %}
26
+ {% else %}
27
+ {% set selectAllClass = '' %}
28
+ {% endif %}
24
29
  <input
25
30
  type="radio"
26
31
  id="{{ radio.id }}"
27
- class="ons-radio__input ons-js-radio{{ ' ' + radio.classes if radio.classes else '' }}{{ ' ons-js-other' if radio.other else '' }}{{ ' ons-js-select-all-children' if radio.other.selectAllChildren == true else '' }}"
32
+ class="ons-radio__input ons-js-radio{{ ' ' + radio.classes if radio.classes else '' }}{{ ' ons-js-other' if radio.other else '' }}{{ selectAllClass }}"
28
33
  value="{{ radio.value }}"
29
34
  name="{{ params.name }}"
30
35
  {% if (radio.checked is defined and radio.checked) or (params.value is defined and params.value == radio.value) %} checked {% endif %}
@@ -39,7 +44,6 @@
39
44
  "classes": "ons-radio__label " + radio.label.classes | default(''),
40
45
  "description": radio.label.description
41
46
  }) }}
42
-
43
47
  {% if radio.other is defined and radio.other %}
44
48
  {% set otherType = radio.other.otherType | default('input') %}
45
49
  <span class="ons-radio__other{{ " " + 'ons-radio__other--open' if radio.other.open else "" }}" id="{{ radio.id }}-other-wrap">
@@ -1,3 +1,5 @@
1
+ @use 'sass:math';
2
+
1
3
  $summary-row-spacing: 1rem;
2
4
  $summary-col-spacing: 1rem;
3
5
  $hub-row-spacing: 1.3rem;
@@ -101,8 +103,8 @@ $hub-row-spacing: 1.3rem;
101
103
  padding-right: $summary-col-spacing;
102
104
 
103
105
  @include mq('s') {
104
- padding-left: $summary-col-spacing / 2;
105
- padding-right: $summary-col-spacing / 2;
106
+ padding-left: math.div($summary-col-spacing, 2);
107
+ padding-right: math.div($summary-col-spacing, 2);
106
108
 
107
109
  &:first-child {
108
110
  padding-left: $summary-col-spacing;
@@ -211,7 +211,7 @@
211
211
  }
212
212
 
213
213
  &:focus {
214
- @extend a:focus;
214
+ @extend %a-focus;
215
215
  .ons-svg-icon {
216
216
  fill: $color-black;
217
217
  }
@@ -0,0 +1,26 @@
1
+ {% from "components/modal/_macro.njk" import onsModal %}
2
+ {% macro onsTimeoutModal(params) %}
3
+ {% call onsModal({
4
+ "title": params.title,
5
+ "btnText": params.btnText,
6
+ "classes": "ons-js-timeout-modal",
7
+ "attributes": {
8
+ "data-redirect-url": params.redirectUrl,
9
+ "data-timeout-time": params.serverTimeoutTime,
10
+ "data-show-modal-time": params.showModalTimeInSeconds,
11
+ "data-server-session-expiry-endpoint": params.serverSessionExpiryEndpoint,
12
+ "data-countdown-text": params.countdownText,
13
+ "data-redirecting-text": params.redirectingText,
14
+ "data-minutes-text-singular": params.minutesTextSingular,
15
+ "data-minutes-text-plural": params.minutesTextPlural,
16
+ "data-seconds-text-singular": params.secondsTextSingular,
17
+ "data-seconds-text-plural": params.secondsTextPlural,
18
+ "aria-describedby": "timeout-time-remaining"
19
+ }
20
+ })
21
+ %}
22
+ <p>{{ params.textFirstLine }}</p>
23
+ <p class="ons-js-timeout-timer" aria-hidden="true" aria-relevant="additions"></p>
24
+ <p class="ons-js-timeout-timer-acc ons-u-vh" role="status" id="timeout-time-remaining"></p>
25
+ {% endcall %}
26
+ {% endmacro %}
@@ -0,0 +1,16 @@
1
+ import domready from '../../js/domready';
2
+
3
+ async function modals() {
4
+ const timeouts = [...document.querySelectorAll('.ons-js-timeout-modal')];
5
+
6
+ if (timeouts.length) {
7
+ const Timeout = (await import('./timeout')).default;
8
+
9
+ timeouts.forEach(context => {
10
+ let url = context.getAttribute('data-server-session-expiry-endpoint');
11
+ new Timeout(context, url);
12
+ });
13
+ }
14
+ }
15
+
16
+ domready(modals);