@dodlhuat/basix 1.4.3 → 1.5.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 (66) hide show
  1. package/README.md +43 -9
  2. package/css/alert.scss +9 -9
  3. package/css/badge.scss +5 -25
  4. package/css/bottom-sheet.scss +2 -6
  5. package/css/breadcrumb.scss +18 -9
  6. package/css/calendar.scss +15 -26
  7. package/css/carousel.scss +3 -3
  8. package/css/chart.scss +1 -6
  9. package/css/checkbox.scss +1 -1
  10. package/css/chips.scss +13 -23
  11. package/css/code-viewer.scss +1 -1
  12. package/css/color-picker.scss +3 -5
  13. package/css/context-menu.scss +3 -8
  14. package/css/datepicker.scss +4 -4
  15. package/css/defaults.scss +25 -0
  16. package/css/docs.scss +6 -6
  17. package/css/dropdown.scss +3 -8
  18. package/css/editor.scss +13 -17
  19. package/css/file-uploader.scss +6 -17
  20. package/css/flyout-menu.scss +3 -0
  21. package/css/form.scss +32 -25
  22. package/css/gallery.scss +15 -0
  23. package/css/group-picker.scss +28 -17
  24. package/css/icons.scss +7 -327
  25. package/css/lightbox.scss +7 -7
  26. package/css/mixins.scss +52 -0
  27. package/css/modal.scss +4 -8
  28. package/css/parameters.scss +8 -2
  29. package/css/placeholder.scss +2 -17
  30. package/css/popover.scss +2 -7
  31. package/css/properties.scss +0 -5
  32. package/css/push-menu.scss +1 -1
  33. package/css/stepper.scss +2 -2
  34. package/css/style.css +198 -486
  35. package/css/style.css.map +1 -1
  36. package/css/style.min.css +1 -1
  37. package/css/style.min.css.map +1 -1
  38. package/css/tabs.scss +3 -7
  39. package/css/timepicker.scss +2 -2
  40. package/css/tooltip.scss +1 -1
  41. package/css/typography.scss +3 -3
  42. package/css/virtual-dropdown.scss +6 -11
  43. package/js/bottom-sheet.d.ts +2 -0
  44. package/js/bottom-sheet.js +3 -1
  45. package/js/carousel.d.ts +1 -0
  46. package/js/carousel.js +3 -2
  47. package/js/docs-nav.js +1 -1
  48. package/js/gallery.d.ts +5 -0
  49. package/js/gallery.js +35 -0
  50. package/js/group-picker.d.ts +1 -0
  51. package/js/group-picker.js +8 -5
  52. package/js/lightbox.d.ts +3 -1
  53. package/js/lightbox.js +8 -4
  54. package/js/modal.d.ts +2 -0
  55. package/js/modal.js +4 -2
  56. package/js/push-menu.d.ts +6 -2
  57. package/js/push-menu.js +13 -8
  58. package/js/select.js +1 -1
  59. package/js/sidebar-nav.d.ts +1 -0
  60. package/js/sidebar-nav.js +2 -1
  61. package/js/toast.d.ts +2 -0
  62. package/js/toast.js +5 -1
  63. package/package.json +2 -1
  64. package/svg-icons/chevron_right.svg +1 -0
  65. package/svg-icons/keyboard_arrow_down.svg +1 -0
  66. package/fonts/MaterialSymbolsOutlined.woff2 +0 -0
package/js/lightbox.js CHANGED
@@ -5,6 +5,7 @@ class Lightbox {
5
5
  closeable;
6
6
  onOpen;
7
7
  onClose;
8
+ iconBasePath;
8
9
  wrapper = null;
9
10
  imgEl = null;
10
11
  captionEl = null;
@@ -22,6 +23,7 @@ class Lightbox {
22
23
  this.closeable = options.closeable ?? true;
23
24
  this.onOpen = options.onOpen;
24
25
  this.onClose = options.onClose;
26
+ this.iconBasePath = options.iconBasePath ?? 'svg-icons/';
25
27
  }
26
28
  show() {
27
29
  this.hide();
@@ -233,8 +235,9 @@ class Lightbox {
233
235
  }, { signal: this.listeners.signal });
234
236
  }
