lostcoords-ui 0.13.0 → 0.14.1
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 +41 -8
- data/app/assets/tailwind/lostcoords/ui/emoji-picker.css +0 -18
- data/app/assets/tailwind/lostcoords/ui/search.css +3 -1
- 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 +6 -4
- data/app/views/lostcoords/ui/components/_lc_dialog.html.erb +9 -6
- data/app/views/lostcoords/ui/components/_lc_search.html.erb +1 -1
- data/config/locales/en.yml +1 -0
- data/config/locales/es.yml +1 -0
- data/config/locales/ja.yml +1 -0
- 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: 31a2d350b8b17edbaf8d35a06be137d9838dc7c7f974a74cdf971deae872587a
|
|
4
|
+
data.tar.gz: 9a8d18e452f6ce14c0dcae506a531c0d1163716f73256a00caca747e5766c395
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d26f83e72eca4a78f711a953d7eaccc579847a5efd75022e3caa309df140897ccc8eb4d181c99592c2e18b874d8f2d8a6c34ab735b477decd01c8891716a1ee0
|
|
7
|
+
data.tar.gz: eb92a40b4396e4e78cd1fa6e502c6d7d83e63ecd7735e3e6da1fcb9586e266e4d8093855d13e135b6eb9007a53ce28bd0e8805e9b6314858ec137b89926e159e
|
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,35 @@ 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.1
|
|
174
|
+
|
|
175
|
+
Two phone fixes, with nothing to edit:
|
|
176
|
+
|
|
177
|
+
- **The `lc_search` trigger is a plain icon button on phones**, with no fill until it is hovered, so it
|
|
178
|
+
matches the icon buttons beside it in a bar. From `sm` up it is the same filled pill.
|
|
179
|
+
- **`lc_confirm_sheet` has the ✕ on phones**, at the top start like every other sheet, with the message
|
|
180
|
+
centred in the title bar. It cancels, as Cancel does. Its label is `lostcoords.ui.confirm.close`.
|
|
181
|
+
|
|
182
|
+
## Changes in 0.14.0
|
|
183
|
+
|
|
184
|
+
Phone sheets have one look. One option to drop, and the rest needs no edit:
|
|
185
|
+
|
|
186
|
+
- **Every phone sheet spans the screen's width and sits on its bottom edge**, with round top corners and no
|
|
187
|
+
grabber. Before, a sheet shorter than the large detent floated inset as a card with a grabber on top.
|
|
188
|
+
`detents: "fit"` (the default) is now a half sheet at its content's height, up to the large detent;
|
|
189
|
+
`"large"` fills the screen; `"medium large"` drags between the two. A swipe down still dismisses.
|
|
190
|
+
- **`lc_dialog` on phones has the sheet's title bar**: the ✕ at the start, 44px on a muted circle, the title
|
|
191
|
+
centred and the description centred under it. The bar stays pinned while the body scrolls. From `sm` up the
|
|
192
|
+
dialog is unchanged.
|
|
193
|
+
- **`sheet.close(label, **attributes)` is that ✕ for a sheet with a header of its own.** Put it in
|
|
194
|
+
`sheet.header`; from `sm` up it is a plain icon button that the caller places.
|
|
195
|
+
- **`lc_sheet` no longer takes `handle:`**, and the `handle` target is gone from `lc-sheet`. Remove
|
|
196
|
+
`handle: true` and any `data-lc-sheet-target="handle"` element. A mouse still drags a sheet by its top 28px.
|
|
197
|
+
- **The page no longer shrinks back behind a large sheet.** It stays in place under the sheet's backdrop.
|
|
198
|
+
`html[data-lc-sheet-page]` and the `--lc-sheet-page-*` variables are gone, and so are `--lc-sheet-p` and
|
|
199
|
+
`--lc-sheet-inset`.
|
|
200
|
+
- **`lc_confirm_sheet` and the emoji picker lose their grabber room** on phones.
|
|
201
|
+
|
|
173
202
|
## Changes in 0.13.0
|
|
174
203
|
|
|
175
204
|
Two renames to make, and the rest needs no edit:
|
|
@@ -915,8 +944,9 @@ The icon trigger is muted at rest, with full ink and a slightly larger icon on h
|
|
|
915
944
|
`wrapper_attributes:` styles the element that holds the trigger and panel, an `inline-flex` box by default,
|
|
916
945
|
for example `class: "flex min-w-0"` when the trigger fills a grid cell. A `data: { controller: }` there joins the panel's own.
|
|
917
946
|
|
|
918
|
-
`lc_dialog` handles modal content and the mobile sheet layout
|
|
919
|
-
|
|
947
|
+
`lc_dialog` handles modal content and the mobile sheet layout: on phones it is a sheet across the screen's
|
|
948
|
+
width, with the ✕ at the start of its title bar and the title centred. The default `detents: "fit"` is a half
|
|
949
|
+
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
950
|
appear with their parent component examples.
|
|
921
951
|
|
|
922
952
|
`size:` sets the desktop width: `:sm` (24rem), `:md` (32rem, the modal default), `:lg` (40rem) or `:xl`
|
|
@@ -962,17 +992,20 @@ modal `<dialog>` sheet, which is what `lc_dialog` and `lc_confirm_sheet` render;
|
|
|
962
992
|
shows while it is `:popover-open` or carries `[data-open]`, so a native `[popover]` and a FloatingPanel
|
|
963
993
|
picker both work; a div you toggle yourself sets `data-open` and removes it to slide out. From `sm` up
|
|
964
994
|
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
|
|
995
|
+
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
996
|
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.
|
|
997
|
+
and a sheet on phones. The block gets a builder: `sheet.close "Close"` is the ✕ every phone sheet has at the
|
|
998
|
+
start of its header, and `sheet.header` and `sheet.footer` stay pinned to the top and
|
|
969
999
|
bottom of the scrolling content, painted with the sheet's surface (`--lc-sheet-bg` on phones, `--popover`
|
|
970
1000
|
above), so content scrolls under them. Put the footer last in a scroller padded with `px-inset`; it bleeds to
|
|
971
1001
|
the scroller's edges and clears the home indicator.
|
|
972
1002
|
|
|
973
1003
|
```erb
|
|
974
1004
|
<%= lc_sheet as: :dialog, size: :lg, aria: { label: "New expense" } do |sheet| %>
|
|
975
|
-
<%= sheet.header do
|
|
1005
|
+
<%= sheet.header do %>
|
|
1006
|
+
<h2 class="mx-auto">New expense</h2>
|
|
1007
|
+
<%= sheet.close "Close", data: { action: "expense#close" } %>
|
|
1008
|
+
<% end %>
|
|
976
1009
|
<div class="min-h-0 overflow-y-auto px-inset">
|
|
977
1010
|
…
|
|
978
1011
|
<%= sheet.footer do %><%= lc_button "Save" %><% end %>
|
|
@@ -1017,7 +1050,7 @@ from the page the link opens. Inside a paragraph, keep `content:` to phrasing el
|
|
|
1017
1050
|
|
|
1018
1051
|
### Search
|
|
1019
1052
|
|
|
1020
|
-
`lc_search` renders a search trigger, a pill with the ⌘K hint that
|
|
1053
|
+
`lc_search` renders a search trigger, a pill with the ⌘K hint that is a plain icon button on phones, and
|
|
1021
1054
|
the full-screen search it opens. Attributes go to the trigger, which is what sits in your layout.
|
|
1022
1055
|
Build results from `lc_search_group` and `lc_search_result`.
|
|
1023
1056
|
|
|
@@ -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,4 +1,4 @@
|
|
|
1
|
-
/* lc_search: a pill
|
|
1
|
+
/* lc_search: a trigger, a pill from sm up, that opens a full-screen search over a
|
|
2
2
|
blurred page. The controller animates it open and closed. */
|
|
3
3
|
@layer components {
|
|
4
4
|
.lc-search-trigger {
|
|
@@ -20,10 +20,12 @@
|
|
|
20
20
|
/* The bar grows out of the trigger, so the trigger steps aside while search is open. */
|
|
21
21
|
[data-slot="search"][data-open] & { opacity: 0; }
|
|
22
22
|
|
|
23
|
+
/* On phones it is a plain icon button, like the ones beside it in a bar. */
|
|
23
24
|
@media (width < 40rem) {
|
|
24
25
|
justify-content: center;
|
|
25
26
|
inline-size: var(--spacing-control-sm);
|
|
26
27
|
padding-inline: 0;
|
|
28
|
+
background: transparent;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
@media (width >= 40rem) { inline-size: calc(var(--spacing) * 64); }
|
|
@@ -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,10 +1,12 @@
|
|
|
1
1
|
<%# locals: (id:, attributes:) %>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
<%# On phones the message sits in the sheet's title bar, with the ✕ every sheet closes from. It cancels. %>
|
|
3
|
+
<%= lc_sheet(as: :dialog, **attributes) do |sheet| %>
|
|
4
|
+
<form method="dialog" class="flex flex-col gap-inset p-inset max-sm:pt-0" data-slot="confirm-sheet-content">
|
|
5
|
+
<div class="flex flex-col gap-tight max-sm:-mx-inset max-sm:min-h-14 max-sm:justify-center max-sm:px-14 max-sm:py-2 max-sm:text-center" data-slot="confirm-sheet-header">
|
|
5
6
|
<p id="<%= id %>-message" class="<%= lc_heading_class(size: :subheading) %>" data-slot="confirm-sheet-message"></p>
|
|
6
|
-
<p id="<%= id %>-description" class="<%= lc_text_class(size: :small, tone: :muted) %>" data-slot="confirm-sheet-description" hidden></p>
|
|
7
|
+
<p id="<%= id %>-description" class="<%= lc_text_class(size: :small, tone: :muted, extra: "max-sm:text-balance") %>" data-slot="confirm-sheet-description" hidden></p>
|
|
7
8
|
</div>
|
|
9
|
+
<%= sheet.close lc_t("lostcoords.ui.confirm.close"), size: :sm, type: "submit", value: "cancel", class: "sm:hidden", data: { slot: "confirm-sheet-dismiss" } %>
|
|
8
10
|
<div class="grid grid-cols-2 gap-related" data-slot="confirm-sheet-actions">
|
|
9
11
|
<button type="submit" value="cancel" class="<%= lc_button_class(variant: :secondary, block: true) %>" data-slot="confirm-sheet-cancel"><%= lc_t("lostcoords.ui.confirm.cancel") %></button>
|
|
10
12
|
<button type="submit" value="confirm" class="<%= lc_button_class(variant: :primary, block: true) %>" data-slot="confirm-sheet-accept" data-variant="primary"><%= lc_t("lostcoords.ui.confirm.accept") %></button>
|
|
@@ -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. %>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<%# locals: (id:, label:, src:, param:, placeholder:, trigger:, empty:, prompt:, shortcut:, attributes:, content:) %>
|
|
2
2
|
<div class="contents" data-slot="search" data-controller="lc-search" data-action="turbo:before-cache@document->lc-search#reset" data-lc-search-src-value="<%= src %>" data-lc-search-param-value="<%= param %>" data-lc-search-empty-value="<%= empty %>" data-lc-search-one-value="<%= lc_t("lostcoords.ui.search.results.one", count: "%{count}") %>" data-lc-search-other-value="<%= lc_t("lostcoords.ui.search.results.other", count: "%{count}") %>">
|
|
3
3
|
<%= tag.button(**attributes) do %>
|
|
4
|
-
<%= lc_icon "magnifying-glass", options: { class: "size-4 shrink-0", "aria-hidden": true } %>
|
|
4
|
+
<%= lc_icon "magnifying-glass", options: { class: "size-4 shrink-0 max-sm:size-4.5", "aria-hidden": true } %>
|
|
5
5
|
<span class="flex-1 truncate text-start max-sm:sr-only"><%= trigger %></span>
|
|
6
6
|
<% if shortcut %><%= lc_kbd shortcut, class: "hidden bg-transparent px-0 any-pointer-fine:sm:inline", aria: { hidden: true } %><% end %>
|
|
7
7
|
<% end %>
|
data/config/locales/en.yml
CHANGED
data/config/locales/es.yml
CHANGED
data/config/locales/ja.yml
CHANGED
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)
|