@ons/design-system 47.0.0 → 48.0.2

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.
@@ -209,6 +209,76 @@ $button-shadow-size: 3px;
209
209
  }
210
210
  }
211
211
 
212
+ &--text-link {
213
+ vertical-align: baseline;
214
+ }
215
+
216
+ &--text-link & {
217
+ &__inner {
218
+ background: transparent;
219
+ border: none;
220
+ border-radius: 0;
221
+ box-shadow: none;
222
+ color: $color-text-link;
223
+ font-weight: normal;
224
+ padding: 0;
225
+ .ons-svg-icon {
226
+ fill: $color-text-link;
227
+ }
228
+ }
229
+ }
230
+
231
+ &--text-link-inverse & {
232
+ &__inner {
233
+ color: $color-white;
234
+ .ons-svg-icon {
235
+ fill: $color-white;
236
+ }
237
+ }
238
+ }
239
+
240
+ &--text-link:hover &,
241
+ &--text-link:active &,
242
+ &--text-link.active & {
243
+ &__inner {
244
+ background: none;
245
+ color: $color-text-link-hover;
246
+ .ons-svg-icon {
247
+ fill: $color-text-link-hover;
248
+ }
249
+ }
250
+ }
251
+
252
+ &--text-link-inverse:hover &,
253
+ &--text-link-inverse:active &,
254
+ &--text-link-inverse.active & {
255
+ &__inner {
256
+ color: $color-branded-tint;
257
+ .ons-svg-icon {
258
+ fill: $color-branded-tint;
259
+ }
260
+ }
261
+ }
262
+
263
+ &--text-link:focus:hover & {
264
+ &__inner {
265
+ color: $color-black;
266
+ }
267
+ }
268
+
269
+ &--text-link:focus &,
270
+ &--text-link.active:focus &,
271
+ &--text-link:active:focus & {
272
+ &__inner {
273
+ background-color: $color-focus;
274
+ box-shadow: 0 -2px $color-focus, 0 4px $color-text-link-focus !important;
275
+ color: $color-text-link-focus;
276
+ .ons-svg-icon {
277
+ fill: $color-text-link-focus;
278
+ }
279
+ }
280
+ }
281
+
212
282
  &--ghost &,
213
283
  &--mobile & {
214
284
  &__inner {
@@ -232,6 +302,7 @@ $button-shadow-size: 3px;
232
302
  }
233
303
 
234
304
  &--ghost,
305
+ &--text-link,
235
306
  &--mobile {
236
307
  &:active,
237
308
  .active {
@@ -245,6 +316,7 @@ $button-shadow-size: 3px;
245
316
  }
246
317
 
247
318
  &--ghost:focus:hover,
319
+ &--text-link:focus:hover,
248
320
  &--mobile:focus:hover {
249
321
  outline: none;
250
322
  }
@@ -294,13 +366,15 @@ $button-shadow-size: 3px;
294
366
  }
295
367
  }
296
368
 
