@parallelogram-js/dashboard 0.0.0-stage → 0.1.2

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.
Files changed (78) hide show
  1. package/CHANGELOG.md +124 -0
  2. package/LICENSE +21 -0
  3. package/README.md +1391 -2
  4. package/dist/parallelogram-dashboard.css +9478 -0
  5. package/dist/parallelogram-dashboard.css.map +1 -0
  6. package/dist/parallelogram-dashboard.min.css +1 -0
  7. package/package.json +72 -4
  8. package/scss/_base.scss +403 -0
  9. package/scss/_datetime.scss +50 -0
  10. package/scss/_icon.scss +40 -0
  11. package/scss/_index.scss +61 -0
  12. package/scss/_mixins.scss +396 -0
  13. package/scss/_tokens.scss +340 -0
  14. package/scss/_utilities.scss +464 -0
  15. package/scss/_variables.scss +219 -0
  16. package/scss/components/_accordion.scss +297 -0
  17. package/scss/components/_actionbar.scss +333 -0
  18. package/scss/components/_alert.scss +183 -0
  19. package/scss/components/_auth.scss +98 -0
  20. package/scss/components/_avatar.scss +203 -0
  21. package/scss/components/_badge.scss +176 -0
  22. package/scss/components/_banner.scss +344 -0
  23. package/scss/components/_breadcrumb.scss +220 -0
  24. package/scss/components/_button.scss +264 -0
  25. package/scss/components/_card.scss +256 -0
  26. package/scss/components/_chart.scss +246 -0
  27. package/scss/components/_command.scss +267 -0
  28. package/scss/components/_dashboard.scss +681 -0
  29. package/scss/components/_data-list.scss +280 -0
  30. package/scss/components/_dropdown.scss +318 -0
  31. package/scss/components/_empty.scss +226 -0
  32. package/scss/components/_filebrowser.scss +906 -0
  33. package/scss/components/_form-layout.scss +332 -0
  34. package/scss/components/_input.scss +310 -0
  35. package/scss/components/_list.scss +130 -0
  36. package/scss/components/_media.scss +239 -0
  37. package/scss/components/_modal.scss +298 -0
  38. package/scss/components/_navbar.scss +312 -0
  39. package/scss/components/_notification.scss +59 -0
  40. package/scss/components/_pageheader.scss +99 -0
  41. package/scss/components/_pagination.scss +165 -0
  42. package/scss/components/_progress.scss +333 -0
  43. package/scss/components/_separator.scss +129 -0
  44. package/scss/components/_sheet.scss +286 -0
  45. package/scss/components/_sidebar.scss +324 -0
  46. package/scss/components/_skeleton.scss +246 -0
  47. package/scss/components/_stat.scss +218 -0
  48. package/scss/components/_table.scss +589 -0
  49. package/scss/components/_tabs.scss +266 -0
  50. package/scss/components/_timeline.scss +339 -0
  51. package/scss/components/_toast.scss +259 -0
  52. package/scss/components/_toolbar.scss +301 -0
  53. package/scss/components/_tooltip.scss +250 -0
  54. package/scss/main.scss +6 -0
  55. package/src/js/behaviours/accordion.js +58 -0
  56. package/src/js/behaviours/action-bar-list.js +406 -0
  57. package/src/js/behaviours/action-bar.js +29 -0
  58. package/src/js/behaviours/chart.js +339 -0
  59. package/src/js/behaviours/collapsible.js +34 -0
  60. package/src/js/behaviours/editable-table.js +91 -0
  61. package/src/js/behaviours/expandable.js +80 -0
  62. package/src/js/behaviours/overflow-actions.js +137 -0
  63. package/src/js/behaviours/publish-schedule.js +91 -0
  64. package/src/js/behaviours/search-clear.js +19 -0
  65. package/src/js/behaviours/segmented-control.js +43 -0
  66. package/src/js/behaviours/submenu.js +73 -0
  67. package/src/js/behaviours/table-columns.js +77 -0
  68. package/src/js/behaviours/table-paste.js +305 -0
  69. package/src/js/behaviours/table-reorder.js +252 -0
  70. package/src/js/behaviours/table-sort.js +101 -0
  71. package/src/js/behaviours/tabs.js +148 -0
  72. package/src/js/behaviours/toast-manager.js +106 -0
  73. package/src/js/behaviours/toggle.js +186 -0
  74. package/src/js/behaviours/unsaved-guard.js +88 -0
  75. package/src/js/core-loader.js +26 -0
  76. package/src/js/index.js +85 -0
  77. package/src/js/polyfills/dialog-commands.js +20 -0
  78. package/src/js/util/dom.js +39 -0