235
237
  buildTemplate() {
238
+ const icon = (name) => `<svg class="icon-svg" aria-hidden="true"><use href="${this.iconBasePath}icons.svg#${name}"/></svg>`;
236
239
  return `
237
- ${this.closeable ? '<button class="lightbox-close" aria-label="Close lightbox"><span class="icon icon-close"></span></button>' : ''}
240
+ ${this.closeable ? `<button class="lightbox-close" aria-label="Close lightbox">${icon('close')}</button>` : ''}
238
241
  <div class="lightbox" role="document">
239
242
  <div class="lightbox-img-wrap">
240
243
  <div class="lightbox-spinner"><div class="spinner"></div></div>
@@ -244,15 +247,15 @@ class Lightbox {
244
247
  <div class="lightbox-counter" hidden></div>
245
248
  </div>
246
249
  <button class="lightbox-prev" aria-label="Previous image" hidden>
247
- <span class="icon icon-navigate_before"></span>
250
+ ${icon('chevron_left')}
248
251
  </button>
249
252
  <button class="lightbox-next" aria-label="Next image" hidden>
250
- <span class="icon icon-navigate_next"></span>
253
+ ${icon('chevron_right')}
251
254
  </button>
252
255
  <div class="lightbox-background"></div>
253
256
  `;
254
257
  }