297
- &--mobile[aria-expanded='true'] {
369
+ &--mobile[aria-expanded='true'],
370
+ &--text-link[aria-expanded='true'] {
298
371
  .ons-svg-icon {
299
372
  transform: rotate(270deg);
300
373
  }
301
374
  }
302
375
 
303
- &--mobile {
376
+ &--mobile,
377
+ &--text-link {
304
378
  .ons-svg-icon {
305
379
  transform: rotate(90deg);
306
380
  }
@@ -14,7 +14,6 @@
14
14
  {% call onsPanel({
15
15
  "type": "error",
16
16
  "id": params.id,
17
- "classes": "ons-u-mb-s",
18
17
  "dsExample": params.dsExample
19
18
  }) %}
20
19
  {{ content | safe }}
@@ -70,6 +70,14 @@
70
70
  }
71
71
 
72
72
  .ons-header-service-nav {
73
+ display: inline-block;
74
+
75
+ &--mobile {
76
+ background: $color-branded-tint;
77
+ padding: 1rem;
78
+ width: 100%;
79
+ }
80
+
73
81
  &__list {
74
82
  list-style: none;
75
83
  margin: 0;
@@ -79,9 +87,22 @@
79
87
  &__item {
80
88
  display: inline-block;
81
89
  margin: 0 0 0 1rem;
82
-
90
+ &--mobile {
91
+ display: block;
92
+ margin: 0 0 0.5rem;
93
+ }
83
94
  &:first-child {
84
95
  margin-left: 0;
85
96
  }
86
97
  }
98
+
99
+ .ons-language-links {
100
+ border-top: 1px solid $color-branded;
101
+ margin: 1.5rem 0 0;
102
+ padding: 1rem 0 0;
103
+
104
+ &__item {
105
+ margin: 0 0 0.5rem;
106
+ }
107
+ }
87
108
  }
@@ -44,9 +44,6 @@
44
44
  border-top: 3px solid $color-header;
45
45
  padding: 0.934rem 0;
46
46
  }
47
- &--with-description {
48
- height: auto;
49
- }
50
47
  }
51
48
  &__title {
52
49
  @extend .ons-u-fs-r--b;
@@ -59,13 +56,6 @@
59
56
  margin-top: 0.8rem;
60
57
  }
61
58
 
62
- &--with-description {
63
- @include mq(m) {
64
- margin-bottom: 0;
65
- margin-top: 0.5rem;
66
- }
67
- }
68
-
69
59
  //to allow for differences in size between welsh and english logos
70
60
  &-census-logo-en {
71
61
  @include mq(xxs) {
@@ -94,7 +84,7 @@
94
84
  }
95
85
  }
96
86
  }
97
- &__desc {
87
+ &__description {
98
88
  @extend .ons-u-fs-s;
99
89
  @extend .ons-u-fs-r\@s;
100
90
 
@@ -105,12 +95,14 @@
105
95
  margin: 0 0 1.1rem;
106
96
  }
107
97
  }
108
- // Modifier - Hero variant
109
- &--hero {
98
+ // Modifier - variants
99
+ &--description {
110
100
  .ons-header {
111
101
  &__title {
112
102
  @extend .ons-u-fs-m;
113
103
  @extend .ons-u-fs-xxl\@m;
104
+
105
+ margin-bottom: 0;
114
106
  }
115
107
  }
116
108
  }
@@ -135,11 +127,11 @@
135
127
  }
136
128
  &__grid-top {
137
129
  min-height: 36px;
138
- }
139
- &-service-nav__link {
140
- color: $color-white;
141
- &:hover {
142
- text-decoration: underline solid $color-white 3px;
130
+ a {
131
+ color: $color-white;
132
+ &:hover {
133
+ text-decoration: underline solid $color-white 3px;
134
+ }
143
135
  }
144
136
  }
145
137
  }
@@ -157,13 +149,13 @@
157
149
  }
158
150
 
