@happyvertical/smrt-images 0.60.16 → 0.60.17

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.
@@ -178,98 +178,98 @@ async function handleAIEdit() {
178
178
  }
179
179
  </script>
180
180
 
181
- <div class="smrt-image-editor" data-smrt-component="ImageEditor">
182
- <div class="header">
181
+ <div class="smrt-image-editor__root" data-smrt-component="ImageEditor">
182
+ <div class="smrt-image-editor__header" data-smrt-part="header">
183
183
  <h3>{t(M['images.image_editor.title'])}</h3>
184
184
  {#if onCancel}
185
- <Button variant="ghost" size="sm" class="close-btn--x" onclick={onCancel}>×</Button>
185
+ <Button variant="ghost" size="sm" class="smrt-image-editor__close" onclick={onCancel}>×</Button>
186
186
  {/if}
187
187
  </div>
188
188
 
189
189
  {#if !image}
190
- <div class="empty-state">{t(M['images.image_editor.no_image_selected'])}</div>
190
+ <div class="smrt-image-editor__empty" data-smrt-part="empty">{t(M['images.image_editor.no_image_selected'])}</div>
191
191
  {:else}
192
- <div class="editor-content">
193
- <div class="image-preview" style="background-image: url({image.url})">
192
+ <div class="smrt-image-editor__content" data-smrt-part="body">
193
+ <div class="smrt-image-editor__preview" data-smrt-part="panel" style="background-image: url({image.url})">
194
194
  <!-- Optional: Interactive crop overlay could go here -->
195
195
  </div>
196
196
 
197
- <div class="editor-controls">
198
- <div class="mode-selector">
197
+ <div class="smrt-image-editor__controls" data-smrt-part="panel">
198
+ <div class="smrt-image-editor__modes" data-smrt-part="nav">
199
199
  <Button
200
200
  variant={mode === 'standard' ? 'primary' : 'ghost'}
201
- class="mode-tab"
201
+ class="smrt-image-editor__mode-button"
202
202
  onclick={() => (mode = 'standard')}
203
203
  >{t(M['images.image_editor.standard_tools'])}</Button>
204
204
  <Button
205
205
  variant={mode === 'ai' ? 'primary' : 'ghost'}
206
- class="mode-tab"
206
+ class="smrt-image-editor__mode-button"
207
207
  onclick={() => (mode = 'ai')}
208
208
  >{t(M['images.image_editor.ai_edit'])}</Button>
209
209
  </div>
210
210
 
211
211
  {#if error}
212
- <div class="error-msg">{error}</div>
212
+ <div class="smrt-image-editor__error" data-smrt-part="error">{error}</div>
213
213
  {/if}
214
214
  {#if successMessage}
215
- <div class="success-msg">{successMessage}</div>
215
+ <div class="smrt-image-editor__success" data-smrt-part="status">{successMessage}</div>
216
216
  {/if}
217
217
 
218
218
  {#if mode === 'standard'}
219
219
  <!-- Standard Operations -->
220
- <div class="tool-section">
220
+ <div class="smrt-image-editor__tool" data-smrt-part="group">
221
221
  <h4>Resize</h4>
222
- <div class="row">
223
- <label>Width <Input type="number" class="dim-input" bind:value={width} onfocus={() => isEditingDimensions = true} /></label>
224
- <label>Height <Input type="number" class="dim-input" bind:value={height} onfocus={() => isEditingDimensions = true} /></label>
225
- <Button variant="ghost" class="tonal-btn--filled" disabled={isProcessing} onclick={handleResize}>{t(M['images.image_editor.apply_resize'])}</Button>
222
+ <div class="smrt-image-editor__row" data-smrt-part="row">
223
+ <label>Width <Input type="number" class="smrt-image-editor__dimension-input" bind:value={width} onfocus={() => isEditingDimensions = true} /></label>
224
+ <label>Height <Input type="number" class="smrt-image-editor__dimension-input" bind:value={height} onfocus={() => isEditingDimensions = true} /></label>
225
+ <Button variant="ghost" class="smrt-image-editor__tonal-button" disabled={isProcessing} onclick={handleResize}>{t(M['images.image_editor.apply_resize'])}</Button>
226
226
  </div>
227
227
  {#if isEditingDimensions}
228
- <div class="row"><Button variant="ghost" size="sm" class="text-btn--link" onclick={resetDimensions}>{t(M['images.image_editor.reset_dimensions'])}</Button></div>
228
+ <div class="smrt-image-editor__row" data-smrt-part="row"><Button variant="ghost" size="sm" class="smrt-image-editor__text-button" onclick={resetDimensions}>{t(M['images.image_editor.reset_dimensions'])}</Button></div>
229
229
  {/if}
230
230
  </div>
231
231
 
232
- <div class="tool-section">
232
+ <div class="smrt-image-editor__tool" data-smrt-part="group">
233
233
  <h4>Crop</h4>
234
- <div class="row">
235
- <label>X <Input type="number" class="dim-input" bind:value={cropX} onfocus={() => isCropping = true} /></label>
236
- <label>Y <Input type="number" class="dim-input" bind:value={cropY} onfocus={() => isCropping = true} /></label>
234
+ <div class="smrt-image-editor__row" data-smrt-part="row">
235
+ <label>X <Input type="number" class="smrt-image-editor__dimension-input" bind:value={cropX} onfocus={() => isCropping = true} /></label>
236
+ <label>Y <Input type="number" class="smrt-image-editor__dimension-input" bind:value={cropY} onfocus={() => isCropping = true} /></label>
237
237
  </div>
238
- <div class="row">
239
- <label>W <Input type="number" class="dim-input" bind:value={cropW} onfocus={() => isCropping = true} /></label>
240
- <label>H <Input type="number" class="dim-input" bind:value={cropH} onfocus={() => isCropping = true} /></label>
241
- <Button variant="ghost" class="tonal-btn--filled" disabled={isProcessing} onclick={handleCrop}>{t(M['images.image_editor.apply_crop'])}</Button>
238
+ <div class="smrt-image-editor__row" data-smrt-part="row">
239
+ <label>W <Input type="number" class="smrt-image-editor__dimension-input" bind:value={cropW} onfocus={() => isCropping = true} /></label>
240
+ <label>H <Input type="number" class="smrt-image-editor__dimension-input" bind:value={cropH} onfocus={() => isCropping = true} /></label>
241
+ <Button variant="ghost" class="smrt-image-editor__tonal-button" disabled={isProcessing} onclick={handleCrop}>{t(M['images.image_editor.apply_crop'])}</Button>
242
242
  </div>
243
243
  {#if isCropping}
244
- <div class="row"><Button variant="ghost" size="sm" class="text-btn--link" onclick={resetDimensions}>{t(M['images.image_editor.reset_dimensions'])}</Button></div>
244
+ <div class="smrt-image-editor__row" data-smrt-part="row"><Button variant="ghost" size="sm" class="smrt-image-editor__text-button" onclick={resetDimensions}>{t(M['images.image_editor.reset_dimensions'])}</Button></div>
245
245
  {/if}
246
246
  </div>
247
247
 
248
- <div class="tool-section">
248
+ <div class="smrt-image-editor__tool" data-smrt-part="group">
249
249
  <h4>{t(M['images.image_editor.convert_format'])}</h4>
250
- <div class="row">
251
- <Select class="format-select" bind:value={format}>
250
+ <div class="smrt-image-editor__row" data-smrt-part="row">
251
+ <Select class="smrt-image-editor__format" bind:value={format}>
252
252
  <option value="webp">WebP</option>
253
253
  <option value="jpeg">JPEG</option>
254
254
  <option value="png">PNG</option>
255
255
  </Select>
256
- <Button variant="ghost" class="tonal-btn--filled" disabled={isProcessing} onclick={handleConvert}>Convert</Button>
256
+ <Button variant="ghost" class="smrt-image-editor__tonal-button" disabled={isProcessing} onclick={handleConvert}>Convert</Button>
257
257
  </div>
258
258
  </div>
259
259
  {:else}
260
260
  <!-- AI Operations -->
261
- <div class="tool-section">
261
+ <div class="smrt-image-editor__tool" data-smrt-part="group">
262
262
  <h4>{t(M['images.image_editor.ai_powered_edit'])}</h4>
263
- <p class="hint">{t(M['images.image_editor.ai_powered_edit_hint'])}</p>
263
+ <p class="smrt-image-editor__hint" data-smrt-part="description">{t(M['images.image_editor.ai_powered_edit_hint'])}</p>
264
264
  <Textarea
265
- class="ai-prompt"
265
+ class="smrt-image-editor__prompt"
266
266
  bind:value={prompt}
267
267
  placeholder={t(M['images.image_editor.ai_prompt_placeholder'])}
268
268
  rows={4}
269
269
  />
270
270
  <Button
271
271
  variant="primary"
272
- class="primary-btn--pill"
272
+ class="smrt-image-editor__primary-button"
273
273
  disabled={isProcessing || !prompt.trim()}
274
274
  onclick={handleAIEdit}
275
275
  >
@@ -284,189 +284,206 @@ async function handleAIEdit() {
284
284
 
285
285
  <style>
286
286
  @layer smrt.reset, smrt.structure, smrt.theme;
287
- @layer smrt.theme {
288
- .smrt-image-editor {
287
+ @layer smrt.structure {
288
+ .smrt-image-editor__root {
289
289
  display: flex;
290
290
  flex-direction: column;
291
291
  gap: 1rem;
292
292
  padding: 1.5rem;
293
- background: var(--smrt-color-surface-container);
294
- color: var(--smrt-color-on-surface);
295
- border-radius: var(--smrt-radius-lg);
296
- border: var(--smrt-hairline);
297
293
  }
298
-
299
- .header {
294
+ .smrt-image-editor__header {
300
295
  display: flex;
301
296
  justify-content: space-between;
302
297
  align-items: center;
303
- border-bottom: var(--smrt-hairline);
304
298
  padding-bottom: 1rem;
305
299
  margin-bottom: 0.5rem;
306
300
  }
307
-
308
- .header h3 {
301
+ .smrt-image-editor__header h3 {
309
302
  margin: 0;
310
- font-size: var(--smrt-typography-title-medium-size, 1.15rem);
311
- font-weight: var(--smrt-typography-weight-medium, 500);
312
- }
313
-
314
- /* The migrated close Button keeps ghost styling; only bump the × glyph size.
315
- :global() pierces into the Button child's rendered <button> (see #1589). */
316
- .header :global(.close-btn--x) {
317
- color: inherit;
318
- font-size: var(--smrt-typography-headline-small-size, 1.5rem);
319
- line-height: 1;
320
303
  }
321
-
322
- .empty-state {
304
+ .smrt-image-editor__empty {
323
305
  padding: 2rem;
324
- text-align: center;
325
- color: var(--smrt-color-outline);
326
306
  }
327
-
328
- .editor-content {
307
+ .smrt-image-editor__content {
329
308
  display: flex;
330
309
  flex-wrap: wrap;
331
310
  gap: 2rem;
332
311
  }
333
-
334
- .image-preview {
312
+ .smrt-image-editor__preview {
335
313
  flex: 1;
336
314
  min-width: 300px;
337
315
  min-height: 300px;
338
- background-size: contain;
339
- background-position: center;
340
- background-repeat: no-repeat;
341
- background-color: var(--smrt-color-surface-container-high);
342
- border-radius: var(--smrt-radius-md);
343
- border: 1px dashed var(--smrt-color-outline-variant);
344
316
  }
345
-
346
- .editor-controls {
317
+ .smrt-image-editor__controls {
347
318
  flex: 1;
348
319
  min-width: 300px;
349
320
  display: flex;
350
321
  flex-direction: column;
351
322
  gap: 1.5rem;
352
323
  }
353
-
354
324
  /* Segmented button style for tabs */
355
- .mode-selector {
325
+ .smrt-image-editor__modes {
356
326
  display: flex;
357
- background: var(--smrt-color-surface-container-high);
358
- border-radius: var(--smrt-radius-full);
359
327
  padding: 0.25rem;
360
328
  gap: 0.25rem;
361
329
  }
362
-
363
330
  /* The mode toggles are migrated Buttons (variant primary = active, ghost =
364
- inactive). Keep the segmented-pill sizing by piercing into each Button's
365
- rendered <button> (see #1589 scoping rule). */
366
- .mode-selector :global(.mode-tab) {
331
+ inactive). Keep the segmented-pill sizing by piercing into each Button's
332
+ rendered <button> (see #1589 scoping rule). */
333
+ .smrt-image-editor__modes :global(.smrt-image-editor__mode-button) {
367
334
  flex: 1;
368
335
  padding: 0.6rem 1rem;
369
- font-weight: var(--smrt-typography-weight-medium, 500);
370
- border-radius: var(--smrt-radius-full);
371
336
  }
372
-
373
- .tool-section h4 {
337
+ .smrt-image-editor__tool h4 {
374
338
  margin: 0 0 1rem 0;
375
- font-size: var(--smrt-typography-title-medium-size, 0.95rem);
376
- font-weight: var(--smrt-typography-weight-medium, 500);
377
- color: var(--smrt-color-on-surface-variant);
378
339
  }
379
-
380
- .row {
340
+ .smrt-image-editor__row {
381
341
  display: flex;
382
342
  gap: 0.75rem;
383
343
  align-items: center;
384
344
  margin-bottom: 0.75rem;
385
345
  flex-wrap: wrap;
386
346
  }
387
-
388
- .row label {
347
+ .smrt-image-editor__row label {
389
348
  display: flex;
390
349
  flex-direction: column;
391
- font-size: var(--smrt-typography-label-medium-size, 0.8rem);
392
- font-weight: var(--smrt-typography-weight-medium, 500);
393
- color: var(--smrt-color-outline);
394
350
  gap: 0.25rem;
395
351
  }
396
-
397
352
  /* Layout-only overrides for the migrated form primitives. The Input / Select /
398
- Textarea primitives own the visual styling (background, border, focus ring);
399
- these :global() rules only pierce their rendered controls to constrain box
400
- size and spacing (see #1589 scoping rule). */
401
- .row label :global(.dim-input) {
353
+ Textarea primitives own the visual styling (background, border, focus ring);
354
+ these :global() rules only pierce their rendered controls to constrain box
355
+ size and spacing (see #1589 scoping rule). */
356
+ .smrt-image-editor__row label :global(.smrt-image-editor__dimension-input) {
402
357
  width: 90px;
403
358
  }
404
-
405
359
  /* Size the format Select to its content instead of the primitive's full-width
406
- default so it sits inline beside the Convert button in the flex row. */
407
- .row :global(.format-select) {
360
+ default so it sits inline beside the Convert button in the flex row. */
361
+ .smrt-image-editor__row :global(.smrt-image-editor__format) {
408
362
  width: auto;
409
363
  }
410
-
411
- .tool-section :global(.ai-prompt) {
364
+ .smrt-image-editor__tool :global(.smrt-image-editor__prompt) {
412
365
  margin-bottom: 1rem;
413
366
  }
367
+ /* Migrated Buttons keep their bespoke filled-tonal / text-link / pill looks.
368
+ :global() pierces into each Button's rendered <button> (see #1589). */
369
+ .smrt-image-editor__tool :global(.smrt-image-editor__tonal-button) {
370
+ padding: 0.6rem 1.2rem;
371
+ margin-top: 1.25rem;
372
+ }
373
+ .smrt-image-editor__tool :global(.smrt-image-editor__text-button) {
374
+ padding: 0;
375
+ }
376
+ .smrt-image-editor__tool :global(.smrt-image-editor__primary-button) {
377
+ padding: 0.6rem 1.5rem;
378
+ }
379
+ .smrt-image-editor__hint {
380
+ margin: 0 0 0.5rem 0;
381
+ }
382
+ .smrt-image-editor__error {
383
+ padding: 0.5rem;
384
+ }
385
+ .smrt-image-editor__success {
386
+ padding: 0.5rem;
387
+ }
388
+ }
414
389
 
390
+ @layer smrt.theme {
391
+ .smrt-image-editor__root {
392
+ background: var(--smrt-color-surface-container);
393
+ color: var(--smrt-color-on-surface);
394
+ border-radius: var(--smrt-radius-lg);
395
+ border: var(--smrt-hairline);
396
+ }
397
+ .smrt-image-editor__header {
398
+ border-bottom: var(--smrt-hairline);
399
+ }
400
+ .smrt-image-editor__header h3 {
401
+ font-size: var(--smrt-typography-title-medium-size, 1.15rem);
402
+ font-weight: var(--smrt-typography-weight-medium, 500);
403
+ }
404
+ /* The migrated close Button keeps ghost styling; only bump the × glyph size.
405
+ :global() pierces into the Button child's rendered <button> (see #1589). */
406
+ .smrt-image-editor__header :global(.smrt-image-editor__close) {
407
+ color: inherit;
408
+ font-size: var(--smrt-typography-headline-small-size, 1.5rem);
409
+ line-height: 1;
410
+ }
411
+ .smrt-image-editor__empty {
412
+ text-align: center;
413
+ color: var(--smrt-color-outline);
414
+ }
415
+ .smrt-image-editor__preview {
416
+ background-size: contain;
417
+ background-position: center;
418
+ background-repeat: no-repeat;
419
+ background-color: var(--smrt-color-surface-container-high);
420
+ border-radius: var(--smrt-radius-md);
421
+ border: 1px dashed var(--smrt-color-outline-variant);
422
+ }
423
+ /* Segmented button style for tabs */
424
+ .smrt-image-editor__modes {
425
+ background: var(--smrt-color-surface-container-high);
426
+ border-radius: var(--smrt-radius-full);
427
+ }
428
+ /* The mode toggles are migrated Buttons (variant primary = active, ghost =
429
+ inactive). Keep the segmented-pill sizing by piercing into each Button's
430
+ rendered <button> (see #1589 scoping rule). */
431
+ .smrt-image-editor__modes :global(.smrt-image-editor__mode-button) {
432
+ font-weight: var(--smrt-typography-weight-medium, 500);
433
+ border-radius: var(--smrt-radius-full);
434
+ }
435
+ .smrt-image-editor__tool h4 {
436
+ font-size: var(--smrt-typography-title-medium-size, 0.95rem);
437
+ font-weight: var(--smrt-typography-weight-medium, 500);
438
+ color: var(--smrt-color-on-surface-variant);
439
+ }
440
+ .smrt-image-editor__row label {
441
+ font-size: var(--smrt-typography-label-medium-size, 0.8rem);
442
+ font-weight: var(--smrt-typography-weight-medium, 500);
443
+ color: var(--smrt-color-outline);
444
+ }
415
445
  /* Migrated Buttons keep their bespoke filled-tonal / text-link / pill looks.
416
- :global() pierces into each Button's rendered <button> (see #1589). */
417
- .tool-section :global(.tonal-btn--filled) {
446
+ :global() pierces into each Button's rendered <button> (see #1589). */
447
+ .smrt-image-editor__tool :global(.smrt-image-editor__tonal-button) {
418
448
  background: var(--smrt-color-surface-container-highest);
419
449
  color: var(--smrt-color-primary);
420
450
  border: var(--smrt-hairline);
421
- padding: 0.6rem 1.2rem;
422
451
  border-radius: var(--smrt-radius-full);
423
452
  font-weight: var(--smrt-typography-weight-medium, 500);
424
453
  transition: background 0.2s;
425
- margin-top: 1.25rem;
426
454
  }
427
-
428
- .tool-section :global(.tonal-btn--filled:hover:not(:disabled)) {
455
+ .smrt-image-editor__tool :global(.smrt-image-editor__tonal-button:hover:not(:disabled)) {
429
456
  background: var(--smrt-color-surface-container-high);
430
457
  }
431
-
432
- .tool-section :global(.text-btn--link) {
458
+ .smrt-image-editor__tool :global(.smrt-image-editor__text-button) {
433
459
  text-decoration: underline;
434
- padding: 0;
435
460
  }
436
- .tool-section :global(.text-btn--link:hover) {
461
+ .smrt-image-editor__tool :global(.smrt-image-editor__text-button:hover) {
437
462
  color: var(--smrt-color-on-surface);
438
463
  }
439
-
440
- .tool-section :global(.primary-btn--pill) {
441
- padding: 0.6rem 1.5rem;
464
+ .smrt-image-editor__tool :global(.smrt-image-editor__primary-button) {
442
465
  border-radius: var(--smrt-radius-full);
443
466
  font-weight: var(--smrt-typography-weight-medium, 500);
444
467
  }
445
-
446
- .tool-section :global(.primary-btn--pill:hover:not(:disabled)) {
468
+ .smrt-image-editor__tool :global(.smrt-image-editor__primary-button:hover:not(:disabled)) {
447
469
  filter: brightness(1.1);
448
470
  }
449
-
450
- .hint {
471
+ .smrt-image-editor__hint {
451
472
  font-size: var(--smrt-typography-body-small-size, 0.8rem);
452
473
  color: var(--smrt-color-outline);
453
- margin: 0 0 0.5rem 0;
454
474
  }
455
-
456
- .error-msg {
475
+ .smrt-image-editor__error {
457
476
  color: var(--smrt-color-error);
458
477
  background: color-mix(in srgb, var(--smrt-color-error) 10%, transparent);
459
- padding: 0.5rem;
460
478
  border-radius: var(--smrt-radius-sm);
461
479
  font-size: var(--smrt-typography-body-medium-size, 0.85rem);
462
480
  }
463
-
464
- .success-msg {
481
+ .smrt-image-editor__success {
465
482
  color: var(--smrt-color-success);
466
483
  background: color-mix(in srgb, var(--smrt-color-success) 10%, transparent);
467
- padding: 0.5rem;
468
484
  border-radius: var(--smrt-radius-sm);
469
485
  font-size: var(--smrt-typography-body-medium-size, 0.85rem);
470
486
  }
471
487
  }
488
+
472
489
  </style>