255
- static bind(selector = '[data-lightbox]') {
258
+ static bind(selector = '[data-lightbox]', iconBasePath) {
256
259
  const elements = document.querySelectorAll(selector);
257
260
  const groups = new Map();
258
261
  elements.forEach((el) => {
@@ -273,6 +276,7 @@ class Lightbox {
273
276
  new Lightbox({
274
277
  images: items.map((i) => i.image),
275
278
  startIndex: idx,
279
+ iconBasePath,
276
280
  }).show();
277
281
  });
278
282
  });
package/js/modal.d.ts CHANGED
@@ -5,6 +5,7 @@ interface ModalOptions {
5
5
  footer?: string;
6
6
  closeable?: boolean;
7
7
  type?: ModalType;
8
+ iconBasePath?: string;
8
9
  }
9
10
  declare class Modal {
10
11
  private content;
@@ -12,6 +13,7 @@ declare class Modal {
12
13
  private readonly footer?;
13
14
  private readonly closeable;
14
15
  private readonly type;
16
+ private readonly iconBasePath;
15
17
  private template;
16
18
  private modalWrapper;
17
19
  private listeners;
package/js/modal.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { sanitizeHtml } from './utils.js';
2
2
  import { ListenerGroup } from './listeners.js';
3
- const CLOSE_ICON = '<div class="icon icon-close close"></div>';
4
3
  class Modal {
5
4
  content;
6
5
  header;
7
6
  footer;
8
7
  closeable;
9
8
  type;
9
+ iconBasePath;
10
10
  template;
11
11
  modalWrapper = null;
12
12
  listeners = new ListenerGroup();
@@ -17,6 +17,7 @@ class Modal {
17
17
  this.footer = contentOrOptions.footer;
18
18
  this.closeable = contentOrOptions.closeable ?? true;
19
19
  this.type = contentOrOptions.type ?? 'default';
20
+ this.iconBasePath = contentOrOptions.iconBasePath ?? 'svg-icons/';
20
21
  }
21
22
  else {
22
23
  this.content = contentOrOptions;
@@ -24,6 +25,7 @@ class Modal {
24
25
  this.footer = footer;
25
26
  this.closeable = closeable;
26
27
  this.type = type;
28
+ this.iconBasePath = 'svg-icons/';
27
29
  }
28
30
  this.template = this.buildTemplate();
29
31
  }
@@ -72,7 +74,7 @@ class Modal {
72
74
  buildTemplate() {
73
75
  const parts = [`<div class="modal modal-${this.type}">`];
74
76
  if (this.closeable) {
75
- parts.push(CLOSE_ICON);
77
+ parts.push(`<svg class="icon-svg close" aria-hidden="true"><use href="${this.iconBasePath}icons.svg#close"/></svg>`);
76
78
  }
77
79
  if (this.header !== undefined) {
78
80
  const headerClass = `header ${this.type}-bg`;
package/js/push-menu.d.ts CHANGED
@@ -6,13 +6,17 @@ interface PushMenuElements {
6
6
  controlIcon: HTMLElement | null;
7
7
  backdrop: HTMLElement | null;
8
8
  }
9
+ interface PushMenuOptions {
10
+ iconBasePath?: string;
11
+ }
9
12
  declare class PushMenu {
13
+ private static iconBasePath;
10
14
  private static elements;
11
15
  private static initialized;
12
16
  private static panelStack;
13
17
  private static listeners;
14
18
  private static clickNavListeners;
15
- static init(): void;
19
+ static init(options?: PushMenuOptions): void;
16
20
  private static buildPanels;
17
21
  private static extractSubPanels;
18
22
  static openPanel(panel: HTMLElement): void;
@@ -28,4 +32,4 @@ declare class PushMenu {
28
32
  static destroy(): void;
29
33
  static refresh(): void;
30
34
  }
31
- export { PushMenu, type PushMenuElements };
35
+ export { PushMenu, type PushMenuElements, type PushMenuOptions };
package/js/push-menu.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { ListenerGroup } from './listeners.js';
2
2
  class PushMenu {
3
+ static iconBasePath = 'svg-icons/';
3
4
  static elements = {
4
5
  navigation: null,
5
6
  content: null,
@@ -12,11 +13,12 @@ class PushMenu {
12
13
  static panelStack = [];
13
14
  static listeners = new ListenerGroup();
14
15
  static clickNavListeners = null;
15
- static init() {
16
+ static init(options = {}) {
16
17
  if (this.initialized) {
17
18
  console.warn('PushMenu: Already initialized');
18
19
  return;
19
20
  }
21
+ this.iconBasePath = options.iconBasePath ?? 'svg-icons/';
20
22
  this.refresh();
21
23
  if (!this.elements.navigation || !this.elements.content) {
22
24
  throw new Error('PushMenu: Required elements not found (.navigation, .push-content)');
@@ -60,7 +62,7 @@ class PushMenu {
60
62
  const backBtn = document.createElement('button');
61
63
  backBtn.classList.add('push-menu-back');
62
64
  backBtn.setAttribute('aria-label', 'Back');
63
- backBtn.innerHTML = `<span class="icon icon-navigate_before" aria-hidden="true"></span>`;
65
+ backBtn.innerHTML = `<svg class="icon-svg" aria-hidden="true"><use href="${PushMenu.iconBasePath}icons.svg#chevron_left"/></svg>`;
64
66
  header.addEventListener('click', () => PushMenu.goBack());
65
67
  const titleEl = document.createElement('span');
66
68
  titleEl.classList.add('push-menu-panel-title');
@@ -76,7 +78,7 @@ class PushMenu {
76
78
  const chevron = document.createElement('span');
77
79
  chevron.classList.add('push-menu-chevron');
78
80
  chevron.setAttribute('aria-hidden', 'true');
79
- chevron.innerHTML = `<span class="icon icon-navigate_next" aria-hidden="true"></span>`;
81
+ chevron.innerHTML = `<svg class="icon-svg" aria-hidden="true"><use href="${PushMenu.iconBasePath}icons.svg#chevron_right"/></svg>`;
80
82
  trigger.appendChild(chevron);
81
83
  if (parentAnchor) {
82
84
  parentAnchor.replaceWith(trigger);
@@ -144,13 +146,16 @@ class PushMenu {
144
146
  this.elements.header?.classList.toggle('pushed', !isPushed);
145
147
  this.elements.backdrop?.classList.toggle('pushed', !isPushed);
146
148
  if (this.elements.controlIcon) {
147
- if (isPushed) {
148
- this.elements.controlIcon.classList.remove('icon-menu_open');
149
- this.elements.controlIcon.classList.add('icon-menu');
149
+ const iconName = isPushed ? 'menu' : 'menu_open';
150
+ const useEl = this.elements.controlIcon.querySelector('use');
151
+ if (useEl) {
152
+ const existingHref = useEl.getAttribute('href') ?? '';
153
+ const basePath = existingHref.includes('#') ? existingHref.split('#')[0] : PushMenu.iconBasePath + 'icons.svg';
154
+ useEl.setAttribute('href', `${basePath}#${iconName}`);
150
155
  }
151
156
  else {
152
- this.elements.controlIcon.classList.add('icon-menu_open');
153
- this.elements.controlIcon.classList.remove('icon-menu');
157
+ this.elements.controlIcon.classList.remove('icon-menu_open', 'icon-menu');
158
+ this.elements.controlIcon.classList.add(`icon-${iconName}`);
154
159
  }
155
160
  }
156
161
  }
package/js/select.js CHANGED
@@ -140,7 +140,7 @@ class Select {
140
140
  dropdownOptions.className = 'dropdown-options';
141
141
  const optionsMenu = document.createElement('div');
142
142
  optionsMenu.className = 'dropdown-options-menu hidden';
143
- optionsMenu.innerHTML = 'Select options<span class="dropdown-options-icon icon icon-close"></span>';
143
+ optionsMenu.innerHTML = 'Select options<svg class="icon-svg dropdown-options-icon" aria-hidden="true"><use href="svg-icons/icons.svg#close"/></svg>';
144
144
  dropdownOptions.appendChild(optionsMenu);
145
145
  Array.from(select.options).forEach((opt) => {
146
146
  const optDiv = document.createElement('div');
@@ -3,6 +3,7 @@ interface SidebarNavOptions {
3
3
  breakpoint?: number;
4
4
  swipeThreshold?: number;
5
5
  swipeEdge?: number;
6
+ iconBasePath?: string;
6
7
  }
7
8
  declare class SidebarNav {
8
9
  private nav;
package/js/sidebar-nav.js CHANGED
@@ -15,6 +15,7 @@ class SidebarNav {
15
15
  breakpoint: options.breakpoint ?? 768,
16
16
  swipeThreshold: options.swipeThreshold ?? 60,
17
17
  swipeEdge: options.swipeEdge ?? 20,
18
+ iconBasePath: options.iconBasePath ?? 'svg-icons/',
18
19
  };
19
20
  this.nav = container?.querySelector('.sidebar-nav') ?? null;
20
21
  this.backdrop = container?.querySelector('.sidebar-backdrop') ?? null;
@@ -47,7 +48,7 @@ class SidebarNav {
47
48
  this.closeBtn = document.createElement('button');
48
49
  this.closeBtn.className = 'sidebar-close';
49
50
  this.closeBtn.setAttribute('aria-label', 'Close navigation');
50
- this.closeBtn.innerHTML = '<div class="icon icon-close"></div>';
51
+ this.closeBtn.innerHTML = `<svg class="icon-svg" aria-hidden="true"><use href="${this.opts.iconBasePath}icons.svg#close"/></svg>`;
51
52
  this.closeBtn.addEventListener('click', () => this.close(), sig);
52
53
  this.nav?.append(this.closeBtn);
53
54
  }
package/js/toast.d.ts CHANGED
@@ -4,12 +4,14 @@ interface ToastOptions {
4
4
  header?: string;
5
5
  type?: ToastType;
6
6
  closeable?: boolean;
7
+ iconBasePath?: string;
7
8
  }
8
9
  declare class Toast {
9
10
  private readonly content;
10
11
  private readonly header;
11
12
  private readonly type?;
12
13
  private readonly closeable;
14
+ private readonly iconBasePath;
13
15
  private readonly closureIcon;
14
16
  private readonly template;
15
17
  private toastElement;
package/js/toast.js CHANGED
@@ -5,7 +5,8 @@ class Toast {
5
5
  header;
6
6
  type;
7
7
  closeable;
8
- closureIcon = '<div class="icon icon-close close"></div>';
8
+ iconBasePath;
9
+ closureIcon;
9
10
  template;
10
11
  toastElement = null;
11
12
  timerId = null;
@@ -16,13 +17,16 @@ class Toast {
16
17
  this.header = contentOrOptions.header ?? '';
17
18
  this.type = contentOrOptions.type;
18
19
  this.closeable = contentOrOptions.closeable ?? true;
20
+ this.iconBasePath = contentOrOptions.iconBasePath ?? 'svg-icons/';
19
21
  }
20
22
  else {
21
23
  this.content = contentOrOptions;
22
24
  this.header = header;
23
25
  this.type = type;
24
26
  this.closeable = closeable;
27
+ this.iconBasePath = 'svg-icons/';
25
28
  }
29
+ this.closureIcon = `<svg class="icon-svg close" aria-hidden="true"><use href="${this.iconBasePath}icons.svg#close"/></svg>`;
26
30
  this.template = this.buildTemplate();
27
31
  }
28
32
  show(ms) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dodlhuat/basix",
3
- "version": "1.4.3",
3
+ "version": "1.5.0",
4
4
  "description": "Basix is intended as a starter for the rapid development of a design. Each design element can be added individually to include only the data required. It is using plain javascript / typescript and therefore is not dependent on any plugin.",
5
5
  "exports": {
6
6
  "./css/*": "./css/*",
@@ -36,6 +36,7 @@
36
36
  "eslint": "^10.5.0",
37
37
  "eslint-config-prettier": "^10.1.8",
38
38
  "prettier": "^3.8.4",
39
+ "sass": "^1.100.0",
39
40
  "typescript": "^6.0.0",
40
41
  "typescript-eslint": "^8.61.0"
41
42
  }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M530-481 332-679l43-43 241 241-241 241-43-43 198-198Z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M480-344 240-584l43-43 197 197 197-197 43 43-240 240Z"/></svg>
Binary file