159
151
  .ons-header__logo--large {
160
- @include mq(xxs, 399px) {
152
+ @include mq(xxs, 454px) {
161
153
  display: none;
162
154
  }
163
155
  }
164
156
 
165
157
  .ons-header__logo--small {
166
- @include mq(400px) {
158
+ @include mq(455px) {
167
159
  display: none;
168
160
  }
169
161
  }
@@ -11,7 +11,7 @@
11
11
  {% set currentLanguageISOCode = currentLanguage.ISOCode %}
12
12
  {% endif %}
13
13
 
14
- <header class="ons-header {{ params.classes if params.classes }}" role="banner">
14
+ <header class="ons-header {% if params.variants is not string %}{% for variant in params.variants %} ons-header--{{ variant }}{% endfor %}{% else %} ons-header--{{ params.variants }}{% endif %}" role="banner">
15
15
  {% if params.phase is defined and params.phase %}
16
16
  {% from "components/phase-banner/_macro.njk" import onsPhaseBanner %}
17
17
  {{ onsPhaseBanner(params.phase) }}
@@ -19,7 +19,6 @@
19
19
  <div class="ons-header__top">
20
20
  <div class="ons-container{{ ' ons-container--full-width' if params.fullWidth }}{{ ' ons-container--wide' if params.wide }}">
21
21
  <div class="ons-header__grid-top ons-grid ons-grid--gutterless ons-grid--flex ons-grid--between ons-grid--vertical-center ons-grid--no-wrap{{ ' ons-header__grid-top-tall' if params.customHeaderLogo is defined and params.customHeaderLogo }}">
22
-
23
22
  <div class="ons-grid__col ons-col-auto">
24
23
  <div class="ons-header__logo--large">
25
24
  {%-if params.logoHref is defined and params.logoHref %}<a class="ons-header__logo-link" href="{{ params.logoHref }}">{% endif -%}
@@ -42,20 +41,28 @@
42
41
  {% if params.logoHref is defined and params.logoHref %}</a>{% endif %}
43
42
  </div>
44
43
  </div>
45
-
46
44
  {% if params.language is defined and params.language or params.serviceLinks is defined and params.serviceLinks %}
47
45
  <div class="ons-header__links ons-grid__col ons-col-auto">
48
46
  {% if params.language is defined and params.language %}
49
- <div class="ons-grid__col ons-col-auto">
47
+ <div class="ons-grid__col ons-col-auto {{ ' ons-u-mr-s ons-u-d-no@xxs@xs' if params.serviceLinks is defined and params.serviceLinks else '' }}">
50
48
  {% from "components/language-selector/_macro.njk" import onsLanguageSelector %}
51
49
  {{ onsLanguageSelector(params.language) }}
52
50
  </div>
53
51
  {% endif %}
54
52
  {% if params.serviceLinks is defined and params.serviceLinks %}
55
- <div class="ons-grid__col ons-col-auto ons-u-d-no@xxs@m">
56
- <nav class="ons-header-service-nav {{ params.serviceLinks.classes }}" aria-label="{{ params.serviceLinks.ariaLabel | default("Service links navigation") }}">
53
+ {% if params.serviceLinks.itemsList | length == 1 and params.language is defined and params.language %}
54
+ {% set breakpoint = 'xs' %}
55
+ {% set controlVisibility = true %}
56
+ {% elif params.serviceLinks.itemsList | length > 1 %}
57
+ {% set breakpoint = 'm' %}
58
+ {% set controlVisibility = true %}
59
+ {% else %}
60
+ {% set controlVisibility = false %}
61
+ {% endif %}
62
+ <div class="ons-grid__col ons-col-auto{% if controlVisibility == true %} ons-u-d-no@xxs@{{ breakpoint }}{% endif %}">
63
+ <nav class="ons-header-service-nav ons{{ params.serviceLinks.classes }}" aria-label="{{ params.serviceLinks.ariaLabel | default("Service links navigation") }}">
57
64
  <ul class="ons-header-service-nav__list" aria-label="{{ params.serviceLinks.ariaListLabel | default("Service Links") }}">
58
- {% for item in (params.serviceLinks.itemsList if params.serviceLinks.itemsList is iterable else params.serviceLinks.itemsList.items()) %}
65
+ {% for item in (params.serviceLinks.itemsList if params.serviceLinks.itemsList is iterable else params.serviceLinks.itemsList.items()) %}
59
66
  <li class="ons-header-service-nav__item">
60
67
  <a
61
68
  href="{{ item.url }}"
@@ -67,13 +74,55 @@
67
74
  </ul>
68
75
  </nav>
69
76
  </div>
77
+ {% if params.serviceLinks.itemsList | length > 1 or params.language is defined and params.language %}
78
+ {% if params.variants == 'internal' %}
79
+ {% set buttonVariant = ["text-link", "text-link-inverse"] %}
80
+ {% else %}
81
+ {% set buttonVariant = "text-link" %}
82
+ {% endif %}
83
+ <div class="ons-grid__col ons-col-auto ons-u-d-no@{{ breakpoint }}">
84
+ {{ onsButton({
85
+ "text": params.serviceLinks.toggleServicesButton.text | default("Menu") ,
86
+ "classes": "ons-u-d-no ons-js-toggle-services",
87
+ "buttonStyle": "mobile",
88
+ "variants": buttonVariant,
89
+ "attributes": {
90
+ "aria-label": params.serviceLinks.toggleServicesButton.ariaLabel | default("Toggle menu") ,
91
+ "aria-controls": params.serviceLinks.id,
92
+ "aria-haspopup": "true",
93
+ "aria-expanded": "false"
94
+ }
95
+ }) }}
96
+ </div>
97
+ {% endif %}
70
98
  {% endif %}
71
99
  </div>
72
100
  {% endif %}
73
101
  </div>
74
102
  </div>
103
+ {% if params.serviceLinks is defined and params.serviceLinks %}
104
+ <nav class="ons-header-service-nav ons-header-service-nav--mobile ons-u-d-no ons-js-services-mobile-nav" id="{{ params.serviceLinks.id }}" aria-label="{{ params.serviceLinks.ariaLabel | default("Service links navigation") }}">
105
+ <ul class="ons-header-service-nav__list" aria-label="{{ params.serviceLinks.ariaListLabel | default("Service Links") }}">
106
+ {% for item in (params.serviceLinks.itemsList if params.serviceLinks.itemsList is iterable else params.serviceLinks.itemsList.items()) %}
107
+ <li class="ons-header-service-nav__item ons-header-service-nav__item--mobile">
108
+ <a
109
+ href="{{ item.url }}"
110
+ class="ons-header-service-nav__link"
111
+ {% if item.id is defined and item.id %} id="{{ item.id }}"{% endif %}
112
+ >{{ item.title }}</a>
113
+ </li>
114
+ {% endfor %}
115
+ {% if params.language is defined and params.language %}
116
+ <div class="ons-u-d-no@xs">
117
+ {% from "components/language-selector/_macro.njk" import onsLanguageSelector %}
118
+ {{ onsLanguageSelector(params.language) }}
119
+ </div>
120
+ {% endif %}
121
+ </ul>
122
+ </nav>
123
+ {% endif %}
75
124
  </div>
76
- <div class="ons-header__main{% if params.desc is defined and params.desc %} ons-header__main--with-description{% endif %}">
125
+ <div class="ons-header__main">
77
126
  <div class="ons-container{{ ' ons-container--full-width' if params.fullWidth }}{{ ' ons-container--wide' if params.wide }}">
78
127
  <div class="ons-grid ons-grid--gutterless ons-grid--flex ons-grid--between ons-grid--vertical-center ons-grid--no-wrap">
79
128
  <div class="ons-grid__col ons-col-auto ons-u-flex-shrink{% if params.titleLogo == 'census-logo-en' %} ons-header__title-census-logo-en{% endif %}">
@@ -87,9 +136,12 @@
87
136
  })
