@parallelogram-js/dashboard 0.1.4 → 0.1.6

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.4",
3
+ "version": "0.1.6",
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
@@ -174,6 +174,10 @@ $chrome-tokens: (
174
174
  --radius: var(--radius-lg);
175
175
  --control-border-width: #{$control-border-width};
176
176
  --icon-stroke-width: #{$icon-stroke-width};
177
+ --navmenu-width: #{$navmenu-width};
178
+ --navmenu-labelled-width: #{$navmenu-labelled-width};
179
+ --subnav-width: #{$subnav-width};
180
+ --navmenu-logo-height: #{$navmenu-logo-height};
177
181
 
178
182
  // Chrome regions
179
183
  @each $region, $tokens in $chrome-tokens {
@@ -218,5 +218,14 @@ $icon-size-lg: 1.5rem !default; // 24px
218
218
  $sidebar-width: 16rem !default; // 256px
219
219
  $sidebar-width-collapsed: 4rem !default; // 64px
220
220
 
221
+ // Dashboard rail and section menu widths, emitted as --navmenu-width, --navmenu-labelled-width
222
+ // and --subnav-width so a theme can change them
223
+ $navmenu-width: 4rem !default; // 64px
224
+ $navmenu-labelled-width: 14rem !default; // 224px
225
+ $subnav-width: 16rem !default; // 256px
226
+
227
+ // Height of the logo in a labelled rail's header, emitted as --navmenu-logo-height
228
+ $navmenu-logo-height: 1.5rem !default; // 24px
229
+
221
230
  // Navbar height
222
231
  $navbar-height: 4rem !default; // 64px
@@ -252,15 +252,23 @@
252
252
  padding: 0;
253
253
  }
254
254
 
255
- // Grows to fill the bar; once it would drop below its minimum, segments fold into "more"
255
+ // Grows to fill the bar; once it would drop below its minimum, segments fold into "more". Its
256
+ // label, detail and badges sit on one baseline, whatever their size, and the line sits in the
257
+ // middle of the bar. The label and detail grow from nothing up to their own width, so nothing
258
+ // they say pushes the line to wrap: they truncate instead, the label last.
256
259
  &__title {
257
260
  flex: 1 1 auto;
261
+ flex-wrap: wrap;
262
+ align-content: center;
263
+ align-items: baseline;
258
264
  min-width: 10rem;
259
265
  gap: $spacing-xs;
260
266
  }
261
267
 
262
268
  &__label {
269
+ flex: 4 1 0;
263
270
  min-width: 0;
271
+ max-width: max-content;
264
272
  font-weight: $font-weight-medium;
265
273
  color: inherit;
266
274
  text-decoration: none;
@@ -274,8 +282,9 @@
274
282
 
275
283
  // Gives way before the label does
276
284
  &__meta {
277
- flex-shrink: 4;
285
+ flex: 1 1 0;
278
286
  min-width: 0;
287
+ max-width: max-content;
279
288
  font-size: $font-size-xs;
280
289
  color: var(--fg-muted);
281
290
  @include text-truncate;
@@ -27,6 +27,12 @@
27
27
  display: flex;
28
28
  min-height: 100vh;
29
29
  background-color: var(--bg);
30
+
31
+ // The section menu and the main column are offset by the rail's width, so a labelled rail
32
+ // sets it for the whole shell rather than only for itself
33
+ &:has(> .navmenu--labelled) {
34
+ --navmenu-width: var(--navmenu-labelled-width);
35
+ }
30
36
  }
31
37
 
32
38
  // --------------------------------------------------------------------------
@@ -38,7 +44,7 @@
38
44
  top: 0;
39
45
  display: flex;
40
46
  flex-direction: column;
41
- width: 4rem;
47
+ width: var(--navmenu-width);
42
48
  height: 100vh;
43
49
  @include chrome-region(navmenu);
44
50
  border-right: 1px solid var(--border);
@@ -132,6 +138,12 @@
132
138
  }
133
139
  }
134
140
 
141
+ // Shown only in a labelled rail; the icon rail names its items with the tooltip
142
+ &__label,
143
+ &__section-title {
144
+ display: none;
145
+ }
146
+
135
147
  // Fixed so the rail's scrolling area can't clip it. With no offsets it keeps its static position,
136
148
  // centred on the item by the item's flex alignment, and is then moved clear of the rail's edge
