@parallelogram-js/dashboard 0.1.9 → 0.1.10

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": "@parallelogram-js/dashboard",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "A BEM-style CSS dashboard library inspired by shadcn/ui",
5
5
  "main": "dist/parallelogram-dashboard.css",
6
6
  "type": "module",
package/scss/_tokens.scss CHANGED
@@ -40,6 +40,8 @@ $theme-tokens: (
40
40
  secondary: ($zinc-100, $zinc-800),
41
41
  secondary-fg: ($zinc-900, $zinc-50),
42
42
  secondary-hover: ($zinc-200, $zinc-700),
43
+ secondary-muted: ($zinc-100, $zinc-800),
44
+ secondary-muted-fg: ($zinc-600, $zinc-300),
43
45
 
44
46
  // Destructive
45
47
  destructive: ($red-500, $red-600),
@@ -178,6 +180,7 @@ $chrome-tokens: (
178
180
  --navmenu-labelled-width: #{$navmenu-labelled-width};
179
181
  --subnav-width: #{$subnav-width};
180
182
  --navmenu-logo-height: #{$navmenu-logo-height};
183
+ --subnav-logo-height: #{$subnav-logo-height};
181
184
 
182
185
  // Chrome regions
183
186
  @each $region, $tokens in $chrome-tokens {
@@ -224,8 +224,10 @@ $navmenu-width: 4rem !default; // 64px
224
224
  $navmenu-labelled-width: 14rem !default; // 224px
225
225
  $subnav-width: 16rem !default; // 256px
226
226
 
227
- // Height of the logo in a labelled rail's header, emitted as --navmenu-logo-height
227
+ // Height of the logo in a labelled rail's header and in the section menu's header, emitted as
228
+ // --navmenu-logo-height and --subnav-logo-height
228
229
  $navmenu-logo-height: 1.5rem !default; // 24px
230
+ $subnav-logo-height: 1.5rem !default; // 24px
229
231
 
230
232
  // Navbar height
231
233
  $navbar-height: 4rem !default; // 64px
@@ -41,6 +41,11 @@
41
41
  color: var(--secondary-fg);
42
42
  }
43
43
 
44
+ &--secondary-muted {
45
+ background-color: var(--secondary-muted);
46
+ color: var(--secondary-muted-fg);
47
+ }
48
+
44
49
  // Outline
45
50
  &--outline {
46
51
  background-color: transparent;
@@ -118,6 +123,16 @@
118
123
  border-radius: $radius-full;
119
124
  }
120
125
 
126
+ &--round {
127
+ justify-content: center;
128
+ min-width: 1.25rem;
129
+ height: 1.25rem;
130
+ padding: 0 $spacing-3xs;
131
+ border-radius: $radius-full;
132
+ font-size: 0.625rem;
133
+ font-variant-numeric: tabular-nums;
134
+ }
135
+
121
136
  // Dot indicator (no text, just a colored dot)
122
137
  &--dot {
123
138
  width: 0.5rem;
@@ -103,6 +103,20 @@ $card-inner-radius: calc(#{$radius} - 1px);
103
103
  color: var(--fg-muted);
104
104
  }
105
105
 
106
+ &__link {
107
+ color: inherit;
108
+ text-decoration: none;
109
+ @include transition-colors;
110
+
111
+ &:hover {
112
+ color: var(--primary);
113
+ }
114
+
115
+ &:focus-visible {
116
+ @include focus-ring;
117
+ }
118
+ }
119
+
106
120
  &__content {
107
121
  padding: $spacing-sm;
108
122
  padding-top: 0;
@@ -328,6 +328,25 @@
328
328
  @include text-truncate;
329
329
  }
330
330
 
331
+ &__logo {
332
+ display: flex;
333
+ align-items: center;
334
+ min-width: 0;
335
+ height: 100%;
336
+ color: var(--fg);
337
+
338
+ svg,
339
+ img {
340
+ width: auto;
341
+ height: var(--subnav-logo-height);
342
+ max-width: 100%;
343
+ }
344
+
345
+ svg:not(.icon) {
346
+ fill: currentColor;
347
+ }
348
+ }
349
+
331
350
  &__actions {
332
351
  display: flex;
333
352
  align-items: center;
@@ -475,6 +494,20 @@
475
494
  &--disabled {
476
495
  @include disabled;
477
496
  }
497
+
498
+ &--static {
499
+ cursor: default;
500
+
501
+ &:hover {
502
+ color: var(--fg-muted);
503
+ background-color: transparent;
504
+ }
505
+ }
506
+
507
+ &--muted,
508
+ &--muted:hover {
509
+ color: var(--fg-subtle);
510
+ }
478
511
  }
479
512
 
480
513
  &__item-icon {
@@ -488,11 +521,40 @@
488
521
  .subnav__item--active & {
489
522
  color: var(--fg);
490
523
  }
524
+
525
+ .subnav__item--static:hover & {
526
+ color: var(--fg-subtle);
527
+ }
491
528
  }
492
529
 
493
530
  &__item-text {
494
531
  flex: 1;
495
532
  @include text-truncate;
533
+
534
+ &--stacked {
535
+ display: flex;
536
+ flex-direction: column;
537
+ min-width: 0;
538
+ }
539
+ }
540
+
541
+ &__item-primary,
542
+ &__item-secondary {
543
+ @include text-truncate;
544
+ }
545
+
546
+ &__item-primary {
547
+ font-weight: $font-weight-medium;
548
+ color: var(--fg);
549
+
550
+ .subnav__item--muted & {
551
+ color: var(--fg-muted);
552
+ }
553
+ }
554
+
555
+ &__item-secondary {
556
+ font-size: $font-size-xs;
557
+ color: var(--fg-muted);
496
558
  }
497
559
 
498
560
  &__item-badge {
@@ -643,6 +705,13 @@
643
705
  padding: $spacing-lg;
644
706
  }
645
707
 
708
+ .dashboard__alerts {
709
+ display: flex;
710
+ flex-direction: column;
711
+ gap: $spacing-xs;
712
+ margin-bottom: $spacing-md;
713
+ }
714
+
646
715
  // Open and close the off-canvas .subnav; only needed below lg, where the subnav leaves the layout
647
716
  .dashboard__subnav-toggle,
648
717
  .subnav__close {
@@ -151,6 +151,15 @@ $dropdown-open: '.dropdown:has(> .dropdown__trigger[aria-expanded="true"]), .dro
151
151
  color: var(--destructive-fg);
152
152
  }
153
153
  }
154
+
155
+ &--warning {
156
+ color: var(--warning-muted-fg);
157
+
158
+ &:hover {
159
+ background-color: var(--warning);
160
+ color: var(--warning-fg);
161
+ }
162
+ }
154
163
  }
155
164
 
156
165
  &__item-icon,
@@ -317,4 +326,11 @@ $dropdown-open: '.dropdown:has(> .dropdown__trigger[aria-expanded="true"]), .dro
317
326
  &--full {
318
327
  min-width: 100%;
319
328
  }
329
+
330
+ &--scrollable,
331
+ &--scrollable[popover] {
332
+ max-height: var(--dropdown-max-height, 20rem);
333
+ overflow-y: auto;
334
+ @include scrollbar-thin;
335
+ }
320
336
  }
