lostcoords-ui 0.12.2 → 0.14.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.
- checksums.yaml +4 -4
- data/README.md +87 -21
- data/app/assets/tailwind/lostcoords/ui/components/menu.css +0 -1
- data/app/assets/tailwind/lostcoords/ui/dialog.css +7 -0
- data/app/assets/tailwind/lostcoords/ui/emoji-picker.css +0 -18
- data/app/assets/tailwind/lostcoords/ui/popover.css +10 -0
- data/app/assets/tailwind/lostcoords/ui/sheet.css +13 -55
- data/app/helpers/lostcoords/ui/card_helper.rb +1 -1
- data/app/helpers/lostcoords/ui/dialog_helper.rb +6 -6
- data/app/helpers/lostcoords/ui/list_group_helper.rb +24 -24
- data/app/helpers/lostcoords/ui/menu_helper.rb +31 -24
- data/app/helpers/lostcoords/ui/primitives_helper.rb +8 -15
- data/app/helpers/lostcoords/ui/sheet_helper.rb +17 -17
- data/app/helpers/lostcoords/ui/tailwind_helper.rb +8 -2
- data/app/javascript/lostcoords/ui/controllers/lc_hovercard_controller.js +3 -2
- data/app/javascript/lostcoords/ui/controllers/lc_menu_controller.js +14 -9
- data/app/javascript/lostcoords/ui/controllers/lc_search_controller.js +1 -1
- data/app/javascript/lostcoords/ui/controllers/lc_sheet_controller.js +3 -71
- data/app/javascript/lostcoords/ui/controllers/lc_tooltip_controller.js +3 -5
- data/app/javascript/lostcoords/ui/helpers/catalog_picker.js +1 -1
- data/app/javascript/lostcoords/ui/helpers/floating_panel.js +16 -14
- data/app/views/lostcoords/ui/components/_emoji_picker.html.erb +0 -2
- data/app/views/lostcoords/ui/components/_lc_confirm_sheet.html.erb +2 -2
- data/app/views/lostcoords/ui/components/_lc_dialog.html.erb +9 -6
- data/lib/lostcoords/ui/parts.rb +9 -0
- data/lib/lostcoords/ui/version.rb +1 -1
- metadata +1 -2
- data/app/views/lostcoords/ui/components/_lc_floating_panel.html.erb +0 -13
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '04927955e774659aeb96601df9709ce28b3da2dbe5a01b825ef40dfcdac4d734'
|
|
4
|
+
data.tar.gz: 56effa1904b9810b0dc2962b3f76bdf9fdaabc8217d94343c4ce60d78caaaa6e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c9d662bdbbe4c811716da94da3994301d8e2be14a7ebed8fa7bc1079c8fe2a3bdb474e921039cc3ee9b059d3d9d8bd5f94d5591f372bcbc45c365d68bb8b9827
|
|
7
|
+
data.tar.gz: 550982086a4c06631fefa58593a5706e3e96f40cb297ddc96e3ea7ed6363bf8224625c8e8b1aab278aaf8c232b74dccbc7cb8ec1863fa756455cabaa90efe28a
|
data/README.md
CHANGED
|
@@ -21,7 +21,7 @@ lockfile pins its gem version, so publishing a library update does not upgrade c
|
|
|
21
21
|
## Install
|
|
22
22
|
|
|
23
23
|
```ruby
|
|
24
|
-
gem "lostcoords-ui", "~> 0.
|
|
24
|
+
gem "lostcoords-ui", "~> 0.14.0"
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
The engine adds its rendering helpers to host views, its views and translations to the host's lookup
|
|
@@ -170,6 +170,67 @@ Omit `only` to register every library controller. Unknown identifiers raise befo
|
|
|
170
170
|
registered, and repeated calls on the same application keep later overrides, so register defaults
|
|
171
171
|
before application overrides.
|
|
172
172
|
|
|
173
|
+
## Changes in 0.14.0
|
|
174
|
+
|
|
175
|
+
Phone sheets have one look. One option to drop, and the rest needs no edit:
|
|
176
|
+
|
|
177
|
+
- **Every phone sheet spans the screen's width and sits on its bottom edge**, with round top corners and no
|
|
178
|
+
grabber. Before, a sheet shorter than the large detent floated inset as a card with a grabber on top.
|
|
179
|
+
`detents: "fit"` (the default) is now a half sheet at its content's height, up to the large detent;
|
|
180
|
+
`"large"` fills the screen; `"medium large"` drags between the two. A swipe down still dismisses.
|
|
181
|
+
- **`lc_dialog` on phones has the sheet's title bar**: the ✕ at the start, 44px on a muted circle, the title
|
|
182
|
+
centred and the description centred under it. The bar stays pinned while the body scrolls. From `sm` up the
|
|
183
|
+
dialog is unchanged.
|
|
184
|
+
- **`sheet.close(label, **attributes)` is that ✕ for a sheet with a header of its own.** Put it in
|
|
185
|
+
`sheet.header`; from `sm` up it is a plain icon button that the caller places.
|
|
186
|
+
- **`lc_sheet` no longer takes `handle:`**, and the `handle` target is gone from `lc-sheet`. Remove
|
|
187
|
+
`handle: true` and any `data-lc-sheet-target="handle"` element. A mouse still drags a sheet by its top 28px.
|
|
188
|
+
- **The page no longer shrinks back behind a large sheet.** It stays in place under the sheet's backdrop.
|
|
189
|
+
`html[data-lc-sheet-page]` and the `--lc-sheet-page-*` variables are gone, and so are `--lc-sheet-p` and
|
|
190
|
+
`--lc-sheet-inset`.
|
|
191
|
+
- **`lc_confirm_sheet` and the emoji picker lose their grabber room** on phones.
|
|
192
|
+
|
|
193
|
+
## Changes in 0.13.0
|
|
194
|
+
|
|
195
|
+
Two renames to make, and the rest needs no edit:
|
|
196
|
+
|
|
197
|
+
- **`tag:` is `as:` on `lc_list_group`, `lc_list_row`, `lc_list_field`, `lc_list_item` and `lc_sheet`**, as on
|
|
198
|
+
every other builder that picks its element. Before: `lc_sheet tag: :dialog`, `lc_list_row "Alerts", tag: :label`.
|
|
199
|
+
After: `lc_sheet as: :dialog`, `lc_list_row "Alerts", as: :label`. A leftover `tag:` no longer picks the element:
|
|
200
|
+
it renders as a `tag` attribute, so search your views for it.
|
|
201
|
+
- **`lc_dialog_class` takes `kind:` as a keyword**, like every other class helper. Before:
|
|
202
|
+
`lc_dialog_class(:context)`. After: `lc_dialog_class(kind: :context)`.
|
|
203
|
+
|
|
204
|
+
Changed:
|
|
205
|
+
|
|
206
|
+
- **A split button's toggle runs your actions before the menu's.** `toggle: { data: { action: … } }` now comes
|
|
207
|
+
first in `data-action`, as `trigger_attributes:` does on `lc_menu`. `lc_split_button` renders through the same
|
|
208
|
+
code as `lc_menu`, so the two cannot drift.
|
|
209
|
+
|
|
210
|
+
Fixed:
|
|
211
|
+
|
|
212
|
+
- **A menu in a row that a Turbo morph reordered no longer breaks the next visit.** The morph moves a menu's
|
|
213
|
+
trigger and panel, which carry ids, into the row that takes its place and removes the emptied host. That
|
|
214
|
+
host's `lc-menu` failed to disconnect and left listeners behind, and the next visit threw
|
|
215
|
+
`Missing target element "popover" for "lc-menu" controller` once per orphaned menu. `FloatingPanel` now
|
|
216
|
+
listens to the document only while its panel is open, and no teardown reads a target; a subclass's
|
|
217
|
+
`disconnect` should not read one either.
|
|
218
|
+
- **A trigger that a morph replaces keeps its arrow keys.** `lc-menu` hears keys on its host, not on the
|
|
219
|
+
trigger and panel it found when it connected.
|
|
220
|
+
- **Menus, popovers, dialogs, phone sheets and linked cards stay put under reduced motion.** They still fade, but
|
|
221
|
+
no longer slide, grow or lift. Before, only the document reset in `base.css` shortened these, so a host that
|
|
222
|
+
skips `base.css` kept the movement.
|
|
223
|
+
|
|
224
|
+
New options:
|
|
225
|
+
|
|
226
|
+
- **`lc_menu` and `lc_popover` take the same options.** `lc_menu` gains `trigger_variant:`, `lc_popover` gains
|
|
227
|
+
`side:` and `trigger_size:`, and `trigger_size:` now also sizes a text trigger.
|
|
228
|
+
|
|
229
|
+
Faster:
|
|
230
|
+
|
|
231
|
+
- **`lc_tw` keeps one class merger for the process** instead of one per view, so a class list merged in one
|
|
232
|
+
request is a cache hit in the next.
|
|
233
|
+
|
|
173
234
|
## Changes in 0.12.2
|
|
174
235
|
|
|
175
236
|
Nothing needs an edit. Fixed:
|
|
@@ -359,7 +420,7 @@ Everything else in 0.8 is additive. These changes need edits in an app built on
|
|
|
359
420
|
mark the selected item with `checked:` or the group's `value:` instead of `selected:`. A group without
|
|
360
421
|
`name:` keeps the radio buttons and `lc-selection:change`; it no longer has an `input` target.
|
|
361
422
|
- **`lc_sheet_data` is gone.** Before: `tag.dialog data: lc_sheet_data({ controller: "picker" }, detents: "large")`.
|
|
362
|
-
After: `lc_sheet
|
|
423
|
+
After: `lc_sheet as: :dialog, detents: "large", data: { controller: "picker" }`. `lc_sheet` also renders
|
|
363
424
|
non-dialog sheets, so drop any hand-written `data-controller="lc-sheet"` and handle element too.
|
|
364
425
|
- **The `lc-confirm-dialog` controller is gone.** Before: a pre-rendered confirm `<dialog>` wired to
|
|
365
426
|
`lc-confirm-dialog`. After: render `lc_confirm_sheet` once in the layout and put `data-turbo-confirm` on
|
|
@@ -393,7 +454,7 @@ Primary, secondary and destructive buttons have visible filled surfaces. Ghost b
|
|
|
393
454
|
Primary, secondary and destructive buttons are flat. Secondary buttons use a soft neutral fill distinct from page and card backgrounds.
|
|
394
455
|
Outline buttons have a transparent fill and a visible edge. Glass buttons use the shared translucent material, rim and shadow for floating controls.
|
|
395
456
|
The default light theme uses white pages and softly shaded cards, with no visible card borders or resting shadows.
|
|
396
|
-
|
|
457
|
+
Menu and popover triggers accept `trigger_variant` using the same button variants.
|
|
397
458
|
Button hover and press fills mix 94% of the base background with 6% of its foreground in OKLab.
|
|
398
459
|
Ghost and icon buttons stay transparent at rest and use the secondary base for that calculation.
|
|
399
460
|
Apps can override `--secondary` for the neutral base, or `--lc-button-bg` and `--lc-button-ink` on individual buttons.
|
|
@@ -550,7 +611,7 @@ makes the summary look like that `lc_button` without the native marker, and `ind
|
|
|
550
611
|
<%= lc_list_row "Email", subtitle: "ada@example.com", icon: "envelope" do %>
|
|
551
612
|
<%= lc_button "Change", variant: :secondary, size: :sm %>
|
|
552
613
|
<% end %>
|
|
553
|
-
<%= lc_list_row "Alerts",
|
|
614
|
+
<%= lc_list_row "Alerts", as: :label do %><%= check_box_tag :alerts, class: lc_switch_class %><% end %>
|
|
554
615
|
<% end %>
|
|
555
616
|
<% end %>
|
|
556
617
|
```
|
|
@@ -559,8 +620,8 @@ makes the summary look like that `lc_button` without the native marker, and `ind
|
|
|
559
620
|
only the group's ends round. The group rounds its first and last shown child, so a collapsible or any other
|
|
560
621
|
element at an end rounds too, and a `hidden` row hands its corners to the next one shown. Rows are card surfaces, so fields and buttons in them follow
|
|
561
622
|
`--card-input` and `--card-secondary`. `lc_list_row` with a title lays out `icon:` (a name, or your own
|
|
562
|
-
markup such as a logo), the title, `subtitle:` and the block as trailing content; `
|
|
563
|
-
`label`, `li`, `details` or `a` (`href:`). `href:` with `
|
|
623
|
+
markup such as a logo), the title, `subtitle:` and the block as trailing content; `as:` makes it a
|
|
624
|
+
`label`, `li`, `details` or `a` (`href:`). `href:` with `as: :li` or `:div` links the title instead
|
|
564
625
|
and stretches it over the row, so the block can hold buttons and links of its own; a click anywhere
|
|
565
626
|
else in the row follows the title. Without a title the block is the whole row, and
|
|
566
627
|
`padded: false` leaves the padding to content such as an `lc_list_item` button or summary, which lays
|
|
@@ -582,8 +643,8 @@ with `--primary-soft` and its text turns semibold, and the focus halo rings the
|
|
|
582
643
|
|
|
583
644
|
`lc_list_field` is a form row in the same group: a label column, then the block as the control. In a
|
|
584
645
|
narrow row the label folds to its `icon:`, and the text stays the accessible name. `id:` makes the label
|
|
585
|
-
a `<label>` for that control; `
|
|
586
|
-
`
|
|
646
|
+
a `<label>` for that control; `as: :fieldset` names a group of controls, such as chips, with a legend.
|
|
647
|
+
`as: :span, surface: false` draws the row inside another element, such as a collapsible's summary.
|
|
587
648
|
`lc_input(plain: true)` drops the field's fill, border, padding and height so the text sits in the row,
|
|
588
649
|
which tints while that input has focus. Toggles take `--lc-field-bg` like fields, so on a card or list
|
|
589
650
|
row they use `--card-input`.
|
|
@@ -593,7 +654,7 @@ row they use `--card-input`.
|
|
|
593
654
|
<%= lc_list_field "Description", icon: "pencil", id: "description" do %>
|
|
594
655
|
<%= lc_input plain: true, id: "description", name: "description" %>
|
|
595
656
|
<% end %>
|
|
596
|
-
<%= lc_list_field "Paid by", icon: "user",
|
|
657
|
+
<%= lc_list_field "Paid by", icon: "user", as: :fieldset do %>
|
|
597
658
|
<div class="flex flex-wrap gap-related"><%= lc_toggle "Ada", size: :sm, aria: { pressed: true } %></div>
|
|
598
659
|
<% end %>
|
|
599
660
|
<% end %>
|
|
@@ -856,8 +917,9 @@ options stay on the menu's columns.
|
|
|
856
917
|
`trigger` targets. With `click->lc-popover#toggleFromRow` on that host, a click anywhere on it that
|
|
857
918
|
misses a control opens the panel; mark other regions `data-lc-menu-ignore`.
|
|
858
919
|
`lc_menu` and `lc_popover` take `trigger: :icon` with `icon:` for a quiet icon button named by `label:`,
|
|
859
|
-
or rendered content such as an avatar for a custom trigger. `
|
|
860
|
-
`
|
|
920
|
+
or rendered content such as an avatar for a custom trigger. `trigger_size: :sm` makes any trigger a small control, and
|
|
921
|
+
`trigger_variant:` picks the button variant of a text trigger.
|
|
922
|
+
`side: :top` opens the panel above its trigger, for one near the bottom of the screen. `trigger_attributes:` adds attributes such as `class:` or `title:` to either.
|
|
861
923
|
For any other trigger, call the yielded part's `trigger` with a block. It receives the attributes that
|
|
862
924
|
wire an element as the trigger (its id, `aria-haspopup`, `aria-expanded`, `aria-controls` and the
|
|
863
925
|
Stimulus target and action), merged with any passed to `trigger`, and the element it renders replaces
|
|
@@ -873,8 +935,9 @@ The icon trigger is muted at rest, with full ink and a slightly larger icon on h
|
|
|
873
935
|
`wrapper_attributes:` styles the element that holds the trigger and panel, an `inline-flex` box by default,
|
|
874
936
|
for example `class: "flex min-w-0"` when the trigger fills a grid cell. A `data: { controller: }` there joins the panel's own.
|
|
875
937
|
|
|
876
|
-
`lc_dialog` handles modal content and the mobile sheet layout
|
|
877
|
-
|
|
938
|
+
`lc_dialog` handles modal content and the mobile sheet layout: on phones it is a sheet across the screen's
|
|
939
|
+
width, with the ✕ at the start of its title bar and the title centred. The default `detents: "fit"` is a half
|
|
940
|
+
sheet at its content's height; `"large"` fills the screen and `"medium large"` drags between half and full. Icon buttons, avatar groups, motion and mobile dialogs
|
|
878
941
|
appear with their parent component examples.
|
|
879
942
|
|
|
880
943
|
`size:` sets the desktop width: `:sm` (24rem), `:md` (32rem, the modal default), `:lg` (40rem) or `:xl`
|
|
@@ -914,23 +977,26 @@ has `data-turbo-confirm-tone="destructive"`, or the submitter is an `lc_button_t
|
|
|
914
977
|
the sheet beside the menu on desktop. `ask(message, { description, accept, destructive, anchor })` from the
|
|
915
978
|
same module opens it from your own code and resolves to `true` or `false`.
|
|
916
979
|
|
|
917
|
-
`lc_sheet` renders any other phone sheet, with the `lc-sheet` controller wired. `
|
|
980
|
+
`lc_sheet` renders any other phone sheet, with the `lc-sheet` controller wired. `as: :dialog` makes a
|
|
918
981
|
modal `<dialog>` sheet, which is what `lc_dialog` and `lc_confirm_sheet` render; with `size:` it gets
|
|
919
|
-
`lc_dialog`'s frame and width without its header, for content that brings its own. The default `
|
|
982
|
+
`lc_dialog`'s frame and width without its header, for content that brings its own. The default `as: :div`
|
|
920
983
|
shows while it is `:popover-open` or carries `[data-open]`, so a native `[popover]` and a FloatingPanel
|
|
921
984
|
picker both work; a div you toggle yourself sets `data-open` and removes it to slide out. From `sm` up
|
|
922
985
|
the div keeps your frame, or `anchored: true` makes it a popover under its trigger inside a positioned
|
|
923
|
-
ancestor. `detents:` takes the same stops as `lc_dialog
|
|
924
|
-
content. A swipe down dispatches `lc-sheet:dismiss`; unless a listener cancels it, an open popover then
|
|
986
|
+
ancestor. `detents:` takes the same stops as `lc_dialog`. A swipe down dispatches `lc-sheet:dismiss`; unless a listener cancels it, an open popover then
|
|
925
987
|
hides. `surface: :glass` draws a div in the translucent menu material, as a picker that is a menu on desktop
|
|
926
|
-
and a sheet on phones. The block gets a builder: `sheet.
|
|
988
|
+
and a sheet on phones. The block gets a builder: `sheet.close "Close"` is the ✕ every phone sheet has at the
|
|
989
|
+
start of its header, and `sheet.header` and `sheet.footer` stay pinned to the top and
|
|
927
990
|
bottom of the scrolling content, painted with the sheet's surface (`--lc-sheet-bg` on phones, `--popover`
|
|
928
991
|
above), so content scrolls under them. Put the footer last in a scroller padded with `px-inset`; it bleeds to
|
|
929
992
|
the scroller's edges and clears the home indicator.
|
|
930
993
|
|
|
931
994
|
```erb
|
|
932
|
-
<%= lc_sheet
|
|
933
|
-
<%= sheet.header do
|
|
995
|
+
<%= lc_sheet as: :dialog, size: :lg, aria: { label: "New expense" } do |sheet| %>
|
|
996
|
+
<%= sheet.header do %>
|
|
997
|
+
<h2 class="mx-auto">New expense</h2>
|
|
998
|
+
<%= sheet.close "Close", data: { action: "expense#close" } %>
|
|
999
|
+
<% end %>
|
|
934
1000
|
<div class="min-h-0 overflow-y-auto px-inset">
|
|
935
1001
|
…
|
|
936
1002
|
<%= sheet.footer do %><%= lc_button "Save" %><% end %>
|
|
@@ -1222,7 +1288,7 @@ Generated by `bin/rails lostcoords:ui:builders`; `bin/lint` checks this list aga
|
|
|
1222
1288
|
- `lc_checkbox_class(extra: nil)` (ChoiceHelper)
|
|
1223
1289
|
- `lc_radio_class(extra: nil)` (ChoiceHelper)
|
|
1224
1290
|
- `lc_switch_class(extra: nil)` (ChoiceHelper)
|
|
1225
|
-
- `lc_dialog_class(kind
|
|
1291
|
+
- `lc_dialog_class(kind: :modal, size: nil, extra: nil)` (DialogHelper)
|
|
1226
1292
|
- `lc_emoji_picker_groups` (EmojiPickerHelper)
|
|
1227
1293
|
- `lc_emoji_picker_count` (EmojiPickerHelper)
|
|
1228
1294
|
- `lc_emoji_picker_version` (EmojiPickerHelper)
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* lc_menu, lc_menu_option and lc_popover. */
|
|
2
2
|
@source "../../../../../helpers/lostcoords/ui/menu_helper.rb";
|
|
3
|
-
@source "../../../../../views/lostcoords/ui/components/_lc_floating_panel.html.erb";
|
|
4
3
|
@source "../../../../../javascript/lostcoords/ui/controllers/lc_menu_controller.js";
|
|
5
4
|
@source "../../../../../javascript/lostcoords/ui/controllers/lc_popover_controller.js";
|
|
@@ -73,7 +73,14 @@
|
|
|
73
73
|
backdrop-filter: none;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
/* The dialog still fades; it no longer moves or grows. */
|
|
76
77
|
@media (prefers-reduced-motion: reduce) {
|
|
78
|
+
transform: none;
|
|
79
|
+
|
|
80
|
+
&[open] {
|
|
81
|
+
@starting-style { transform: none; }
|
|
82
|
+
}
|
|
83
|
+
|
|
77
84
|
&::backdrop { transition: none; }
|
|
78
85
|
}
|
|
79
86
|
}
|
|
@@ -129,22 +129,6 @@
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
/* Drag handle for swipe-to-dismiss. Full-width grab strip, so the touch target
|
|
133
|
-
is large; the host's sheet draws the pill.
|
|
134
|
-
touch-action: none lets a vertical drag pull the sheet down rather than
|
|
135
|
-
scroll. Drag-to-dismiss is wired by the sheet controller. */
|
|
136
|
-
.lc-emoji-picker__handle {
|
|
137
|
-
flex: 0 0 auto;
|
|
138
|
-
display: grid;
|
|
139
|
-
place-items: center;
|
|
140
|
-
inline-size: 100%;
|
|
141
|
-
min-block-size: 1.75rem;
|
|
142
|
-
touch-action: none;
|
|
143
|
-
cursor: grab;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
.lc-emoji-picker__handle:active { cursor: grabbing; }
|
|
147
|
-
|
|
148
132
|
/* ---- Search row --------------------------------------------------- */
|
|
149
133
|
.lc-emoji-picker__search {
|
|
150
134
|
flex: 0 0 auto;
|
|
@@ -451,8 +435,6 @@
|
|
|
451
435
|
@media (prefers-reduced-motion: reduce) { transition: none; }
|
|
452
436
|
}
|
|
453
437
|
|
|
454
|
-
.lc-emoji-picker__handle { display: none; }
|
|
455
|
-
|
|
456
438
|
main:has(.lc-emoji-picker__popover[data-open]),
|
|
457
439
|
.lc-emoji-picker:has(.lc-emoji-picker__popover[data-open]) {
|
|
458
440
|
z-index: var(--lc-z-overlay);
|
|
@@ -22,4 +22,14 @@
|
|
|
22
22
|
transform: var(--lc-popover-from, translateY(--spacing(-1)) scale(0.98));
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
|
|
26
|
+
/* The panel still fades; it no longer moves or grows. */
|
|
27
|
+
@media (prefers-reduced-motion: reduce) {
|
|
28
|
+
/* stylelint-disable-next-line no-invalid-position-declaration -- an @utility body nests like a rule */
|
|
29
|
+
transform: none;
|
|
30
|
+
|
|
31
|
+
&:is([data-open], :popover-open) {
|
|
32
|
+
@starting-style { transform: none; }
|
|
33
|
+
}
|
|
34
|
+
}
|
|
25
35
|
}
|
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
@layer components {
|
|
2
|
-
@media (width < 40rem) {
|
|
3
|
-
/* UIKit's 36×5 grabber. */
|
|
4
|
-
:is(
|
|
5
|
-
[data-lc-sheet-target~="handle"],
|
|
6
|
-
:is(dialog[data-controller~="lc-sheet"], .lc-sheet):not(:has([data-lc-sheet-target~="handle"]))
|
|
7
|
-
)::before {
|
|
8
|
-
content: "";
|
|
9
|
-
display: block;
|
|
10
|
-
inline-size: 2.25rem;
|
|
11
|
-
block-size: 0.3125rem;
|
|
12
|
-
border-radius: 9999px;
|
|
13
|
-
background: color-mix(in oklab, var(--muted-foreground) 45%, transparent);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
2
|
/* From sm up an anchored sheet is a popover under its trigger, opened by a
|
|
18
3
|
FloatingPanel ([data-open]); the positioned ancestor is the caller's. */
|
|
19
4
|
@media (width >= 40rem) {
|
|
@@ -36,39 +21,34 @@
|
|
|
36
21
|
}
|
|
37
22
|
|
|
38
23
|
@layer modules {
|
|
39
|
-
/* Phones: every modal dialog is
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
[data-open]. */
|
|
24
|
+
/* Phones: every modal dialog is a sheet (lc-sheet), and so is any .lc-sheet
|
|
25
|
+
panel. It spans the screen's width and sits on its bottom edge, at its
|
|
26
|
+
content's height up to the large detent. Lives in this layer so it
|
|
27
|
+
out-ranks a panel's own frame. A dialog is open while [open]; a .lc-sheet
|
|
28
|
+
while :popover-open or [data-open]. */
|
|
45
29
|
@media (width < 40rem) {
|
|
46
30
|
:is(dialog[data-controller~="lc-sheet"], .lc-sheet) {
|
|
47
|
-
--lc-sheet-p: 0;
|
|
48
|
-
--lc-sheet-inset: 0.5rem;
|
|
49
31
|
--lc-sheet-radius: 2.25rem;
|
|
50
32
|
--lc-sheet-bg: var(--background);
|
|
51
|
-
--lc-sheet-gap: calc(var(--lc-sheet-inset) * (1 - var(--lc-sheet-p)));
|
|
52
33
|
|
|
53
34
|
position: fixed;
|
|
54
35
|
|
|
55
36
|
/* Anchored from the top edge: the keyboard covers it and
|
|
56
37
|
nothing moves. */
|
|
57
|
-
inset:
|
|
38
|
+
inset: var(--lc-sheet-floor, 100dvh) 0 auto;
|
|
58
39
|
translate: 0 -100%;
|
|
59
|
-
margin: 0
|
|
40
|
+
margin: 0;
|
|
60
41
|
inline-size: auto;
|
|
61
42
|
max-inline-size: none;
|
|
62
43
|
block-size: auto;
|
|
63
44
|
max-block-size: calc(var(--lc-sheet-floor, 100dvh) - max(env(safe-area-inset-top), 0.75rem) - 0.625rem);
|
|
64
|
-
padding: 0 0
|
|
45
|
+
padding: 0 0 env(safe-area-inset-bottom);
|
|
65
46
|
overflow: hidden auto;
|
|
66
47
|
overscroll-behavior: contain;
|
|
67
48
|
scrollbar-width: none;
|
|
68
49
|
border: 1px solid var(--lc-glass-edge);
|
|
69
|
-
border-
|
|
70
|
-
|
|
71
|
-
calc(var(--lc-sheet-radius) * (1 - var(--lc-sheet-p))) calc(var(--lc-sheet-radius) * (1 - var(--lc-sheet-p)));
|
|
50
|
+
border-block-end: 0;
|
|
51
|
+
border-radius: var(--lc-sheet-radius) var(--lc-sheet-radius) 0 0;
|
|
72
52
|
background: var(--lc-sheet-bg);
|
|
73
53
|
box-shadow: var(--lc-glass-rim), 0 -8px 40px -12px rgb(0 0 0 / 0.28);
|
|
74
54
|
opacity: 1;
|
|
@@ -85,14 +65,6 @@
|
|
|
85
65
|
@starting-style { transform: translateY(var(--lc-sheet-offscreen)); }
|
|
86
66
|
}
|
|
87
67
|
|
|
88
|
-
&::before {
|
|
89
|
-
position: absolute;
|
|
90
|
-
z-index: 1;
|
|
91
|
-
inset: 0.3125rem auto auto 50%;
|
|
92
|
-
translate: -50% 0;
|
|
93
|
-
pointer-events: none;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
68
|
&::backdrop {
|
|
97
69
|
background: var(--lc-scrim-sheet);
|
|
98
70
|
backdrop-filter: none;
|
|
@@ -109,7 +81,10 @@
|
|
|
109
81
|
@starting-style { opacity: 0; }
|
|
110
82
|
}
|
|
111
83
|
|
|
84
|
+
/* The sheet appears in place; lc-sheet's own slides already skip under reduced motion. */
|
|
112
85
|
@media (prefers-reduced-motion: reduce) {
|
|
86
|
+
transition: none;
|
|
87
|
+
|
|
113
88
|
&::backdrop { transition: none; }
|
|
114
89
|
}
|
|
115
90
|
}
|
|
@@ -121,22 +96,5 @@
|
|
|
121
96
|
|
|
122
97
|
&:is(:popover-open, [data-open]) { display: flex; }
|
|
123
98
|
}
|
|
124
|
-
|
|
125
|
-
/* Behind a large sheet the page shrinks back and rounds off, over black,
|
|
126
|
-
as UIKit's page sheet does; lc-sheet drives the variables. */
|
|
127
|
-
html[data-lc-sheet-page] {
|
|
128
|
-
background: #000;
|
|
129
|
-
|
|
130
|
-
> body {
|
|
131
|
-
transform-origin: 50% var(--lc-sheet-page-origin, 0);
|
|
132
|
-
transform:
|
|
133
|
-
translateY(calc(var(--lc-sheet-page-p, 0) * (max(env(safe-area-inset-top), 0.75rem) - 0.25rem)))
|
|
134
|
-
scale(var(--lc-sheet-page-scale, 1));
|
|
135
|
-
clip-path: inset(var(--lc-sheet-page-origin, 0) 0 0 round calc(var(--lc-sheet-page-p, 0) * 0.75rem));
|
|
136
|
-
transition:
|
|
137
|
-
transform var(--lc-sheet-page-transition, 0s),
|
|
138
|
-
clip-path var(--lc-sheet-page-transition, 0s);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
99
|
}
|
|
142
100
|
}
|
|
@@ -8,7 +8,7 @@ module Lostcoords::Ui
|
|
|
8
8
|
md: "p-inset",
|
|
9
9
|
sm: "[--lc-inset:var(--spacing-content)] p-inset"
|
|
10
10
|
}.freeze
|
|
11
|
-
HOVER_LIFT = "transition-[transform,box-shadow] duration-(--lc-motion-control) ease-(--lc-ease-out) hover:-translate-y-0.5 hover:shadow-(--lc-shadow)"
|
|
11
|
+
HOVER_LIFT = "transition-[transform,box-shadow] duration-(--lc-motion-control) ease-(--lc-ease-out) motion-safe:hover:-translate-y-0.5 hover:shadow-(--lc-shadow)"
|
|
12
12
|
|
|
13
13
|
def lc_card_class(interactive: false, padding: :md, extra: nil)
|
|
14
14
|
padding = lc_option!(:padding, padding, CARD_PADDING.keys)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Lostcoords::Ui
|
|
2
2
|
module DialogHelper
|
|
3
|
-
# Below sm these open as
|
|
3
|
+
# Below sm these open as sheets (sheet.css), which paint their own surface.
|
|
4
4
|
SHEET_DIALOG_SURFACE =
|
|
5
5
|
"sm:border sm:border-(--lc-glass-edge) sm:rounded-3xl sm:bg-popover text-popover-foreground sm:shadow-[var(--lc-glass-rim),var(--lc-shadow-lg)]"
|
|
6
6
|
|
|
@@ -30,7 +30,7 @@ module Lostcoords::Ui
|
|
|
30
30
|
CONFIRM_SHEET_ID = "lc-confirm-sheet"
|
|
31
31
|
|
|
32
32
|
# size: :sm, :md, :lg or :xl. A modal defaults to :md; a context dialog keeps its compact width.
|
|
33
|
-
def lc_dialog_class(kind
|
|
33
|
+
def lc_dialog_class(kind: :modal, size: nil, extra: nil)
|
|
34
34
|
kind = lc_option!(:kind, kind, DIALOGS.keys)
|
|
35
35
|
size = lc_option!(:size, size, DIALOG_SIZES.keys) unless size.nil?
|
|
36
36
|
size ||= :md if kind == :modal
|
|
@@ -48,12 +48,12 @@ module Lostcoords::Ui
|
|
|
48
48
|
lc_label!(trigger, :trigger) unless trigger == false
|
|
49
49
|
lc_label!(close_action, :close_action)
|
|
50
50
|
detents = lc_option!(:detents, detents, SheetHelper::SHEET_DETENTS.map(&:to_sym)).to_s
|
|
51
|
-
defaults = { class: lc_dialog_class(kind, size: size), aria: { describedby: ("#{id}-description" if description.present?) }, data: { slot: "dialog" } }
|
|
51
|
+
defaults = { class: lc_dialog_class(kind: kind, size: size), aria: { describedby: ("#{id}-description" if description.present?) }, data: { slot: "dialog" } }
|
|
52
52
|
required = { id: id, aria: { labelledby: "#{id}-title" }, data: ({ lc_dialog_target: "dialog" } if trigger) }.compact
|
|
53
53
|
parts = Parts::Dialog.new(self, id, close_action)
|
|
54
54
|
content = capture(parts, &block) if block
|
|
55
|
-
title_tag = tag.h2(title, **lc_attributes({ class: lc_heading_class(size: :subheading), data: { slot: "dialog-title" } }, title_attributes, { id: "#{id}-title" }))
|
|
56
|
-
description_tag = tag.p(description, **lc_attributes({ class: lc_text_class(size: :small, tone: :muted), data: { slot: "dialog-description" } }, description_attributes, { id: "#{id}-description" })) if description.present?
|
|
55
|
+
title_tag = tag.h2(title, **lc_attributes({ class: lc_heading_class(size: :subheading, extra: "max-sm:text-center"), data: { slot: "dialog-title" } }, title_attributes, { id: "#{id}-title" }))
|
|
56
|
+
description_tag = tag.p(description, **lc_attributes({ class: lc_text_class(size: :small, tone: :muted, extra: "max-sm:text-center max-sm:text-balance"), data: { slot: "dialog-description" } }, description_attributes, { id: "#{id}-description" })) if description.present?
|
|
57
57
|
raise ArgumentError, "dialog.trigger can't be used with trigger: false" if trigger == false && parts.rendered_trigger
|
|
58
58
|
render "lostcoords/ui/components/lc_dialog", id: id, title: title_tag, description: description_tag, trigger: trigger, rendered_trigger: parts.rendered_trigger, detents: detents,
|
|
59
59
|
close_action: close_action, close_label: close_label || lc_t("lostcoords.ui.dialog.close", title: title),
|
|
@@ -63,7 +63,7 @@ module Lostcoords::Ui
|
|
|
63
63
|
# The sheet Turbo's confirm opens. Render it once in the layout and set
|
|
64
64
|
# Turbo.config.forms.confirm to `confirm` from lostcoords/ui/helpers/confirm.
|
|
65
65
|
def lc_confirm_sheet(**attributes)
|
|
66
|
-
defaults = { class: lc_dialog_class(:context), data: { slot: "confirm-sheet", turbo_permanent: true } }
|
|
66
|
+
defaults = { class: lc_dialog_class(kind: :context), data: { slot: "confirm-sheet", turbo_permanent: true } }
|
|
67
67
|
required = { id: CONFIRM_SHEET_ID, tabindex: -1, aria: { labelledby: "#{CONFIRM_SHEET_ID}-message", describedby: "#{CONFIRM_SHEET_ID}-description" } }
|
|
68
68
|
render "lostcoords/ui/components/lc_confirm_sheet", id: CONFIRM_SHEET_ID, attributes: lc_attributes(defaults, attributes, required)
|
|
69
69
|
end
|
|
@@ -9,7 +9,7 @@ module Lostcoords::Ui
|
|
|
9
9
|
LIST_ITEM = "flex min-h-16 min-w-0 items-center gap-heading px-content py-heading text-start sm:px-inset"
|
|
10
10
|
LIST_ROW_PADDING = "px-content py-heading sm:px-inset"
|
|
11
11
|
LIST_ICON = "grid size-10 shrink-0 place-items-center rounded-full bg-tile [&>svg:not([class*='size-'])]:size-4.5"
|
|
12
|
-
|
|
12
|
+
LIST_ROW_ELEMENTS = %i[div li label details a].freeze
|
|
13
13
|
LIST_ROW_HOVER = "transition-colors duration-(--lc-motion-quick) hover:bg-accent"
|
|
14
14
|
# A linked li or div row: the title's link covers the row, the row's own controls sit above it,
|
|
15
15
|
# and the row shows the link's focus ring.
|
|
@@ -25,7 +25,7 @@ module Lostcoords::Ui
|
|
|
25
25
|
"group/choice flex items-center gap-heading cursor-pointer transition-colors duration-(--lc-motion-quick) " \
|
|
26
26
|
"hover:bg-accent has-checked:bg-primary-soft has-checked:font-semibold has-disabled:cursor-not-allowed has-disabled:opacity-45"
|
|
27
27
|
LIST_ROW_CHOICE_CHECK = "ms-auto size-4 shrink-0 text-primary invisible group-has-checked/choice:visible"
|
|
28
|
-
|
|
28
|
+
LIST_FIELD_ELEMENTS = %i[div fieldset span].freeze
|
|
29
29
|
LIST_FIELD = "@container px-content py-2.5 transition-colors duration-(--lc-motion-quick) has-[[data-plain]:focus]:bg-accent"
|
|
30
30
|
LIST_FIELD_GRID = "grid min-h-9 grid-cols-[1.25rem_minmax(0,1fr)] items-center gap-x-heading gap-y-related @md:grid-cols-[8rem_minmax(0,1fr)]"
|
|
31
31
|
LIST_FIELD_LABEL =
|
|
@@ -50,9 +50,9 @@ module Lostcoords::Ui
|
|
|
50
50
|
|
|
51
51
|
# Rows as in iOS settings: each row is its own card-coloured panel, 2px apart, and only the
|
|
52
52
|
# first and last rows round.
|
|
53
|
-
def lc_list_group(
|
|
54
|
-
|
|
55
|
-
content_tag(
|
|
53
|
+
def lc_list_group(as: :div, **attributes, &block)
|
|
54
|
+
as = lc_option!(:as, as, %i[div ul])
|
|
55
|
+
content_tag(as, (capture(&block) if block), **lc_attributes({ class: LIST_GROUP, data: { slot: "list-group" } }, attributes))
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
# With a title, the row lays out icon:, the title and subtitle, then the block as its trailing
|
|
@@ -63,21 +63,21 @@ module Lostcoords::Ui
|
|
|
63
63
|
# choice: :radio makes the row one choice of a radio group: a label around a hidden radio named
|
|
64
64
|
# name: with value:, then the title or block, then a check shown while checked:. input: adds
|
|
65
65
|
# attributes to the radio.
|
|
66
|
-
def lc_list_row(title = nil, subtitle: nil, icon: nil, href: nil,
|
|
66
|
+
def lc_list_row(title = nil, subtitle: nil, icon: nil, href: nil, as: nil, padded: true, choice: nil, name: nil, value: nil, checked: false, input: {}, **attributes, &block)
|
|
67
67
|
return lc_list_choice_row(title, choice, name, value, checked, input, attributes, &block) if choice
|
|
68
68
|
raise ArgumentError, "name:, value:, checked: and input: belong to a choice: row" if name || value || checked || input.any?
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
titled = href &&
|
|
72
|
-
raise ArgumentError, "href: needs
|
|
70
|
+
as = lc_option!(:as, as || (href ? :a : :div), LIST_ROW_ELEMENTS)
|
|
71
|
+
titled = href && as != :a
|
|
72
|
+
raise ArgumentError, "href: needs as: :a, :li or :div" if titled && !%i[li div].include?(as)
|
|
73
73
|
raise ArgumentError, "href: on an li or div row links its title, so it needs one" if titled && title.blank?
|
|
74
74
|
|
|
75
75
|
link = (titled ? lc_tw(LIST_ROW_HOVER, LIST_ROW_LINKED) : lc_tw("no-underline", LIST_ROW_HOVER)) if href
|
|
76
76
|
defaults = { href: (href unless titled), data: { slot: "list-row" } }
|
|
77
|
-
return lc_list_item(title, subtitle: subtitle, icon: icon, link: (href if titled),
|
|
77
|
+
return lc_list_item(title, subtitle: subtitle, icon: icon, link: (href if titled), as: as, **lc_attributes(defaults.merge(class: lc_tw(LIST_ROW, link)), attributes), &block) if title.present?
|
|
78
78
|
|
|
79
79
|
classes = lc_tw(LIST_ROW, (LIST_ROW_PADDING if padded), link)
|
|
80
|
-
content_tag(
|
|
80
|
+
content_tag(as, (capture(&block) if block), **lc_attributes(defaults.merge(class: classes), attributes))
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
private def lc_list_choice_row(title, choice, name, value, checked, input, attributes, &block)
|
|
@@ -100,36 +100,36 @@ module Lostcoords::Ui
|
|
|
100
100
|
|
|
101
101
|
# A form row: a label column, then the block as the control. In a narrow row the label folds to
|
|
102
102
|
# icon: alone and stays the accessible name. id: makes the label a <label> for that control;
|
|
103
|
-
#
|
|
104
|
-
# for a row drawn inside another element, such as a collapsible's summary (with
|
|
105
|
-
def lc_list_field(label, icon: nil, id: nil,
|
|
103
|
+
# as: :fieldset names a group of controls with a legend. surface: false drops the row's panel,
|
|
104
|
+
# for a row drawn inside another element, such as a collapsible's summary (with as: :span).
|
|
105
|
+
def lc_list_field(label, icon: nil, id: nil, as: :div, surface: true, **attributes, &block)
|
|
106
106
|
lc_label!(label, :label)
|
|
107
|
-
|
|
108
|
-
raise ArgumentError, "id: labels one control; a fieldset is named by its legend" if id &&
|
|
107
|
+
as = lc_option!(:as, as, LIST_FIELD_ELEMENTS)
|
|
108
|
+
raise ArgumentError, "id: labels one control; a fieldset is named by its legend" if id && as == :fieldset
|
|
109
109
|
|
|
110
|
-
inline =
|
|
110
|
+
inline = as == :span ? :span : :div
|
|
111
111
|
text = content_tag(:span, label, class: "@max-md:sr-only", data: { slot: "list-field-text" })
|
|
112
112
|
glyph = (icon.is_a?(ActiveSupport::SafeBuffer) ? icon : lc_icon(icon, options: { "aria-hidden": true })) if icon.present?
|
|
113
|
-
label_classes = lc_tw(LIST_FIELD_LABEL, ("self-start min-h-control-sm" if
|
|
113
|
+
label_classes = lc_tw(LIST_FIELD_LABEL, ("self-start min-h-control-sm" if as == :fieldset))
|
|
114
114
|
label_tag = if id
|
|
115
115
|
content_tag(:label, safe_join([ glyph, text ].compact), for: id, class: label_classes, data: { slot: "list-field-label" })
|
|
116
116
|
else
|
|
117
|
-
content_tag(:span, safe_join([ glyph, text ].compact), class: label_classes, aria: { hidden: (true if
|
|
117
|
+
content_tag(:span, safe_join([ glyph, text ].compact), class: label_classes, aria: { hidden: (true if as == :fieldset) }, data: { slot: "list-field-label" })
|
|
118
118
|
end
|
|
119
119
|
grid = content_tag(inline, safe_join([ label_tag, (capture(&block) if block) ].compact), class: LIST_FIELD_GRID)
|
|
120
|
-
legend = content_tag(:legend, label, class: "sr-only") if
|
|
121
|
-
classes = lc_tw((LIST_ROW if surface), LIST_FIELD, ("block" if
|
|
122
|
-
content_tag(
|
|
120
|
+
legend = content_tag(:legend, label, class: "sr-only") if as == :fieldset
|
|
121
|
+
classes = lc_tw((LIST_ROW if surface), LIST_FIELD, ("block" if as == :span), ("m-0 min-w-0 border-0" if as == :fieldset))
|
|
122
|
+
content_tag(as, safe_join([ legend, grid ].compact), **lc_attributes({ class: classes, data: { slot: "list-field" } }, attributes))
|
|
123
123
|
end
|
|
124
124
|
|
|
125
125
|
# The row layout without the row's surface, for an element inside a free-form row: a summary, a
|
|
126
126
|
# button that opens an editor. icon: takes an icon name or your own markup, such as a logo.
|
|
127
127
|
# link: links the title to that URL and stretches the link over the nearest positioned ancestor.
|
|
128
|
-
def lc_list_item(title, subtitle: nil, icon: nil, link: nil,
|
|
128
|
+
def lc_list_item(title, subtitle: nil, icon: nil, link: nil, as: :div, **attributes, &block)
|
|
129
129
|
lc_label!(title, :title)
|
|
130
130
|
glyph = icon.is_a?(ActiveSupport::SafeBuffer) ? icon : lc_icon(icon) if icon.present?
|
|
131
131
|
title = link_to(title, link, class: LIST_LINK, data: { slot: "list-link" }) if link
|
|
132
|
-
content_tag(
|
|
132
|
+
content_tag(as, **lc_attributes({ class: LIST_ITEM, data: { slot: "list-item" } }, attributes)) do
|
|
133
133
|
text = safe_join([
|
|
134
134
|
content_tag(:span, title, class: "font-semibold", data: { slot: "list-title" }),
|
|
135
135
|
(content_tag(:span, subtitle, class: "text-small text-muted-foreground [overflow-wrap:anywhere]", data: { slot: "list-subtitle" }) if subtitle.present?)
|