@content-blocks/js 0.5.0 → 0.7.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 (136) hide show
  1. package/dist/cjs/content-accordion_11.cjs.entry.js +79 -61
  2. package/dist/cjs/content-accordion_11.cjs.entry.js.map +1 -1
  3. package/dist/cjs/content-blocks.cjs.js +2 -2
  4. package/dist/cjs/content-carousel.cjs.entry.js +2 -1
  5. package/dist/cjs/content-carousel.cjs.entry.js.map +1 -1
  6. package/dist/cjs/content-navigation-block.cjs.entry.js +24 -20
  7. package/dist/cjs/content-navigation-block.cjs.entry.js.map +1 -1
  8. package/dist/cjs/content-split-block.cjs.entry.js +4 -4
  9. package/dist/cjs/content-split-block.cjs.entry.js.map +1 -1
  10. package/dist/cjs/content-tabs.cjs.entry.js +3 -3
  11. package/dist/cjs/{index-072153fb.js → index-9f20d89a.js} +34 -4
  12. package/dist/cjs/index-9f20d89a.js.map +1 -0
  13. package/dist/cjs/index.cjs.js +1 -1
  14. package/dist/cjs/loader.cjs.js +2 -2
  15. package/dist/cjs/{utils-9856e159.js → utils-db61cd70.js} +1 -3
  16. package/dist/cjs/utils-db61cd70.js.map +1 -0
  17. package/dist/cjs/{window-resize-service-77b2c64e.js → window-resize-service-ac5c2012.js} +2 -2
  18. package/dist/cjs/{window-resize-service-77b2c64e.js.map → window-resize-service-ac5c2012.js.map} +1 -1
  19. package/dist/collection/blocks/content-hero-block/content-hero-block.css +6 -0
  20. package/dist/collection/blocks/content-split-block/content-split-block.js +1 -1
  21. package/dist/collection/blocks/content-split-block/content-split-block.js.map +1 -1
  22. package/dist/collection/blocks/content-text-block/content-text-block.css +8 -8
  23. package/dist/collection/blocks/content-text-block/content-text-block.js +4 -4
  24. package/dist/collection/blocks/content-text-block/content-text-block.js.map +1 -1
  25. package/dist/collection/components/content-accordion/content-accordion.js +4 -6
  26. package/dist/collection/components/content-accordion/content-accordion.js.map +1 -1
  27. package/dist/collection/components/content-carousel/content-carousel.js +1 -0
  28. package/dist/collection/components/content-carousel/content-carousel.js.map +1 -1
  29. package/dist/collection/components/content-navigation-block/content-navigation-block.js +21 -17
  30. package/dist/collection/components/content-navigation-block/content-navigation-block.js.map +1 -1
  31. package/dist/collection/components/content-overlay/content-overlay.css +12 -9
  32. package/dist/collection/components/content-overlay/content-overlay.js +32 -17
  33. package/dist/collection/components/content-overlay/content-overlay.js.map +1 -1
  34. package/dist/collection/elements/content-button/content-button.js +2 -6
  35. package/dist/collection/elements/content-button/content-button.js.map +1 -1
  36. package/dist/collection/elements/content-image/content-image.css +4 -7
  37. package/dist/collection/elements/content-image/content-image.js +82 -21
  38. package/dist/collection/elements/content-image/content-image.js.map +1 -1
  39. package/dist/collection/formatters/content-grid-formatter/content-grid-formatter.css +1 -0
  40. package/dist/collection/formatters/content-grid-formatter/content-grid-formatter.js +58 -15
  41. package/dist/collection/formatters/content-grid-formatter/content-grid-formatter.js.map +1 -1
  42. package/dist/collection/formatters/content-spacer/content-spacer.css +16 -3
  43. package/dist/collection/formatters/content-spacer/content-spacer.js +47 -5
  44. package/dist/collection/formatters/content-spacer/content-spacer.js.map +1 -1
  45. package/dist/collection/stories/ContentHeroBlock.stories.js +2 -2
  46. package/dist/collection/stories/ContentHeroBlock.stories.js.map +1 -1
  47. package/dist/collection/stories/FullPageExample.stories.js +11 -11
  48. package/dist/collection/stories/FullPageExample.stories.js.map +1 -1
  49. package/dist/components/content-accordion.js +3 -4
  50. package/dist/components/content-accordion.js.map +1 -1
  51. package/dist/components/content-button.js +3 -6
  52. package/dist/components/content-button.js.map +1 -1
  53. package/dist/components/content-carousel.js +2 -0
  54. package/dist/components/content-carousel.js.map +1 -1
  55. package/dist/components/content-grid-formatter2.js +19 -12
  56. package/dist/components/content-grid-formatter2.js.map +1 -1
  57. package/dist/components/content-hero-block.js +2 -1
  58. package/dist/components/content-hero-block.js.map +1 -1
  59. package/dist/components/content-image.js +30 -22
  60. package/dist/components/content-image.js.map +1 -1
  61. package/dist/components/content-line.js +1 -0
  62. package/dist/components/content-line.js.map +1 -1
  63. package/dist/components/content-navigation-block.js +22 -17
  64. package/dist/components/content-navigation-block.js.map +1 -1
  65. package/dist/components/content-overlay.js +29 -13
  66. package/dist/components/content-overlay.js.map +1 -1
  67. package/dist/components/content-spacer.js +8 -4
  68. package/dist/components/content-spacer.js.map +1 -1
  69. package/dist/components/content-split-block.js +2 -1
  70. package/dist/components/content-split-block.js.map +1 -1
  71. package/dist/components/content-tabs.js +1 -0
  72. package/dist/components/content-tabs.js.map +1 -1
  73. package/dist/components/content-text-block.js +5 -4
  74. package/dist/components/content-text-block.js.map +1 -1
  75. package/dist/components/content-tout-block.js +1 -0
  76. package/dist/components/content-tout-block.js.map +1 -1
  77. package/dist/components/content-video.js +1 -0
  78. package/dist/components/content-video.js.map +1 -1
  79. package/dist/components/utils.js +1 -1
  80. package/dist/components/utils.js.map +1 -1
  81. package/dist/content-blocks/content-blocks.esm.js +1 -1
  82. package/dist/content-blocks/content-blocks.esm.js.map +1 -1
  83. package/dist/content-blocks/index.esm.js +1 -1
  84. package/dist/content-blocks/p-24657e66.entry.js +10 -0
  85. package/dist/content-blocks/p-24657e66.entry.js.map +1 -0
  86. package/dist/content-blocks/{p-30ab003a.entry.js → p-271fb304.entry.js} +2 -2
  87. package/dist/content-blocks/p-271fb304.entry.js.map +1 -0
  88. package/dist/content-blocks/p-288eace9.js +3 -0
  89. package/dist/content-blocks/p-288eace9.js.map +1 -0
  90. package/dist/content-blocks/{p-fd14acd9.entry.js → p-4bfbd7ef.entry.js} +2 -2
  91. package/dist/content-blocks/{p-fd14acd9.entry.js.map → p-4bfbd7ef.entry.js.map} +1 -1
  92. package/dist/content-blocks/{p-ebaee21f.entry.js → p-6a177aef.entry.js} +2 -2
  93. package/dist/content-blocks/{p-ebaee21f.entry.js.map → p-6a177aef.entry.js.map} +1 -1
  94. package/dist/content-blocks/{p-2c515f18.entry.js → p-8cc22c1e.entry.js} +2 -2
  95. package/dist/content-blocks/{p-da2c36ea.js → p-b04fe808.js} +2 -2
  96. package/dist/content-blocks/{p-da2c36ea.js.map → p-b04fe808.js.map} +1 -1
  97. package/dist/content-blocks/{p-3b4b9ad1.js → p-cfb4593f.js} +2 -2
  98. package/dist/esm/content-accordion_11.entry.js +79 -61
  99. package/dist/esm/content-accordion_11.entry.js.map +1 -1
  100. package/dist/esm/content-blocks.js +3 -3
  101. package/dist/esm/content-carousel.entry.js +2 -1
  102. package/dist/esm/content-carousel.entry.js.map +1 -1
  103. package/dist/esm/content-navigation-block.entry.js +24 -20
  104. package/dist/esm/content-navigation-block.entry.js.map +1 -1
  105. package/dist/esm/content-split-block.entry.js +4 -4
  106. package/dist/esm/content-split-block.entry.js.map +1 -1
  107. package/dist/esm/content-tabs.entry.js +3 -3
  108. package/dist/esm/{index-5c31f78b.js → index-e848c048.js} +34 -4
  109. package/dist/esm/index-e848c048.js.map +1 -0
  110. package/dist/esm/index.js +1 -1
  111. package/dist/esm/loader.js +3 -3
  112. package/dist/esm/{utils-4f29a9cf.js → utils-4f78228e.js} +2 -2
  113. package/dist/esm/utils-4f78228e.js.map +1 -0
  114. package/dist/esm/{window-resize-service-332e7420.js → window-resize-service-f40ec51c.js} +2 -2
  115. package/dist/esm/{window-resize-service-332e7420.js.map → window-resize-service-f40ec51c.js.map} +1 -1
  116. package/dist/types/blocks/content-text-block/content-text-block.d.ts +1 -1
  117. package/dist/types/components/content-accordion/content-accordion.d.ts +6 -7
  118. package/dist/types/components/content-overlay/content-overlay.d.ts +6 -4
  119. package/dist/types/components.d.ts +67 -15
  120. package/dist/types/elements/content-button/content-button.d.ts +2 -2
  121. package/dist/types/elements/content-image/content-image.d.ts +13 -0
  122. package/dist/types/formatters/content-grid-formatter/content-grid-formatter.d.ts +10 -4
  123. package/dist/types/formatters/content-spacer/content-spacer.d.ts +11 -2
  124. package/dist/types/typings.d.ts +3 -3
  125. package/package.json +1 -1
  126. package/dist/cjs/index-072153fb.js.map +0 -1
  127. package/dist/cjs/utils-9856e159.js.map +0 -1
  128. package/dist/content-blocks/p-2faf0c78.js +0 -3
  129. package/dist/content-blocks/p-2faf0c78.js.map +0 -1
  130. package/dist/content-blocks/p-30ab003a.entry.js.map +0 -1
  131. package/dist/content-blocks/p-b8009321.entry.js +0 -10
  132. package/dist/content-blocks/p-b8009321.entry.js.map +0 -1
  133. package/dist/esm/index-5c31f78b.js.map +0 -1
  134. package/dist/esm/utils-4f29a9cf.js.map +0 -1
  135. /package/dist/content-blocks/{p-2c515f18.entry.js.map → p-8cc22c1e.entry.js.map} +0 -0
  136. /package/dist/content-blocks/{p-3b4b9ad1.js.map → p-cfb4593f.js.map} +0 -0
