@jungherz-de/notionkit-elements 1.12.0 → 1.13.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jungherz-de/notionkit-elements",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
4
4
  "description": "Vanilla JavaScript Web Components wrapping the NotionKit CSS foundation – <nk-*> custom elements with Shadow DOM, automatic theme sync and native form participation.",
5
5
  "license": "MIT",
6
6
  "author": "Jungherz GmbH <info@jungherz.com> (https://www.jungherz.com)",
@@ -62,10 +62,10 @@
62
62
  "dark-mode"
63
63
  ],
64
64
  "peerDependencies": {
65
- "@jungherz-de/notionkit": ">=1.12.0"
65
+ "@jungherz-de/notionkit": ">=1.13.0"
66
66
  },
67
67
  "devDependencies": {
68
- "@jungherz-de/notionkit": "^1.12.0",
68
+ "@jungherz-de/notionkit": "^1.13.0",
69
69
  "@playwright/test": "^1.50.0",
70
70
  "@rollup/plugin-node-resolve": "^15.0.0",
71
71
  "@rollup/plugin-terser": "^0.4.0",
@@ -5,6 +5,8 @@ import { NkElement } from '../../base.js';
5
5
  // → <div class="nk-cover"><img src="cover.jpg" alt=""></div>: the picture fills
6
6
  // the band, cropped rather than stretched; `position` moves the crop, as
7
7
  // Notion's "Reposition" does. The gradient stays underneath while it loads.
8
+ // The band is as tall as the token --nk-cover-height (200px), which reaches
9
+ // the shadow root: style="--nk-cover-height: 30vh" sets one cover.
8
10
  class NkPageCover extends NkElement {
9
11
  static get observedAttributes() { return ['src', 'position']; }
10
12
 
@@ -20,9 +20,9 @@ class NkPage extends NkElement {
20
20
  render() {
21
21
  this._page = this.createElement('div', ['nk-page']);
22
22
  this._icon = this.createElement('div', ['nk-page-icon'], { role: 'button', title: 'Change icon' });
23
- const iconSlot = this.createElement('slot', [], { name: 'icon' });
24
- iconSlot.appendChild(this._icon);
25
- this._page.appendChild(iconSlot);
23
+ this._iconSlot = this.createElement('slot', [], { name: 'icon' });
24
+ this._iconSlot.appendChild(this._icon);
25
+ this._page.appendChild(this._iconSlot);
26
26
  this._page.appendChild(document.createElement('slot'));
27
27
  this._cover = this.createElement('div', ['nk-cover']);
28
28
  this._coverSlot = this.createElement('slot', [], { name: 'cover' });
@@ -48,11 +48,14 @@ class NkPage extends NkElement {
48
48
  if (this._icon.textContent !== icon) this._icon.textContent = icon;
49
49
  this._icon.style.display = icon ? '' : 'none';
50
50
  this._cover.style.display = this.getBoolAttr('cover') ? '' : 'none';
51
- // `covered` is the stylesheet's twin of `.nk-cover + .nk-page`: the icon
52
- // overlaps the cover and the page drops its top padding. Without a cover
53
- // (attribute or a slotted nk-page-cover) the icon sits in the padding.
54
- const slotted = this._coverSlot.assignedNodes().some(n => n.nodeType === Node.ELEMENT_NODE || n.data.trim());
55
- this._page.classList.toggle('covered', this.getBoolAttr('cover') || slotted);
51
+ // `covered` is the stylesheet's twin of `.nk-cover + .nk-page` with an
52
+ // icon: the icon overlaps the cover and the page drops its top padding.
53
+ // Without a cover (attribute or a slotted nk-page-cover) the icon sits in
54
+ // the padding; without an icon (attribute or slot="icon") the page keeps
55
+ // it, so the title never touches the cover (NotionKit 1.13.0).
56
+ const filled = slot => slot.assignedNodes().some(n => n.nodeType === Node.ELEMENT_NODE || n.data.trim());
57
+ const covered = this.getBoolAttr('cover') || filled(this._coverSlot), iconed = !!icon || filled(this._iconSlot);
58
+ this._page.classList.toggle('covered', covered && iconed);
56
59
  this._page.classList.toggle('full', this.getBoolAttr('full'));
57
60
  this._page.classList.toggle('small', this.getBoolAttr('small'));
58
61
  }
@@ -62,10 +65,15 @@ class NkPage extends NkElement {
62
65
  this._onCover = () => this._sync();
63
66
  this._icon.addEventListener('click', this._onIcon);
64
67
  this._coverSlot.addEventListener('slotchange', this._onCover);
68
+ this._iconSlot.addEventListener('slotchange', this._onCover);
65
69
  this._sync();
66
70
  }
67
71
 
68
- teardownEvents() { this._icon?.removeEventListener('click', this._onIcon); this._coverSlot?.removeEventListener('slotchange', this._onCover); }
72
+ teardownEvents() {
73
+ this._icon?.removeEventListener('click', this._onIcon);
74
+ this._coverSlot?.removeEventListener('slotchange', this._onCover);
75
+ this._iconSlot?.removeEventListener('slotchange', this._onCover);
76
+ }
69
77
 
70
78
  onAttributeChanged(name) {
71
79
  if (name === 'narrow') this._build();