88
137
  }}
89
138
  {% else %}
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 }}>
139
+ <{{ title_tag }} class="ons-header__title">{{ params.title }}</{{ title_tag }}>
91
140
  {% endif %}
92
141
  {% if params.titleLogoHref is defined and params.titleLogoHref %}</a>{% endif %}
142
+ {% if params.description is defined and params.description %}
143
+ <p class="ons-header__description">{{ params.description }}</p>
144
+ {% endif %}
93
145
  </div>
94
146
  {% if params.button is defined and params.button %}
95
147
  <div class="ons-grid__col ons-col-auto ons-u-flex-no-shrink ons-u-d-no@xxs@m">
@@ -105,7 +157,7 @@
105
157
  }) }}
106
158
  </div>
107
159
  {% endif %}
108
- {% if params.toggleButton is defined and params.toggleButton or params.autosuggest is defined and params.autosuggest %}
160
+ {% if params.navigation is defined and params.navigation and params.navigation.toggleButton is defined and params.navigation.toggleButton or params.autosuggest is defined and params.autosuggest %}
109
161
  <div class="ons-grid__col ons-col-auto ons-u-flex-no-shrink ons-u-d-no@m">
110
162
  {% if params.autosuggest is defined and params.autosuggest and isPatternLib is defined and isPatternLib %}
