@14ch/svelte-ui 0.0.2 → 0.0.3

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/README.md CHANGED
@@ -346,6 +346,15 @@ MIT License - see the [LICENSE](LICENSE) file for details.
346
346
 
347
347
  ## Changelog
348
348
 
349
+ ### v0.0.3
350
+
351
+ - Improved text vertical alignment in Button, Fab, TabItem, Checkbox, and Radio components using `text-box-trim`
352
+ - Text labels now appear more visually centered within their containers
353
+
354
+ ### v0.0.2
355
+
356
+ (Previous release notes...)
357
+
349
358
  ### v0.0.1
350
359
 
351
360
  - Initial release
@@ -293,12 +293,13 @@
293
293
  --svelte-ui-button-height-sm: var(--svelte-ui-form-height-sm);
294
294
  --svelte-ui-button-height: var(--svelte-ui-form-height);
295
295
  --svelte-ui-button-height-lg: var(--svelte-ui-form-height-lg);
296
- --svelte-ui-button-padding-sm: 0 8px;
297
- --svelte-ui-button-padding: 0 12px;
298
- --svelte-ui-button-padding-lg: 0 16px;
296
+ --svelte-ui-button-padding-sm: 6px 8px;
297
+ --svelte-ui-button-padding: 8px 12px;
298
+ --svelte-ui-button-padding-lg: 12px 16px;
299
299
  --svelte-ui-button-font-size-sm: 14px;
300
300
  --svelte-ui-button-font-size: inherit;
301
301
  --svelte-ui-button-font-size-lg: 16px;
302
+ --svelte-ui-button-line-height: 1.2em;
302
303
  --svelte-ui-button-border-radius: var(--svelte-ui-border-radius);
303
304
  --svelte-ui-button-border-radius-rounded: var(--svelte-ui-border-radius-rounded);
304
305
  --svelte-ui-button-disabled-opacity: var(--svelte-ui-disabled-opacity);
@@ -412,6 +413,7 @@
412
413
  --svelte-ui-checkbox-icon-size: 1rem;
413
414
  --svelte-ui-checkbox-icon-size-sm: 0.875rem;
414
415
  --svelte-ui-checkbox-icon-size-lg: 1.25rem;
416
+ --svelte-ui-checkbox-line-height: 1.2em;
415
417
  --svelte-ui-checkbox-disabled-opacity: var(--svelte-ui-disabled-opacity);
416
418
  --svelte-ui-checkbox-border-color: var(--svelte-ui-border-color);
417
419
  --svelte-ui-checkbox-bg-checked: var(--svelte-ui-checkbox-checked-color);
@@ -437,6 +439,7 @@
437
439
  var(--svelte-ui-switch-height-lg) - var(--svelte-ui-switch-thumb-margin) * 2
438
440
  );
439
441
  --svelte-ui-switch-gap: 8px;
442
+ --svelte-ui-switch-line-height: 1.2em;
440
443
  --svelte-ui-switch-disabled-opacity: var(--svelte-ui-disabled-opacity);
441
444
  --svelte-ui-switch-border-radius: var(--svelte-ui-border-radius-rounded);
442
445
  --svelte-ui-switch-thumb-border-radius: var(--svelte-ui-border-radius-rounded);
@@ -457,9 +460,8 @@
457
460
  --svelte-ui-radio-min-height: 20px;
458
461
  --svelte-ui-radio-min-height-sm: 16px;
459
462
  --svelte-ui-radio-min-height-lg: 24px;
460
- --svelte-ui-radio-padding: 0 0 0 24px;
461
- --svelte-ui-radio-padding-sm: 0 0 0 20px;
462
- --svelte-ui-radio-padding-lg: 0 0 0 28px;
463
+ --svelte-ui-radio-gap: 8px;
464
+ --svelte-ui-radio-line-height: 1.2em;
463
465
  --svelte-ui-radio-disabled-opacity: var(--svelte-ui-disabled-opacity);
464
466
  --svelte-ui-radio-border-color: var(--svelte-ui-border-color);
465
467
  --svelte-ui-radio-bg-checked: var(--svelte-ui-radio-checked-color);
@@ -502,9 +502,11 @@
502
502
 
503
503
  .button__label {
504
504
  width: 100%;
505
- display: flex;
506
- align-items: center;
507
- justify-content: center;
505
+ display: block;
506
+ text-align: center;
507
+ line-height: var(--svelte-ui-button-line-height);
508
+ text-box-trim: trim-both;
509
+ text-box-edge: cap alphabetic;
508
510
  transition-property: opacity;
509
511
  transition-duration: var(--svelte-ui-transition-duration);
510
512
  }