@@ -270,6 +270,23 @@
270
270
  color: var(--fg-muted);
271
271
  }
272
272
 
273
+ &__addon--btn {
274
+ padding: 0 $spacing-2xs;
275
+ background-color: transparent;
276
+ cursor: pointer;
277
+ @include transition-colors;
278
+
279
+ &:hover {
280
+ background-color: var(--bg-muted);
281
+ color: var(--fg);
282
+ }
283
+
284
+ &:focus-visible {
285
+ z-index: 1;
286
+ @include focus-ring;
287
+ }
288
+ }
289
+
273
290
  // --------------------------------------------------------------------------
274
291
  // Fieldset
275
292
  // --------------------------------------------------------------------------
@@ -290,6 +290,29 @@
290
290
  user-select: none;
291
291
  }
292
292
 
293
+ &:has(> .switch__text) {
294
+ align-items: flex-start;
295
+ gap: $spacing-xs;
296
+ }
297
+
298
+ &__text {
299
+ display: flex;
300
+ flex-direction: column;
301
+ gap: $spacing-3xs;
302
+ min-width: 0;
303
+ user-select: none;
304
+
305
+ > .switch__label {
306
+ font-weight: $font-weight-medium;
307
+ line-height: var(--switch-height);
308
+ }
309
+ }
310
+
311
+ &__description {
312
+ font-size: $font-size-xs;
313
+ color: var(--fg-muted);
314
+ }
315
+
293
316
  &--sm {
294
317
  --switch-width: 1.75rem;
295
318
  --switch-height: 1rem;
@@ -312,3 +335,76 @@
312
335
  cursor: not-allowed;
313
336
  }