111
163
  <span class="ons-grid ons-u-d-no@xxs@xs">
@@ -124,14 +176,14 @@
124
176
  }) }}
125
177
  </span>
126
178
  {% endif %}
127
- {% if params.toggleButton is defined and params.toggleButton %}
179
+ {% if params.navigation.toggleButton is defined and params.navigation.toggleButton %}
128
180
  {{ onsButton({
129
- "text": params.toggleButton.text,
181
+ "text": params.navigation.toggleButton.text | default("Menu"),
130
182
  "classes": "ons-u-ml-xs ons-u-d-no ons-js-toggle-main",
131
183
  "buttonStyle": "mobile",
132
184
  "variants": ["mobile", "ghost"],
133
185
  "attributes": {
134
- "aria-label": params.toggleButton.ariaLabel | default("Toggle main menu") ,
186
+ "aria-label": params.navigation.toggleButton.ariaLabel | default("Toggle menu") ,
135
187
  "aria-controls": params.navigation.id,
136
188
  "aria-haspopup": "true",
137
189
  "aria-expanded": "false"
@@ -141,9 +193,6 @@
141
193
  </div>
142
194
  {% endif %}
143
195
  </div>
144
- {% if params.desc is defined and params.desc %}
145
- <p class="ons-header__desc">{{ params.desc }}</p>
146
- {% endif %}
147
196
  </div>
148
197
  </div>
149
198
  {% if params.navigation is defined and params.navigation %}
@@ -4,6 +4,9 @@ domready(async () => {
4
4
  const toggleMainBtn = document.querySelector('.ons-js-toggle-main');
5
5
  const navEl = document.querySelector('.ons-js-header-nav');
6
6
  const navHideClass = 'ons-u-d-no@xxs@m';
7
+ const toggleServicesBtn = document.querySelector('.ons-js-toggle-services');
8
+ const servicesEl = document.querySelector('.ons-js-services-mobile-nav');
9
+ const servicesHideClass = 'ons-u-d-no';
7
10
  const toggleSearchBtn = document.querySelector('.ons-js-toggle-search');
8
11
  const searchEl = document.querySelector('.ons-js-header-search');
9
12
  const searchHideClass = 'ons-u-d-no@xs@m';
@@ -19,4 +22,10 @@ domready(async () => {
19
22
 
20
23
  new searchToggle(toggleSearchBtn, searchEl, searchHideClass).registerEvents();
21
24
  }
25
+
26
+ if (toggleServicesBtn) {
27
+ const servicesToggle = (await import('./header-nav')).default;
28
+
29
+ new servicesToggle(toggleServicesBtn, servicesEl, servicesHideClass).registerEvents();
30
+ }
22
31
  });
@@ -11,7 +11,6 @@ export default class NavToggle {
11
11
  this.nav = nav;
12
12
  this.hideClass = hideClass;
13
13
  this.toggle.classList.remove('ons-u-d-no');
14
-
15
14
  this.setAria();
16
15
  onViewportChange(this.setAria.bind(this));
17
16
  }
@@ -56,7 +55,11 @@ export default class NavToggle {
56
55
  } else if (hasAria) {
57
56
  this.toggle.removeAttribute(attrExpanded);
58
57
  this.nav.removeAttribute(attrHidden);
59
- this.nav.classList.remove(this.hideClass);
58
+ if (this.hideClass !== 'ons-u-d-no') {
59
+ this.nav.classList.remove(this.hideClass);
60
+ } else {
61
+ this.closeNav();
62
+ }
60
63
  }
61
64
  }
62
65
  }
@@ -20,7 +20,7 @@
20
20
  {% else %}
21
21
  {% set listEl = 'ul' %}
22
22
  {% endif %}
23
- <{{listEl}} {% if params.id is defined and params.id %}id="{{ params.id }}"{% endif %}class="{% if listLength > 1 or listEl == 'ul' %}ons-list{% else %}ons-list--p{% endif %}{% if params.classes is defined and params.classes %} {{ params.classes -}}{% endif %}{% if params.variants is defined and params.variants %}{% if params.variants is not string %}{% for variant in params.variants %} ons-list--{{ variant }}{% endfor %}{% else %} ons-list--{{ params.variants }}{% endif %}{% endif %}{% if otherClasses %} {{ otherClasses -}}{% endif %}">
23
+ <{{listEl}} {% if params.id is defined and params.id %}id="{{ params.id }}"{% endif %}class="{% if listLength > 1 or listEl == 'ul' %}ons-list{% else %}ons-list--p{% endif %}{% if params.classes is defined and params.classes %} {{ params.classes -}}{% endif %}{% if params.variants is defined and params.variants %}{% if params.variants is not string %}{% for variant in params.variants %} ons-list--{{ variant }}{% endfor %}{% else %} ons-list--{{ params.variants }}{% endif %}{% endif %}{% if otherClasses %} {{ otherClasses -}}{% endif %}"{% 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 }}{% if value is defined and value %}="{{ value }}"{% endif %}{% endfor %}{% endif %}>
24
24
  {%- for item in (params.itemsList if params.itemsList is iterable else params.itemsList.items()) -%}
25
25
  {% if listLength > 1 or listEl == 'ul' %}
26
26
  <li class="ons-list__item{% if item.listClasses is defined and item.listClasses %} {{ item.listClasses }}{% endif %}"{% if item.current is defined and item.current %} aria-current="true"{% endif %}>
@@ -38,21 +38,19 @@
38
38
  {% set itemText = item.title %}
39
39
  {% endif %}
40
40
 
41
- {%- if item.index is defined and item.index or item.prefix is defined and item.prefix or (params.iconPosition is defined and params.iconPosition == 'before') -%}
41
+ {%- if item.prefix is defined and item.prefix or (params.iconPosition is defined and params.iconPosition == 'before') -%}
42
42
  <span class="ons-list__prefix"{% if listEl != 'ol' %} aria-hidden="true"{% endif %}>
43
- {%- if item.prefix is defined and item.prefix -%}
44
- {{- item.prefix -}}.
45
- {%- elif (item.index is defined and item.index and listEl != 'ol') or (item.index is defined and item.index and listEl == 'ol' and 'bare' in variants) -%}
46
- {{- loop.index -}}.
47
- {% elif params.iconPosition is defined and params.iconPosition == 'before' %}
48
- {% from "components/icons/_macro.njk" import onsIcon %}
49
- {{
50
- onsIcon({
51
- "iconType": iconType,
52
- "iconSize": params.iconSize
53
- })
54
- }}
55
- {%- endif -%}
43
+ {%- if item.prefix is defined and item.prefix -%}
44
+ {{- item.prefix -}}.
45
+ {% elif params.iconPosition is defined and params.iconPosition == 'before' %}
46
+ {% from "components/icons/_macro.njk" import onsIcon %}
47
+ {{
48
+ onsIcon({
49
+ "iconType": iconType,
50
+ "iconSize": params.iconSize
51
+ })
52
+ }}
53
+ {%- endif -%}
56
54
  </span>
57
55
  {%- endif -%}
58
56
  {%- if item.url is defined and item.url and item.current != true -%}
@@ -65,7 +63,7 @@
65
63
  })
66
64
  }}
