@micropasts/iiif-manifest-summary 0.1.0 → 0.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.
package/README.md CHANGED
@@ -185,7 +185,20 @@ It is registered globally under `iiif-manifest-summary-tw` when it is not alread
185
185
  | `listen` | No | Custom event name | Listens for the named window event and uses `event.detail.manifest` to change manifests. |
186
186
  | `card-class` | No | Tailwind/CSS classes | Extra classes appended to the built-in card classes. |
187
187
 
188
- The Tailwind component uses a dark variant for Tailwind's `dark` class strategy and is intended for a Tailwind-enabled page.
188
+ The component's `dark:` utilities follow the host application's Tailwind dark-mode
189
+ configuration. With Tailwind's default media-based strategy, they automatically
190
+ follow the system color scheme, including changes while the page is open. If the
191
+ application configures a class- or selector-based dark variant instead, the
192
+ application is responsible for updating that selector; the component does not
193
+ change the page's theme.
194
+
195
+ Ensure Tailwind scans the component's source (including dependencies if installed
196
+ from npm), or otherwise includes its utility classes in the generated CSS. For
197
+ example, Tailwind v3 can include
198
+ `./node_modules/@micropasts/iiif-manifest-summary/src/tailwind.js` in its
199
+ `content` configuration; Tailwind v4 can register the same file with `@source`.
200
+ The demo uses a class-based variant, follows system changes until its theme toggle
201
+ is used, and then preserves the chosen theme in local storage.
189
202
 
190
203
  #### Static Tailwind classes
191
204
 