@@ -0,0 +1,297 @@
1
+ // ==========================================================================
2
+ // Accordion Component
3
+ // ==========================================================================
4
+
5
+ @use "../variables" as *;
6
+ @use "../mixins" as *;
7
+
8
+ // An item is open when it is a <details open> or its trigger has aria-expanded="true"
9
+ $accordion-open: '.accordion__item[open], .accordion__item:has(> .accordion__trigger[aria-expanded="true"], > * > .accordion__trigger[aria-expanded="true"]), .accordion__item--open';
10
+ $collapsible-open: '.collapsible[open], .collapsible:has(> .collapsible__trigger[aria-expanded="true"]), .collapsible--open';
11
+
12
+ // Animates from 0 to the content's natural height, however tall it is. Closed content is also
13
+ // hidden from focus and assistive tech, which <details> does natively but button triggers do not.
14
+ @mixin disclosure-content {
15
+ display: grid;
16
+ grid-template-rows: 0fr;
17
+ overflow: hidden;
18
+ visibility: hidden;
19
+ transition:
20
+ grid-template-rows $transition-base $transition-easing,
21
+ visibility $transition-base;
22
+
23
+ > * {
24
+ min-height: 0;
25
+ }
26
+ }
27
+
28
+ // A grid row cannot shrink below its item's padding, so closed bodies drop theirs
29
+ @mixin disclosure-body {
30
+ transition-property: padding, border-width;
31
+ transition-duration: $transition-base;
32
+ transition-timing-function: $transition-easing;
33
+ }
34
+
35
+ // --------------------------------------------------------------------------
36
+ // Accordion Container
37
+ // --------------------------------------------------------------------------
38
+
39
+ .accordion {
40
+ display: flex;
41
+ flex-direction: column;
42
+
43
+ // --------------------------------------------------------------------------
44
+ // Accordion Item
45
+ // --------------------------------------------------------------------------
46
+
47
+ &__item {
48
+ border-bottom: 1px solid var(--border);
49
+
50
+ &:last-child {
51
+ border-bottom: none;
52
+ }
53
+ }
54
+
55
+ &__trigger {
56
+ display: flex;
57
+ align-items: center;
58
+ justify-content: space-between;
59
+ width: 100%;
60
+ list-style: none;
61
+ padding: $spacing-sm 0;
62
+ font-size: $font-size-base;
63
+ font-weight: $font-weight-medium;
64
+ text-align: left;
65
+ color: var(--fg);
66
+ background: transparent;
67
+ border: none;
68
+ cursor: pointer;
69
+ @include transition-colors;
70
+
71
+ &:hover {
72
+ color: var(--fg-muted);
73
+ }
74
+
75
+ &:focus-visible {
76
+ @include focus-ring;
77
+ border-radius: $radius-sm;
78
+ }
79
+
80
+ &::-webkit-details-marker {
81
+ display: none;
82
+ }
83
+ }
84
+
85
+ &__icon {
86
+ flex-shrink: 0;
87
+ width: $icon-size-md;
88
+ height: $icon-size-md;
89
+ color: var(--fg-muted);
90
+ @include transition-default;
91
+
92
+ :is(#{$accordion-open}) & {
93
+ transform: rotate(180deg);
94
+ }
95
+ }
96
+
97
+ &__content {
98
+ @include disclosure-content;
99
+
100
+ :is(#{$accordion-open}) & {
101
+ grid-template-rows: 1fr;
102
+ visibility: visible;
103
+ }
104
+ }
105
+
106
+ &__body {
107
+ @include disclosure-body;
108
+ padding-bottom: $spacing-sm;
109
+ font-size: $font-size-sm;
110
+ color: var(--fg-muted);
111
+ line-height: $line-height-relaxed;
112
+ }
113
+
114
+ // --------------------------------------------------------------------------
115
+ // Variants
116
+ // --------------------------------------------------------------------------
117
+
118
+ // Bordered variant
119
+ &--bordered {
120
+ border: 1px solid var(--border);
121
+ border-radius: $radius;
122
+
123
+ .accordion__item {
124
+ border-bottom: 1px solid var(--border);
125
+ padding: 0 $spacing-sm;
126
+
127
+ &:last-child {
128
+ border-bottom: none;
129
+ }
130
+ }
131
+ }
132
+
133
+ // Separated variant (cards)
134
+ &--separated {
135
+ gap: $spacing-xs;
136
+
137
+ .accordion__item {
138
+ border: 1px solid var(--border);
139
+ border-radius: $radius;
140
+ padding: 0 $spacing-sm;
141
+ background-color: var(--card);
142
+ }
143
+ }
144
+
145
+ // Flush variant (no padding)
146
+ &--flush {
147
+ .accordion__trigger {
148
+ padding: $spacing-xs 0;
149
+ }
150
+
151
+ .accordion__body {
152
+ padding-bottom: $spacing-xs;
153
+ }
154
+ }
155
+
156
+ // With icons
157
+ &--icons {
158
+ .accordion__trigger {
159
+ gap: $spacing-xs;
160
+ }
161
+
162
+ .accordion__trigger-icon {
163
+ flex-shrink: 0;
164
+ width: $icon-size-md;
165
+ height: $icon-size-md;
166
+ color: var(--fg-muted);
167
+ }
168
+
169
+ .accordion__trigger-text {
170
+ flex: 1;
171
+ }
172
+ }
173
+ }
174
+
175
+ // --------------------------------------------------------------------------
176
+ // Collapsible (single item variant)
177
+ // --------------------------------------------------------------------------
178
+
179
+ .collapsible {
180
+ border: 1px solid var(--border);
181
+ border-radius: $radius;
182
+
183
+ &__trigger {
184
+ display: flex;
185
+ align-items: center;
186
+ justify-content: space-between;
187
+ width: 100%;
188
+ padding: $spacing-sm;
189
+ font-size: $font-size-sm;
190
+ font-weight: $font-weight-medium;
191
+ text-align: left;
192
+ color: var(--fg);
193
+ background: transparent;
194
+ border: none;
195
+ cursor: pointer;
196
+ list-style: none;
197
+ @include transition-colors;
198
+
199
+ &:hover {
200
+ background-color: var(--bg-muted);
201
+ }
202
+
203
+ &::-webkit-details-marker {
204
+ display: none;
205
+ }
206
+ }
207
+
208
+ &__icon {
209
+ flex-shrink: 0;
210
+ width: $icon-size-md;
211
+ height: $icon-size-md;
212
+ color: var(--fg-muted);
213
+ @include transition-default;
214
+
215
+ :is(#{$collapsible-open}) & {
216
+ transform: rotate(180deg);
217
+ }
218
+ }
219
+
220
+ &__content {
221
+ @include disclosure-content;
222
+
223
+ :is(#{$collapsible-open}) & {
224
+ grid-template-rows: 1fr;
225
+ visibility: visible;
226
+ }
227
+ }
228
+
229
+ &__body {
230
+ @include disclosure-body;
231
+ padding: 0 $spacing-sm $spacing-sm;
232
+ font-size: $font-size-sm;
233
+ color: var(--fg-muted);
234
+ border-top: 1px solid var(--border);
235
+ padding-top: $spacing-sm;
236
+ }
237
+ }
238
+
239
+ .accordion__item:not(#{$accordion-open}) .accordion__body,
240
+ .accordion--flush .accordion__item:not(#{$accordion-open}) .accordion__body,
241
+ .collapsible:not(#{$collapsible-open}) .collapsible__body {
242
+ padding-block: 0;
243
+ border-top-width: 0;
244
+ }
245
+
246
+ // --------------------------------------------------------------------------
247
+ // Details/Summary (native HTML)
248
+ // --------------------------------------------------------------------------
249
+
250
+ details.accordion-native {
251
+ border-bottom: 1px solid var(--border);
252
+
253
+ &:last-child {
254
+ border-bottom: none;
255
+ }
256
+
257
+ summary {
258
+ display: flex;
259
+ align-items: center;
260
+ justify-content: space-between;
261
+ padding: $spacing-sm 0;
262
+ font-size: $font-size-base;
263
+ font-weight: $font-weight-medium;
264
+ color: var(--fg);
265
+ cursor: pointer;
266
+ list-style: none;
267
+
268
+ &::-webkit-details-marker {
269
+ display: none;
270
+ }
271
+
272
+ &::after {
273
+ content: "";
274
+ width: 0.5rem;
275
+ height: 0.5rem;
276
+ border-right: 2px solid var(--fg-muted);
277
+ border-bottom: 2px solid var(--fg-muted);
278
+ transform: rotate(45deg);
279
+ @include transition-default;
280
+ }
281
+
282
+ &:hover {
283
+ color: var(--fg-muted);
284
+ }
285
+ }
286
+
287
+ &[open] summary::after {
288
+ transform: rotate(-135deg);
289
+ }
290
+
291
+ .accordion-native__content {
292
+ padding-bottom: $spacing-sm;
293
+ font-size: $font-size-sm;
294
+ color: var(--fg-muted);
295
+ line-height: $line-height-relaxed;
296
+ }
297
+ }
@@ -0,0 +1,333 @@
1
+ // ==========================================================================
2
+ // Action Bar Component
3
+ // A segmented bar that stands for one record, e.g. a page in a page tree or a row in a
4
+ // record index. Segments (reorder handle, selection, title, switches, dropdowns, actions)
5
+ // are joined by keylines. Several bars stack in an .actionbar__list, which can be sorted.
6
+ // ==========================================================================
7
+
8
+ @use "../variables" as *;
9
+ @use "../mixins" as *;
10
+
11
+ .actionbar {
12
+ --actionbar-height: #{$btn-height-md};
13
+
14
+ display: flex;
15
+ align-items: stretch;
16
+ min-width: 0;
17
+ height: var(--actionbar-height);
18
+ font-size: $font-size-sm;
19
+ color: var(--fg);
20
+ background-color: var(--card);
21
+ border: 1px solid var(--border);
22
+ border-radius: $radius-md;
23
+ @include transition-colors;
24
+
25
+ &--sm {
26
+ --actionbar-height: #{$btn-height-sm};
27
+
28
+ font-size: $font-size-xs;
29
+ }
30
+
31
+ &--lg {
32
+ --actionbar-height: 3rem;
33
+ }
34
+
35
+ // Selected through its own selection checkbox
36
+ &:has(.actionbar__select :checked) {
37
+ background-color: var(--accent);
38
+ border-color: var(--primary);
39
+ }
40
+
41
+ // The record is unavailable, e.g. unpublished or locked; controls stay usable
42
+ &[aria-disabled="true"] .actionbar__title {
43
+ opacity: 0.55;
44
+ }
45
+
46
+ // Lifted while being dragged into a new position
47
+ &[data-dragging] {
48
+ position: relative;
49
+ z-index: 2;
50
+ border-color: var(--primary);
51
+ box-shadow: $shadow-lg;
52
+ cursor: grabbing;
53
+ }
54
+
55
+ // Where a dragged bar will land: a line before or after this bar, or inside it as a child
56
+ &[data-drop] {
57
+ position: relative;
58
+ }
59
+
60
+ &[data-drop="before"]::after,
61
+ &[data-drop="after"]::after {
62
+ content: "";
63
+ position: absolute;
64
+ left: 0;
65
+ right: 0;
66
+ height: 2px;
67
+ border-radius: 1px;
68
+ background-color: var(--primary);
69
+ pointer-events: none;
70
+ }
71
+
72
+ // Centred in the gap between bars in a list
73
+ &[data-drop="before"]::after {
74
+ top: calc(#{$spacing-2xs} / -2 - 2px);
75
+ }
76
+
77
+ &[data-drop="after"]::after,
78
+ &[data-drop="first-inside"]::after {
79
+ bottom: calc(#{$spacing-2xs} / -2 - 2px);
80
+ }
81
+
82
+ // Dropping below an open parent lands as its first child, so the line is indented
83
+ &[data-drop="first-inside"]::after {
84
+ content: "";
85
+ position: absolute;
86
+ left: $spacing-xl;
87
+ right: 0;
88
+ height: 2px;
89
+ border-radius: 1px;
90
+ background-color: var(--primary);
91
+ pointer-events: none;
92
+ }
93
+
94
+ &[data-drop="inside"] {
95
+ border-color: var(--primary);
96
+ box-shadow: inset 0 0 0 1px var(--primary);
97
+ }
98
+
99
+ // --------------------------------------------------------------------------
100
+ // Segments
101
+ // --------------------------------------------------------------------------
102
+
103
+ &__segment {
104
+ position: relative;
105
+ display: flex;
106
+ flex-shrink: 0;
107
+ align-items: center;
108
+ gap: $spacing-2xs;
109
+ padding: 0 $spacing-xs;
110
+ color: inherit;
111
+ font: inherit;
112
+ text-decoration: none;
113
+ white-space: nowrap;
114
+ background-color: transparent;
115
+ border: 0;
116
+
117
+ & + & {
118
+ border-left: 1px solid var(--border);
119
+ }
120
+
121
+ // Round the outermost *visible* segments: the "more" segment and folded segments stay in
122
+ // the markup while hidden, and clipping the bar instead would cut off dropdown menus
123
+ &:not([hidden]):not(:has(~ .actionbar__segment:not([hidden]))) {
124
+ border-top-right-radius: calc(#{$radius-md} - 1px);
125
+ border-bottom-right-radius: calc(#{$radius-md} - 1px);
126
+ }
127
+
128
+ &:not([hidden]):first-child {
129
+ border-top-left-radius: calc(#{$radius-md} - 1px);
130
+ border-bottom-left-radius: calc(#{$radius-md} - 1px);
131
+ }
132
+
133
+ // A whole segment can be a button or link
134
+ &:is(button, a) {
135
+ cursor: pointer;
136
+ @include transition-colors;
137
+
138
+ &:hover {
139
+ background-color: var(--accent);
140
+ color: var(--accent-fg);
141
+ }
142
+
143
+ &:focus-visible {
144
+ outline: 2px solid var(--ring);
145
+ outline-offset: -2px;
146
+ }
147
+
148
+ &:disabled,
149
+ &[aria-disabled="true"] {
150
+ @include disabled;
151
+ }
152
+ }
153
+
154
+ .icon {
155
+ width: $icon-size-sm;
156
+ height: $icon-size-sm;
157
+ flex-shrink: 0;
158
+ }
159
+
160
+ // Per-segment emphasis
161
+ &--primary {
162
+ color: var(--primary-fg);
163
+ background-color: var(--primary);
164
+
165
+ &:is(button, a):hover {
166
+ color: var(--primary-fg);
167
+ background-color: var(--primary-hover);
168
+ }
169
+ }
170
+
171
+ &--outline::before {
172
+ content: "";
173
+ position: absolute;
174
+ inset: $spacing-3xs;
175
+ border: 1px solid var(--ring);
176
+ border-radius: $radius-sm;
177
+ pointer-events: none;
178
+ }
179
+
180
+ &--muted {
181
+ color: var(--fg-muted);
182
+ background-color: var(--bg-muted);
183
+ }
184
+ }
185
+
186
+ // A button that fills its segment, e.g. a dropdown trigger
187
+ &__trigger {
188
+ display: flex;
189
+ align-items: center;
190
+ gap: $spacing-2xs;
191
+ height: 100%;
192
+ margin: 0 calc(#{$spacing-xs} * -1);
193
+ padding: 0 $spacing-xs;
194
+ color: inherit;
195
+ font: inherit;
196
+ background: transparent;
197
+ border: 0;
198
+ border-radius: inherit;
199
+ cursor: pointer;
200
+ @include transition-colors;
201
+
202
+ &:hover,
203
+ &[aria-expanded="true"] {
204
+ background-color: var(--accent);
205
+ color: var(--accent-fg);
206
+ }
207
+
208
+ &:focus-visible {
209
+ outline: 2px solid var(--ring);
210
+ outline-offset: -2px;
211
+ }
212
+ }
213
+
214
+ // --------------------------------------------------------------------------
215
+ // Built-in segments
216
+ // --------------------------------------------------------------------------
217
+
218
+ &__handle {
219
+ justify-content: center;
220
+ width: var(--actionbar-height);
221
+ padding: 0;
222
+ color: var(--fg-muted);
223
+ cursor: grab;
224
+ touch-action: none;
225
+
226
+ &:active,
227
+ &[aria-pressed="true"] {
228
+ cursor: grabbing;
229
+ color: var(--primary);
230
+ }
231
+ }
232
+
233
+ // Shows or hides a nested list of child records
234
+ &__toggle {
235
+ justify-content: center;
236
+ width: var(--actionbar-height);
237
+ padding: 0;
238
+ color: var(--fg-muted);
239
+
240
+ .icon {
241
+ @include transition-transform;
242
+ }
243
+
244
+ &[aria-expanded="false"] .icon {
245
+ transform: rotate(-90deg);
246
+ }
247
+ }
248
+
249
+ &__select {
250
+ justify-content: center;
251
+ width: var(--actionbar-height);
252
+ padding: 0;
253
+ }
254
+
255
+ // Grows to fill the bar; once it would drop below its minimum, segments fold into "more"
256
+ &__title {
257
+ flex: 1 1 auto;
258
+ min-width: 10rem;
259
+ gap: $spacing-xs;
260
+ }
261
+
262
+ &__label {
263
+ min-width: 0;
264
+ font-weight: $font-weight-medium;
265
+ color: inherit;
266
+ text-decoration: none;
267
+ @include text-truncate;
268
+
269
+ &:is(a):hover {
270
+ text-decoration: underline;
271
+ text-underline-offset: 3px;
272
+ }
273
+ }
274
+
275
+ // Gives way before the label does
276
+ &__meta {
277
+ flex-shrink: 4;
278
+ min-width: 0;
279
+ font-size: $font-size-xs;
280
+ color: var(--fg-muted);
281
+ @include text-truncate;
282
+ }
283
+
284
+ &__title .badge {
285
+ flex-shrink: 0;
286
+ }
287
+
288
+ // Holds segments that no longer fit; filled by main.js
289
+ &__more {
290
+ padding: 0 $spacing-xs;
291
+
292
+ .dropdown__menu {
293
+ right: 0;
294
+ left: auto;
295
+ }
296
+ }
297
+
298
+ // --------------------------------------------------------------------------
299
+ // List of bars (one record each), optionally nested for trees
300
+ // --------------------------------------------------------------------------
301
+
302
+ &__list {
303
+ display: flex;
304
+ flex-direction: column;
305
+ gap: $spacing-2xs;
306
+ margin: 0;
307
+ padding: 0;
308
+ list-style: none;
309
+
310
+ // Nested lists show hierarchy, e.g. child pages
311
+ & & {
312
+ margin-top: $spacing-2xs;
313
+ padding-left: $spacing-xl;
314
+ }
315
+ }
316
+ }
317
+
318
+ // On phones, even with every foldable segment folded, a full-size title, indent and detail leave
319
+ // no room for the label
320
+ @include max-sm {
321
+ .actionbar__title {
322
+ min-width: 6rem;
323
+ }
324
+
325
+ .actionbar__list .actionbar__list {
326
+ padding-left: $spacing-sm;
327
+ }
328
+
329
+ // The label matters more than its secondary detail (such as a page's path)
330
+ .actionbar__meta {
331
+ display: none;
332
+ }
333
+ }