67
65
  {%- else -%}
68
- <a href="{{ item.url }}" class="ons-list__link {% if item.variants == 'inPageLink' %}ons-js-inpagelink {% endif %} {{ item.classes }}"{% if item.index is defined and item.index %} data-qa="list-item-{{ loop.index }}"{% endif %}{% if item.target is defined and item.target %} target="{{ item.target }}"{% endif %}{% if item.rel is defined and item.rel %} rel="{{ item.rel }}"{% endif %}>
66
+ <a href="{{ item.url }}" class="ons-list__link{% if item.variants == 'inPageLink' %} ons-js-inpagelink{% endif %}{% if item.classes is defined and item.classes %} {{ item.classes }}{% endif %}"{% if item.target is defined and item.target %} target="{{ item.target }}"{% endif %}{% if item.attributes is defined and item.attributes %}{% for attribute, value in (item.attributes.items() if item.attributes is mapping and item.attributes.items else item.attributes) %} {{ attribute }}{% if value is defined and value %}="{{ value }}"{% endif %}{% endfor %}{% endif %}>
69
67
  {%- if item.prefix is defined and item.prefix -%}<span class="ons-u-vh">{{- item.prefix -}}</span>{%- endif -%} {{- itemText | safe -}}
70
68
  {%- if item.target is defined and item.target == "_blank" -%}<span class="ons-u-vh">{{- item.screenreaderMessage | default("this link will open in a new tab") -}}</span>{%- endif -%}
