@arclux/arc-ui 1.1.0 → 1.2.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": "@arclux/arc-ui",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "ARC UI — Lit Web Components implementing the Arclight design system.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -6,6 +6,7 @@ export class ArcTag extends LitElement {
6
6
  variant: { type: String, reflect: true },
7
7
  removable: { type: Boolean, reflect: true },
8
8
  disabled: { type: Boolean, reflect: true },
9
+ color: { type: String },
9
10
  };
10
11
 
11
12
  static styles = [
@@ -120,6 +121,7 @@ export class ArcTag extends LitElement {
120
121
  this.variant = 'default';
121
122
  this.removable = false;
122
123
  this.disabled = false;
124
+ this.color = '';
123
125
  }
124
126
 
125
127
  _remove(e) {
@@ -132,8 +134,15 @@ export class ArcTag extends LitElement {
132
134
  }
133
135
 
134
136
  render() {
137
+ const colorStyle = this.color
138
+ ? `border-color: rgba(${this.color}, 0.2); color: rgb(${this.color}); background: rgba(${this.color}, 0.06);`
139
+ : '';
140
+
135
141
  return html`
136
- <span class="tag" part="tag">
142
+ <span class="tag" part="tag" style=${colorStyle}
143
+ @mouseenter=${this.color ? (e) => { e.currentTarget.style.boxShadow = `0 0 12px rgba(${this.color}, 0.15)`; } : null}
144
+ @mouseleave=${this.color ? (e) => { e.currentTarget.style.boxShadow = ''; } : null}
145
+ >
137
146
  <span class="tag__label" part="label"><slot></slot></span>
138
147
  ${this.removable ? html`
139
148
  <button
@@ -3,11 +3,13 @@ import { tokenStyles } from '../shared-styles.js';
3
3
 
4
4
  export class ArcButton extends LitElement {
5
5
  static properties = {
6
- variant: { type: String, reflect: true },
7
- size: { type: String, reflect: true },
8
- href: { type: String },
9
- disabled: { type: Boolean, reflect: true },
10
- type: { type: String },
6
+ variant: { type: String, reflect: true },
7
+ size: { type: String, reflect: true },
8
+ href: { type: String },
9
+ disabled: { type: Boolean, reflect: true },
10
+ type: { type: String },
11
+ _hasPrefix: { state: true },
12
+ _hasSuffix: { state: true },
11
13
  };
12
14
 
13
15
  static styles = [
@@ -95,6 +97,21 @@ export class ArcButton extends LitElement {
95
97
  /* Disabled */
96
98
  :host([disabled]) .btn { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
97
99
 
100
+ /* Prefix / Suffix */
101
+ .btn__prefix,
102
+ .btn__suffix {
103
+ display: inline-flex;
104
+ align-items: center;
105
+ }
106
+
107
+ .btn__prefix--empty,
108
+ .btn__suffix--empty { display: none; }
109
+
110
+ ::slotted([slot="prefix"]),
111
+ ::slotted([slot="suffix"]) {
112
+ display: flex;
113
+ }
114
+
98
115
  @media (prefers-reduced-motion: reduce) {
99
116
  :host *,
100
117
  :host *::before,
@@ -114,13 +131,35 @@ export class ArcButton extends LitElement {
114
131
  this.href = '';
115
132
  this.disabled = false;
116
133
  this.type = 'button';
134
+ this._hasPrefix = false;
135
+ this._hasSuffix = false;
136
+ }
137
+
138
+ _onPrefixSlotChange(e) {
139
+ this._hasPrefix = e.target.assignedNodes({ flatten: true }).length > 0;
140
+ }
141
+
142
+ _onSuffixSlotChange(e) {
143
+ this._hasSuffix = e.target.assignedNodes({ flatten: true }).length > 0;
144
+ }
145
+
146
+ _renderContent() {
147
+ return html`
148
+ <span class="btn__prefix ${this._hasPrefix ? '' : 'btn__prefix--empty'}">
149
+ <slot name="prefix" @slotchange=${this._onPrefixSlotChange}></slot>
150
+ </span>
151
+ <slot></slot>
152
+ <span class="btn__suffix ${this._hasSuffix ? '' : 'btn__suffix--empty'}">
153
+ <slot name="suffix" @slotchange=${this._onSuffixSlotChange}></slot>
154
+ </span>
155
+ `;
117
156
  }
118
157
 
119
158
  render() {
120
159
  if (this.href) {
121
- return html`<a class="btn" href=${this.href} part="button"><slot></slot></a>`;
160
+ return html`<a class="btn" href=${this.href} part="button">${this._renderContent()}</a>`;
122
161
  }
123
- return html`<button class="btn" type=${this.type} ?disabled=${this.disabled} part="button"><slot></slot></button>`;
162
+ return html`<button class="btn" type=${this.type} ?disabled=${this.disabled} part="button">${this._renderContent()}</button>`;
124
163
  }
125
164
  }
126
165
 
@@ -16,6 +16,8 @@ export class ArcInput extends LitElement {
16
16
  required: { type: Boolean },
17
17
  multiline: { type: Boolean },
18
18
  rows: { type: Number },
19
+ _hasPrefix: { state: true },
20
+ _hasSuffix: { state: true },
19
21
  };
20
22
 
21
23
  static styles = [
@@ -38,15 +40,12 @@ export class ArcInput extends LitElement {
38
40
  color: var(--text-muted);
39
41
  }
40
42
 
41
- .input-group__field {
42
- font-family: var(--font-body);
43
- font-size: var(--body-size);
44
- font-weight: 300;
45
- color: var(--text-primary);
43
+ .input-group__wrapper {
44
+ display: flex;
45
+ align-items: center;
46
46
  background: var(--bg-surface);
47
47
  border: 1px solid var(--border-default);
48
48
  border-radius: var(--radius-md);
49
- padding: var(--space-sm) var(--space-md);
50
49
  transition:
51
50
  border-color var(--transition-fast),
52
51
  box-shadow var(--transition-fast),
@@ -55,17 +54,53 @@ export class ArcInput extends LitElement {
55
54
  width: 100%;
56
55
  }
57
56
 
58
- textarea.input-group__field { resize: vertical; }
59
-
60
- .input-group__field::placeholder { color: var(--text-ghost); }
61
- .input-group__field:hover:not(:focus) { border-color: var(--border-bright); }
62
- .input-group__field:focus {
63
- outline: none;
57
+ .input-group__wrapper:hover:not(:focus-within) { border-color: var(--border-bright); }
58
+ .input-group__wrapper:focus-within {
64
59
  border-color: rgba(var(--accent-primary-rgb), 0.4);
65
60
  box-shadow: var(--focus-glow);
66
61
  background: var(--bg-card);
67
62
  }
68
- .input-group__field:disabled { opacity: 0.4; cursor: not-allowed; }
63
+
64
+ :host([disabled]) .input-group__wrapper { opacity: 0.4; cursor: not-allowed; }
65
+
66
+ .input-group__field {
67
+ font-family: var(--font-body);
68
+ font-size: var(--body-size);
69
+ font-weight: 300;
70
+ color: var(--text-primary);
71
+ background: transparent;
72
+ border: none;
73
+ padding: var(--space-sm) var(--space-md);
74
+ box-sizing: border-box;
75
+ width: 100%;
76
+ min-width: 0;
77
+ }
78
+
79
+ .input-group__field:focus { outline: none; }
80
+ .input-group__field::placeholder { color: var(--text-ghost); }
81
+ .input-group__field:disabled { cursor: not-allowed; }
82
+
83
+ textarea.input-group__field { resize: vertical; }
84
+
85
+ .input-group__prefix,
86
+ .input-group__suffix {
87
+ display: flex;
88
+ align-items: center;
89
+ color: var(--text-muted);
90
+ flex-shrink: 0;
91
+ }
92
+
93
+ .input-group__prefix { padding-left: var(--space-md); }
94
+ .input-group__suffix { padding-right: var(--space-md); }
95
+
96
+ .input-group__prefix--empty,
97
+ .input-group__suffix--empty { display: none; }
98
+
99
+ ::slotted([slot="prefix"]),
100
+ ::slotted([slot="suffix"]) {
101
+ width: 20px;
102
+ height: 20px;
103
+ }
69
104
 
70
105
  @media (prefers-reduced-motion: reduce) {
71
106
  :host *,
@@ -92,6 +127,8 @@ export class ArcInput extends LitElement {
92
127
  this.multiline = false;
93
128
  this.rows = 5;
94
129
  this._fieldId = `arc-input-${++inputIdCounter}`;
130
+ this._hasPrefix = false;
131
+ this._hasSuffix = false;
95
132
  }
96
133
 
97
134
  updated(changed) {
@@ -112,6 +149,14 @@ export class ArcInput extends LitElement {
112
149
  this.dispatchEvent(new CustomEvent('arc-change', { detail: { value: this.value }, bubbles: true, composed: true }));
113
150
  }
114
151
 
152
+ _onPrefixSlotChange(e) {
153
+ this._hasPrefix = e.target.assignedNodes({ flatten: true }).length > 0;
154
+ }
155
+
156
+ _onSuffixSlotChange(e) {
157
+ this._hasSuffix = e.target.assignedNodes({ flatten: true }).length > 0;
158
+ }
159
+
115
160
  render() {
116
161
  const id = this.name || this._fieldId;
117
162
  const field = this.multiline
@@ -149,7 +194,15 @@ export class ArcInput extends LitElement {
149
194
  return html`
150
195
  <div class="input-group">
151
196
  ${this.label ? html`<label class="input-group__label" for=${id} part="label">${this.label}</label>` : ''}
152
- ${field}
197
+ <div class="input-group__wrapper" part="wrapper">
198
+ <div class="input-group__prefix ${this._hasPrefix ? '' : 'input-group__prefix--empty'}" part="prefix">
199
+ <slot name="prefix" @slotchange=${this._onPrefixSlotChange}></slot>
200
+ </div>
201
+ ${field}
202
+ <div class="input-group__suffix ${this._hasSuffix ? '' : 'input-group__suffix--empty'}" part="suffix">
203
+ <slot name="suffix" @slotchange=${this._onSuffixSlotChange}></slot>
204
+ </div>
205
+ </div>
153
206
  </div>
154
207
  `;
155
208
  }