@kodaris/krubble-components 1.0.28 → 1.0.30

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.
@@ -448,7 +448,8 @@
448
448
  /**
449
449
  * A customizable button component.
450
450
  *
451
- * @slot - The button content
451
+ * @slot - The button content (text)
452
+ * @slot icon - Optional icon to display alongside the button text
452
453
  * @fires click - Fired when the button is clicked
453
454
  * @fires option-select - Fired when a dropdown option is selected
454
455
  */
@@ -475,6 +476,11 @@
475
476
  * Dropdown options - when provided, button becomes a dropdown
476
477
  */
477
478
  this.options = [];
479
+ /**
480
+ * Position of the icon relative to the text content.
481
+ * @attr icon-position
482
+ */
483
+ this.iconPosition = 'left';
478
484
  this._state = 'idle';
479
485
  this._stateText = '';
480
486
  this._dropdownOpened = false;
@@ -608,7 +614,10 @@
608
614
  }
609
615
  render() {
610
616
  const content = b `
611
- <slot></slot>
617
+ <span class="content">
618
+ <slot name="icon"></slot>
619
+ <slot></slot>
620
+ </span>
612
621
  ${this.options.length ? b `<svg class="caret" xmlns="http://www.w3.org/2000/svg" height="20" width="20" viewBox="0 0 24 24" fill="currentColor"><path d="M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z"/></svg>` : A}
613
622
  ${this._state !== 'idle'
614
623
  ? b `<span class="state-overlay">
@@ -757,9 +766,9 @@
757
766
  }
758
767
 
759
768
  /* Content */
760
- :host(.kr-button--loading) slot,
761
- :host(.kr-button--success) slot,
762
- :host(.kr-button--error) slot {
769
+ :host(.kr-button--loading) .content,
770
+ :host(.kr-button--success) .content,
771
+ :host(.kr-button--error) .content {
763
772
  visibility: hidden;
764
773
  }
765
774
 
@@ -860,6 +869,34 @@
860
869
  color: inherit;
861
870
  text-decoration: none;
862
871
  }
872
+
873
+ /* Content wrapper for icon + text layout */
874
+ .content {
875
+ display: inline-flex;
876
+ align-items: center;
877
+ gap: 6px;
878
+ }
879
+
880
+ :host([icon-position="right"]) .content {
881
+ flex-direction: row-reverse;
882
+ }
883
+
884
+ /* Icon styling */
885
+ ::slotted([slot="icon"]) {
886
+ width: 18px;
887
+ height: 18px;
888
+ flex-shrink: 0;
889
+ }
890
+
891
+ :host(.kr-button--small) ::slotted([slot="icon"]) {
892
+ width: 14px;
893
+ height: 14px;
894
+ }
895
+
896
+ :host(.kr-button--large) ::slotted([slot="icon"]) {
897
+ width: 22px;
898
+ height: 22px;
899
+ }
863
900
  `;
864
901
  __decorate$e([
865
902
  n$1({ type: String, reflect: true })
@@ -882,6 +919,9 @@
882
919
  __decorate$e([
883
920
  n$1({ type: Array })
884
921
  ], exports.KRButton.prototype, "options", void 0);
922
+ __decorate$e([
923
+ n$1({ type: String, reflect: true, attribute: 'icon-position' })
924
+ ], exports.KRButton.prototype, "iconPosition", void 0);
885
925
  __decorate$e([
886
926
  r$1()
887
927
  ], exports.KRButton.prototype, "_state", void 0);