71
69
  </a>
@@ -5,19 +5,21 @@
5
5
  role="dialog"
6
6
  aria-labelledby="ons-modal-title"
7
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 }}
8
+ >
9
+ <div class="ons-modal__content">
10
+ <h1 id="ons-modal-title" class="ons-modal__title">
11
+ {{ params.title }}
12
+ </h1>
13
+ <div class="ons-modal__body">
14
+ {{ (params.body if params else "") | safe }}{{ caller() if caller }}
15
+ </div>
16
+ {% if params.btnText %}
17
+ {% from "components/button/_macro.njk" import onsButton %}
18
+ {{ onsButton({
19
+ "text": params.btnText,
20
+ "classes": "ons-js-modal-btn ons-u-mt-s"
21
+ }) }}
22
+ {% endif %}
14
23
  </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
24
  </dialog>
23
25
  {% endmacro %}
@@ -9,8 +9,20 @@ $backdrop-colour: rgba(0, 0, 0, 0.8);
9
9
  margin-right: 2rem;
10
10
  max-width: 500px;
11
11
  padding: 2rem;
12
+ position: relative;
12
13
  width: auto;
13
14
 
15
+ &-ie11 & {
16
+ background: $color-white;
17
+ bottom: 0;
18
+ height: 350px;
19
+ left: 0;
20
+ position: fixed;
21
+ right: 0;
22
+ top: 50%;
23
+ transform: translate(0, -50%);
24
+ }
25
+
14
26
  @media screen and (min-width: 600px) {
15
27
  margin-left: auto;
16
28
  margin-right: auto;
@@ -24,6 +36,11 @@ $backdrop-colour: rgba(0, 0, 0, 0.8);
24
36
 
25
37
  & + .backdrop {
26
38
  background: $backdrop-colour;
39
+ height: 100%;
40
+ left: 0;
41
+ position: absolute;
42
+ top: 0;
43
+ width: 100%;
27
44
  }
28
45
  }
29
46
 
@@ -1,6 +1,7 @@
1
1
  import dialogPolyfill from 'dialog-polyfill';
2
2
 
3
3
  const overLayClass = 'ons-modal-overlay';
4
+ const ie11Class = 'ons-modal-ie11';
4
5
 