@@ -14,30 +14,41 @@ export class ContentOverlay {
14
14
  this.open = 'false';
15
15
  this.fullScreen = 'true';
16
16
  this.classes = undefined;
17
- this.horizontalAlignment = 'center';
18
- this.verticalAlignment = 'center';
17
+ this.horizontal = 'center';
18
+ this.vertical = 'center';
19
19
  this.closeTitle = 'Close Overlay';
20
20
  this.isActive = false;
21
21
  this.activeClass = '';
22
22
  this.classString = '';
23
23
  this.contentSlot = undefined;
24
24
  this.isFullScreen = false;
25
+ this.hasCloseButton = false;
26
+ this.originalMarkup = undefined;
25
27
  }
26
28
  onContentBlockActivated(event) {
27
29
  if (this.hostElement.getAttribute('id') === event.detail.getAttribute('id')) {
28
30
  event.preventDefault();
29
- this.openOverlay();
31
+ if (!this.isActive) {
32
+ this.openOverlay();
33
+ }
34
+ else {
35
+ this.closeOverlay();
36
+ }
30
37
  }
31
38
  }
32
39
  async openOverlay() {
33
- if (this.isActive) {
34
- return false;
35
- }
40
+ // if (this.isActive) {
41
+ // return false;
42
+ // }
36
43
  this.isActive = true;
44
+ if (!this.originalMarkup) {
45
+ this.originalMarkup = this.contentSlot.querySelector('[slot="content"]').innerHTML;
46
+ }
37
47
  if (this.target) {
38
48
  let targetElement = document.getElementById(this.target);
39
49
  if (targetElement) {
40
50
  targetElement.classList.add('content-block-overlay-container');
51
+ targetElement.appendChild(this.hostElement);
41
52
  }
42
53
  }
43
54
  else if (this.isFullScreen) {
@@ -46,6 +57,7 @@ export class ContentOverlay {
46
57
  }
47
58
  }
48
59
  if (this.contentSlot) {
60
+ this.contentSlot.innerHTML = this.originalMarkup;
49
61
  this.setComputedActiveClass();
50
62
  if (this.isFullScreen) {
51
63
  this.focusTrap = focusTrap.createFocusTrap(this.hostElement, {
@@ -60,6 +72,7 @@ export class ContentOverlay {
60
72
  this.contentOverlayActivated.emit(this.hostElement);
61
73
  }
62
74
  async closeOverlay() {
75
+ this.contentSlot.innerHTML = '';
63
76
  this.isActive = false;
64
77
  this.activeClass = '';
65
78
  if (this.focusTrap) {
@@ -82,11 +95,10 @@ export class ContentOverlay {
82
95
  this.activeClass = `content-overlay ${this.isActive ? 'content-overlay-active' : 'content-overlay-inactive'} content-overlay--${positioningValue}`;
83
96
  }
84
97
  componentWillLoad() {
85
- this.contentSlot = this.hostElement.querySelector('[slot="content"]');
86
98
  this.contentElement = this.hostElement.querySelector('.js-content-overlay-content');
87
99
  WindowResizeService.registerProp(this.classes).subscribe(newValue => (this.classString = `${newValue}`));
88
- WindowResizeService.registerProp(this.horizontalAlignment).subscribe(newValue => this.hostElement.setAttribute('horizontal-alignment', newValue));
89
- WindowResizeService.registerProp(this.verticalAlignment).subscribe(newValue => this.hostElement.setAttribute('vertical-alignment', newValue));
100
+ WindowResizeService.registerProp(this.horizontal).subscribe(newValue => this.hostElement.setAttribute('horizontal', newValue));
101
+ WindowResizeService.registerProp(this.vertical).subscribe(newValue => this.hostElement.setAttribute('vertical', newValue));
90
102
  WindowResizeService.registerProp(this.fullScreen).subscribe(newValue => {
91
103
  if (!this.target)
92
104
  this.isFullScreen = newValue === 'true';
@@ -94,13 +106,14 @@ export class ContentOverlay {
94
106
  WindowResizeService.registerProp(this.open).subscribe(newValue => {
95
107
  this.hostElement.setAttribute('open', newValue);
96
108
  });
109
+ this.hasCloseButton = !!this.hostElement.querySelector('[slot="closeButton"]');
97
110
  }
98
111
  closeOverlayButtonClicked(event) {
99
112
  event.preventDefault();
100
113
  this.closeOverlay();
101
114
  }
102
115
  render() {
103
- return (h(Host, { class: `${this.activeClass} ${this.classString}` }, h("div", { class: "content-block-overlay-container" }, h("div", { class: `content-overlay-background ${this.isActive ? 'active' : ''}` }, h("div", { ref: element => (this.dialogElement = element), role: "dialog", "aria-modal": "true", class: this.isActive ? 'active' : 'hidden', "aria-expanded": this.isActive }, h("div", { class: "content-overlay__header" }, h("button", { onClick: e => this.closeOverlayButtonClicked(e), class: "content-overlay__close", title: this.closeTitle }, h("slot", { name: "closeButton" })), h("slot", { name: "header" })), h("div", { class: "js-content-overlay-content content-overlay__content" }, h("slot", { name: "content" })))))));
116
+ return (h(Host, { class: `${this.activeClass} ${this.classString}` }, h("div", { class: "content-block-overlay-container" }, h("div", { class: `content-overlay-background ${this.isActive ? 'active' : ''}` }, h("div", { ref: element => (this.dialogElement = element), role: "dialog", "aria-modal": "true", class: this.isActive ? 'active' : 'hidden', "aria-expanded": this.isActive }, h("div", { class: "content-overlay__header" }, h("button", { onClick: e => this.closeOverlayButtonClicked(e), class: "content-overlay__close", title: this.closeTitle }, !this.hasCloseButton && (h("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", width: "16", height: "16", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M6 18 18 6M6 6l12 12" }))), h("slot", { name: "closeButton" })), h("slot", { name: "header" })), h("div", { class: "content-overlay__content", ref: (el) => (this.contentSlot = el) }, h("slot", { name: "content" })))))));
104
117
  }
105
118
  componentDidRender() {
106
119
  if (this.open === 'true') {
@@ -240,7 +253,7 @@ export class ContentOverlay {
240
253
  "attribute": "classes",
241
254
  "reflect": false
242
255
  },
243
- "horizontalAlignment": {
256
+ "horizontal": {
244
257
  "type": "string",
245
258
  "mutable": true,
246
259
  "complexType": {
@@ -278,11 +291,11 @@ export class ContentOverlay {
278
291
  }],
279
292
  "text": "A pipe delimited setting for horizontal alignment. This only applies when fullscreen mode is activated."
280
293
  },
281
- "attribute": "horizontal-alignment",
294
+ "attribute": "horizontal",
282
295
  "reflect": true,
283
296
  "defaultValue": "'center'"
284
297
  },
285
- "verticalAlignment": {
298
+ "vertical": {
286
299
  "type": "string",
287
300
  "mutable": true,
288
301
  "complexType": {
@@ -314,7 +327,7 @@ export class ContentOverlay {
314
327
  }],
315
328
  "text": "A pipe delimited setting for vertical alignment. This only applies when fullscreen mode is activated."
316
329
  },
317
- "attribute": "vertical-alignment",
330
+ "attribute": "vertical",
318
331
  "reflect": true,
319
332
  "defaultValue": "'center'"
320
333
  },
@@ -347,7 +360,9 @@ export class ContentOverlay {
347
360
  "activeClass": {},
348
361
  "classString": {},
349
362
  "contentSlot": {},
350
- "isFullScreen": {}
363
+ "isFullScreen": {},
364
+ "hasCloseButton": {},
365
+ "originalMarkup": {}
351
366
  };
352
367
  }
353
368
  static get events() {
@@ -377,7 +392,7 @@ export class ContentOverlay {
377
392
  return {
378
393
  "openOverlay": {
379
394
  "complexType": {
380
- "signature": "() => Promise<boolean>",
395
+ "signature": "() => Promise<void>",
381
396
  "parameters": [],
382
397
  "references": {
383
398
  "Promise": {
@@ -385,7 +400,7 @@ export class ContentOverlay {
385
400
  "id": "global::Promise"
386
401
  }
387
402
  },
388
- "return": "Promise<boolean>"
403
+ "return": "Promise<void>"
389
404
  },
390
405
  "docs": {
391
406
  "text": "",
@@ -1 +1 @@
1
- {"version":3,"file":"content-overlay.js","sourceRoot":"","sources":["../../../../src/components/content-overlay/content-overlay.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,EAAE,KAAK,EAAoC,MAAM,EAAS,MAAM,wBAAwB,CAAC;AAChG,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAG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CAAC;IACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Prop, State, Listen, Element } from '@stencil/core';\nimport { Event, EventEmitter, HTMLStencilElement, Method, Watch } from '@stencil/core/internal';\nimport { WindowResizeService } from '../../services/window-resize-service';\nimport { ContentLineTextAlignOptions, ContentVerticalAlignments, ResponsiveBoolean, ResponsiveString } from '../../typings';\nimport { getCurrentValue } from '../../utils/utils';\nimport * as focusTrap from 'focus-trap';\nimport './libraries/aria-utilities';\nimport './libraries/aria-dialog';\n/**\n * @slot closeButton - Contents of the overlay close button.\n * @slot header - This is adjacent to the close button, usually a header or title for the overlay.\n * @slot content - Contents that sit inside the overlay.\n */\n@Component({\n tag: 'content-overlay',\n styleUrl: 'content-overlay.scss',\n shadow: false,\n})\nexport class ContentOverlay {\n @Element() hostElement: HTMLStencilElement;\n /**\n * @type String\n * @responsive\n */\n @Prop() target: string;\n\n /**\n * @type Boolean\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n open: ResponsiveBoolean = 'false';\n /**\n * @type Boolean\n * @responsive\n */\n @Prop() fullScreen: ResponsiveBoolean = 'true';\n /**\n * @type String\n * @responsive\n */\n @Prop() classes: ResponsiveString;\n /**\n * A pipe delimited setting for horizontal alignment. This only applies when fullscreen mode is activated.\n * @type Select\n * @options default\n * @options left\n * @options center\n * @options right\n * @responsive\n */\n @Prop({\n reflect: true,\n mutable: true,\n })\n horizontalAlignment: ContentLineTextAlignOptions = 'center';\n /**\n * A pipe delimited setting for vertical alignment. This only applies when fullscreen mode is activated.\n * @type Select\n * @options top\n * @options center\n * @options bottom\n */\n @Prop({\n reflect: true,\n mutable: true,\n })\n verticalAlignment: ContentVerticalAlignments = 'center';\n\n /**\n * Title attribute value for the close button.\n * @type String\n */\n @Prop() closeTitle: string = 'Close Overlay';\n\n @State() isActive: boolean = false;\n @State() activeClass: string = '';\n @State() classString: string = '';\n @Event({\n bubbles: true,\n })\n contentOverlayActivated: EventEmitter<HTMLElement>;\n\n @State() contentSlot: HTMLTemplateElement;\n\n dialogElement: HTMLDivElement;\n contentElement: HTMLDivElement;\n\n @State() isFullScreen: boolean = false;\n ariaDialog;\n focusTrap;\n @Listen('contentBlockActivated')\n onContentBlockActivated(event: CustomEvent) {\n if (this.hostElement.getAttribute('id') === event.detail.getAttribute('id')) {\n event.preventDefault();\n this.openOverlay();\n }\n }\n\n @Method()\n async openOverlay() {\n if (this.isActive) {\n return false;\n }\n this.isActive = true;\n if (this.target) {\n let targetElement = document.getElementById(this.target);\n if (targetElement) {\n targetElement.classList.add('content-block-overlay-container');\n }\n } else if (this.isFullScreen) {\n if (document.querySelectorAll(`#${this.hostElement.getAttribute('id')}`).length === 1) {\n document.body.appendChild(this.hostElement);\n }\n }\n if (this.contentSlot) {\n this.setComputedActiveClass();\n if (this.isFullScreen) {\n this.focusTrap = focusTrap.createFocusTrap(this.hostElement, {\n fallbackFocus: this.hostElement,\n onDeactivate: () => {\n this.isActive = false;\n this.setComputedActiveClass();\n },\n });\n }\n }\n this.contentOverlayActivated.emit(this.hostElement);\n }\n\n @Method()\n async closeOverlay() {\n this.isActive = false;\n this.activeClass = '';\n if (this.focusTrap) {\n try {\n this.focusTrap.deactivate();\n } catch (e) {\n console.log(e);\n }\n }\n }\n\n setComputedActiveClass() {\n let positioningValue = 'static';\n if (this.target) {\n positioningValue = 'absolute';\n }\n if (this.isFullScreen) {\n positioningValue = 'fullscreen';\n }\n this.activeClass = `content-overlay ${this.isActive ? 'content-overlay-active' : 'content-overlay-inactive'} content-overlay--${positioningValue}`;\n }\n\n componentWillLoad() {\n this.contentSlot = this.hostElement.querySelector('[slot=\"content\"]');\n this.contentElement = this.hostElement.querySelector('.js-content-overlay-content');\n\n WindowResizeService.registerProp(this.classes).subscribe(newValue => (this.classString = `${newValue}`));\n\n WindowResizeService.registerProp(this.horizontalAlignment).subscribe(newValue =>\n this.hostElement.setAttribute('horizontal-alignment', newValue as ContentLineTextAlignOptions),\n );\n WindowResizeService.registerProp(this.verticalAlignment).subscribe(newValue => this.hostElement.setAttribute('vertical-alignment', newValue as ContentVerticalAlignments));\n WindowResizeService.registerProp(this.fullScreen).subscribe(newValue => {\n if (!this.target) this.isFullScreen = (newValue as string) === 'true';\n });\n WindowResizeService.registerProp(this.open).subscribe(newValue => {\n this.hostElement.setAttribute('open', newValue as string);\n });\n }\n\n closeOverlayButtonClicked(event) {\n event.preventDefault();\n this.closeOverlay();\n }\n\n render() {\n return (\n <Host class={`${this.activeClass} ${this.classString}`}>\n <div class=\"content-block-overlay-container\">\n <div class={`content-overlay-background ${this.isActive ? 'active' : ''}`}>\n <div ref={element => (this.dialogElement = element)} role=\"dialog\" aria-modal=\"true\" class={this.isActive ? 'active' : 'hidden'} aria-expanded={this.isActive}>\n <div class=\"content-overlay__header\">\n <button onClick={e => this.closeOverlayButtonClicked(e)} class=\"content-overlay__close\" title={this.closeTitle}>\n <slot name=\"closeButton\"></slot>\n </button>\n <slot name=\"header\"></slot>\n </div>\n <div class=\"js-content-overlay-content content-overlay__content\">\n <slot name=\"content\"></slot>\n </div>\n </div>\n </div>\n </div>\n </Host>\n );\n }\n\n componentDidRender() {\n if (this.open === 'true') {\n this.openOverlay();\n }\n if (this.isActive && this.focusTrap && !this.focusTrap.active) {\n try {\n this.focusTrap.activate();\n } catch (e) {\n console.log(e);\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"content-overlay.js","sourceRoot":"","sources":["../../../../src/components/content-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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Prop, State, Listen, Element } from '@stencil/core';\nimport { Event, EventEmitter, HTMLStencilElement, Method, Watch } from '@stencil/core/internal';\nimport { WindowResizeService } from '../../services/window-resize-service';\nimport { ContentLineTextAlignOptions, ContentVerticalAlignments, ResponsiveBoolean, ResponsiveString } from '../../typings';\nimport { getCurrentValue } from '../../utils/utils';\nimport * as focusTrap from 'focus-trap';\nimport './libraries/aria-utilities';\nimport './libraries/aria-dialog';\n/**\n * @slot closeButton - Contents of the overlay close button.\n * @slot header - This is adjacent to the close button, usually a header or title for the overlay.\n * @slot content - Contents that sit inside the overlay.\n */\n@Component({\n tag: 'content-overlay',\n styleUrl: 'content-overlay.scss',\n shadow: false,\n})\nexport class ContentOverlay {\n @Element() hostElement: HTMLStencilElement;\n /**\n * @type String\n * @responsive\n */\n @Prop() target: string;\n\n /**\n * @type Boolean\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n open: ResponsiveBoolean = 'false';\n /**\n * @type Boolean\n * @responsive\n */\n @Prop() fullScreen: ResponsiveBoolean = 'true';\n /**\n * @type String\n * @responsive\n */\n @Prop() classes: ResponsiveString;\n /**\n * A pipe delimited setting for horizontal alignment. This only applies when fullscreen mode is activated.\n * @type Select\n * @options default\n * @options left\n * @options center\n * @options right\n * @responsive\n */\n @Prop({\n reflect: true,\n mutable: true,\n })\n horizontal: ContentLineTextAlignOptions = 'center';\n /**\n * A pipe delimited setting for vertical alignment. This only applies when fullscreen mode is activated.\n * @type Select\n * @options top\n * @options center\n * @options bottom\n */\n @Prop({\n reflect: true,\n mutable: true,\n })\n vertical: ContentVerticalAlignments = 'center';\n\n /**\n * Title attribute value for the close button.\n * @type String\n */\n @Prop() closeTitle: string = 'Close Overlay';\n\n @State() isActive: boolean = false;\n @State() activeClass: string = '';\n @State() classString: string = '';\n @Event({\n bubbles: true,\n })\n contentOverlayActivated: EventEmitter<HTMLElement>;\n\n @State() contentSlot: HTMLElement;\n\n dialogElement: HTMLDivElement;\n contentElement: HTMLDivElement;\n\n @State() isFullScreen: boolean = false;\n @State() hasCloseButton: boolean = false;\n @State() originalMarkup: string;\n ariaDialog;\n focusTrap;\n @Listen('contentBlockActivated')\n onContentBlockActivated(event: CustomEvent) {\n if (this.hostElement.getAttribute('id') === event.detail.getAttribute('id')) {\n event.preventDefault();\n if (!this.isActive) {\n this.openOverlay();\n } else {\n this.closeOverlay();\n }\n }\n }\n\n @Method()\n async openOverlay() {\n // if (this.isActive) {\n // return false;\n // }\n this.isActive = true;\n if (!this.originalMarkup) {\n this.originalMarkup = this.contentSlot.querySelector('[slot=\"content\"]').innerHTML;\n }\n if (this.target) {\n let targetElement = document.getElementById(this.target);\n if (targetElement) {\n targetElement.classList.add('content-block-overlay-container');\n targetElement.appendChild(this.hostElement);\n }\n } else if (this.isFullScreen) {\n if (document.querySelectorAll(`#${this.hostElement.getAttribute('id')}`).length === 1) {\n document.body.appendChild(this.hostElement);\n }\n }\n if (this.contentSlot) {\n this.contentSlot.innerHTML = this.originalMarkup;\n this.setComputedActiveClass();\n if (this.isFullScreen) {\n this.focusTrap = focusTrap.createFocusTrap(this.hostElement, {\n fallbackFocus: this.hostElement,\n onDeactivate: () => {\n this.isActive = false;\n this.setComputedActiveClass();\n },\n });\n }\n }\n this.contentOverlayActivated.emit(this.hostElement);\n }\n\n @Method()\n async closeOverlay() {\n this.contentSlot.innerHTML = '';\n this.isActive = false;\n this.activeClass = '';\n if (this.focusTrap) {\n try {\n this.focusTrap.deactivate();\n } catch (e) {\n console.log(e);\n }\n }\n }\n\n setComputedActiveClass() {\n let positioningValue = 'static';\n if (this.target) {\n positioningValue = 'absolute';\n }\n if (this.isFullScreen) {\n positioningValue = 'fullscreen';\n }\n this.activeClass = `content-overlay ${this.isActive ? 'content-overlay-active' : 'content-overlay-inactive'} content-overlay--${positioningValue}`;\n }\n\n componentWillLoad() {\n this.contentElement = this.hostElement.querySelector('.js-content-overlay-content');\n\n WindowResizeService.registerProp(this.classes).subscribe(newValue => (this.classString = `${newValue}`));\n\n WindowResizeService.registerProp(this.horizontal).subscribe(newValue => this.hostElement.setAttribute('horizontal', newValue as ContentLineTextAlignOptions));\n WindowResizeService.registerProp(this.vertical).subscribe(newValue => this.hostElement.setAttribute('vertical', newValue as ContentVerticalAlignments));\n WindowResizeService.registerProp(this.fullScreen).subscribe(newValue => {\n if (!this.target) this.isFullScreen = (newValue as string) === 'true';\n });\n WindowResizeService.registerProp(this.open).subscribe(newValue => {\n this.hostElement.setAttribute('open', newValue as string);\n });\n this.hasCloseButton = !!this.hostElement.querySelector('[slot=\"closeButton\"]');\n }\n\n closeOverlayButtonClicked(event) {\n event.preventDefault();\n this.closeOverlay();\n }\n\n render() {\n return (\n <Host class={`${this.activeClass} ${this.classString}`}>\n <div class=\"content-block-overlay-container\">\n <div class={`content-overlay-background ${this.isActive ? 'active' : ''}`}>\n <div ref={element => (this.dialogElement = element)} role=\"dialog\" aria-modal=\"true\" class={this.isActive ? 'active' : 'hidden'} aria-expanded={this.isActive}>\n <div class=\"content-overlay__header\">\n <button onClick={e => this.closeOverlayButtonClicked(e)} class=\"content-overlay__close\" title={this.closeTitle}>\n {!this.hasCloseButton && (\n <svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M6 18 18 6M6 6l12 12\" />\n </svg>\n )}\n <slot name=\"closeButton\"></slot>\n </button>\n <slot name=\"header\"></slot>\n </div>\n <div class=\"content-overlay__content\" ref={(el: HTMLDivElement) => (this.contentSlot = el)}>\n <slot name=\"content\"></slot>\n </div>\n </div>\n </div>\n </div>\n </Host>\n );\n }\n\n componentDidRender() {\n if (this.open === 'true') {\n this.openOverlay();\n }\n if (this.isActive && this.focusTrap && !this.focusTrap.active) {\n try {\n this.focusTrap.activate();\n } catch (e) {\n console.log(e);\n }\n }\n }\n}\n"]}
@@ -33,21 +33,17 @@ export class ContentButton {
33
33
  });
34
34
  }
35
35
  onHandleClickEvent(ev) {
36
- console.log(ev);
37
36
  if (this.hasContentToActivate) {
38
- console.log('this.hascontenttoactivate');
39
37
  ev.preventDefault();
40
- ev.stopPropagation();
38
+ // ev.stopPropagation();
41
39
  this.activatedContent.dispatchEvent(new CustomEvent('contentBlockActivated', { detail: this.activatedContent }));
42
40
  this.activatedContent.scrollIntoView({ behavior: 'smooth' });
43
41
  }
44
42
  else if (this.href && this.href.length > 1 && this.href.substring(0, 1) === '#') {
45
43
  let element = document.getElementById(this.href.substring(1));
46
- console.log(this.href.substring(1));
47
44
  if (element) {
48
45
  ev.preventDefault();
49
- ev.stopPropagation();
50
- console.log(element);
46
+ // ev.stopPropagation();
51
47
  element.dispatchEvent(new CustomEvent('contentBlockActivated', { detail: element }));
52
48
  // element.scrollIntoView({ behavior: 'smooth' });
53
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"content-button.js","sourceRoot":"","sources":["../../../../src/elements/content-button/content-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,OAAO,EAAsB,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAG3E;;;;GAIG;AAMH,MAAM,OAAO,aAAa;;;;uBAmBN,EAAE;2BACG,EAAE;8BAIS,KAAK;;;;;;;IAmCvC,iBAAiB;QACf,IAAI,CAAC,gBAAgB,GAAG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CACC;YACJ,YAAM,IAAI,EAAC,kBAAkB,GAAQ,CAChC,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Host, Prop } from '@stencil/core';\nimport { Element, HTMLStencilElement, State } from '@stencil/core/internal';\nimport { WindowResizeService } from '../../services/window-resize-service';\nimport { ResponsiveString } from '../../typings';\n\n/**\n * @slot content - Inner contents of the button, usually plaintext.\n * @slot - Default slot, same as content slot.\n * @slot activatedContent - If this slot is used, the content in this will be scrolled to and triggered.\n */\n@Component({\n tag: 'content-button',\n styleUrl: 'content-button.scss',\n shadow: false,\n})\nexport class ContentButton {\n @Element() hostElement: HTMLStencilElement;\n /**\n * @type URL\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n href: string;\n /**\n * @type String\n */\n @Prop() target: string;\n /**\n * The classes for the button.\n * @type String\n * @responsive\n */\n @Prop() classes = '';\n @State() classString = '';\n /**\n * @type Boolean\n */\n @Prop() clickableBlock: boolean = false;\n /**\n * @type Boolean\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n expanded: string;\n /**\n\n /**\n * Aria-controls value\n * @type Target\n */\n @Prop() controls: string;\n\n /**\n * @type String\n * @responsive\n */\n @Prop() linkLabel: ResponsiveString;\n /**\n * @type String\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n linkClass: ResponsiveString;\n @State() hasContentToActivate: boolean;\n\n public activatedContent: HTMLDivElement;\n\n componentWillLoad() {\n this.activatedContent = this.hostElement.querySelector('[slot=\"activatedContent\"]');\n this.hasContentToActivate = !!this.activatedContent;\n // If this is a clickable block, forcefully add a # to force an anchor link\n if (!this.href || this.href === '#') {\n this.href = 'javascript:void(0);';\n }\n\n WindowResizeService.registerProp(this.linkClass).subscribe(newValue => {\n this.linkClass = newValue as string;\n });\n\n WindowResizeService.registerProp(this.classes).subscribe(newValue => {\n this.classString = newValue as string;\n });\n }\n\n onHandleClickEvent(ev) {\n console.log(ev);\n if (this.hasContentToActivate) {\n console.log('this.hascontenttoactivate');\n ev.preventDefault();\n ev.stopPropagation();\n this.activatedContent.dispatchEvent(new CustomEvent('contentBlockActivated', { detail: this.activatedContent }));\n this.activatedContent.scrollIntoView({ behavior: 'smooth' });\n } else if (this.href && this.href.length > 1 && this.href.substring(0, 1) === '#') {\n let element = document.getElementById(this.href.substring(1));\n console.log(this.href.substring(1));\n if (element) {\n ev.preventDefault();\n ev.stopPropagation();\n console.log(element);\n element.dispatchEvent(new CustomEvent('contentBlockActivated', { detail: element }));\n // element.scrollIntoView({ behavior: 'smooth' });\n }\n }\n }\n\n render() {\n return (\n <Host class={this.classString}>\n <a\n aria-label={this.linkLabel}\n class={this.linkClass}\n role={this.href === 'javascript:void(0);' ? 'button' : ''}\n onClick={ev => this.onHandleClickEvent(ev)}\n aria-expanded={this.expanded}\n aria-controls={this.controls}\n href={this.href}\n target={this.target}\n >\n {!this.clickableBlock ? (\n <span>\n <slot name=\"content\"></slot>\n <slot></slot>\n </span>\n ) : (\n <div class=\"content-button__clickable-content\">\n <slot name=\"content\"></slot>\n <slot></slot>\n </div>\n )}\n </a>\n <slot name=\"activatedContent\"></slot>\n </Host>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"content-button.js","sourceRoot":"","sources":["../../../../src/elements/content-button/content-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,OAAO,EAAmC,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Host, Prop } from '@stencil/core';\nimport { Element, HostElement, HTMLStencilElement, State } from '@stencil/core/internal';\nimport { WindowResizeService } from '../../services/window-resize-service';\nimport { ResponsiveString } from '../../typings';\n\n/**\n * @slot content - Inner contents of the button, usually plaintext.\n * @slot - Default slot, same as content slot.\n * @slot activatedContent - If this slot is used, the content in this will be scrolled to and triggered.\n */\n@Component({\n tag: 'content-button',\n styleUrl: 'content-button.scss',\n shadow: false,\n})\nexport class ContentButton {\n @Element() hostElement: HostElement;\n /**\n * @type URL\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n href: string;\n /**\n * @type String\n */\n @Prop() target: string;\n /**\n * The classes for the button.\n * @type String\n * @responsive\n */\n @Prop() classes = '';\n @State() classString = '';\n /**\n * @type Boolean\n */\n @Prop() clickableBlock: boolean = false;\n /**\n * @type Boolean\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n expanded: string;\n /**\n\n /**\n * Aria-controls value\n * @type Target\n */\n @Prop() controls: string;\n\n /**\n * @type String\n * @responsive\n */\n @Prop() linkLabel: ResponsiveString;\n /**\n * @type String\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n linkClass: ResponsiveString;\n @State() hasContentToActivate: boolean;\n\n public activatedContent: HTMLDivElement;\n\n componentWillLoad() {\n this.activatedContent = this.hostElement.querySelector('[slot=\"activatedContent\"]');\n this.hasContentToActivate = !!this.activatedContent;\n // If this is a clickable block, forcefully add a # to force an anchor link\n if (!this.href || this.href === '#') {\n this.href = 'javascript:void(0);';\n }\n\n WindowResizeService.registerProp(this.linkClass).subscribe(newValue => {\n this.linkClass = newValue as string;\n });\n\n WindowResizeService.registerProp(this.classes).subscribe(newValue => {\n this.classString = newValue as string;\n });\n }\n\n onHandleClickEvent(ev) {\n if (this.hasContentToActivate) {\n ev.preventDefault();\n // ev.stopPropagation();\n this.activatedContent.dispatchEvent(new CustomEvent('contentBlockActivated', { detail: this.activatedContent }));\n this.activatedContent.scrollIntoView({ behavior: 'smooth' });\n } else if (this.href && this.href.length > 1 && this.href.substring(0, 1) === '#') {\n let element = document.getElementById(this.href.substring(1));\n if (element) {\n ev.preventDefault();\n // ev.stopPropagation();\n element.dispatchEvent(new CustomEvent('contentBlockActivated', { detail: element }));\n // element.scrollIntoView({ behavior: 'smooth' });\n }\n }\n }\n\n render() {\n return (\n <Host class={this.classString}>\n <a\n aria-label={this.linkLabel}\n class={this.linkClass}\n role={this.href === 'javascript:void(0);' ? 'button' : ''}\n onClick={ev => this.onHandleClickEvent(ev)}\n aria-expanded={this.expanded}\n aria-controls={this.controls}\n href={this.href}\n target={this.target}\n >\n {!this.clickableBlock ? (\n <span>\n <slot name=\"content\"></slot>\n <slot></slot>\n </span>\n ) : (\n <div class=\"content-button__clickable-content\">\n <slot name=\"content\"></slot>\n <slot></slot>\n </div>\n )}\n </a>\n <slot name=\"activatedContent\"></slot>\n </Host>\n );\n }\n}\n"]}
@@ -14,6 +14,10 @@ content-image.content-image-loading {
14
14
  content-image.content-image-loaded {
15
15
  opacity: 1;
16
16
  }
17
+ content-image[aspect-ratio] img, content-image[aspect-ratio] picture, content-image[aspect-ratio] video {
18
+ aspect-ratio: var(--aspect-ratio);
19
+ object-fit: cover;
20
+ }
17
21
  content-image img,
18
22
  content-image picture,
19
23
  content-image video {
@@ -21,13 +25,6 @@ content-image video {
21
25
  width: 100%;
22
26
  height: 100%;
23
27
  }
24
- content-hero-block content-image img, content-grid-formatter content-image img,
25
- content-hero-block content-image picture,
26
- content-grid-formatter content-image picture,
27
- content-hero-block content-image video,
28
- content-grid-formatter content-image video {
29
- height: auto;
30
- }
31
28
  content-image .content-image__media-content {
32
29
  display: none;
33
30
  position: absolute;
@@ -1,6 +1,6 @@
1
1
  import { h, Host } from "@stencil/core";
2
2
  import { WindowResizeService } from "../../services/window-resize-service";
3
- import { breakpointValues, getValueAtIndex } from "../../utils/utils";
3
+ import { getCurrentValue } from "../../utils/utils";
4
4
  /**
5
5
  * @slot mediaContent - Content displayed over media. If you want to reveal content on hover, use a tout block
6
6
  */
@@ -13,6 +13,8 @@ export class ContentImage {
13
13
  this.alt = undefined;
14
14
  this.width = '16';
15
15
  this.height = '9';
16
+ this.aspectRatio = undefined;
17
+ this.type = 'image';
16
18
  this.videoType = 'video/mp4';
17
19
  this.showContent = 'false|true';
18
20
  this.lazyLoadIsComplete = false;
@@ -21,6 +23,7 @@ export class ContentImage {
21
23
  this.classString = '';
22
24
  this.inlineStyle = {};
23
25
  this.hasMediaContent = false;
26
+ this.pictureImageSrc = undefined;
24
27
  }
25
28
  preloadImage(src) {
26
29
  return new Promise(r => {
@@ -32,12 +35,8 @@ export class ContentImage {
32
35
  }
33
36
  componentWillLoad() {
34
37
  this.hasMediaContent = !!this.hostElement.querySelector('[slot="mediaContent"]');
35
- WindowResizeService.registerProp(this.src).subscribe(newValue => {
36
- this.showVideoAsGif = newValue.indexOf('.mp4') >= 0;
37
- if (!this.lazyLoadIsComplete) {
38
- this.lazyLoadIsComplete = true;
39
- }
40
- this.src = newValue;
38
+ WindowResizeService.registerProp(this.aspectRatio).subscribe(newValue => {
39
+ this.inlineStyle = Object.assign(Object.assign({}, this.inlineStyle), { '--aspect-ratio': `${newValue}` });
41
40
  });
42
41
  WindowResizeService.registerProp(this.alt).subscribe(newValue => {
43
42
  this.alt = newValue;
@@ -52,6 +51,23 @@ export class ContentImage {
52
51
  this.classString = `${newValue}`;
53
52
  });
54
53
  }
54
+ componentDidLoad() {
55
+ let observer = new IntersectionObserver(entries => {
56
+ entries.forEach(async (entry) => {
57
+ if (entry.isIntersecting) {
58
+ this.lazyLoadIsComplete = true;
59
+ this.pictureImageSrc = getCurrentValue(this.src);
60
+ this.showVideoAsGif = this.pictureImageSrc.indexOf('.mp4') >= 0 || getCurrentValue(this.type) === 'video';
61
+ }
62
+ });
63
+ }, {
64
+ root: null,
65
+ // rootMargin: `${Math.max(100, window.innerHeight * 0.95)}px`,
66
+ rootMargin: `0px`,
67
+ threshold: 0.1,
68
+ });
69
+ observer.observe(this.hostElement);
70
+ }
55
71
  watchLazyLoadIsComplete(newValue) {
56
72
  if (newValue === true) {
57
73
  this.activeLazyLoadClass = 'content-image-loaded';
@@ -66,19 +82,7 @@ export class ContentImage {
66
82
  }
67
83
  }
68
84
  render() {
69
- let pictureSrcSet = '';
70
- let pictureImageSrc = '';
71
- if (this.src) {
72
- breakpointValues.forEach((_bp, index) => {
73
- if (index === 0) {
74
- pictureImageSrc = getValueAtIndex(0, this.src);
75
- }
76
- else {
77
- pictureSrcSet += `${getValueAtIndex(index, this.src)} ${breakpointValues[index]}w,`;
78
- }
79
- });
80
- }
81
- return (h(Host, { class: `${this.activeLazyLoadClass} ${this.classString}`, style: this.inlineStyle, content: this.showContent }, this.hasMediaContent && (h("div", { class: "content-image__media-content" }, h("slot", { name: "mediaContent" }))), this.showVideoAsGif ? (h("video", { autoplay: true, muted: true, loop: true, preload: "none", playsinline: true, width: this.width, height: this.height }, h("source", { src: this.lazyLoadIsComplete ? this.src : null, type: this.videoType }))) : (h("picture", null, h("source", { srcSet: pictureSrcSet }), h("img", { width: this.width, height: this.height, src: pictureImageSrc, alt: this.alt })))));
85
+ return (h(Host, { class: `${this.activeLazyLoadClass} ${this.classString}`, style: this.inlineStyle, content: this.showContent }, this.hasMediaContent && (h("div", { class: "content-image__media-content" }, h("slot", { name: "mediaContent" }))), this.showVideoAsGif ? (h("video", { autoplay: true, muted: true, loop: true, preload: "none", playsinline: true, width: this.width, height: this.height }, h("source", { src: this.lazyLoadIsComplete ? this.pictureImageSrc : null, type: this.videoType }))) : (h("img", { width: this.width, height: this.height, src: this.pictureImageSrc, alt: this.alt }))));
82
86
  }
83
87
  static get is() { return "content-image"; }
84
88
  static get originalStyleUrls() {
@@ -261,6 +265,62 @@ export class ContentImage {
261
265
  "reflect": false,
262
266
  "defaultValue": "'9'"
263
267
  },
268
+ "aspectRatio": {
269
+ "type": "string",
270
+ "mutable": true,
271
+ "complexType": {
272
+ "original": "ResponsiveString",
273
+ "resolved": "string",
274
+ "references": {
275
+ "ResponsiveString": {
276
+ "location": "import",
277
+ "path": "../../typings",
278
+ "id": "src/typings.d.ts::ResponsiveString"
279
+ }
280
+ }
281
+ },
282
+ "required": false,
283
+ "optional": false,
284
+ "docs": {
285
+ "tags": [{
286
+ "name": "type",
287
+ "text": "String"
288
+ }, {
289
+ "name": "responsive",
290
+ "text": undefined
291
+ }],
292
+ "text": ""
293
+ },
294
+ "attribute": "aspect-ratio",
295
+ "reflect": false
296
+ },
297
+ "type": {
298
+ "type": "string",
299
+ "mutable": false,
300
+ "complexType": {
301
+ "original": "'image' | 'video'",
302
+ "resolved": "\"image\" | \"video\"",
303
+ "references": {}
304
+ },
305
+ "required": false,
306
+ "optional": true,
307
+ "docs": {
308
+ "tags": [{
309
+ "name": "type",
310
+ "text": "Select"
311
+ }, {
312
+ "name": "options",
313
+ "text": "image"
314
+ }, {
315
+ "name": "options",
316
+ "text": "video"
317
+ }],
318
+ "text": ""
319
+ },
320
+ "attribute": "type",
321
+ "reflect": false,
322
+ "defaultValue": "'image'"
323
+ },
264
324
  "videoType": {
265
325
  "type": "string",
266
326
  "mutable": false,
@@ -325,7 +385,8 @@ export class ContentImage {
325
385
  "activeLazyLoadClass": {},
326
386
  "classString": {},
327
387
  "inlineStyle": {},
328
- "hasMediaContent": {}
388
+ "hasMediaContent": {},
389
+ "pictureImageSrc": {}
329
390
  };
330
391
  }
331
392
  static get elementRef() { return "hostElement"; }
@@ -1 +1 @@
1
- {"version":3,"file":"content-image.js","sourceRoot":"","sources":["../../../../src/elements/content-image/content-image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Host, Element, Prop, State, Watch } from '@stencil/core';\nimport { HostElement } from '@stencil/core/internal';\nimport { WindowResizeService } from '../../services/window-resize-service';\nimport { ResponsiveBoolean, ResponsiveNumber, ResponsiveString } from '../../typings';\nimport { breakpointValues, getValueAtIndex } from '../../utils/utils';\n\n/**\n * @slot mediaContent - Content displayed over media. If you want to reveal content on hover, use a tout block\n */\n@Component({\n tag: 'content-image',\n styleUrl: 'content-image.scss',\n shadow: false,\n})\nexport class ContentImage {\n @Element() hostElement: HostElement;\n /**\n * @type String\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n classes: ResponsiveString;\n /**\n * @type Boolean\n */\n @Prop() lazyLoad: boolean = true;\n /**\n * @type Media\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: false,\n })\n src!: ResponsiveString;\n @State() activeSrc;\n /**\n * @type String\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n alt: ResponsiveString;\n /**\n * @type Number\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: false,\n })\n width: ResponsiveNumber = '16';\n /**\n * @type Number\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: false,\n })\n height: ResponsiveNumber = '9';\n /**\n * @type Select\n * @options video/mp4\n */\n @Prop() videoType?: string = 'video/mp4';\n\n /**\n * If true, the content in the mediaContent slot will be visible.\n * @type Boolean\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n showContent: ResponsiveBoolean = 'false|true';\n\n @State() lazyLoadIsComplete: boolean = false;\n @State() showVideoAsGif: boolean = false;\n @State() activeLazyLoadClass = '';\n @State() classString = '';\n @State() inlineStyle?: { [key: string]: string } = {};\n @State() hasMediaContent: boolean = false;\n preloadImage(src) {\n return new Promise(r => {\n const image = new Image();\n image.onload = r;\n image.onerror = r;\n image.src = src;\n });\n }\n\n componentWillLoad() {\n this.hasMediaContent = !!this.hostElement.querySelector('[slot=\"mediaContent\"]');\n\n WindowResizeService.registerProp(this.src).subscribe(newValue => {\n this.showVideoAsGif = (newValue as string).indexOf('.mp4') >= 0;\n if (!this.lazyLoadIsComplete) {\n this.lazyLoadIsComplete = true;\n }\n this.src = newValue as string;\n });\n WindowResizeService.registerProp(this.alt).subscribe(newValue => {\n this.alt = newValue as string;\n });\n WindowResizeService.registerProp(this.height).subscribe(newValue => {\n this.height = newValue as string;\n });\n WindowResizeService.registerProp(this.showContent).subscribe(newValue => {\n this.showContent = newValue as string;\n });\n WindowResizeService.registerProp(this.classes).subscribe(newValue => {\n this.classString = `${newValue}`;\n });\n }\n\n @Watch('lazyLoadIsComplete')\n watchLazyLoadIsComplete(newValue: boolean) {\n if (newValue === true) {\n this.activeLazyLoadClass = 'content-image-loaded';\n } else {\n if (!this.lazyLoad) {\n this.activeLazyLoadClass = 'content-image-no-lazyload';\n } else {\n this.activeLazyLoadClass = 'content-image-loading';\n }\n }\n }\n\n render() {\n let pictureSrcSet = '';\n let pictureImageSrc = '';\n if (this.src) {\n breakpointValues.forEach((_bp, index) => {\n if (index === 0) {\n pictureImageSrc = getValueAtIndex(0, this.src);\n } else {\n pictureSrcSet += `${getValueAtIndex(index, this.src)} ${breakpointValues[index]}w,`;\n }\n });\n }\n return (\n <Host class={`${this.activeLazyLoadClass} ${this.classString}`} style={this.inlineStyle} content={this.showContent}>\n {this.hasMediaContent && (\n <div class=\"content-image__media-content\">\n <slot name=\"mediaContent\"></slot>\n </div>\n )}\n {this.showVideoAsGif ? (\n <video autoplay muted loop preload=\"none\" playsinline width={this.width} height={this.height}>\n <source src={this.lazyLoadIsComplete ? this.src : null} type={this.videoType} />\n </video>\n ) : (\n <picture>\n <source srcSet={pictureSrcSet} />\n <img width={this.width} height={this.height} src={pictureImageSrc} alt={this.alt} />\n </picture>\n )}\n </Host>\n );\n }\n}\n"]}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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Host, Element, Prop, State, Watch } from '@stencil/core';\nimport { HostElement } from '@stencil/core/internal';\nimport { WindowResizeService } from '../../services/window-resize-service';\nimport { ResponsiveBoolean, ResponsiveNumber, ResponsiveString } from '../../typings';\nimport { breakpointValues, getCurrentValue, getValueAtIndex } from '../../utils/utils';\n\n/**\n * @slot mediaContent - Content displayed over media. If you want to reveal content on hover, use a tout block\n */\n@Component({\n tag: 'content-image',\n styleUrl: 'content-image.scss',\n shadow: false,\n})\nexport class ContentImage {\n @Element() hostElement: HostElement;\n /**\n * @type String\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n classes: ResponsiveString;\n /**\n * @type Boolean\n */\n @Prop() lazyLoad: boolean = true;\n /**\n * @type Media\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: false,\n })\n src!: ResponsiveString;\n @State() activeSrc;\n /**\n * @type String\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n alt: ResponsiveString;\n /**\n * @type Number\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: false,\n })\n width: ResponsiveNumber = '16';\n /**\n * @type Number\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: false,\n })\n height: ResponsiveNumber = '9';\n\n /**\n * @type String\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: false,\n })\n aspectRatio: ResponsiveString;\n /**\n * @type Select\n * @options image\n * @options video\n */\n @Prop() type?: 'image' | 'video' = 'image';\n\n /**\n * @type Select\n * @options video/mp4\n */\n @Prop() videoType?: string = 'video/mp4';\n\n /**\n * If true, the content in the mediaContent slot will be visible.\n * @type Boolean\n * @responsive\n */\n @Prop({\n mutable: true,\n reflect: true,\n })\n showContent: ResponsiveBoolean = 'false|true';\n\n @State() lazyLoadIsComplete: boolean = false;\n @State() showVideoAsGif: boolean = false;\n @State() activeLazyLoadClass = '';\n @State() classString = '';\n @State() inlineStyle?: { [key: string]: string } = {};\n @State() hasMediaContent: boolean = false;\n @State() pictureImageSrc: string;\n preloadImage(src) {\n return new Promise(r => {\n const image = new Image();\n image.onload = r;\n image.onerror = r;\n image.src = src;\n });\n }\n\n componentWillLoad() {\n this.hasMediaContent = !!this.hostElement.querySelector('[slot=\"mediaContent\"]');\n WindowResizeService.registerProp(this.aspectRatio).subscribe(newValue => {\n this.inlineStyle = { ...this.inlineStyle, '--aspect-ratio': `${newValue}` };\n });\n WindowResizeService.registerProp(this.alt).subscribe(newValue => {\n this.alt = newValue as string;\n });\n WindowResizeService.registerProp(this.height).subscribe(newValue => {\n this.height = newValue as string;\n });\n WindowResizeService.registerProp(this.showContent).subscribe(newValue => {\n this.showContent = newValue as string;\n });\n WindowResizeService.registerProp(this.classes).subscribe(newValue => {\n this.classString = `${newValue}`;\n });\n }\n\n componentDidLoad() {\n let observer = new IntersectionObserver(\n entries => {\n entries.forEach(async entry => {\n if (entry.isIntersecting) {\n this.lazyLoadIsComplete = true;\n this.pictureImageSrc = getCurrentValue(this.src);\n this.showVideoAsGif = this.pictureImageSrc.indexOf('.mp4') >= 0 || getCurrentValue(this.type) === 'video';\n }\n });\n },\n {\n root: null,\n // rootMargin: `${Math.max(100, window.innerHeight * 0.95)}px`,\n rootMargin: `0px`,\n threshold: 0.1,\n },\n );\n observer.observe(this.hostElement);\n }\n\n @Watch('lazyLoadIsComplete')\n watchLazyLoadIsComplete(newValue: boolean) {\n if (newValue === true) {\n this.activeLazyLoadClass = 'content-image-loaded';\n } else {\n if (!this.lazyLoad) {\n this.activeLazyLoadClass = 'content-image-no-lazyload';\n } else {\n this.activeLazyLoadClass = 'content-image-loading';\n }\n }\n }\n\n render() {\n return (\n <Host class={`${this.activeLazyLoadClass} ${this.classString}`} style={this.inlineStyle} content={this.showContent}>\n {this.hasMediaContent && (\n <div class=\"content-image__media-content\">\n <slot name=\"mediaContent\"></slot>\n </div>\n )}\n {this.showVideoAsGif ? (\n <video autoplay muted loop preload=\"none\" playsinline width={this.width} height={this.height}>\n <source src={this.lazyLoadIsComplete ? this.pictureImageSrc : null} type={this.videoType} />\n </video>\n ) : (\n <img width={this.width} height={this.height} src={this.pictureImageSrc} alt={this.alt} />\n )}\n </Host>\n );\n }\n}\n"]}
@@ -12,6 +12,7 @@ content-grid-formatter * {
12
12
  content-grid-formatter[type=grid] {
13
13
  display: grid;
14
14
  grid-template-columns: repeat(var(--columns), 1fr);
15
+ column-gap: var(--column-gap);
15
16
  }
16
17
  content-grid-formatter[type=flex] {
17
18
  display: flex;