lostcoords-ui 0.13.0 → 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 +31 -7
- data/app/assets/tailwind/lostcoords/ui/emoji-picker.css +0 -18
- data/app/assets/tailwind/lostcoords/ui/sheet.css +10 -55
- data/app/helpers/lostcoords/ui/dialog_helper.rb +3 -3
- data/app/helpers/lostcoords/ui/sheet_helper.rb +10 -10
- data/app/javascript/lostcoords/ui/controllers/lc_sheet_controller.js +3 -71
- data/app/views/lostcoords/ui/components/_emoji_picker.html.erb +0 -2
- data/app/views/lostcoords/ui/components/_lc_confirm_sheet.html.erb +1 -1
- 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 -1
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,26 @@ 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
|
+
|
|
173
193
|
## Changes in 0.13.0
|
|
174
194
|
|
|
175
195
|
Two renames to make, and the rest needs no edit:
|
|
@@ -915,8 +935,9 @@ The icon trigger is muted at rest, with full ink and a slightly larger icon on h
|
|
|
915
935
|
`wrapper_attributes:` styles the element that holds the trigger and panel, an `inline-flex` box by default,
|
|
916
936
|
for example `class: "flex min-w-0"` when the trigger fills a grid cell. A `data: { controller: }` there joins the panel's own.
|
|
917
937
|
|
|
918
|
-
`lc_dialog` handles modal content and the mobile sheet layout
|
|
919
|
-
|
|
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
|
|
920
941
|
appear with their parent component examples.
|
|
921
942
|
|
|
922
943
|
`size:` sets the desktop width: `:sm` (24rem), `:md` (32rem, the modal default), `:lg` (40rem) or `:xl`
|
|
@@ -962,17 +983,20 @@ modal `<dialog>` sheet, which is what `lc_dialog` and `lc_confirm_sheet` render;
|
|
|
962
983
|
shows while it is `:popover-open` or carries `[data-open]`, so a native `[popover]` and a FloatingPanel
|
|
963
984
|
picker both work; a div you toggle yourself sets `data-open` and removes it to slide out. From `sm` up
|
|
964
985
|
the div keeps your frame, or `anchored: true` makes it a popover under its trigger inside a positioned
|
|
965
|
-
ancestor. `detents:` takes the same stops as `lc_dialog
|
|
966
|
-
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
|
|
967
987
|
hides. `surface: :glass` draws a div in the translucent menu material, as a picker that is a menu on desktop
|
|
968
|
-
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
|
|
969
990
|
bottom of the scrolling content, painted with the sheet's surface (`--lc-sheet-bg` on phones, `--popover`
|
|
970
991
|
above), so content scrolls under them. Put the footer last in a scroller padded with `px-inset`; it bleeds to
|
|
971
992
|
the scroller's edges and clears the home indicator.
|
|
972
993
|
|
|
973
994
|
```erb
|
|
974
995
|
<%= lc_sheet as: :dialog, size: :lg, aria: { label: "New expense" } do |sheet| %>
|
|
975
|
-
<%= sheet.header do
|
|
996
|
+
<%= sheet.header do %>
|
|
997
|
+
<h2 class="mx-auto">New expense</h2>
|
|
998
|
+
<%= sheet.close "Close", data: { action: "expense#close" } %>
|
|
999
|
+
<% end %>
|
|
976
1000
|
<div class="min-h-0 overflow-y-auto px-inset">
|
|
977
1001
|
…
|
|
978
1002
|
<%= sheet.footer do %><%= lc_button "Save" %><% end %>
|
|
@@ -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);
|
|
@@ -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;
|
|
@@ -124,22 +96,5 @@
|
|
|
124
96
|
|
|
125
97
|
&:is(:popover-open, [data-open]) { display: flex; }
|
|
126
98
|
}
|
|
127
|
-
|
|
128
|
-
/* Behind a large sheet the page shrinks back and rounds off, over black,
|
|
129
|
-
as UIKit's page sheet does; lc-sheet drives the variables. */
|
|
130
|
-
html[data-lc-sheet-page] {
|
|
131
|
-
background: #000;
|
|
132
|
-
|
|
133
|
-
> body {
|
|
134
|
-
transform-origin: 50% var(--lc-sheet-page-origin, 0);
|
|
135
|
-
transform:
|
|
136
|
-
translateY(calc(var(--lc-sheet-page-p, 0) * (max(env(safe-area-inset-top), 0.75rem) - 0.25rem)))
|
|
137
|
-
scale(var(--lc-sheet-page-scale, 1));
|
|
138
|
-
clip-path: inset(var(--lc-sheet-page-origin, 0) 0 0 round calc(var(--lc-sheet-page-p, 0) * 0.75rem));
|
|
139
|
-
transition:
|
|
140
|
-
transform var(--lc-sheet-page-transition, 0s),
|
|
141
|
-
clip-path var(--lc-sheet-page-transition, 0s);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
99
|
}
|
|
145
100
|
}
|
|
@@ -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
|
|
|
@@ -52,8 +52,8 @@ module Lostcoords::Ui
|
|
|
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),
|
|
@@ -3,19 +3,20 @@ module Lostcoords::Ui
|
|
|
3
3
|
SHEET_ELEMENTS = %i[div dialog].freeze
|
|
4
4
|
SHEET_DETENTS = [ "fit", "medium large", "large" ].freeze
|
|
5
5
|
SHEET_SURFACES = %i[glass].freeze
|
|
6
|
-
SHEET_HANDLE = "grid min-h-7 w-full flex-none cursor-grab touch-none place-items-center active:cursor-grabbing sm:hidden"
|
|
7
6
|
|
|
8
|
-
# A panel that is
|
|
9
|
-
# <dialog> (lc_dialog builds on it). A :div shows while
|
|
10
|
-
# from sm up it keeps your frame, or with anchored: true it
|
|
11
|
-
#
|
|
12
|
-
#
|
|
7
|
+
# A panel that is a sheet on phones, with the lc-sheet controller: it spans the screen's width and sits
|
|
8
|
+
# on its bottom edge. as: :dialog is a modal <dialog> (lc_dialog builds on it). A :div shows while
|
|
9
|
+
# [data-open] or, with popover:, :popover-open; from sm up it keeps your frame, or with anchored: true it
|
|
10
|
+
# is a popover under its trigger, opened by a FloatingPanel inside a positioned ancestor.
|
|
11
|
+
# detents: "fit" is a half sheet at its content's height, "large" fills the screen and "medium large"
|
|
12
|
+
# drags between half the screen and all of it.
|
|
13
13
|
# A swipe down dispatches lc-sheet:dismiss; unless a listener cancels it, an open popover hides.
|
|
14
14
|
# With as: :dialog, size: draws lc_dialog's modal frame at that width, for a dialog whose content
|
|
15
15
|
# brings its own header and labels the dialog with aria-label.
|
|
16
16
|
# surface: :glass draws a :div in the translucent menu material, a menu on desktop and a sheet on phones.
|
|
17
|
-
# Yields a builder whose header and footer parts stay pinned while the content scrolls
|
|
18
|
-
|
|
17
|
+
# Yields a builder whose header and footer parts stay pinned while the content scrolls, and whose close
|
|
18
|
+
# part is the ✕ at the header's start.
|
|
19
|
+
def lc_sheet(as: :div, anchored: false, detents: "fit", size: nil, surface: nil, **attributes, &block)
|
|
19
20
|
as = lc_option!(:as, as, SHEET_ELEMENTS)
|
|
20
21
|
detents = lc_option!(:detents, detents, SHEET_DETENTS.map(&:to_sym)).to_s
|
|
21
22
|
surface = lc_option!(:surface, surface, SHEET_SURFACES) unless surface.nil?
|
|
@@ -26,9 +27,8 @@ module Lostcoords::Ui
|
|
|
26
27
|
defaults = { data: { slot: "sheet", controller: "lc-sheet", lc_sheet_detents_value: detents } }
|
|
27
28
|
defaults[:class] = lc_tw("lc-sheet", ("lc-sheet-anchored" if anchored), (lc_glass_class(shape: :picker) if surface == :glass)) unless as == :dialog
|
|
28
29
|
defaults[:class] = lc_dialog_class(size: size) if size
|
|
29
|
-
strip = tag.span(class: SHEET_HANDLE, aria: { hidden: true }, data: { slot: "sheet-handle", lc_sheet_target: "handle" }) if handle
|
|
30
30
|
content = capture(Parts::Sheet.new(self), &block) if block
|
|
31
|
-
content_tag(as,
|
|
31
|
+
content_tag(as, content, **lc_attributes(defaults, attributes))
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
end
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { Controller } from "@hotwired/stimulus"
|
|
2
|
-
import { holdDocumentScroll } from "lostcoords/ui/helpers/dismiss_stack"
|
|
3
2
|
import { SHEET_TIMING, sheetDuration } from "lostcoords/ui/helpers/sheet_motion"
|
|
4
3
|
import { hideTopLayer, supportsTopLayer } from "lostcoords/ui/helpers/top_layer"
|
|
5
4
|
import { isSheetViewport, prefersReducedMotion, TEXT_ENTRY } from "lostcoords/ui/helpers/viewport"
|
|
6
5
|
|
|
7
6
|
const PROJECTION_MS = 180
|
|
8
7
|
const MEDIUM_FRACTION = 0.5
|
|
9
|
-
const PAGE_SCALE_LOSS = 0.06
|
|
10
8
|
const NO_DRAG = "input[type=range], [data-lc-sheet-no-drag]"
|
|
11
|
-
const
|
|
12
|
-
const GRABBER_ZONE = 28
|
|
9
|
+
const DRAG_ZONE = 28
|
|
13
10
|
const KEYBOARD_FREE = 0.5
|
|
14
11
|
|
|
15
12
|
export default class extends Controller {
|
|
16
|
-
static targets = ["handle"]
|
|
17
13
|
static values = { detents: { type: String, default: "fit" } }
|
|
18
14
|
|
|
19
15
|
connect() {
|
|
@@ -59,7 +55,6 @@ export default class extends Controller {
|
|
|
59
55
|
this.stopMouseTracking()
|
|
60
56
|
clearTimeout(this.settleTimer)
|
|
61
57
|
clearTimeout(this.transitionTimer)
|
|
62
|
-
this.releasePage()
|
|
63
58
|
this.resetSurface()
|
|
64
59
|
}
|
|
65
60
|
|
|
@@ -72,8 +67,6 @@ export default class extends Controller {
|
|
|
72
67
|
this.detent = detents[0]
|
|
73
68
|
if (detents.length > 1 || this.detent.large)
|
|
74
69
|
this.element.style.blockSize = `${this.detent.height}px`
|
|
75
|
-
this.setLargeness(this.detent.large ? 1 : 0)
|
|
76
|
-
if (this.detent.large) this.animatePage(1)
|
|
77
70
|
}
|
|
78
71
|
|
|
79
72
|
// The keyboard rises over the sheet. Safari and in-app browsers shrink the
|
|
@@ -86,11 +79,7 @@ export default class extends Controller {
|
|
|
86
79
|
|
|
87
80
|
closed() {
|
|
88
81
|
this.gesture = null
|
|
89
|
-
|
|
90
|
-
this.later(() => {
|
|
91
|
-
this.releasePage()
|
|
92
|
-
this.resetSurface()
|
|
93
|
-
})
|
|
82
|
+
this.later(() => this.resetSurface())
|
|
94
83
|
}
|
|
95
84
|
|
|
96
85
|
// Touch: decide on the first move whether the gesture is the sheet's or the
|
|
@@ -149,8 +138,7 @@ export default class extends Controller {
|
|
|
149
138
|
|
|
150
139
|
onPointerDown(event) {
|
|
151
140
|
if (!this.isSheet || event.pointerType !== "mouse" || event.button !== 0) return
|
|
152
|
-
|
|
153
|
-
if (!event.target.closest(HANDLE) && fromTop > GRABBER_ZONE) return
|
|
141
|
+
if (event.clientY - this.element.getBoundingClientRect().top > DRAG_ZONE) return
|
|
154
142
|
|
|
155
143
|
this.begin(event.clientX, event.clientY, event.timeStamp, null)
|
|
156
144
|
this.startDrag(event.clientY)
|
|
@@ -206,7 +194,6 @@ export default class extends Controller {
|
|
|
206
194
|
gesture.startVisible = this.visibleHeight()
|
|
207
195
|
this.element.style.transition = "none"
|
|
208
196
|
this.element.style.willChange = "transform"
|
|
209
|
-
this.pageTransition("0s")
|
|
210
197
|
|
|
211
198
|
const field = document.activeElement
|
|
212
199
|
if (this.element.contains(field) && field.matches("input, textarea, select")) field.blur()
|
|
@@ -240,7 +227,6 @@ export default class extends Controller {
|
|
|
240
227
|
settle(detent, detents = this.detents()) {
|
|
241
228
|
this.detent = detent
|
|
242
229
|
this.transition()
|
|
243
|
-
this.pageTransition()
|
|
244
230
|
this.show(detent.height, detents)
|
|
245
231
|
}
|
|
246
232
|
|
|
@@ -298,16 +284,6 @@ export default class extends Controller {
|
|
|
298
284
|
style.transform = ""
|
|
299
285
|
if (resizes || visible > largest) style.blockSize = `${visible}px`
|
|
300
286
|
}
|
|
301
|
-
|
|
302
|
-
if (!detents.some((detent) => detent.large)) return
|
|
303
|
-
const clamp = (n) => Math.max(0, Math.min(1, n))
|
|
304
|
-
if (detents.length > 1) {
|
|
305
|
-
const p = clamp((visible - smallest) / (largest - smallest))
|
|
306
|
-
this.setLargeness(p)
|
|
307
|
-
this.setPage(p)
|
|
308
|
-
} else {
|
|
309
|
-
this.setPage(clamp(visible / largest))
|
|
310
|
-
}
|
|
311
287
|
}
|
|
312
288
|
|
|
313
289
|
rubberBand(wanted, detents) {
|
|
@@ -341,49 +317,6 @@ export default class extends Controller {
|
|
|
341
317
|
return parseFloat(getComputedStyle(this.element).maxBlockSize) || window.innerHeight
|
|
342
318
|
}
|
|
343
319
|
|
|
344
|
-
setLargeness(p) {
|
|
345
|
-
this.element.style.setProperty("--lc-sheet-p", p.toFixed(3))
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
setPage(p) {
|
|
349
|
-
const root = document.documentElement
|
|
350
|
-
if (!this.ownsPage) {
|
|
351
|
-
if (p <= 0) return
|
|
352
|
-
this.releaseScroll = holdDocumentScroll()
|
|
353
|
-
const lockedTop = -parseFloat(document.body.style.top || "0")
|
|
354
|
-
root.style.setProperty("--lc-sheet-page-origin", `${window.scrollY + lockedTop}px`)
|
|
355
|
-
root.dataset.lcSheetPage = ""
|
|
356
|
-
this.ownsPage = true
|
|
357
|
-
}
|
|
358
|
-
root.style.setProperty("--lc-sheet-page-p", p.toFixed(3))
|
|
359
|
-
root.style.setProperty("--lc-sheet-page-scale", (1 - PAGE_SCALE_LOSS * p).toFixed(4))
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
animatePage(p) {
|
|
363
|
-
this.pageTransition()
|
|
364
|
-
if (p > 0 && !this.ownsPage) {
|
|
365
|
-
this.setPage(0.001)
|
|
366
|
-
requestAnimationFrame(() => requestAnimationFrame(() => this.setPage(p)))
|
|
367
|
-
} else {
|
|
368
|
-
this.setPage(p)
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
releasePage() {
|
|
373
|
-
if (!this.ownsPage) return
|
|
374
|
-
this.ownsPage = false
|
|
375
|
-
const root = document.documentElement
|
|
376
|
-
delete root.dataset.lcSheetPage
|
|
377
|
-
for (const name of ["p", "scale", "origin", "transition"])
|
|
378
|
-
root.style.removeProperty(`--lc-sheet-page-${name}`)
|
|
379
|
-
this.releaseScroll()
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
pageTransition(value = prefersReducedMotion() ? "0s" : SHEET_TIMING) {
|
|
383
|
-
if (this.ownsPage || value !== "0s")
|
|
384
|
-
document.documentElement.style.setProperty("--lc-sheet-page-transition", value)
|
|
385
|
-
}
|
|
386
|
-
|
|
387
320
|
transition() {
|
|
388
321
|
const timing = prefersReducedMotion() ? "0s" : SHEET_TIMING
|
|
389
322
|
this.element.style.transition = `transform ${timing}, block-size ${timing}, display ${timing} allow-discrete, overlay ${timing} allow-discrete`
|
|
@@ -405,7 +338,6 @@ export default class extends Controller {
|
|
|
405
338
|
style.transform = ""
|
|
406
339
|
style.willChange = ""
|
|
407
340
|
style.blockSize = ""
|
|
408
|
-
style.removeProperty("--lc-sheet-p")
|
|
409
341
|
style.removeProperty("--lc-sheet-floor")
|
|
410
342
|
}
|
|
411
343
|
|
|
@@ -48,8 +48,6 @@
|
|
|
48
48
|
aria-label="<%= label %>"
|
|
49
49
|
hidden
|
|
50
50
|
>
|
|
51
|
-
<span class="lc-emoji-picker__handle" data-lc-sheet-target="handle" aria-hidden="true"></span>
|
|
52
|
-
|
|
53
51
|
<div class="lc-emoji-picker__search">
|
|
54
52
|
<div class="lc-emoji-picker__search-field">
|
|
55
53
|
<svg class="lc-emoji-picker__search-icon" viewBox="0 0 20 20" fill="none" aria-hidden="true">
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<%# locals: (id:, attributes:) %>
|
|
2
2
|
<%= lc_sheet(as: :dialog, **attributes) do %>
|
|
3
|
-
<form method="dialog" class="flex flex-col gap-inset p-inset
|
|
3
|
+
<form method="dialog" class="flex flex-col gap-inset p-inset" data-slot="confirm-sheet-content">
|
|
4
4
|
<div class="flex flex-col gap-tight max-sm:text-center">
|
|
5
5
|
<p id="<%= id %>-message" class="<%= lc_heading_class(size: :subheading) %>" data-slot="confirm-sheet-message"></p>
|
|
6
6
|
<p id="<%= id %>-description" class="<%= lc_text_class(size: :small, tone: :muted) %>" data-slot="confirm-sheet-description" hidden></p>
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
<%# locals: (id:, title:, description:, trigger:, rendered_trigger:, detents:, close_action:, close_label:, attributes:, actions:, content:) %>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
<%# On phones the header is the sheet's title bar: pinned, the ✕ at its start and the title centred. %>
|
|
3
|
+
<% dialog = lc_sheet(as: :dialog, detents: detents, **attributes) do |sheet| %>
|
|
4
|
+
<div class="flex min-h-0 flex-col gap-inset p-inset max-sm:pt-0 sm:h-full sm:max-h-[inherit]" data-slot="dialog-content">
|
|
5
|
+
<header class="flex shrink-0 items-start justify-between gap-content max-sm:sticky max-sm:top-0 max-sm:z-sticky max-sm:-mx-inset max-sm:min-h-14 max-sm:flex-col max-sm:items-center max-sm:justify-center max-sm:bg-(--lc-sheet-bg) max-sm:px-14 max-sm:py-2" data-slot="dialog-header">
|
|
5
6
|
<div class="flex min-w-0 flex-col gap-tight">
|
|
6
7
|
<%= title %>
|
|
7
8
|
<%= description %>
|
|
8
9
|
</div>
|
|
9
|
-
<div class="flex shrink-0 items-center gap-related -me-related -mt-tight" data-slot="dialog-actions">
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
<div class="flex shrink-0 items-center gap-related -me-related -mt-tight max-sm:contents" data-slot="dialog-actions">
|
|
11
|
+
<% if actions.present? %>
|
|
12
|
+
<div class="contents max-sm:absolute max-sm:end-3 max-sm:top-0 max-sm:flex max-sm:h-14 max-sm:items-center max-sm:gap-related"><%= actions %></div>
|
|
13
|
+
<% end %>
|
|
14
|
+
<%= sheet.close close_label, size: :sm, data: { action: close_action, slot: "dialog-dismiss" } %>
|
|
12
15
|
</div>
|
|
13
16
|
</header>
|
|
14
17
|
<%# Children keep their height, so a long body scrolls instead of squashing a fixed-height button. %>
|
data/lib/lostcoords/ui/parts.rb
CHANGED
|
@@ -86,14 +86,23 @@ module Lostcoords::Ui
|
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
# Rows that stay put while the sheet's content scrolls under them, painted with the sheet's surface.
|
|
89
|
+
# On phones the header is the sheet's title bar: the ✕ at its start and the title centred.
|
|
89
90
|
# The footer sits last in an inset-padded scroller and bleeds to its edges, clearing the home indicator.
|
|
90
91
|
class Sheet < Base
|
|
91
92
|
SURFACE = "sticky z-sticky bg-(--lc-sheet-bg,var(--popover))"
|
|
92
93
|
|
|
94
|
+
# Every phone sheet closes from a 44px ✕ at its header's start.
|
|
95
|
+
CLOSE = "max-sm:absolute max-sm:start-3 max-sm:top-1.5 max-sm:size-11 max-sm:bg-muted max-sm:[&_svg]:size-5"
|
|
96
|
+
|
|
93
97
|
def header(**attributes, &block)
|
|
94
98
|
part(:header, "sheet-header", "#{SURFACE} top-0 flex min-h-14 shrink-0 items-center", attributes, &block)
|
|
95
99
|
end
|
|
96
100
|
|
|
101
|
+
# Goes in the header. From sm up it is a plain icon button, placed by the caller.
|
|
102
|
+
def close(label, **attributes)
|
|
103
|
+
view.lc_icon_button(label, **slot("sheet-close", attributes, class: CLOSE)) { view.lc_icon("x-mark", options: { aria: { hidden: true } }) }
|
|
104
|
+
end
|
|
105
|
+
|
|
97
106
|
def footer(**attributes, &block)
|
|
98
107
|
part(:footer, "sheet-footer", "#{SURFACE} bottom-0 -mx-inset flex flex-wrap items-center justify-end gap-related " \
|
|
99
108
|
"px-inset pt-3 pb-[max(env(safe-area-inset-bottom),--spacing(3))]", attributes, &block)
|