@@ -330,6 +330,7 @@
330
330
  display: flex;
331
331
  align-items: center;
332
332
  width: fit-content;
333
+ min-height: var(--svelte-ui-checkbox-min-height);
333
334
  contain: layout;
334
335
  }
335
336
 
@@ -344,14 +345,15 @@
344
345
 
345
346
  /* Label */
346
347
  .checkbox__label {
347
- display: flex;
348
- align-items: center;
349
- min-height: var(--svelte-ui-checkbox-min-height);
348
+ display: block;
350
349
  padding-left: var(--svelte-ui-checkbox-gap);
351
350
  white-space: nowrap;
352
351
  font-size: inherit;
353
352
  color: inherit;
353
+ line-height: var(--svelte-ui-checkbox-line-height);
354
354
  cursor: pointer;
355
+ text-box-trim: trim-both;
356
+ text-box-edge: cap alphabetic;
355
357
  }
356
358
 
357
359
  /* Checkbox box */
@@ -115,7 +115,7 @@
115
115
  return styles.join('; ');
116
116
  });
117
117
 
118
- const dialogClasses = $derived(['dialog', scrollable && 'scrollable'].filter(Boolean).join(' '));
118
+ const dialogClasses = $derived([scrollable && 'scrollable'].filter(Boolean).join(' ')); // dialogクラス自体はcustomClassに含めない
119
119
 
120
120
  const ariaLabelledby = $derived(title ? 'dialog-title' : undefined);