137
149
  &__tooltip {
@@ -198,6 +210,84 @@
198
210
  }
199
211
  }
200
212
 
213
+ // --------------------------------------------------------------------------
214
+ // Labelled Rail
215
+ // --------------------------------------------------------------------------
216
+ //
217
+ // The rail at --navmenu-labelled-width, each item an icon beside its label, with section titles
218
+ // and a logo that can be wider than it is tall. Below md it is the same bottom bar as the icon
219
+ // rail, with each label under its icon.
220
+
221
+ .navmenu--labelled {
222
+ .navmenu__header {
223
+ justify-content: flex-start;
224
+ padding: 0 $spacing-sm;
225
+ }
226
+
227
+ .navmenu__logo {
228
+ width: auto;
229
+ height: auto;
230
+
231
+ svg {
232
+ width: auto;
233
+ height: var(--navmenu-logo-height);
234
+ }
235
+ }
236
+
237
+ .navmenu__content {
238
+ padding: $spacing-2xs $spacing-xs;
239
+ }
240
+
241
+ .navmenu__section-title {
242
+ display: block;
243
+ padding: $spacing-3xs $spacing-2xs;
244
+ font-size: $font-size-xs;
245
+ font-weight: $font-weight-medium;
246
+ color: var(--fg-muted);
247
+ text-transform: uppercase;
248
+ letter-spacing: $letter-spacing-wide;
249
+ }
250
+
251
+ .navmenu__item {
252
+ justify-content: flex-start;
253
+ gap: $spacing-2xs;
254
+ width: auto;
255
+ height: auto;
256
+ margin: 0;
257
+ padding: $spacing-2xs;
258
+ font-size: $font-size-sm;
259
+
260
+ &[aria-current="page"],
261
+ &--active {
262
+ font-weight: $font-weight-medium;
263
+ }
264
+
265
+ svg {
266
+ width: $icon-size-md;
267
+ height: $icon-size-md;
268
+ flex-shrink: 0;
269
+ }
270
+ }
271
+
272
+ .navmenu__label {
273
+ display: block;
274
+ flex: 1;
275
+ @include text-truncate;
276
+ }
277
+
278
+ .navmenu__tooltip {
279
+ display: none;
280
+ }
281
+
282
+ .navmenu__footer {
283
+ padding: $spacing-2xs $spacing-xs;
284
+ }
285
+
286
+ .navmenu__avatar {
287
+ margin: 0;
288
+ }
289
+ }
290
+
201
291
  // --------------------------------------------------------------------------
202
292
  // Sub Navigation (Expanded Sidebar)
203
293
  // --------------------------------------------------------------------------
@@ -207,7 +297,7 @@
207
297
  top: 0;
208
298
  display: flex;
209
299
  flex-direction: column;
210
- width: 16rem;
300
+ width: var(--subnav-width);
211
301
  height: 100vh;
212
302
  @include chrome-region(subnav);
213
303
  border-right: 1px solid var(--border);
@@ -576,7 +666,7 @@
576
666
 
577
667
  .subnav {
578
668
  position: fixed;
579
- left: 4rem;
669
+ left: var(--navmenu-width);
580
670
  top: 0;
581
671
  bottom: 0;
582
672
  z-index: $z-fixed + 1;
@@ -588,7 +678,7 @@
588
678
  }
589
679
 
590
680
  .dashboard__main {
591
- margin-left: 4rem;
681
+ margin-left: var(--navmenu-width);
592
682
  }
593
683
  }
594
684
 
@@ -644,6 +734,26 @@
644
734
  }
645
735
  }
646
736
 
737
+ .navmenu--labelled {
738
+ .navmenu__section-title {
739
+ display: none;
740
+ }
741
+
742
+ .navmenu__item {
743
+ flex-direction: column;
744
+ justify-content: center;
745
+ gap: 0.125rem;
746
+ min-width: 3.5rem;
747
+ padding: $spacing-3xs $spacing-2xs;
748
+ font-size: $font-size-xs;
749
+ line-height: $line-height-tight;
750
+ }
751
+
752
+ .navmenu__label {
753
+ flex: none;
754
+ }
755
+ }
756
+
647
757
  // Leaves a strip of the overlay showing so a tap beside the panel closes it
648
758
  .subnav {
649
759
  left: 0;