5
6
  export default class Modal {
6
7
  constructor(component) {
@@ -8,7 +9,7 @@ export default class Modal {
8
9
  this.launcher = document.querySelector(`[data-modal-id=${component.id}]`);
9
10
  this.closeButton = component.querySelector('.ons-js-modal-btn');
10
11
  this.lastFocusedEl = null;
11
-
12
+ this.dialogCSSSupported = true;
12
13
  this.initialise();
13
14
  }
14
15
 
@@ -33,6 +34,7 @@ export default class Modal {
33
34
  } else {
34
35
  try {
35
36
  dialogPolyfill.registerDialog(this.component);
37
+ this.dialogCSSSupported = false;
36
38
  return true;
37
39
  } catch (error) {
38
40
  /* istanbul ignore next */
@@ -44,9 +46,15 @@ export default class Modal {
44
46
  openDialog(event) {
45
47
  if (!this.isDialogOpen()) {
46
48
  this.component.classList.add('ons-u-db');
47
- document.querySelector('body').className += ' ' + overLayClass;
49
+ document.querySelector('body').classList.add(overLayClass);
50
+
51
+ if (!this.dialogCSSSupported) {
52
+ document.querySelector('body').classList.add(ie11Class);
53
+ }
54
+
48
55
  this.makePageContentInert();
49
56
  this.saveLastFocusedEl();
57
+
50
58
  if (event) {
51
59
  const modal = document.getElementById(event.target.getAttribute('data-modal-id'));
52
60
  modal.showModal();
@@ -96,6 +104,11 @@ export default class Modal {
96
104
  }
97
105
  this.component.classList.remove('ons-u-db');
98
106
  document.querySelector('body').classList.remove(overLayClass);
107
+
108
+ if (!this.dialogCSSSupported) {
109
+ document.querySelector('body').classList.remove(ie11Class);
110
+ }
111
+
99
112
  this.component.close();
100
113
  this.setFocusOnLastFocusedEl(this.lastFocusedEl);
101
114
  this.removeInertFromPageContent();
@@ -27,10 +27,8 @@
27
27
  {% endif %}
28
28
 
29
29
  {% if params is defined and params and params.type == "warn-branded" or params.type == "announcement" %}
30
- <div class="{{containerClass}}">
31
- <div class="ons-container">
32
- {% elif params.type is defined and params.type == "warn" %}
33
- <div class="ons-container">
30
+ <div class="{{containerClass}}">
31
+ <div class="ons-container">
34
32
  {% endif %}
35
33
 
36
34
  <div {% if params is defined and params and params.type == 'error' and params.title is defined and params.title %}aria-labelledby="error-summary-title" role="alert" tabindex="-1" {% if params.dsExample != true %}autofocus="autofocus" {% endif %}{% endif %}class="ons-panel{{ typeClass }}{{ iconClass }}{{ noTitleClass }}{{ spaciousClass }}{{ classes }}"{% if params is defined and params and params.attributes is defined and params.attributes %}{% for attribute, value in (params.attributes.items() if params is defined and params and params.attributes is mapping and params.attributes.items is defined and params.attributes.items else params.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}{% if params is defined and params and params.id is defined and params.id %} id="{{params.id}}"{% endif %}>
@@ -91,14 +89,11 @@
91
89
  <div class="ons-panel__body{% if params is defined and params and params.iconSize is defined and params.iconSize %} ons-svg-icon-margin--{{ params.iconSize }}{% endif %}">{{ (params.body if params else "") | safe }}
92
90
  {{ caller() if caller }}
93
91
  </div>
94
-
95
92
  </div>
96
93
 
97
94
  {% if params is defined and params and params.type == "warn-branded" or params.type == "announcement" %}
95
+ </div>
98
96
  </div>
99
- </div>
100
- {% elif params.type is defined and params.type == "warn" %}
101
- </div>
102
97
  {% endif %}
103
98
 
104
99
  {% endmacro %}