121
121
  const ariaDescribedbyValue = $derived(
@@ -136,7 +136,7 @@
136
136
  customStyles={dialogStyles}
137
137
  id={id ? `${id}-modal` : undefined}
138
138
  >
139
- <div class="dialog">
139
+ <div class="dialog {scrollable ? 'scrollable' : ''}">
140
140
  {#if header || title}
141
141
  <div class="dialog__header">
142
142
  {#if header}
@@ -166,11 +166,7 @@
166
166
  </div>
167
167
  </Modal>
168
168
 
169
- <style>:global(.dialog) {
170
- color: var(--svelte-ui-dialog-title-color);
171
- }
172
-
173
- .dialog {
169
+ <style>.dialog {
174
170
  display: flex;
175
171
  flex-direction: column;
176
172
  justify-content: stretch;
@@ -218,28 +214,15 @@
218
214
  border-bottom: 1px solid var(--svelte-ui-border-weak-color);
219
215
  }
220
216
 
221
- :global(.dialog.scrollable) .dialog__header {
217
+ :global(.scrollable) .dialog__header {
222
218
  margin-bottom: 0;
223
219
  border-bottom: solid var(--svelte-ui-border-width, 1px) var(--svelte-ui-border-weak-color);
224
220
  }
225
- :global(.dialog.scrollable) .dialog__body {
221
+ :global(.scrollable) .dialog__body {
226
222
  flex-shrink: 1;
227
223
  padding: var(--svelte-ui-dialog-body-padding);
228
224
  overflow: auto;
229
225
  }
230
- :global(.dialog.scrollable) .dialog__footer {
226
+ :global(.scrollable) .dialog__footer {
231
227
  border-top: solid var(--svelte-ui-border-width, 1px) var(--svelte-ui-border-weak-color);
232
- }
233
-
234
- /* Screen reader only content */
235
- :global(.sr-only) {
236
- position: absolute;
237
- width: 1px;
238
- height: 1px;
239
- padding: 0;
240
- margin: -1px;
241
- overflow: hidden;
242
- clip: rect(0, 0, 0, 0);
243
- white-space: nowrap;
244
- border: 0;
245
228
  }</style>
@@ -123,7 +123,9 @@
123
123
  });
124
124
 
125
125
  const drawerClasses = $derived(
126
- ['drawer', `drawer--${position}`, scrollable && 'drawer--scrollable'].filter(Boolean).join(' ')
126
+ ['drawer-wrapper', `drawer-wrapper--${position}`, scrollable && 'drawer-wrapper--scrollable']
127
+ .filter(Boolean)
128
+ .join(' ')
127
129
  );
128
130
 
129
131
  const ariaLabelledby = $derived(title ? 'drawer-title' : undefined);
@@ -176,7 +178,7 @@
176
178
  </Modal>
177
179
 
178
180
  <style>@charset "UTF-8";
179
- :global(.drawer) {
181
+ :global(.drawer-wrapper) {
180
182
  width: 100%;
181
183
  height: 100%;
182
184
  min-height: 100%;
@@ -186,7 +188,7 @@
186
188
  color: var(--svelte-ui-drawer-title-color);
187
189
  }
188
190
 
189
- :global(.drawer:-internal-dialog-in-top-layer) {
191
+ :global(.drawer-wrapper:-internal-dialog-in-top-layer) {
190
192
  max-height: none;
191
193
  max-width: none;
192
194
  width: 100%;
@@ -257,31 +259,31 @@
257
259
  transform: translateX(-50%);
258
260
  }
259
261
  }
260
- :global(.drawer--right.fade-in) {
262
+ :global(.drawer-wrapper--right.fade-in) {
261
263
  animation: fadeInFromRight var(--svelte-ui-transition-duration, 300ms) forwards;
262
264
  }
263
265
 
264
- :global(.drawer--right.fade-in::backdrop) {
266
+ :global(.drawer-wrapper--right.fade-in::backdrop) {
265
267
  animation: fadeIn var(--svelte-ui-transition-duration, 300ms) forwards;
266
268
  }
267
269
 
268
- :global(.drawer--left.fade-in) {
270
+ :global(.drawer-wrapper--left.fade-in) {
269
271
  animation: fadeInFromLeft var(--svelte-ui-transition-duration, 300ms) forwards;
270
272
  }
271
273
 
272
- :global(.drawer--left.fade-in::backdrop) {
274
+ :global(.drawer-wrapper--left.fade-in::backdrop) {
273
275
  animation: fadeIn var(--svelte-ui-transition-duration, 300ms) forwards;
274
276
  }
275
277
 
276
- :global(.drawer--left.fade-out) {
278
+ :global(.drawer-wrapper--left.fade-out) {
277
279
  animation: fadeOutToLeft var(--svelte-ui-transition-duration, 300ms) forwards;
278
280
  }
279
281
 
280
- :global(.drawer--right.fade-out) {
282
+ :global(.drawer-wrapper--right.fade-out) {
281
283
  animation: fadeOutToRight var(--svelte-ui-transition-duration, 300ms) forwards;
282
284
  }
283
285
 
284
- :global(.drawer.fade-out::backdrop) {
286
+ :global(.drawer-wrapper.fade-out::backdrop) {
285
287
  animation: fadeOut var(--svelte-ui-transition-duration, 300ms) forwards;
286
288
  }
287
289
 
@@ -356,28 +358,16 @@
356
358
 
357
359
  /* Reduced motion support */
358
360
  @media (prefers-reduced-motion: reduce) {
359
- :global(.drawer.fade-in),
360
- :global(.drawer.fade-in::backdrop),
361
- :global(.drawer.fade-out),
362
- :global(.drawer.fade-out::backdrop),
363
- :global(.drawer--left.fade-in),
364
- :global(.drawer--left.fade-in::backdrop),
365
- :global(.drawer--left.fade-out),
366
- :global(.drawer--right.fade-in),
367
- :global(.drawer--right.fade-in::backdrop),
368
- :global(.drawer--right.fade-out) {
361
+ :global(.drawer-wrapper.fade-in),
362
+ :global(.drawer-wrapper.fade-in::backdrop),
363
+ :global(.drawer-wrapper.fade-out),
364
+ :global(.drawer-wrapper.fade-out::backdrop),
365
+ :global(.drawer-wrapper--left.fade-in),
366
+ :global(.drawer-wrapper--left.fade-in::backdrop),
367
+ :global(.drawer-wrapper--left.fade-out),
368
+ :global(.drawer-wrapper--right.fade-in),
369
+ :global(.drawer-wrapper--right.fade-in::backdrop),
370
+ :global(.drawer-wrapper--right.fade-out) {
369
371
  animation-duration: 0.01s;
370
372
  }
371
- }
372
- /* Screen reader only content */
373
- :global(.sr-only) {
374
- position: absolute;
375
- width: 1px;
376
- height: 1px;
377
- padding: 0;
378
- margin: -1px;
379
- overflow: hidden;
380
- clip: rect(0, 0, 0, 0);
381
- white-space: nowrap;
382
- border: 0;
383
373
  }</style>
@@ -452,8 +452,12 @@
452
452
  justify-content: center;
453
453
  }
454
454
  .fab .fab__label {
455
+ display: block;
455
456
  white-space: nowrap;
456
457
  user-select: none;
458
+ text-align: center;
459
+ text-box-trim: trim-both;
460
+ text-box-edge: cap alphabetic;
457
461
  transition-property: opacity;
458
462
  transition-duration: var(--svelte-ui-transition-duration);
459
463
  }
@@ -581,19 +581,6 @@
581
581
  animation: fadeOut 300ms forwards;
582
582
  }
583
583
 
584
- /* Screen reader only content */
585
- :global(.sr-only) {
586
- position: absolute;
587
- width: 1px;
588
- height: 1px;
589
- padding: 0;
590
- margin: -1px;
591
- overflow: hidden;
592
- clip: rect(0, 0, 0, 0);
593
- white-space: nowrap;
594
- border: 0;
595
- }
596
-
597
584
  /* =============================================
598
585
  * Mobile-specific styles
599
586
  * ============================================= */
@@ -393,7 +393,7 @@
393
393
  }
394
394
  }
395
395
  /* Enhanced mobile menu styles */
396
- :global(.mobile .popup-menu) {
396
+ :global(.popup--mobile) .popup-menu {
397
397
  border-radius: 0;
398
398
  box-shadow: none;
399
399
  background: transparent;
@@ -402,7 +402,7 @@
402
402
  min-width: auto;
403
403
  }
404
404
 
405
- :global(.mobile.fullscreen .popup-menu) {
405
+ :global(.popup--mobile.popup--fullscreen) .popup-menu {
406
406
  background: var(--svelte-ui-surface-color);
407
407
  border-radius: var(--svelte-ui-popup-mobile-border-radius);
408
408
  box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
@@ -410,11 +410,11 @@
410
410
  padding: 0;
411
411
  }
412
412
 
413
- :global(.mobile.fullscreen .popup-menu__list) {
413
+ :global(.popup--mobile.popup--fullscreen) .popup-menu__list {
414
414
  padding: 16px 0;
415
415
  }
416
416
 
417
- :global(.mobile.fullscreen .popup-menu__button) {
417
+ :global(.popup--mobile.popup--fullscreen) .popup-menu__button {
418
418
  padding: 16px 24px;
419
419
  font-size: 1.1rem;
420
420
  min-height: var(--svelte-ui-touch-target-lg);
@@ -349,17 +349,4 @@
349
349
 
350
350
  <style>.button-block {
351
351
  width: fit-content;
352
- }
353
-
354
- /* Screen reader only content */
355
- :global(.sr-only) {
356
- position: absolute;
357
- width: 1px;
358
- height: 1px;
359
- padding: 0;
360
- margin: -1px;
361
- overflow: hidden;
362
- clip: rect(0, 0, 0, 0);
363
- white-space: nowrap;
364
- border: 0;
365
352
  }</style>
@@ -354,6 +354,8 @@
354
354
  display: flex;
355
355
  align-items: center;
356
356
  width: fit-content;
357
+ min-height: var(--svelte-ui-radio-min-height);
358
+ contain: layout;
357
359
  }
358
360
 
359
361
  .radio input[type='radio'] {
@@ -368,13 +370,15 @@
368
370
 
369
371
  /* Label */
370
372
  .radio__label {
371
- display: flex;
372
- align-items: center;
373
+ display: block;
374
+ padding-left: var(--svelte-ui-radio-gap);
373
375
  white-space: nowrap;
374
376
  font-size: inherit;
375
377
  color: inherit;
378
+ line-height: var(--svelte-ui-radio-line-height);
376
379
  cursor: pointer;
377
- min-height: var(--svelte-ui-checkbox-min-height);
380
+ text-box-trim: trim-both;
381
+ text-box-edge: cap alphabetic;
378
382
  }
379
383
 
380
384
  /* Icon */
@@ -382,7 +386,7 @@
382
386
  position: relative;
383
387
  display: flex;
384
388
  align-items: center;
385
- padding: var(--svelte-ui-radio-padding);
389
+ width: var(--svelte-ui-radio-size);
386
390
  white-space: nowrap;
387
391
  font-size: inherit;
388
392
  color: inherit;
@@ -470,7 +474,7 @@
470
474
  }
471
475
 
472
476
  .radio--small .radio__icon {
473
- padding: var(--svelte-ui-radio-padding-sm);
477
+ width: var(--svelte-ui-radio-size-sm);
474
478
  min-height: var(--svelte-ui-radio-min-height-sm);
475
479
  }
476
480
 
@@ -494,7 +498,7 @@
494
498
  }
495
499
 
496
500
  .radio--large .radio__icon {
497
- padding: var(--svelte-ui-radio-padding-lg);
501
+ width: var(--svelte-ui-radio-size-lg);
498
502
  min-height: var(--svelte-ui-radio-min-height-lg);
499
503
  }
500
504
 
@@ -464,10 +464,5 @@
464
464
  width: var(--svelte-ui-slider-thumb-width-mobile);
465
465
  height: var(--svelte-ui-slider-thumb-height-mobile);
466
466
  }
467
-
468
- :global(.slider__custom-thumb) {
469
- width: var(--svelte-ui-slider-custom-thumb-size-mobile);
470
- height: var(--svelte-ui-slider-custom-thumb-size-mobile);
471
- }
472
467
  }
473
468
  </style>
@@ -117,8 +117,4 @@
117
117
  pointer-events: auto;
118
118
  position: relative;
119
119
  }
120
-
121
- .snackbar__item :global(.snackbar-item__content) {
122
- margin-bottom: 0;
123
- }
124
120
  </style>
@@ -328,12 +328,10 @@
328
328
  * Base Styles
329
329
  * ============================================= */
330
330
  .switch {
331
- display: inline-flex;
331
+ display: flex;
332
332
  align-items: center;
333
- font-family: var(--svelte-ui-font-family);
334
- font-size: inherit;
335
- line-height: var(--svelte-ui-line-height);
336
- color: var(--svelte-ui-text-color);
333
+ width: fit-content;
334
+ contain: layout;
337
335
  }
338
336
 
339
337
  .switch-input {
@@ -350,10 +348,13 @@
350
348
  }
351
349
 
352
350
  .switch__label {
353
- display: inline-flex;
354
- align-items: center;
351
+ display: block;
355
352
  padding-left: var(--svelte-ui-switch-gap);
353
+ white-space: nowrap;
354
+ line-height: var(--svelte-ui-checkbox-line-height);
356
355
  cursor: pointer;
356
+ text-box-trim: trim-both;
357
+ text-box-edge: cap alphabetic;
357
358
  user-select: none;
358
359
  }
359
360
  .switch__label--disabled {
@@ -158,23 +158,23 @@
158
158
  data-testid="tab"
159
159
  >
160
160
  {#each tabItems as tabItem, index}
161
- <div class="tab__item">
162
- <TabItem
163
- {tabItem}
164
- isSelected={index === selectedTabIndex}
165
- {textColor}
166
- {selectedTextColor}
167
- {selectedBarColor}
168
- />
169
- </div>
161
+ <TabItem
162
+ {tabItem}
163
+ isSelected={index === selectedTabIndex}
164
+ {textColor}
165
+ {selectedTextColor}
166
+ {selectedBarColor}
167
+ />
170
168
  {/each}
171
169
  </div>
172
170
 
173
171
  <style>.tab {
174
172
  display: flex;
175
173
  justify-content: start;
174
+ position: relative;
176
175
  width: 100%;
177
176
  height: 100%;
177
+ min-height: 36px;
178
178
  overflow-x: auto;
179
179
  overflow-y: visible;
180
180
  -ms-overflow-style: none;
@@ -184,10 +184,4 @@
184
184
 
185
185
  .tab::-webkit-scrollbar {
186
186
  display: none;
187
- }
188
-
189
- .tab__item {
190
- display: block;
191
- height: 100%;
192
- flex-shrink: 0;
193
187
  }</style>
@@ -70,7 +70,7 @@
70
70
  </div>
71
71
  {/if}
72
72
  {#if tabItem.title}
73
- <div class="tab-item__text">
73
+ <div class="tab-item__label">
74
74
  {tabItem.title}
75
75
  </div>
76
76
  {/if}
@@ -83,8 +83,7 @@
83
83
  align-items: center;
84
84
  gap: 8px;
85
85
  position: relative;
86
- height: 100%;
87
- padding: 0 16px;
86
+ padding: 8px 16px;
88
87
  color: var(--text-color);
89
88
  white-space: nowrap;
90
89
  text-decoration: none;
@@ -137,4 +136,9 @@
137
136
 
138
137
  .tab-item--selected::before {
139
138
  opacity: 1;
139
+ }
140
+
141
+ .tab-item__label {
142
+ text-box-trim: trim-both;
143
+ text-box-edge: cap alphabetic;
140
144
  }</style>
@@ -55,7 +55,7 @@
55
55
  <div class="skeleton-text__line" style="width: {widthStyle}">
56
56
  <SkeletonBox
57
57
  width="100%"
58
- height="1em"
58
+ height="1.2em"
59
59
  radius="var(--svelte-ui-skeleton-text-border-radius)"
60
60
  {animated}
61
61
  />
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@14ch/svelte-ui",
3
3
  "description": "Modern Svelte UI components library with TypeScript support",
4
4
  "private": false,
5
- "version": "0.0.2",
5
+ "version": "0.0.3",
6
6
  "type": "module",
7
7
  "keywords": [
8
8
  "svelte",