@gjermundgaraba-designs/pixel-paper 0.23.0 → 0.25.0
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/DESIGN.md +11 -8
- package/dist/src/iconButton/iconButton.d.ts +6 -1
- package/dist/src/iconButton/iconButton.d.ts.map +1 -1
- package/dist/src/iconButton/iconButton.js +7 -2
- package/dist/src/panel/panel.d.ts +3 -0
- package/dist/src/panel/panel.d.ts.map +1 -1
- package/dist/src/panel/panel.js +2 -1
- package/dist/src/rail/index.d.ts +1 -1
- package/dist/src/rail/index.d.ts.map +1 -1
- package/dist/src/rail/index.js +1 -1
- package/dist/src/rail/rail.d.ts +78 -17
- package/dist/src/rail/rail.d.ts.map +1 -1
- package/dist/src/rail/rail.js +98 -41
- package/dist/src/reel/index.d.ts +1 -1
- package/dist/src/reel/index.d.ts.map +1 -1
- package/dist/src/reel/index.js +1 -1
- package/dist/src/reel/reel.d.ts +85 -7
- package/dist/src/reel/reel.d.ts.map +1 -1
- package/dist/src/reel/reel.js +232 -115
- package/dist/src/tips/tips.d.ts +30 -1
- package/dist/src/tips/tips.d.ts.map +1 -1
- package/dist/src/tips/tips.js +53 -31
- package/package.json +1 -1
- package/src/iconButton/iconButton.ts +19 -2
- package/src/panel/panel.ts +5 -0
- package/src/pixel-paper.css +167 -4
- package/src/rail/index.ts +2 -0
- package/src/rail/rail.ts +119 -41
- package/src/reel/index.ts +2 -0
- package/src/reel/reel.ts +221 -31
- package/src/tips/tips.ts +71 -35
- package/src/tokens.css +1 -0
package/src/pixel-paper.css
CHANGED
|
@@ -979,6 +979,19 @@ a.textbtn {
|
|
|
979
979
|
flex: 1 1 100%;
|
|
980
980
|
}
|
|
981
981
|
|
|
982
|
+
/* the shelf: a strip on the head tint under the bar, for a field that picks what the body
|
|
983
|
+
shows */
|
|
984
|
+
.panel-shelf {
|
|
985
|
+
padding: 10px 12px 12px;
|
|
986
|
+
background: var(--head);
|
|
987
|
+
border-bottom: var(--hair) solid var(--rule);
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
/* on the head tint a field's label takes on-head: muted misses AA there */
|
|
991
|
+
.panel-shelf :is(.field > label:not(.choice), .field-label) {
|
|
992
|
+
color: var(--on-head);
|
|
993
|
+
}
|
|
994
|
+
|
|
982
995
|
/* ---------- the panel's title-bar lead and actions ---------- */
|
|
983
996
|
|
|
984
997
|
/* small buttons and icon buttons at the bar's right end, and an icon button before the
|
|
@@ -4828,6 +4841,16 @@ dialog.veil:focus {
|
|
|
4828
4841
|
overflow: visible;
|
|
4829
4842
|
}
|
|
4830
4843
|
|
|
4844
|
+
/* the key that does the same as the control, after its words, as a button prints it */
|
|
4845
|
+
.tip .key-hint {
|
|
4846
|
+
margin-left: 6px;
|
|
4847
|
+
font-family: var(--font-px);
|
|
4848
|
+
font-size: var(--type-label);
|
|
4849
|
+
text-transform: none;
|
|
4850
|
+
letter-spacing: 0;
|
|
4851
|
+
opacity: var(--fade-on-ink);
|
|
4852
|
+
}
|
|
4853
|
+
|
|
4831
4854
|
/* ---------- toolbars: one strip of tools, one stop for Tab ---------- */
|
|
4832
4855
|
|
|
4833
4856
|
/* the rules between tools are the strip's ink showing through a 2px gap */
|
|
@@ -5022,8 +5045,7 @@ dialog.veil:focus {
|
|
|
5022
5045
|
/* ---------- the rail: a column of panels beside the deck, a drawer on a phone ---------- */
|
|
5023
5046
|
|
|
5024
5047
|
/* one element in two places: at rest, fixed down the left edge from the top bar's lower
|
|
5025
|
-
edge (as the stage hangs)
|
|
5026
|
-
popover drawer. The reader's width, when they gave one, is --railed-width, which the view
|
|
5048
|
+
edge (as the stage hangs); on a phone the same element opens as a popover drawer. The reader's width, when they gave one, is --railed-width, which the view
|
|
5027
5049
|
sets on .railed, so the page's padding and the rail's width follow it together; without one,
|
|
5028
5050
|
--rail. It is not inherited: each box it sizes takes it from .railed by name, so a width that
|
|
5029
5051
|
changes under a dragged splitter restyles those four and none of the rows inside them */
|
|
@@ -5046,8 +5068,8 @@ dialog.veil:focus {
|
|
|
5046
5068
|
top: anchor(--topbar bottom, 0px);
|
|
5047
5069
|
bottom: var(--statusbar-h);
|
|
5048
5070
|
left: 0;
|
|
5049
|
-
display:
|
|
5050
|
-
|
|
5071
|
+
display: flex;
|
|
5072
|
+
flex-direction: column;
|
|
5051
5073
|
gap: var(--gap);
|
|
5052
5074
|
width: var(--railed-width, var(--rail));
|
|
5053
5075
|
height: auto;
|
|
@@ -5059,7 +5081,43 @@ dialog.veil:focus {
|
|
|
5059
5081
|
}
|
|
5060
5082
|
|
|
5061
5083
|
.rail > * {
|
|
5084
|
+
flex: none;
|
|
5085
|
+
min-width: 0;
|
|
5086
|
+
}
|
|
5087
|
+
|
|
5088
|
+
/* the rail's top stays put: what comes before its last panel keeps its height, and the last
|
|
5089
|
+
panel takes the room left, at most its own height, its bar, shelf and foot staying while
|
|
5090
|
+
its body scrolls (the padded body, or a flush body's list). The rail scrolls as a whole
|
|
5091
|
+
only when what comes before that panel is taller than the column */
|
|
5092
|
+
.rail > .panel:last-child {
|
|
5093
|
+
display: flex;
|
|
5094
|
+
flex-direction: column;
|
|
5095
|
+
flex: 0 1 auto;
|
|
5096
|
+
min-height: 0;
|
|
5097
|
+
}
|
|
5098
|
+
|
|
5099
|
+
.rail > .panel:last-child > :is(.panel-tb, .panel-shelf, .panel-foot) {
|
|
5100
|
+
flex: none;
|
|
5101
|
+
}
|
|
5102
|
+
|
|
5103
|
+
.rail > .panel:last-child > :not(.panel-tb, .panel-shelf, .panel-foot) {
|
|
5104
|
+
flex: 0 1 auto;
|
|
5105
|
+
min-height: 0;
|
|
5106
|
+
overflow-y: auto;
|
|
5107
|
+
}
|
|
5108
|
+
|
|
5109
|
+
/* a long name ends short of the bar's tools rather than wrapping the bar taller */
|
|
5110
|
+
.rail .panel-tb h2 {
|
|
5062
5111
|
min-width: 0;
|
|
5112
|
+
overflow: hidden;
|
|
5113
|
+
overflow-wrap: normal;
|
|
5114
|
+
white-space: nowrap;
|
|
5115
|
+
text-overflow: ellipsis;
|
|
5116
|
+
}
|
|
5117
|
+
|
|
5118
|
+
/* the toggle is the button itself in the bar's lead */
|
|
5119
|
+
.rail-toggle {
|
|
5120
|
+
display: contents;
|
|
5063
5121
|
}
|
|
5064
5122
|
|
|
5065
5123
|
/* the splitter on the rail's right edge: a 12px strip from the edge outward, over the page's
|
|
@@ -5102,6 +5160,48 @@ dialog.veil:focus {
|
|
|
5102
5160
|
display: none;
|
|
5103
5161
|
}
|
|
5104
5162
|
|
|
5163
|
+
/* folded: the first panel stands its title bar on end on the ground where the rail stood, the
|
|
5164
|
+
toggle at its top and the title and count reading down; the rest of the rail and the
|
|
5165
|
+
splitter are gone, and the deck takes the width. Above 900px only: the drawer opens whole.
|
|
5166
|
+
Folding and unfolding move in three steps, as the drawer enters, but never while a pointer
|
|
5167
|
+
drags the splitter, where the rail follows the pointer */
|
|
5168
|
+
@media not (max-width: 900px) {
|
|
5169
|
+
.railed.folded {
|
|
5170
|
+
--railed-width: var(--rail-folded);
|
|
5171
|
+
}
|
|
5172
|
+
|
|
5173
|
+
.railed.folded > .rail > :not(.rail-head + .panel),
|
|
5174
|
+
.railed.folded > .rail > .rail-head + .panel > :not(.panel-tb),
|
|
5175
|
+
.railed.folded > .rail > .rail-head + .panel > .panel-tb > .panel-acts {
|
|
5176
|
+
display: none;
|
|
5177
|
+
}
|
|
5178
|
+
|
|
5179
|
+
.railed.folded > .rail > .rail-head + .panel {
|
|
5180
|
+
align-self: flex-start;
|
|
5181
|
+
}
|
|
5182
|
+
|
|
5183
|
+
.railed.folded > .rail > .rail-head + .panel > .panel-tb {
|
|
5184
|
+
writing-mode: vertical-rl;
|
|
5185
|
+
min-width: 31px;
|
|
5186
|
+
min-height: 0;
|
|
5187
|
+
padding: 3px 3px 12px;
|
|
5188
|
+
}
|
|
5189
|
+
|
|
5190
|
+
.railed.folded > .rail > .rail-head + .panel > .panel-tb > .meta {
|
|
5191
|
+
margin: 0;
|
|
5192
|
+
}
|
|
5193
|
+
|
|
5194
|
+
.railed,
|
|
5195
|
+
.railed > :is(.rail, .bench) {
|
|
5196
|
+
transition: var(--motion-card) steps(3, end);
|
|
5197
|
+
transition-property: padding-left, width, left;
|
|
5198
|
+
}
|
|
5199
|
+
|
|
5200
|
+
:root[data-pixel-paper-dragging] :is(.railed, .railed > .rail, .railed > .bench) {
|
|
5201
|
+
transition: none;
|
|
5202
|
+
}
|
|
5203
|
+
}
|
|
5204
|
+
|
|
5105
5205
|
@media (max-width: 900px) {
|
|
5106
5206
|
.railed {
|
|
5107
5207
|
padding-left: 0;
|
|
@@ -5140,6 +5240,16 @@ dialog.veil:focus {
|
|
|
5140
5240
|
display: inline-flex;
|
|
5141
5241
|
justify-self: start;
|
|
5142
5242
|
}
|
|
5243
|
+
|
|
5244
|
+
/* the drawer opens and closes but never folds, so it prints no toggle, and the bar the
|
|
5245
|
+
toggle led keeps its own padding */
|
|
5246
|
+
.panel-lead:has(> .rail-toggle) {
|
|
5247
|
+
display: none;
|
|
5248
|
+
}
|
|
5249
|
+
|
|
5250
|
+
.panel-tb:has(> .panel-lead > .rail-toggle) {
|
|
5251
|
+
padding-left: 12px;
|
|
5252
|
+
}
|
|
5143
5253
|
}
|
|
5144
5254
|
|
|
5145
5255
|
@keyframes railIn {
|
|
@@ -5520,6 +5630,54 @@ dialog.veil:focus {
|
|
|
5520
5630
|
opacity: var(--fade-dragged);
|
|
5521
5631
|
}
|
|
5522
5632
|
|
|
5633
|
+
/* under tabs, the reel is its tab list over the scroller, which takes the height left. The
|
|
5634
|
+
list sits a gutter in from the reel's edges, as the windows do */
|
|
5635
|
+
.reel.tabbed {
|
|
5636
|
+
display: flex;
|
|
5637
|
+
flex-direction: column;
|
|
5638
|
+
}
|
|
5639
|
+
|
|
5640
|
+
.reel.tabbed > .reel-view {
|
|
5641
|
+
flex: 1 1 0;
|
|
5642
|
+
height: auto;
|
|
5643
|
+
min-height: 0;
|
|
5644
|
+
}
|
|
5645
|
+
|
|
5646
|
+
.reel-tabs {
|
|
5647
|
+
flex: none;
|
|
5648
|
+
max-width: calc(100% - 2 * var(--reel-gutter));
|
|
5649
|
+
margin: var(--reel-gutter) var(--reel-gutter) 0;
|
|
5650
|
+
}
|
|
5651
|
+
|
|
5652
|
+
/* a tab holds a kind glyph before its words, and gives up width before the list overflows:
|
|
5653
|
+
its words end in an ellipsis */
|
|
5654
|
+
.reel-tabs button {
|
|
5655
|
+
display: inline-flex;
|
|
5656
|
+
align-items: center;
|
|
5657
|
+
gap: 6px;
|
|
5658
|
+
min-width: 0;
|
|
5659
|
+
}
|
|
5660
|
+
|
|
5661
|
+
.reel-tab-words {
|
|
5662
|
+
min-width: 0;
|
|
5663
|
+
overflow: hidden;
|
|
5664
|
+
text-overflow: ellipsis;
|
|
5665
|
+
}
|
|
5666
|
+
|
|
5667
|
+
/* the one slot under tabs: the view less a gutter at every edge, every pane pinned to it */
|
|
5668
|
+
.reel-stage {
|
|
5669
|
+
flex: 1 1 0;
|
|
5670
|
+
height: calc(100cqh - 2 * var(--reel-gutter));
|
|
5671
|
+
min-height: 0;
|
|
5672
|
+
margin-inline: var(--reel-gutter);
|
|
5673
|
+
}
|
|
5674
|
+
|
|
5675
|
+
/* a pane behind the selected tab keeps its place and its size, so what sizes itself by its
|
|
5676
|
+
box (a terminal) is not resized as the tabs change; it is only not drawn */
|
|
5677
|
+
.reel-pane.behind {
|
|
5678
|
+
visibility: hidden;
|
|
5679
|
+
}
|
|
5680
|
+
|
|
5523
5681
|
/* only the grips lift: a pane's text selects and its terminal takes the pointer */
|
|
5524
5682
|
[data-reel-grip] {
|
|
5525
5683
|
cursor: grab;
|
|
@@ -5842,4 +6000,9 @@ dialog.veil:focus {
|
|
|
5842
6000
|
.toasts .toast {
|
|
5843
6001
|
animation: none;
|
|
5844
6002
|
}
|
|
6003
|
+
|
|
6004
|
+
.railed,
|
|
6005
|
+
.railed > :is(.rail, .bench) {
|
|
6006
|
+
transition: none;
|
|
6007
|
+
}
|
|
5845
6008
|
}
|
package/src/rail/index.ts
CHANGED
package/src/rail/rail.ts
CHANGED
|
@@ -27,8 +27,8 @@ const Resizing = Schema.Struct({
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
/** Schema for a rail: whether it is open as a drawer (at 900px and under; wider, it is always
|
|
30
|
-
* in the page and this stays false), and its splitter while a pointer drags it. Its width
|
|
31
|
-
* the parent's. */
|
|
30
|
+
* in the page and this stays false), and its splitter while a pointer drags it. Its width,
|
|
31
|
+
* and whether the reader hid it, are the parent's. */
|
|
32
32
|
export const Model = Schema.Struct({
|
|
33
33
|
id: Schema.String,
|
|
34
34
|
isOpen: Schema.Boolean,
|
|
@@ -43,6 +43,7 @@ export type Model = typeof Model.Type;
|
|
|
43
43
|
* the window growing past 900px while it is open, where the rail is back in the page. */
|
|
44
44
|
export const Message = defineMessageUnion({
|
|
45
45
|
ClickedOpen: {},
|
|
46
|
+
ClickedToggle: {},
|
|
46
47
|
PressedSplitter: { pointerId: Schema.Number, clientX: Schema.Number, width: Schema.Number },
|
|
47
48
|
MovedSplitter: { clientX: Schema.Number },
|
|
48
49
|
ReleasedSplitter: { clientX: Schema.Number },
|
|
@@ -55,14 +56,18 @@ export const Message = defineMessageUnion({
|
|
|
55
56
|
WidenedPastDrawer: {},
|
|
56
57
|
CompletedShowRailDrawer: {},
|
|
57
58
|
CompletedHideRailDrawer: {},
|
|
59
|
+
CompletedFocusRailToggle: {},
|
|
58
60
|
});
|
|
59
61
|
export type Message = typeof Message.Type;
|
|
60
62
|
|
|
61
63
|
/** What a rail asks of its parent. `ResizedRail`: its splitter was let go, or stepped by a
|
|
62
64
|
* key, at `width` pixels, within the rail's bounds; the parent keeps it (per client) and
|
|
63
|
-
* passes it back as the view's `maybeWidth`.
|
|
65
|
+
* passes it back as the view's `maybeWidth`. `ToggledRail`: its toggle was pressed; the
|
|
66
|
+
* parent flips whether it keeps the rail hidden (per client) and passes it back as the view's
|
|
67
|
+
* `isHidden`. */
|
|
64
68
|
export const OutMessage = defineMessageUnion({
|
|
65
69
|
ResizedRail: { width: Schema.Number },
|
|
70
|
+
ToggledRail: {},
|
|
66
71
|
});
|
|
67
72
|
export type OutMessage = typeof OutMessage.Type;
|
|
68
73
|
|
|
@@ -102,6 +107,8 @@ export const isOpen = (model: Model): boolean => model.isOpen;
|
|
|
102
107
|
|
|
103
108
|
const openButtonId = (model: Model): string => `${model.id}-open`;
|
|
104
109
|
|
|
110
|
+
const toggleId = (model: Model): string => `${model.id}-toggle`;
|
|
111
|
+
|
|
105
112
|
// COMMAND
|
|
106
113
|
|
|
107
114
|
const FOCUSABLE =
|
|
@@ -113,11 +120,13 @@ const findRail = (railId: string): Effect.Effect<HTMLElement, Cause.NoSuchElemen
|
|
|
113
120
|
);
|
|
114
121
|
|
|
115
122
|
/** The drawer's first Tab stop past its head: a control the keyboard reaches, so a tree's
|
|
116
|
-
* items other than its one stop (`tabindex="-1"`) are passed over
|
|
123
|
+
* items other than its one stop (`tabindex="-1"`) are passed over, and so is the toggle,
|
|
124
|
+
* which the drawer does not print. */
|
|
117
125
|
export const firstTabStop = (rail: Element): Option.Option<HTMLElement> =>
|
|
118
126
|
Array.findFirst(
|
|
119
127
|
Array.fromIterable(rail.querySelectorAll<HTMLElement>(`.rail-head ~ * :is(${FOCUSABLE})`)),
|
|
120
|
-
(control) =>
|
|
128
|
+
(control) =>
|
|
129
|
+
control.tabIndex >= 0 && control.closest("[inert], [hidden], .rail-toggle") === null,
|
|
121
130
|
);
|
|
122
131
|
|
|
123
132
|
/** Opens the rail as a drawer over the page and puts focus on its first control past its
|
|
@@ -157,6 +166,25 @@ export const HideRailDrawer = Command.define("HideRailDrawer", {
|
|
|
157
166
|
),
|
|
158
167
|
});
|
|
159
168
|
|
|
169
|
+
/** Puts focus on the rail's toggle once the rail has folded or unfolded, if focus was in the
|
|
170
|
+
* rail or on its splitter: folding takes away every control in it but the toggle, which
|
|
171
|
+
* brings it back, and the splitter with them. Focus anywhere else stays where it is. */
|
|
172
|
+
export const FocusRailToggle = Command.define("FocusRailToggle", {
|
|
173
|
+
args: { railId: Schema.String, toggleId: Schema.String },
|
|
174
|
+
messages: [Message.CompletedFocusRailToggle],
|
|
175
|
+
execute: ({ railId, toggleId: buttonId }) =>
|
|
176
|
+
Effect.gen(function* () {
|
|
177
|
+
// NOTE: read before the fold renders, which takes away the control focus is on
|
|
178
|
+
const rail = yield* findRail(railId);
|
|
179
|
+
const active = document.activeElement;
|
|
180
|
+
const isOnSplitter =
|
|
181
|
+
active?.matches(`.rail-resize[aria-controls="${CSS.escape(railId)}"]`) ?? false;
|
|
182
|
+
if (rail.contains(active) || isOnSplitter) {
|
|
183
|
+
yield* Dom.focus(`#${CSS.escape(buttonId)}`);
|
|
184
|
+
}
|
|
185
|
+
}).pipe(Effect.ignore, Effect.as(Message.CompletedFocusRailToggle())),
|
|
186
|
+
});
|
|
187
|
+
|
|
160
188
|
// UPDATE
|
|
161
189
|
|
|
162
190
|
type UpdateReturn = Update.Return<Model, Message>;
|
|
@@ -180,6 +208,14 @@ const open = (model: Model): UpdateReturn => ({
|
|
|
180
208
|
/** Closes the rail's drawer, focus back on its button. */
|
|
181
209
|
export const close = (model: Model): UpdateReturn => closeDrawer(model, true);
|
|
182
210
|
|
|
211
|
+
/** Folds or unfolds the rail from a key of the parent's: the parent flips whether it keeps the
|
|
212
|
+
* rail hidden, as it does for `ToggledRail`, and folds this in, which moves focus in the rail
|
|
213
|
+
* onto the toggle. */
|
|
214
|
+
export const toggle = (model: Model): UpdateReturn => ({
|
|
215
|
+
model,
|
|
216
|
+
commands: [FocusRailToggle({ railId: model.id, toggleId: toggleId(model) })],
|
|
217
|
+
});
|
|
218
|
+
|
|
183
219
|
const withResizing = (model: Model, maybeResizing: Option.Option<typeof Resizing.Type>): Model =>
|
|
184
220
|
modifyFields(model, { maybeResizing: () => maybeResizing });
|
|
185
221
|
|
|
@@ -194,10 +230,12 @@ const dragTo = (model: Model, clientX: number): Model =>
|
|
|
194
230
|
);
|
|
195
231
|
|
|
196
232
|
/** Processes a rail Message and returns the next Model, Commands and OutMessage: a splitter let
|
|
197
|
-
* go where it changes the width, or stepped by a key, asks for the width
|
|
233
|
+
* go where it changes the width, or stepped by a key, asks for the width, and the toggle asks
|
|
234
|
+
* to fold or unfold the rail. */
|
|
198
235
|
export const update = (model: Model, message: Message) =>
|
|
199
236
|
Message.match<Update.ReturnWithOutMessage<Model, Message, OutMessage>>(message, {
|
|
200
237
|
ClickedOpen: () => open(model),
|
|
238
|
+
ClickedToggle: () => ({ ...toggle(model), outMessage: OutMessage.ToggledRail() }),
|
|
201
239
|
PressedSplitter: ({ pointerId, clientX, width }) =>
|
|
202
240
|
Option.isSome(model.maybeResizing)
|
|
203
241
|
? { model }
|
|
@@ -228,6 +266,7 @@ export const update = (model: Model, message: Message) =>
|
|
|
228
266
|
WidenedPastDrawer: () => closeDrawer(model, false),
|
|
229
267
|
CompletedShowRailDrawer: () => ({ model }),
|
|
230
268
|
CompletedHideRailDrawer: () => ({ model }),
|
|
269
|
+
CompletedFocusRailToggle: () => ({ model }),
|
|
231
270
|
});
|
|
232
271
|
|
|
233
272
|
// DRAWER EVENTS
|
|
@@ -351,10 +390,17 @@ export type ViewInputs = Readonly<{
|
|
|
351
390
|
* (for this client: another reader's window is not this one's); none for the stylesheet's.
|
|
352
391
|
* A width out of the rail's bounds prints at the nearer bound. */
|
|
353
392
|
maybeWidth: Option.Option<number>;
|
|
354
|
-
/**
|
|
355
|
-
*
|
|
356
|
-
|
|
357
|
-
|
|
393
|
+
/** Whether the reader folded the rail to its first panel's title bar, as the parent keeps it
|
|
394
|
+
* from `ToggledRail` (for this client, as it keeps the width). The drawer ignores it. */
|
|
395
|
+
isHidden: boolean;
|
|
396
|
+
/** The parent's key for the toggle, which its tip prints after its label; the parent binds
|
|
397
|
+
* it to `toggle`. */
|
|
398
|
+
maybeToggleKeyHint: Option.Option<Button.KeyHintConfig>;
|
|
399
|
+
/** The rail's panels: a tree, places, filters, given the toggle that folds the rail to put in
|
|
400
|
+
* its first panel's `lead`. A function because a Submodel's viewInputs may hold functions
|
|
401
|
+
* only at the top level, and Foldkit runs this one in the parent's boundary, so the
|
|
402
|
+
* handlers in what it returns dispatch the parent's Messages. */
|
|
403
|
+
toAsideView: (toggle: Html) => ReadonlyArray<Html>;
|
|
358
404
|
/** The page beside the rail, `main.deck#main` or `main.bench#main`, given the button that
|
|
359
405
|
* opens the drawer to print first in it. A function because it receives that button, and
|
|
360
406
|
* runs in the parent's boundary like `toAsideView`. */
|
|
@@ -362,10 +408,11 @@ export type ViewInputs = Readonly<{
|
|
|
362
408
|
}>;
|
|
363
409
|
|
|
364
410
|
/**
|
|
365
|
-
* A column of panels beside the deck, fixed under the top bar
|
|
366
|
-
* `
|
|
367
|
-
*
|
|
368
|
-
*
|
|
411
|
+
* A column of panels beside the deck, fixed under the top bar: `div.railed >` the deck, then
|
|
412
|
+
* `aside.rail[popover="auto"][aria-label]`, then its splitter, `div.rail-resize[role="separator"]`,
|
|
413
|
+
* on its right edge. What comes before its last panel keeps its height, and the last panel
|
|
414
|
+
* shrinks to the room left, its bar and foot staying while its body scrolls. One element
|
|
415
|
+
* serves both layouts, so nothing in it renders twice or loses its state. At 900px and under it leaves the page, and
|
|
369
416
|
* `span.rail-open > button.btn.small` at the top of the deck opens the same element as a drawer
|
|
370
417
|
* over a veil, its head (the name and a close glyph) showing. Opening focuses its first
|
|
371
418
|
* control; Escape, a press on the veil, the close glyph, focus leaving or the window growing
|
|
@@ -377,12 +424,19 @@ export type ViewInputs = Readonly<{
|
|
|
377
424
|
* and the rail's width follow it (without one, `--rail`). The drawer keeps its own width. Lift
|
|
378
425
|
* `subscriptions(keyPrefix)` into the application's, or a dragged splitter follows nothing.
|
|
379
426
|
*
|
|
427
|
+
* Its toggle, `span.rail-toggle > button.iconbtn.quiet[aria-expanded]` ("Hide <label>"), comes
|
|
428
|
+
* to `toAsideView` to print as the first panel's `lead`. Pressed, it reports `ToggledRail` for
|
|
429
|
+
* the parent to keep and pass back as `isHidden`: `div.railed.folded` then stands the first
|
|
430
|
+
* panel's title bar on end on the ground (the toggle at its top, "Show <label>"), the rest of
|
|
431
|
+
* the rail and its splitter gone, and the deck takes the width. Focus in the rail lands on the
|
|
432
|
+
* toggle. The drawer, at 900px and under, prints neither the toggle nor the fold.
|
|
433
|
+
*
|
|
380
434
|
* Its state is its own, not `@foldkit/ui`'s Popover: that panel is placed by Floating UI and
|
|
381
435
|
* rendered only while open, and this one is always in the page, placed by the stylesheet, and
|
|
382
436
|
* opened as a native popover so the browser keeps it in the top layer.
|
|
383
437
|
*/
|
|
384
438
|
export const view = defineView<Model, Message, ViewInputs>((model, viewInputs, h): Html => {
|
|
385
|
-
const { label, toAsideView, toDeckView } = viewInputs;
|
|
439
|
+
const { label, isHidden, maybeToggleKeyHint, toAsideView, toDeckView } = viewInputs;
|
|
386
440
|
const maybeWidth = Option.orElse(
|
|
387
441
|
Option.map(model.maybeResizing, ({ width }) => width),
|
|
388
442
|
() => Option.map(viewInputs.maybeWidth, bounded),
|
|
@@ -409,14 +463,58 @@ export const view = defineView<Model, Message, ViewInputs>((model, viewInputs, h
|
|
|
409
463
|
],
|
|
410
464
|
);
|
|
411
465
|
|
|
466
|
+
const toggleButton = h.span(
|
|
467
|
+
[h.Class("rail-toggle")],
|
|
468
|
+
[
|
|
469
|
+
IconButton.view(
|
|
470
|
+
{
|
|
471
|
+
glyph: "sidebar",
|
|
472
|
+
label: `${isHidden ? "Show" : "Hide"} ${label}`,
|
|
473
|
+
isQuiet: true,
|
|
474
|
+
onClick: Message.ClickedToggle(),
|
|
475
|
+
...Option.match(maybeToggleKeyHint, {
|
|
476
|
+
onNone: () => ({}),
|
|
477
|
+
onSome: (keyHint) => ({ keyHint }),
|
|
478
|
+
}),
|
|
479
|
+
attributes: [h.Id(toggleId(model)), h.AriaExpanded(!isHidden), h.AriaControls(model.id)],
|
|
480
|
+
},
|
|
481
|
+
h,
|
|
482
|
+
),
|
|
483
|
+
],
|
|
484
|
+
);
|
|
485
|
+
|
|
486
|
+
const splitter = h.div([
|
|
487
|
+
h.Class("rail-resize"),
|
|
488
|
+
h.Role("separator"),
|
|
489
|
+
h.AriaLabel(`Width of ${label}`),
|
|
490
|
+
h.AriaControls(model.id),
|
|
491
|
+
h.AriaValuemin(WIDTH.least),
|
|
492
|
+
h.AriaValuemax(WIDTH.most),
|
|
493
|
+
h.AriaValuenow(width),
|
|
494
|
+
h.AriaValuetext(`${width} pixels`),
|
|
495
|
+
h.Tabindex(0),
|
|
496
|
+
...splitterAttributes(
|
|
497
|
+
{
|
|
498
|
+
orientation: "vertical",
|
|
499
|
+
isIdle: Option.isNone(model.maybeResizing),
|
|
500
|
+
onPress: (pointerId, clientX) => Message.PressedSplitter({ pointerId, clientX, width }),
|
|
501
|
+
onStep: (direction) =>
|
|
502
|
+
Message.PressedSplitterKey({ width: width + direction * WIDTH.step }),
|
|
503
|
+
},
|
|
504
|
+
h,
|
|
505
|
+
),
|
|
506
|
+
]);
|
|
507
|
+
|
|
412
508
|
// NOTE: the deck comes first so the page's main content, and its h1, precede the rail's
|
|
413
509
|
// panels in reading order; the stylesheet places the rail, fixed, at the left.
|
|
414
510
|
return h.div(
|
|
415
511
|
[
|
|
416
|
-
h.Class("railed"),
|
|
417
|
-
...
|
|
418
|
-
|
|
419
|
-
|
|
512
|
+
h.Class(isHidden ? "railed folded" : "railed"),
|
|
513
|
+
...(isHidden
|
|
514
|
+
? []
|
|
515
|
+
: Array.fromOption(
|
|
516
|
+
Option.map(maybeWidth, (shown) => h.Style({ "--railed-width": `${shown}px` })),
|
|
517
|
+
)),
|
|
420
518
|
],
|
|
421
519
|
[
|
|
422
520
|
toDeckView(openButton),
|
|
@@ -439,30 +537,10 @@ export const view = defineView<Model, Message, ViewInputs>((model, viewInputs, h
|
|
|
439
537
|
),
|
|
440
538
|
],
|
|
441
539
|
),
|
|
442
|
-
...toAsideView(),
|
|
540
|
+
...toAsideView(toggleButton),
|
|
443
541
|
],
|
|
444
542
|
),
|
|
445
|
-
|
|
446
|
-
h.Class("rail-resize"),
|
|
447
|
-
h.Role("separator"),
|
|
448
|
-
h.AriaLabel(`Width of ${label}`),
|
|
449
|
-
h.AriaControls(model.id),
|
|
450
|
-
h.AriaValuemin(WIDTH.least),
|
|
451
|
-
h.AriaValuemax(WIDTH.most),
|
|
452
|
-
h.AriaValuenow(width),
|
|
453
|
-
h.AriaValuetext(`${width} pixels`),
|
|
454
|
-
h.Tabindex(0),
|
|
455
|
-
...splitterAttributes(
|
|
456
|
-
{
|
|
457
|
-
orientation: "vertical",
|
|
458
|
-
isIdle: Option.isNone(model.maybeResizing),
|
|
459
|
-
onPress: (pointerId, clientX) => Message.PressedSplitter({ pointerId, clientX, width }),
|
|
460
|
-
onStep: (direction) =>
|
|
461
|
-
Message.PressedSplitterKey({ width: width + direction * WIDTH.step }),
|
|
462
|
-
},
|
|
463
|
-
h,
|
|
464
|
-
),
|
|
465
|
-
]),
|
|
543
|
+
...(isHidden ? [] : [splitter]),
|
|
466
544
|
],
|
|
467
545
|
);
|
|
468
546
|
});
|