@digital-ai/dot-illustrations 2.0.23 → 2.0.25

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/demo/index.html CHANGED
@@ -66,15 +66,17 @@
66
66
  <h2 class="text-xl font-semibold mb-4 w-full text-center text-gray-900 dark:text-gray-100">Illustration preview</h2>
67
67
  <div id="modal-image" class="mb-4"></div>
68
68
  <div class="w-full flex flex-col gap-2 mb-2">
69
- <label class="text-xs font-medium text-gray-500 dark:text-gray-400" for="modal-id-input">Image ID</label>
69
+ <div class="text-base font-semibold text-center text-gray-800 dark:text-gray-100 mb-1" id="modal-illustration-name"></div>
70
+ </div>
71
+ <div class="w-full flex flex-col gap-2 mb-2">
72
+ <label class="text-xs font-medium text-gray-500 dark:text-gray-400" for="modal-dot-code">Dot Code</label>
70
73
  <div class="flex flex-row items-center gap-2">
71
- <input id="modal-id-input" class="flex-1 px-2 py-1 border border-gray-300 dark:border-gray-700 rounded bg-gray-100 dark:bg-gray-800 text-gray-900 dark:text-white text-base font-mono" readonly />
72
- <button id="modal-copy-id" class="button flex items-center justify-center px-2 py-1 text-xs text-gray-400 border border-gray-300 dark:border-gray-700 rounded bg-white dark:bg-gray-800 font-normal hover:bg-blue-100 dark:hover:bg-blue-900 transition relative text-center">Copy ID</button>
74
+ <textarea id="modal-dot-code" class="flex-1 px-2 py-1 border border-gray-300 dark:border-gray-700 rounded bg-gray-100 dark:bg-gray-800 text-gray-900 dark:text-white text-xs font-mono resize-none" rows="2" readonly></textarea>
75
+ <button id="modal-copy-dot-code" class="button flex items-center justify-center px-2 py-1 text-xs text-gray-400 border border-gray-300 dark:border-gray-700 rounded bg-white dark:bg-gray-800 font-normal hover:bg-blue-100 dark:hover:bg-blue-900 transition relative text-center" title="Copy Dot Code">Copy Dot Code</button>
73
76
  </div>
74
77
  </div>
75
- <div id="modal-description" class="w-full text-center text-sm text-gray-700 dark:text-gray-300 mb-4"></div>
76
78
  <div class="w-full flex flex-col gap-2 mb-2">
77
- <label class="text-xs font-medium text-gray-500 dark:text-gray-400" for="modal-code">Code</label>
79
+ <label class="text-xs font-medium text-gray-500 dark:text-gray-400" for="modal-code">HTML Code</label>
78
80
  <div class="flex flex-row items-center gap-2">
79
81
  <textarea id="modal-code" class="flex-1 px-2 py-1 border border-gray-300 dark:border-gray-700 rounded bg-gray-100 dark:bg-gray-800 text-gray-900 dark:text-white text-xs font-mono resize-none" rows="2" readonly></textarea>
80
82
  <button id="modal-copy-code" class="button flex items-center justify-center px-2 py-1 text-xs text-gray-400 border border-gray-300 dark:border-gray-700 rounded bg-white dark:bg-gray-800 font-normal hover:bg-blue-100 dark:hover:bg-blue-900 transition relative text-center">Copy Code</button>