314
337
  }
338
+
339
+ // --------------------------------------------------------------------------
340
+ // Radio Card
341
+ // --------------------------------------------------------------------------
342
+
343
+ .radiocard {
344
+ position: relative;
345
+ display: flex;
346
+ cursor: pointer;
347
+
348
+ &__input {
349
+ position: absolute;
350
+ inset: 0;
351
+ width: 100%;
352
+ height: 100%;
353
+ margin: 0;
354
+ opacity: 0;
355
+ cursor: pointer;
356
+ }
357
+
358
+ &__content {
359
+ display: flex;
360
+ flex-direction: column;
361
+ gap: $spacing-3xs;
362
+ width: 100%;
363
+ padding: $spacing-sm $spacing-md;
364
+ border: var(--control-border-width) solid var(--input);
365
+ border-radius: $radius-md;
366
+ background-color: var(--bg);
367
+ @include transition-colors;
368
+ }
369
+
370
+ &:hover &__content {
371
+ border-color: var(--fg-subtle);
372
+ }
373
+
374
+ &__input:checked + &__content {
375
+ border-color: var(--primary);
376
+ background-color: color-mix(in srgb, var(--primary) 5%, var(--bg));
377
+ }
378
+
379
+ &__input:focus-visible + &__content {
380
+ @include focus-ring;
381
+ }
382
+
383
+ &__input:disabled + &__content {
384
+ @include disabled;
385
+ }
386
+
387
+ &:has(:disabled) {
388
+ cursor: not-allowed;
389
+ }
390
+
391
+ &__title {
392
+ display: flex;
393
+ align-items: center;
394
+ gap: $spacing-2xs;
395
+ font-size: $font-size-sm;
396
+ font-weight: $font-weight-medium;
397
+ color: var(--fg);
398
+
399
+ > .icon {
400
+ width: $icon-size-md;
401
+ height: $icon-size-md;
402
+ flex-shrink: 0;
403
+ }
404
+ }
405
+
406
+ &__description {
407
+ font-size: $font-size-xs;
408
+ color: var(--fg-muted);
409
+ }
410
+ }
@@ -24,6 +24,14 @@ p-modal > [slot="title"] {
24
24
  letter-spacing: $letter-spacing-tight;
25
25
  }
26
26
 
27
+ p-modal > [slot="actions"] {
28
+ display: flex;
29
+ flex-wrap: wrap;
30
+ justify-content: flex-end;
31
+ gap: $spacing-2xs;
32
+ width: 100%;
33
+ }
34
+
27
35
  p-modal {
28
36
  --modal-backdrop-bg: var(--color-overlay);
29
37
 
@@ -103,6 +103,26 @@
103
103
  }
104
104
  }
105
105
 