@@ -561,7 +561,7 @@ export class IiifManifestSummaryTailwind extends HTMLElement {
561
561
 
562
562
  async load(url) {
563
563
  const c = IiifManifestSummaryTailwind.classes;
564
- this.innerHTML = `<div class="${c.card} text-xs text-zinc-500 animate-pulse">Loading IIIF manifest summary…</div>`;
564
+ this.innerHTML = `<div class="${c.card} text-xs text-zinc-500 dark:text-zinc-400 animate-pulse">Loading IIIF manifest summary…</div>`;
565
565
  this._data = await fetchManifestSummary(url);
566
566
  this._renderData();
567
567
  }
@@ -603,7 +603,7 @@ export class IiifManifestSummaryTailwind extends HTMLElement {
603
603
  ? `<div class="mt-2.5 grid grid-cols-2 gap-2 rounded-md bg-zinc-50 dark:bg-zinc-950/70 p-2 text-xs border border-zinc-200/70 dark:border-zinc-800">${d.metadata
604
604
  .map(
605
605
  (m) =>
606
- `<div><span class="block text-[10px] uppercase tracking-wide text-zinc-500">${this._esc(m.label)}</span><strong class="font-medium text-zinc-900 dark:text-zinc-100">${this._esc(m.value)}</strong></div>`
606
+ `<div><span class="block text-[10px] uppercase tracking-wide text-zinc-500 dark:text-zinc-400">${this._esc(m.label)}</span><strong class="font-medium text-zinc-900 dark:text-zinc-100">${this._esc(m.value)}</strong></div>`
607
607
  )
608
608
  .join('')}</div>`
609
609
  : ''
@@ -559,7 +559,7 @@ class IiifManifestSummaryTailwind extends HTMLElement {
559
559
 
560
560
  async load(url) {
561
561
  const c = IiifManifestSummaryTailwind.classes;
562
- this.innerHTML = `<div class="${c.card} text-xs text-zinc-500 animate-pulse">Loading IIIF manifest summary…</div>`;
562
+ this.innerHTML = `<div class="${c.card} text-xs text-zinc-500 dark:text-zinc-400 animate-pulse">Loading IIIF manifest summary…</div>`;
563
563
  this._data = await fetchManifestSummary(url);
564
564
  this._renderData();
565
565
  }
@@ -601,7 +601,7 @@ class IiifManifestSummaryTailwind extends HTMLElement {
601
601
  ? `<div class="mt-2.5 grid grid-cols-2 gap-2 rounded-md bg-zinc-50 dark:bg-zinc-950/70 p-2 text-xs border border-zinc-200/70 dark:border-zinc-800">${d.metadata
602
602
  .map(
603
603
  (m) =>
604
- `<div><span class="block text-[10px] uppercase tracking-wide text-zinc-500">${this._esc(m.label)}</span><strong class="font-medium text-zinc-900 dark:text-zinc-100">${this._esc(m.value)}</strong></div>`
604
+ `<div><span class="block text-[10px] uppercase tracking-wide text-zinc-500 dark:text-zinc-400">${this._esc(m.label)}</span><strong class="font-medium text-zinc-900 dark:text-zinc-100">${this._esc(m.value)}</strong></div>`
605
605
  )
606
606
  .join('')}</div>`
607
607
  : ''
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micropasts/iiif-manifest-summary",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Zero-dependency JavaScript Web Components for summarizing IIIF Presentation v2 and v3 manifests with thumbnails, rights, canvas counts, and Shadow DOM / Tailwind CSS support.",
5
5
  "type": "module",
6
6
  "main": "./dist/iiif-manifest-summary.esm.js",
@@ -24,6 +24,7 @@
24
24
  "scripts": {
25
25
  "build": "node scripts/build.js",
26
26
  "dev": "node scripts/build.js && npx serve docs",
27
+ "test": "node --test",
27
28
  "prepare": "npm run build"
28
29
  },
29
30
  "keywords": [
@@ -37,4 +38,4 @@
37
38
  "micropasts"
38
39
  ],
39
40
  "license": "MIT"
40
- }
41
+ }
package/src/demo.html CHANGED
@@ -6,11 +6,15 @@
6
6
  <title>@micropasts/iiif-manifest-summary — IIIF Summary Demo</title>
7
7
  <script>
8
8
  (function () {
9
- const saved = localStorage.getItem('iiif-demo-theme');
10
- const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
11
- if (saved === 'dark' || (!saved && prefersDark)) {
12
- document.documentElement.classList.add('dark');
13
- }
9
+ const systemTheme = window.matchMedia('(prefers-color-scheme: dark)');
10
+ const applyTheme = () => {
11
+ const saved = localStorage.getItem('iiif-demo-theme');
12
+ document.documentElement.classList.toggle(
13
+ 'dark', saved === 'dark' || (saved !== 'light' && systemTheme.matches)
14
+ );
15
+ };
16
+ applyTheme();
17
+ systemTheme.addEventListener('change', applyTheme);
14
18
  })();
15
19
  </script>
16
20
  <script src="https://cdn.tailwindcss.com"></script>
package/src/tailwind.js CHANGED
@@ -47,7 +47,7 @@ export class IiifManifestSummaryTailwind extends HTMLElement {
47
47
 
48
48
  async load(url) {
49
49
  const c = IiifManifestSummaryTailwind.classes;
50
- this.innerHTML = `<div class="${c.card} text-xs text-zinc-500 animate-pulse">Loading IIIF manifest summary…</div>`;
50
+ this.innerHTML = `<div class="${c.card} text-xs text-zinc-500 dark:text-zinc-400 animate-pulse">Loading IIIF manifest summary…</div>`;
51
51
  this._data = await fetchManifestSummary(url);
52
52
  this._renderData();
53
53
  }
@@ -89,7 +89,7 @@ export class IiifManifestSummaryTailwind extends HTMLElement {
89
89
  ? `<div class="mt-2.5 grid grid-cols-2 gap-2 rounded-md bg-zinc-50 dark:bg-zinc-950/70 p-2 text-xs border border-zinc-200/70 dark:border-zinc-800">${d.metadata
90
90
  .map(
91
91
  (m) =>
92
- `<div><span class="block text-[10px] uppercase tracking-wide text-zinc-500">${this._esc(m.label)}</span><strong class="font-medium text-zinc-900 dark:text-zinc-100">${this._esc(m.value)}</strong></div>`
92
+ `<div><span class="block text-[10px] uppercase tracking-wide text-zinc-500 dark:text-zinc-400">${this._esc(m.label)}</span><strong class="font-medium text-zinc-900 dark:text-zinc-100">${this._esc(m.value)}</strong></div>`
93
93
  )
94
94
  .join('')}</div>`
95
95
  : ''