package/demo/script.js CHANGED
@@ -70,18 +70,19 @@ const origCopyText = window.copyText;
70
70
  window.copyText = function(button) {
71
71
  var parentDiv = button.closest('.copy-container');
72
72
  var copyText = parentDiv.querySelector('.iconID');
73
- var textToCopy = copyText.textContent;
74
- navigator.clipboard.writeText(textToCopy).then(function() {
73
+ var illustrationId = copyText.textContent;
74
+ var dotCode = `<DotIllustration illustrationId=\"${illustrationId}\" />`;
75
+ navigator.clipboard.writeText(dotCode).then(function() {
75
76
  var tooltip = button.querySelector('.tooltiptext');
76
- tooltip.innerHTML = "Copied: " + textToCopy;
77
+ tooltip.innerHTML = "Copied Dot Code";
77
78
  tooltip.style.visibility = 'visible';
78
79
  setTimeout(function() {
79
- tooltip.innerHTML = "Copy ID";
80
+ tooltip.innerHTML = "Copy Dot Code";
80
81
  tooltip.style.visibility = 'hidden';
81
82
  }, 2000);
82
- showToast('Copied ID: ' + textToCopy);
83
+ showToast('Copied Dot Code: ' + dotCode);
83
84
  }, function(err) {
84
- console.error('Failed to copy text: ', err);
85
+ console.error('Failed to copy dot code: ', err);
85
86
  });
86
87
  }
87
88
 
@@ -109,6 +110,7 @@ document.addEventListener('DOMContentLoaded', () => {
109
110
  localStorage.setItem('theme', 'light');
110
111
  themeToggle.addEventListener('click', () => {
111
112
  setTheme(!root.classList.contains('dark'));
113
+ renderIllustrations();
112
114
  });
113
115
 
114
116
  // --- TABS ---
@@ -198,7 +200,6 @@ document.addEventListener('DOMContentLoaded', () => {
198
200
  const modalIdInput = document.getElementById('modal-id-input');
199
201
  const modalDescription = document.getElementById('modal-description');
200
202
  const modalCode = document.getElementById('modal-code');
201
- const modalCopyId = document.getElementById('modal-copy-id');
202
203
  const modalCopyCode = document.getElementById('modal-copy-code');
203
204
  const modalClose = document.getElementById('modal-close');
204
205
  const modalCloseBottom = document.getElementById('modal-close-bottom');
@@ -208,14 +209,45 @@ document.addEventListener('DOMContentLoaded', () => {
208
209
  if (!descriptionsLoaded) return;
209
210
  const themeClass = root.classList.contains('dark') ? 'dark' : 'light';
210
211
  let categoryClass = "";
211
- if (globalList.includes(illustration)) categoryClass = "global-illustration";
212
- else if (dashboardsList.includes(illustration)) categoryClass = "dashboards-illustration";
213
- modalImage.innerHTML = `<span class=\"dot-illustration\"><img src=\"svgs/${illustration}.svg\" class=\"${illustration} ${themeClass} ${categoryClass}\" style=\"width:286px;height:286px;object-fit:contain;\"/></span>`;
214
- modalIdInput.value = illustration;
215
- const codeString = `<span class=\"dot-illustration\"><img src=\"svgs/${illustration}.svg\" class=\"${illustration} ${themeClass} ${categoryClass}\"/></span>`;
212
+ let categoryFolder = "";
213
+ if (globalList.includes(illustration)) {
214
+ categoryClass = "global-illustration";
215
+ categoryFolder = "global";
216
+ } else if (dashboardsList.includes(illustration)) {
217
+ categoryClass = "dashboards-illustration";
218
+ categoryFolder = "dashboards";
219
+ }
220
+ const svgPath = `illustrations/${themeClass}/${categoryFolder}/${illustration}.svg`;
221
+ modalImage.innerHTML = `<span class=\"dot-illustration\"><img src=\"${svgPath}\" class=\"${illustration} ${themeClass} ${categoryClass}\" style=\"width:286px;height:286px;object-fit:contain;\"/></span>`;
222
+ // Set the illustration name
223
+ const modalIllustrationName = document.getElementById('modal-illustration-name');
224
+ if (modalIllustrationName) modalIllustrationName.textContent = illustration;
225
+ // Set the Dot Code textarea value
226
+ const dotCodeString = `<DotIllustration illustrationId=\"${illustration}\" />`;
227
+ const modalDotCode = document.getElementById('modal-dot-code');
228
+ if (modalDotCode) modalDotCode.value = dotCodeString;
229
+ // Show the HTML code snippet in the modal
230
+ const codeString = `<span class=\"dot-illustration\"><img src=\"${svgPath}\" class=\"${illustration} ${themeClass} ${categoryClass}\"/></span>`;
216
231
  modalCode.value = codeString;
217
232
  modal.classList.add('active');
218
233
  modal.classList.remove('hidden');
234
+ // Attach Copy Dot Code button event listener each time modal opens
235
+ const modalCopyDotCode = document.getElementById('modal-copy-dot-code');
236
+ if (modalCopyDotCode) {
237
+ modalCopyDotCode.onclick = function() {
238
+ if (modalDotCode) {
239
+ navigator.clipboard.writeText(modalDotCode.value).then(function() {
240
+ modalCopyDotCode.textContent = 'Copied!';
241
+ showToast('Copied Dot Code: ' + modalDotCode.value);
242
+ setTimeout(() => {
243
+ modalCopyDotCode.textContent = 'Copy Dot Code';
244
+ }, 2000);
245
+ }, function(err) {
246
+ console.error('Failed to copy dot code: ', err);
247
+ });
248
+ }
249
+ };
250
+ }
219
251
  }
220
252
  function closeModal() {
221
253
  modal.classList.remove('active');
@@ -225,10 +257,6 @@ document.addEventListener('DOMContentLoaded', () => {
225
257
  modalCloseBottom.addEventListener('click', closeModal);
226
258
  modal.addEventListener('click', (e) => { if (e.target === modal) closeModal(); });
227
259
  document.addEventListener('keydown', (e) => { if (modal.classList.contains('active') && e.key === 'Escape') closeModal(); });
228
- modalCopyId.addEventListener('click', () => {
229
- navigator.clipboard.writeText(modalIdInput.value);
230
- showToast('Copied ID: ' + modalIdInput.value);
231
- });
232
260
  modalCopyCode.addEventListener('click', () => {
233
261
  navigator.clipboard.writeText(modalCode.value);
234
262
  showToast('Copied code: ' + modalCode.value);
@@ -259,11 +287,20 @@ document.addEventListener('DOMContentLoaded', () => {
259
287
  const themeClass = root.classList.contains('dark') ? 'dark' : 'light';
260
288
  toShow.forEach(illustration => {
261
289
  let categoryClass = "";
262
- if (globalList.includes(illustration)) categoryClass = "global-illustration";
263
- else if (dashboardsList.includes(illustration)) categoryClass = "dashboards-illustration";
290
+ let categoryFolder = "";
291
+ if (globalList.includes(illustration)) {
292
+ categoryClass = "global-illustration";
293
+ categoryFolder = "global";
294
+ } else if (dashboardsList.includes(illustration)) {
295
+ categoryClass = "dashboards-illustration";
296
+ categoryFolder = "dashboards";
297
+ }
298
+ const svgPath = `illustrations/${themeClass}/${categoryFolder}/${illustration}.svg`;
264
299
  const isFav = favs.includes(illustration);
265
300
  const div = document.createElement("div");
266
301
  div.setAttribute("class", "copy-container relative group flex flex-col items-center justify-between bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl shadow-lg p-2 md:p-3 transition-transform duration-200 hover:scale-105 hover:shadow-2xl h-[302px] w-full justify-center");
302
+ // Show the HTML code snippet in the card
303
+ const codeString = `<span class=\"dot-illustration\"><img src=\"${svgPath}\" class=\"${illustration} ${themeClass} ${categoryClass}\"/></span>`;
267
304
  div.innerHTML = `
268
305
  <button class="absolute top-2 right-2 z-10 p-1 rounded-full bg-white/80 dark:bg-gray-800/80 hover:bg-yellow-100 dark:hover:bg-yellow-300 transition" title="Toggle favourite" onclick="event.stopPropagation(); window.toggleFavourite && window.toggleFavourite('${illustration}')">
269
306
  <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="${isFav ? 'gold' : 'none'}" viewBox="0 0 24 24" stroke="gold">
@@ -272,21 +309,21 @@ document.addEventListener('DOMContentLoaded', () => {
272
309
  </button>
273
310
  <div class="flex-1 flex flex-col justify-center items-center">
274
311
  <span class="dot-illustration">
275
- <img src="svgs/${illustration}.svg" class="${illustration} ${themeClass} ${categoryClass}"/>
312
+ <img src="${svgPath}" class="${illustration} ${themeClass} ${categoryClass}"/>
276
313
  </span>
277
314
  <span class="iconID block text-center text-base font-medium text-gray-800 dark:text-gray-200 my-2">${illustration}</span>
278
315
  </div>
279
316
  <div class="button-group flex flex-row items-center justify-center gap-2 mt-2">
280
317
  <button id="CopyID" class="button flex items-center justify-center min-w-[80px] px-1.5 py-0.5 text-[11px] text-gray-400 border border-gray-300 dark:border-gray-700 rounded bg-white dark:bg-gray-800 font-normal hover:bg-blue-100 dark:hover:bg-blue-900 transition relative text-center" onmouseover="showTooltip(this)" onmouseout="hideTooltip(this)" onclick="copyText(this)">
281
- Copy ID
282
- <span class="tooltiptext left-1/2 -translate-x-1/2 bottom-10 shadow-md">Copy ID</span>
318
+ Copy Dot Code
319
+ <span class="tooltiptext left-1/2 -translate-x-1/2 bottom-10 shadow-md">Copy Dot Code</span>
283
320
  </button>
284
321
  <button class="button flex items-center justify-center min-w-[80px] px-1.5 py-0.5 text-[11px] text-gray-400 border border-gray-300 dark:border-gray-700 rounded bg-white dark:bg-gray-800 font-normal hover:bg-blue-100 dark:hover:bg-blue-900 transition relative text-center" onmouseover="showTooltip(this)" onmouseout="hideTooltip(this)" onclick="copyCode(this)">
285
322
  Copy Code
286
323
  <span class="tooltiptext left-1/2 -translate-x-1/2 bottom-10 shadow-md">Copy Code</span>
287
324
  </button>
288
325
  </div>
289
- <pre class="codeBlock"><code class="codeBlock"><span class="dot-illustration"><img src="svgs/${illustration}.svg" class="${illustration} ${themeClass} ${categoryClass}"/></span></code></pre>
326
+ <pre class="codeBlock"><code class="codeBlock">${codeString}</code></pre>
290
327
  `;
291
328
  list.appendChild(div);
292
329
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digital-ai/dot-illustrations",
3
- "version": "2.0.23",
3
+ "version": "2.0.25",
4
4
  "description": "A central place for the design team to keep illustrations and for dev teams to find them.",
5
5
  "main": "./index.css",
6
6
  "scripts": {