106
+ &--interactive {
107
+ color: inherit;
108
+ text-decoration: none;
109
+ cursor: pointer;
110
+ @include transition-default;
111
+
112
+ &:hover {
113
+ border-color: var(--fg-subtle);
114
+ }
115
+
116
+ &:focus-visible {
117
+ @include focus-ring;
118
+ }
119
+
120
+ &[aria-current]:not([aria-current="false"]) {
121
+ border-color: var(--primary);
122
+ background-color: color-mix(in srgb, var(--primary) 6%, var(--card));
123
+ }
124
+ }
125
+
106
126
  &--compact {
107
127
  padding: $spacing-sm;
108
128
 
@@ -105,6 +105,38 @@
105
105
  vertical-align: middle;
106
106
  }
107
107
 
108
+ &__link {
109
+ color: var(--fg);
110
+ font-weight: $font-weight-medium;
111
+ text-decoration: none;
112
+ @include transition-colors;
113
+
114
+ &:hover {
115
+ color: var(--primary);
116
+ }
117
+
118
+ &:focus-visible {
119
+ @include focus-ring;
120
+ }
121
+ }
122
+
123
+ &__cell--truncate {
124
+ > a,
125
+ > span {
126
+ display: inline-flex;
127
+ align-items: center;
128
+ gap: $spacing-3xs;
129
+ max-width: var(--table-truncate-width, 18.75rem);
130
+ overflow: hidden;
131
+ text-overflow: ellipsis;
132
+ white-space: nowrap;
133
+
134
+ > .icon {
135
+ flex-shrink: 0;
136
+ }
137
+ }
138
+ }
139
+
108
140
  &__caption {
109
141
  margin-top: $spacing-sm;
110
142
  font-size: $font-size-sm;
@@ -24,7 +24,9 @@ function niceMax(value) {
24
24
  * Types: line, area, bar (grouped when there are several series) and stacked-bar.
25
25
  * The first column holds the x labels and every other column is a series. Cells may carry
26
26
  * data-value when their text is formatted. data-chart-format is "number", "currency" or
27
- * "percent". The table stays in the page as the accessible table view.
27
+ * "percent"; data-chart-currency is the ISO 4217 code for "currency" (USD by default) and
28
+ * data-chart-locale the BCP 47 locale the figures are written in (en-US by default). The table
29
+ * stays in the page as the accessible table view.
28
30
  */
29
31
  export class Chart {
30
32
  constructor() {
@@ -44,7 +46,7 @@ export class Chart {
44
46
  table,
45
47
  data,
46
48
  type: figure.dataset.chart || 'line',
47
- format: this._formatter(figure.dataset.chartFormat),
49
+ format: this._formatter(figure.dataset.chartFormat, figure.dataset.chartCurrency, figure.dataset.chartLocale),
48
50
  plot: document.createElement('div'),
49
51
  tooltip: document.createElement('div'),
50
52
  index: null,
@@ -94,13 +96,22 @@ export class Chart {
94
96
  return { series: headers.slice(1), rows };
95
97
  }
96
98
 
97
- _formatter(kind) {
99
+ /**
100
+ * Formats values for the axis (compact) and the tooltip (full). An unknown currency code or
101
+ * locale falls back to the defaults rather than leaving the chart undrawn.
102
+ */
103
+ _formatter(kind, currency = 'USD', locale = 'en-US') {
98
104
  const options = {
99
- currency: { style: 'currency', currency: 'USD', maximumFractionDigits: 0 },
105
+ currency: { style: 'currency', currency, maximumFractionDigits: 0 },
100
106
  percent: { style: 'percent', maximumFractionDigits: 1 },
101
107
  }[kind] || { maximumFractionDigits: 1 };
102
- const full = new Intl.NumberFormat('en-US', options);
103
- const compact = new Intl.NumberFormat('en-US', { ...options, notation: 'compact', maximumFractionDigits: 1 });
108
+ let full;
109
+ try {
110
+ full = new Intl.NumberFormat(locale, options);
111
+ } catch {
112
+ return this._formatter(kind);
113
+ }
114
+ const compact = new Intl.NumberFormat(locale, { ...options, notation: 'compact', maximumFractionDigits: 1 });
104
115
  const scale = kind === 'percent' ? 0.01 : 1;
105
116
  return {
106
117
  full: value => full.format(value * scale),