lostcoords-ui 0.11.0 → 0.12.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 +147 -23
- data/app/assets/tailwind/lostcoords/ui/base.css +2 -2
- data/app/assets/tailwind/lostcoords/ui/core.css +2 -2
- data/app/assets/tailwind/lostcoords/ui/emoji-picker.css +1 -1
- data/app/helpers/lostcoords/ui/avatar_badge_helper.rb +43 -0
- data/app/helpers/lostcoords/ui/badge_helper.rb +20 -2
- data/app/helpers/lostcoords/ui/button_helper.rb +16 -4
- data/app/helpers/lostcoords/ui/card_helper.rb +3 -1
- data/app/helpers/lostcoords/ui/choice_helper.rb +1 -2
- data/app/helpers/lostcoords/ui/emoji_picker_helper.rb +5 -1
- data/app/helpers/lostcoords/ui/file_drop_helper.rb +32 -0
- data/app/helpers/lostcoords/ui/form_helper.rb +18 -4
- data/app/helpers/lostcoords/ui/layout_helper.rb +7 -3
- data/app/helpers/lostcoords/ui/list_group_helper.rb +38 -3
- data/app/helpers/lostcoords/ui/menu_helper.rb +23 -14
- data/app/helpers/lostcoords/ui/primitives_helper.rb +20 -12
- data/app/helpers/lostcoords/ui/render_attributes_helper.rb +1 -1
- data/app/helpers/lostcoords/ui/sheet_helper.rb +9 -3
- data/app/helpers/lostcoords/ui/structures_helper.rb +37 -17
- data/app/helpers/lostcoords/ui/typography_helper.rb +4 -2
- data/app/javascript/lostcoords/ui/controllers/lc_dialog_controller.js +2 -2
- data/app/javascript/lostcoords/ui/helpers/dialog.js +38 -4
- data/app/views/lostcoords/ui/components/_lc_dialog.html.erb +2 -1
- data/lib/lostcoords/ui/form_builder.rb +7 -0
- data/lib/lostcoords/ui/parts.rb +15 -0
- data/lib/lostcoords/ui/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7f17b0b2708cbe55957972ef27eb37ada90b102c0e752d635c08feeffcb2a3e2
|
|
4
|
+
data.tar.gz: c1ce053ec741627c1973016a62663093ca06e3a990ea8f455f7c483ea81bd5ff
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '0709825a84cc4ec2b8367e2e71af48acf097bc29b6804d5da23e8833e707ad5bdc57439769240b970c76ab1eb013e55387fb546fe23cee73d63efd5252fdba64'
|
|
7
|
+
data.tar.gz: f975b43643f0f2f2aa975b24d6882b6c2b87dca5bf211d15d36fb11bac80d670db86289303812d3ed1aed4eee498c35ce7317a4c6fda76c9cc6bd8385936a339
|
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.12.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,57 @@ 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.12.1
|
|
174
|
+
|
|
175
|
+
Nothing needs an edit. Changed:
|
|
176
|
+
|
|
177
|
+
- **A dialog opens with focus on itself.** `lc-dialog` and the new **`showDialog(dialog)`** helper in
|
|
178
|
+
`lostcoords/ui/helpers/dialog` focus the dialog rather than its first control, so the close button no longer
|
|
179
|
+
shows the focus ring after a tap and a first field no longer raises the keyboard. A control marked
|
|
180
|
+
`autofocus` still takes focus.
|
|
181
|
+
- **The focus halo skips dialogs**, including ones with a `tabindex`.
|
|
182
|
+
|
|
183
|
+
New option:
|
|
184
|
+
|
|
185
|
+
- **`lc_section(header: :from_sm)` hides the heading row on phones**, for a section whose content explains
|
|
186
|
+
itself on a small screen, such as a balance card. Screen readers still get the heading; its actions are hidden.
|
|
187
|
+
|
|
188
|
+
## Changes in 0.12.0
|
|
189
|
+
|
|
190
|
+
One edit, and some components look different:
|
|
191
|
+
|
|
192
|
+
- **`lc_menu_option` takes `form_attributes:` for the form `method:` builds.** Before: `form:` set that
|
|
193
|
+
form's attributes. After: `form:` is the option button's own HTML `form` attribute, so an option can submit a
|
|
194
|
+
form elsewhere on the page (`type: "submit", form: "profile-form"`). Rename `form:` to `form_attributes:`
|
|
195
|
+
wherever an option passes it alongside `method:`.
|
|
196
|
+
- **A small icon button draws an 18px icon**, up from 16px; `icon_size:` picks another.
|
|
197
|
+
- **`lc_button_to` and `lc_icon_button_to` wrap their button in a `contents` form**, so the button sits in a
|
|
198
|
+
flex or grid row as if the form weren't there. A caller's `form: { class: }` still merges over it. A
|
|
199
|
+
margin or alignment class that was on the form belongs on the button now.
|
|
200
|
+
- **`lc_list_group` rounds its first and last visible child**, whatever it is, instead of each row rounding
|
|
201
|
+
itself. Non-row children and hidden rows need no corner classes.
|
|
202
|
+
- **`lc_card(padding: :none)` drops the border and clips its children** to its corners, so rows reach the
|
|
203
|
+
edge without negative margins.
|
|
204
|
+
- **A dialog's body no longer shrinks its children**, so a long body scrolls instead of squashing buttons.
|
|
205
|
+
- **The choice card uses the global focus halo** instead of its own outline.
|
|
206
|
+
|
|
207
|
+
New components and options, moved from apps that built them by hand:
|
|
208
|
+
|
|
209
|
+
- **`lc_avatar_badge`** puts an icon badge on an avatar's corner: a decorative mark, a button or a file label.
|
|
210
|
+
- **`lc_file_drop`** (and `form.file_drop`) is a dashed drop zone around a file input.
|
|
211
|
+
- **`lc_list_row(choice: :radio, name:, value:, checked:)`** is a selectable row with a trailing check.
|
|
212
|
+
- **`lc_toggle_group(layout: :inline | :stacked | :adaptive, scroll:)`** and
|
|
213
|
+
**`lc_toggle_group_item(icon:, icon_only:)`**: icons in segmented controls, stacked over their labels on
|
|
214
|
+
narrow groups, and a scrolling track with faded edges.
|
|
215
|
+
- **`lc_menu(side: :top, trigger_size:)`** opens upward and sizes its trigger; `lc_popover_class` and
|
|
216
|
+
`lc_menu_popover_class` take `side:` too.
|
|
217
|
+
- **`lc_icon_button(icon_size:)`** and the **`:inset` variant**, a page-coloured fill for buttons inside a card.
|
|
218
|
+
- **`lc_avatar_stack(size:, overlap:)`**, **`lc_emoji_picker(popover_size:)`**, **`lc_input(icon:)`**,
|
|
219
|
+
**`lc_sheet(surface: :glass)`** with pinned `sheet.header` and `sheet.footer` parts, and
|
|
220
|
+
**`lc_heading(as:)`**.
|
|
221
|
+
- **`registerDialog` takes `priority:` and `restoreFocus:`**, so a host dialog no longer registers with the
|
|
222
|
+
dismiss stack directly. A click on the dialog's own padding no longer closes it.
|
|
223
|
+
|
|
173
224
|
## Changes in 0.11.0
|
|
174
225
|
|
|
175
226
|
Nothing needs an edit. New:
|
|
@@ -321,12 +372,13 @@ Everything else in 0.8 is additive. These changes need edits in an app built on
|
|
|
321
372
|
|
|
322
373
|
## Components
|
|
323
374
|
|
|
324
|
-
[Installation and setup](https://ui.lostcoords.com/installation
|
|
375
|
+
[Installation and setup](https://ui.lostcoords.com/installation) · [Live examples](https://ui.lostcoords.com). Each example renders the same ERB source shown
|
|
325
376
|
in its code panel. The API reference reads signatures from the helper definitions.
|
|
326
377
|
[API JSON](https://ui.lostcoords.com/api.json) and [llms.txt](https://ui.lostcoords.com/llms.txt)
|
|
327
378
|
include those signatures and the runnable examples.
|
|
328
379
|
|
|
329
|
-
Buttons use `primary`, `secondary`, `outline`, `ghost`, `glass` or `destructive`, with `sm`, `md` or `lg` sizes.
|
|
380
|
+
Buttons use `primary`, `secondary`, `outline`, `ghost`, `inset`, `glass` or `destructive`, with `sm`, `md` or `lg` sizes.
|
|
381
|
+
`inset` fills with the page colour and muted ink, for a quiet control on a card.
|
|
330
382
|
Primary, secondary and destructive buttons have visible filled surfaces. Ghost buttons and the
|
|
331
383
|
`lc_icon_button` toolbar action are transparent at rest and show their full shape on hover.
|
|
332
384
|
Primary, secondary and destructive buttons are flat. Secondary buttons use a soft neutral fill distinct from page and card backgrounds.
|
|
@@ -337,7 +389,7 @@ Button hover and press fills mix 94% of the base background with 6% of its foreg
|
|
|
337
389
|
Ghost and icon buttons stay transparent at rest and use the secondary base for that calculation.
|
|
338
390
|
Apps can override `--secondary` for the neutral base, or `--lc-button-bg` and `--lc-button-ink` on individual buttons.
|
|
339
391
|
Inputs use `--input` and `--lc-input-hover`.
|
|
340
|
-
`lc_button_to` preserves Rails' form, HTTP method and CSRF behavior. `lc_icon_button_link_to` and `lc_icon_button_to` are the link and form versions of `lc_icon_button`; a block replaces its icon with custom content. Icon buttons take `lc_button`'s `variant:` and `tone:` too; the default `:ghost` is the quiet toolbar look. `block: true` makes any button full width. Block helpers capture ERB content.
|
|
392
|
+
`lc_button_to` preserves Rails' form, HTTP method and CSRF behavior. Its form is `display: contents`, so the button sits directly in the caller's row or grid; `form: { class: }` merges over that. `lc_icon_button_link_to` and `lc_icon_button_to` are the link and form versions of `lc_icon_button`; a block replaces its icon with custom content. Icon buttons take `lc_button`'s `variant:` and `tone:` too; the default `:ghost` is the quiet toolbar look. Their icon is 18, 20 or 24px for `sm`, `md` or `lg`; `icon_size:` picks another of those tiers, as in `size: :sm, icon_size: :md`. `block: true` makes any button full width. Block helpers capture ERB content.
|
|
341
393
|
Use `icon: "plus"` for a leading Heroicon or `icon_position: :end` for a trailing one. Custom icons and
|
|
342
394
|
spinners use `data-icon="inline-start"` or `data-icon="inline-end"`; buttons adjust that edge's padding.
|
|
343
395
|
`lc_button(expanded_icon: "x-mark")` swaps its content for that icon while `aria-expanded` is true, for a trigger
|
|
@@ -383,6 +435,7 @@ Wrap wide tables in an app-owned horizontal scroll region with an accessible nam
|
|
|
383
435
|
Use `lc_table_class` when an existing table renderer owns the markup.
|
|
384
436
|
|
|
385
437
|
Cards share one API: `lc_card(padding: :md)`, with `:sm` and `:none` for tighter or custom spacing. Padding sizes set `--lc-inset`, so content inside follows the card.
|
|
438
|
+
An unpadded card drops its border and clips its children to its corners, so full-bleed rows meet its edge and a hovered row's fill rounds with it, with no negative margins or corner classes. Menus and dialogs inside it render in the top layer and are not clipped.
|
|
386
439
|
Fields and secondary buttons inside cards take `--card-input` and `--card-secondary`, which default to the page fills; set them in the theme when `--card` equals `--input` or `--secondary`, or set `--lc-field-bg` to change fields in one context. Cards provide avatar cutouts and a validation border when they contain errors. Fills that are muted on the page switch so they stay visible on the card: choice tiles, alerts, neutral badges and skeletons take the page background (`--lc-tile-bg`), and toggle group and tab tracks take the accent fill (`--lc-track-bg`). Set either variable to apply the same context to your own muted surface.
|
|
387
440
|
Add `class: "@container"` when a card owns its width and its children use container queries.
|
|
388
441
|
Use `--lc-card-bg`, `--lc-card-border`, `--lc-card-radius` and `--lc-card-shadow` for local appearance overrides.
|
|
@@ -392,8 +445,15 @@ Use `--lc-card-bg`, `--lc-card-border`, `--lc-card-radius` and `--lc-card-shadow
|
|
|
392
445
|
`lc_avatar` sizes are `xs` (20px), `sm` (26px), `md` (32px), `lg` (48px), `xl` (96px) and `xxl` (112px).
|
|
393
446
|
Between them, both take a step on the spacing scale, as in `size-7`: `lc_avatar` takes `7` (28px) and `11` (44px),
|
|
394
447
|
`lc_icon_badge` takes `6` (24px), `7` (28px) and `11` (44px).
|
|
395
|
-
Pass `as: :button` when the avatar is itself the control, such as a colour picker's trigger.
|
|
396
|
-
|
|
448
|
+
Pass `as: :button` when the avatar is itself the control, such as a colour picker's trigger.
|
|
449
|
+
`lc_avatar_badge(icon, label:, as:)` pins a round badge to an avatar's bottom corner; render it after the avatar
|
|
450
|
+
in a `relative` wrapper. `as: :span` (the default) is a 28px decorative mark, such as a lock on a gated group;
|
|
451
|
+
`as: :button` and `as: :label` are 44px controls named by `label:`, such as a camera that changes the photo. A
|
|
452
|
+
label needs `for:` and shows the focus halo while the visually hidden input after it has focus; as a menu
|
|
453
|
+
trigger, splat `menu.trigger`'s attributes into an `as: :button` badge. `lc_avatar_stack`
|
|
454
|
+
takes `row:` attributes for the inner row that overlaps the avatars, such as a controller target. Its `size:`
|
|
455
|
+
(`xs`, `5.5`, `sm`, `md` or `lg`) pins every avatar in it to one size, and `overlap: :sm` tucks them closer and
|
|
456
|
+
drops the row's padding, for a stack in a line of text. `compact: true` is a preset of both and takes neither.
|
|
397
457
|
Initials and icons scale with the size, including a size set through `--lc-avatar-size` or `--lc-icon-badge-size`;
|
|
398
458
|
set `--lc-avatar-font-scale` or `--lc-icon-badge-font-scale` to change the share, or the `-font-size` variable to pin it.
|
|
399
459
|
Badge, icon badge, Alert and Toast share `neutral`, `primary`, `success`, `warning` and `destructive` tones.
|
|
@@ -409,6 +469,9 @@ With `name:` they are native radios in labels, which bring their own arrows, sub
|
|
|
409
469
|
labelled `nav`; items take `href:` and `current:`. Otherwise they are radio buttons whose selection lives in the
|
|
410
470
|
`lc-selection` controller, which dispatches `lc-selection:change`; items take `value:` and `selected:`. An item
|
|
411
471
|
given another kind's arguments raises. `variant: :pills` lays any of them out as wrapping toggle pills, sized by `size:`, instead of a segmented track.
|
|
472
|
+
Items take `icon:` and `icon_only:` as `lc_toggle` does. A segmented group's `layout: :stacked` puts each item's icon
|
|
473
|
+
over its label, and `layout: :adaptive` makes the group full width and stacks its items only while the group is
|
|
474
|
+
narrower than 24rem. `scroll: true` lets a track wider than its container scroll sideways, its edges fading.
|
|
412
475
|
|
|
413
476
|
```erb
|
|
414
477
|
<%= lc_toggle_group label: "Period", as: :nav do %>
|
|
@@ -421,8 +484,14 @@ given another kind's arguments raises. `variant: :pills` lays any of them out as
|
|
|
421
484
|
<% end %>
|
|
422
485
|
<%= lc_toggle "Food", aria: { pressed: false }, data: { value: "food" } %>
|
|
423
486
|
<%= lc_toggle "Bold", icon: "bold", icon_only: true, tooltip: true %>
|
|
487
|
+
<%= lc_toggle_group label: "View", as: :nav do %>
|
|
488
|
+
<%= lc_toggle_group_item "List", href: "/", current: true, icon: "list-bullet", icon_only: true %>
|
|
489
|
+
<%= lc_toggle_group_item "Calendar", href: "/calendar", icon: "calendar-days", icon_only: true %>
|
|
490
|
+
<% end %>
|
|
424
491
|
```
|
|
425
492
|
|
|
493
|
+
`lc_emoji_picker(popover_size: :lg)` widens the desktop popover from 22rem to 28rem for a roomier grid.
|
|
494
|
+
|
|
426
495
|
`lc_empty_state(title:, text:, icon:)` lays out the usual empty state: a round icon badge, a heading
|
|
427
496
|
(`level:`, 2 by default), a line of muted text, then the block, such as an action. `card: true` puts it on a card.
|
|
428
497
|
Without those options the block is the whole content, as before.
|
|
@@ -478,7 +547,8 @@ makes the summary look like that `lc_button` without the native marker, and `ind
|
|
|
478
547
|
```
|
|
479
548
|
|
|
480
549
|
`lc_list_group` draws grouped settings rows: each row is its own card-coloured panel, 2px apart, and
|
|
481
|
-
only the group's ends round.
|
|
550
|
+
only the group's ends round. The group rounds its first and last shown child, so a collapsible or any other
|
|
551
|
+
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
|
|
482
552
|
`--card-input` and `--card-secondary`. `lc_list_row` with a title lays out `icon:` (a name, or your own
|
|
483
553
|
markup such as a logo), the title, `subtitle:` and the block as trailing content; `tag:` makes it a
|
|
484
554
|
`label`, `li`, `details` or `a` (`href:`). `href:` with `tag: :li` or `:div` links the title instead
|
|
@@ -489,6 +559,18 @@ out the same icon, title and subtitle inside your own element. `lc_list_section`
|
|
|
489
559
|
footnote; with an `id:`, the heading labels the section. Put a form around `lc_list_group` inside it
|
|
490
560
|
when the rows save together.
|
|
491
561
|
|
|
562
|
+
`lc_list_row(choice: :radio, name:, value:, checked:)` makes a row one choice of a radio group: a `label` around a
|
|
563
|
+
visually hidden radio, then the title or block, then a check shown while it is checked. The checked row fills
|
|
564
|
+
with `--primary-soft` and its text turns semibold, and the focus halo rings the row while its radio has focus.
|
|
565
|
+
`input:` adds attributes to the radio, such as `required: true` or a Stimulus action.
|
|
566
|
+
|
|
567
|
+
```erb
|
|
568
|
+
<%= lc_list_group role: "radiogroup", aria: { label: "How did you hear about us?" } do %>
|
|
569
|
+
<%= lc_list_row "A friend", choice: :radio, name: :heard_about, value: "friend", checked: true %>
|
|
570
|
+
<%= lc_list_row "Search", choice: :radio, name: :heard_about, value: "search" %>
|
|
571
|
+
<% end %>
|
|
572
|
+
```
|
|
573
|
+
|
|
492
574
|
`lc_list_field` is a form row in the same group: a label column, then the block as the control. In a
|
|
493
575
|
narrow row the label folds to its `icon:`, and the text stays the accessible name. `id:` makes the label
|
|
494
576
|
a `<label>` for that control; `tag: :fieldset` names a group of controls, such as chips, with a legend.
|
|
@@ -576,6 +658,20 @@ before JavaScript runs.
|
|
|
576
658
|
<% end %>
|
|
577
659
|
```
|
|
578
660
|
|
|
661
|
+
`lc_file_drop(title:, hint:, button:, icon:)` is a dashed drop zone: a label around a visually hidden file
|
|
662
|
+
input, so a click or a dropped file reaches it. `name:` builds the input with `accept:`, `multiple:` and
|
|
663
|
+
`input:` attributes, such as a controller target; `form.file_drop :files, title: …` wraps the form's own
|
|
664
|
+
`file_field`, and its other options (`accept:`, `multiple:`, `data:`) reach the input. `button:` adds a
|
|
665
|
+
decorative button inside, which the label already names.
|
|
666
|
+
|
|
667
|
+
```erb
|
|
668
|
+
<%= form.file_drop :files, title: "Add receipts", hint: "Up to 10 MB each", button: "Browse",
|
|
669
|
+
multiple: true, accept: "image/*,application/pdf", data: { action: "change->upload#update" } %>
|
|
670
|
+
```
|
|
671
|
+
|
|
672
|
+
`lc_input(icon: "magnifying-glass")` draws a leading icon inside the field. The input comes wrapped in a
|
|
673
|
+
span then; `class:` and the other attributes still reach the `<input>`.
|
|
674
|
+
|
|
579
675
|
`lc_checkbox`, `lc_radio` and `lc_switch` render native inputs with a label and optional hint.
|
|
580
676
|
Checkboxes and switches submit an unchecked value like Rails' `check_box`; pass `unchecked_value: nil`
|
|
581
677
|
to omit it. A `nil` label renders the bare input, for a row selector the row labels; give it
|
|
@@ -742,7 +838,8 @@ assistive technology so the label stays the name. Leading visuals share one colu
|
|
|
742
838
|
labels line up with and without them. `hint:` adds a secondary line. `checked: true` or `false` makes
|
|
743
839
|
a `menuitemradio` with a check mark. `checkbox: true` makes a `menuitemcheckbox` that flips its
|
|
744
840
|
`aria-checked` on click, dispatches `lc-menu:check` with `{ checked }`, and leaves the menu open.
|
|
745
|
-
`method:` renders a `button_to` form and passes `params:` and `form:`
|
|
841
|
+
`method:` renders a `button_to` form and passes `params:` on, and `form_attributes:` to the form. `form:` is the
|
|
842
|
+
button's own attribute: with `type: "submit"` the option submits that form from elsewhere on the page.
|
|
746
843
|
`lc_menu_group(label, id:)` wraps options in a `role="group"` labelled by an eyebrow heading; its
|
|
747
844
|
options stay on the menu's columns.
|
|
748
845
|
`lc_menu` and `lc_popover` take `trigger: false` to render only the panel, named by `label:` (or
|
|
@@ -750,7 +847,8 @@ options stay on the menu's columns.
|
|
|
750
847
|
`trigger` targets. With `click->lc-popover#toggleFromRow` on that host, a click anywhere on it that
|
|
751
848
|
misses a control opens the panel; mark other regions `data-lc-menu-ignore`.
|
|
752
849
|
`lc_menu` and `lc_popover` take `trigger: :icon` with `icon:` for a quiet icon button named by `label:`,
|
|
753
|
-
or rendered content such as an avatar for a custom trigger. `
|
|
850
|
+
or rendered content such as an avatar for a custom trigger. `lc_menu(trigger_size: :sm)` makes either one a small control.
|
|
851
|
+
`lc_menu(side: :top)` opens the menu above its trigger, for a menu near the bottom of the screen. `trigger_attributes:` adds attributes such as `class:` or `title:` to either.
|
|
754
852
|
For any other trigger, call the yielded part's `trigger` with a block. It receives the attributes that
|
|
755
853
|
wire an element as the trigger (its id, `aria-haspopup`, `aria-expanded`, `aria-controls` and the
|
|
756
854
|
Stimulus target and action), merged with any passed to `trigger`, and the element it renders replaces
|
|
@@ -815,7 +913,31 @@ picker both work; a div you toggle yourself sets `data-open` and removes it to s
|
|
|
815
913
|
the div keeps your frame, or `anchored: true` makes it a popover under its trigger inside a positioned
|
|
816
914
|
ancestor. `detents:` takes the same stops as `lc_dialog`, and `handle: true` adds a grab strip above the
|
|
817
915
|
content. A swipe down dispatches `lc-sheet:dismiss`; unless a listener cancels it, an open popover then
|
|
818
|
-
hides.
|
|
916
|
+
hides. `surface: :glass` draws a div in the translucent menu material, as a picker that is a menu on desktop
|
|
917
|
+
and a sheet on phones. The block gets a builder: `sheet.header` and `sheet.footer` stay pinned to the top and
|
|
918
|
+
bottom of the scrolling content, painted with the sheet's surface (`--lc-sheet-bg` on phones, `--popover`
|
|
919
|
+
above), so content scrolls under them. Put the footer last in a scroller padded with `px-inset`; it bleeds to
|
|
920
|
+
the scroller's edges and clears the home indicator.
|
|
921
|
+
|
|
922
|
+
```erb
|
|
923
|
+
<%= lc_sheet tag: :dialog, size: :lg, aria: { label: "New expense" } do |sheet| %>
|
|
924
|
+
<%= sheet.header do %>…<% end %>
|
|
925
|
+
<div class="min-h-0 overflow-y-auto px-inset">
|
|
926
|
+
…
|
|
927
|
+
<%= sheet.footer do %><%= lc_button "Save" %><% end %>
|
|
928
|
+
</div>
|
|
929
|
+
<% end %>
|
|
930
|
+
```
|
|
931
|
+
|
|
932
|
+
A controller that opens a `<dialog>` itself shows it with `showDialog(dialog)` and joins it to the dismiss
|
|
933
|
+
stack with `registerDialog`, both from `lostcoords/ui/helpers/dialog`. `showDialog` opens it modal with focus
|
|
934
|
+
on the dialog itself, so no focus ring lands on its close button and no keyboard rises for a first field; a
|
|
935
|
+
control marked `autofocus` still takes focus. With `registerDialog`, Escape, a backdrop click and a swipe close
|
|
936
|
+
it, and the page stops scrolling behind it.
|
|
937
|
+
`registerDialog(dialog, { close, priority, restoreFocus, lockScroll })`: `close` may return `false` to keep the dialog open, such as while it asks to discard changes; `priority` ranks it against panels open in
|
|
938
|
+
it (a dialog is 10, a panel 20); `restoreFocus` runs after a close; `lockScroll: false` leaves the page
|
|
939
|
+
scrollable. It returns the unregister function and ends when the dialog closes; a click on the dialog's own
|
|
940
|
+
padding does not close it.
|
|
819
941
|
|
|
820
942
|
```erb
|
|
821
943
|
<button type="button" popovertarget="filters">Filters</button>
|
|
@@ -985,8 +1107,8 @@ Buttons include hover and press feedback. Override `--lc-motion-quick` (140ms),
|
|
|
985
1107
|
Reduced motion removes control movement and makes copy feedback immediate. Your application owns the
|
|
986
1108
|
pending, success and failure states of network actions such as saving a form.
|
|
987
1109
|
|
|
988
|
-
[Try the copy button](https://ui.lostcoords.com/components/copy_button
|
|
989
|
-
[Motion reference](https://ui.lostcoords.com/components/foundations
|
|
1110
|
+
[Try the copy button](https://ui.lostcoords.com/components/copy_button) ·
|
|
1111
|
+
[Motion reference](https://ui.lostcoords.com/components/foundations#motion)
|
|
990
1112
|
|
|
991
1113
|
### Icons
|
|
992
1114
|
|
|
@@ -1027,7 +1149,7 @@ Heading sizes are `display`, `title`, `heading` and `subheading`. Text sizes are
|
|
|
1027
1149
|
styles a kicker or footer column label; under `lang="ja"` it keeps natural case and letter spacing. Pass `trim: true` to trim the text box.
|
|
1028
1150
|
Stacks and inline groups take the spacing names from [Foundations](#foundations). `lc_stack`, `lc_inline`,
|
|
1029
1151
|
`lc_text` and `lc_card` take `as:` to render a meaningful element, such as `lc_stack(as: :ul)`, `lc_text(as: :span)` or
|
|
1030
|
-
`lc_card(as: :section)`. `lc_section` leaves
|
|
1152
|
+
`lc_card(as: :section)`. `lc_heading(as: :span)` sets text in a heading role without adding a heading to the outline, such as a total in a summary row. `lc_section` leaves
|
|
1031
1153
|
`heading` below its title and `content` between blocks. `lc_split` lays out a main column and an aside: one
|
|
1032
1154
|
column on small screens, and from `lg` a flexible main beside an aside of `aside: :sm` (16rem), `:md` (20rem)
|
|
1033
1155
|
or `:lg` (24rem). `lc_columns(count: 2)` flows groups, such as settings sections, into balanced columns from
|
|
@@ -1036,7 +1158,7 @@ for a heading that needs more than a title, such as a lede under it. `lc_contain
|
|
|
1036
1158
|
`form` widths; only the page container adds gutters. Japanese headings inherit `lang="ja"` and use
|
|
1037
1159
|
natural letter spacing.
|
|
1038
1160
|
|
|
1039
|
-
[Browse the foundations examples](https://ui.lostcoords.com/components/foundations
|
|
1161
|
+
[Browse the foundations examples](https://ui.lostcoords.com/components/foundations).
|
|
1040
1162
|
|
|
1041
1163
|
### Reading content
|
|
1042
1164
|
|
|
@@ -1076,15 +1198,16 @@ Class helpers remain available for custom markup. The application owns its seman
|
|
|
1076
1198
|
Generated by `bin/rails lostcoords:ui:builders`; `bin/lint` checks this list against the style helpers.
|
|
1077
1199
|
|
|
1078
1200
|
<!-- builders -->
|
|
1201
|
+
- `lc_avatar_badge_class(size: :md, control: false, extra: nil)` (AvatarBadgeHelper)
|
|
1079
1202
|
- `lc_icon_badge_class(size: :md, shape: :square, tone: :neutral, extra: nil)` (BadgeHelper)
|
|
1080
1203
|
- `lc_avatar_class(size: :md, ink: false, linked: false, extra: nil)` (BadgeHelper)
|
|
1081
|
-
- `lc_avatar_stack_class(compact: false, extra: nil)` (BadgeHelper)
|
|
1204
|
+
- `lc_avatar_stack_class(compact: false, size: :md, overlap: :md, extra: nil)` (BadgeHelper)
|
|
1082
1205
|
- `lc_avatar_stack_row_class(extra: nil)` (BadgeHelper)
|
|
1083
1206
|
- `lc_badge_class(tone: :neutral, shape: :rounded, extra: nil)` (BadgeHelper)
|
|
1084
1207
|
- `lc_toggle_class(active: false, ghost: false, size: :md, extra: nil)` (BadgeHelper)
|
|
1085
1208
|
- `lc_button_class(variant: :primary, tone: :default, size: :md, block: false, extra: nil)` (ButtonHelper)
|
|
1086
1209
|
- `lc_select_trigger_class(size: :md, block: false, extra: nil)` (ButtonHelper)
|
|
1087
|
-
- `lc_icon_button_class(shape: :square, size: :md, variant: :ghost, tone: :default, extra: nil)` (ButtonHelper)
|
|
1210
|
+
- `lc_icon_button_class(shape: :square, size: :md, icon_size: size, variant: :ghost, tone: :default, extra: nil)` (ButtonHelper)
|
|
1088
1211
|
- `lc_card_class(interactive: false, padding: :md, extra: nil)` (CardHelper)
|
|
1089
1212
|
- `lc_choice_label_class(card: false, extra: nil)` (ChoiceHelper)
|
|
1090
1213
|
- `lc_checkbox_class(extra: nil)` (ChoiceHelper)
|
|
@@ -1103,8 +1226,9 @@ Generated by `bin/rails lostcoords:ui:builders`; `bin/lint` checks this list aga
|
|
|
1103
1226
|
- `lc_spinner_class(size: :md, extra: nil)` (FeedbackHelper)
|
|
1104
1227
|
- `lc_skeleton_class(extra: nil)` (FeedbackHelper)
|
|
1105
1228
|
- `lc_empty_state_class(extra: nil)` (FeedbackHelper)
|
|
1106
|
-
- `
|
|
1107
|
-
- `
|
|
1229
|
+
- `lc_file_drop_class(extra: nil)` (FileDropHelper)
|
|
1230
|
+
- `lc_toggle_group_class(layout: :inline, scroll: false, extra: nil)` (FormHelper)
|
|
1231
|
+
- `lc_toggle_group_item_class(active: false, layout: :inline, extra: nil)` (FormHelper)
|
|
1108
1232
|
- `lc_input_class(size: :md, plain: false, extra: nil)` (FormHelper)
|
|
1109
1233
|
- `lc_select_class(size: :md, extra: nil)` (FormHelper)
|
|
1110
1234
|
- `lc_textarea_class(extra: nil)` (FormHelper)
|
|
@@ -1117,8 +1241,8 @@ Generated by `bin/rails lostcoords:ui:builders`; `bin/lint` checks this list aga
|
|
|
1117
1241
|
- `lc_split_class(aside: :md, extra: nil)` (LayoutHelper)
|
|
1118
1242
|
- `lc_columns_class(count: 2, extra: nil)` (LayoutHelper)
|
|
1119
1243
|
- `lc_section_header_class(extra: nil)` (LayoutHelper)
|
|
1120
|
-
- `lc_popover_class(align: :end, extra: nil)` (MenuHelper)
|
|
1121
|
-
- `lc_menu_popover_class(align: :end, extra: nil)` (MenuHelper)
|
|
1244
|
+
- `lc_popover_class(align: :end, side: :bottom, extra: nil)` (MenuHelper)
|
|
1245
|
+
- `lc_menu_popover_class(align: :end, side: :bottom, extra: nil)` (MenuHelper)
|
|
1122
1246
|
- `lc_menu_option_class(tone: :default, extra: nil)` (MenuHelper)
|
|
1123
1247
|
- `lc_link_class(tone: :inherit, extra: nil)` (NavigationHelper)
|
|
1124
1248
|
- `lc_nav_link_class(compact: false, layout: :column, extra: nil)` (NavigationHelper)
|
|
@@ -1133,7 +1257,7 @@ Generated by `bin/rails lostcoords:ui:builders`; `bin/lint` checks this list aga
|
|
|
1133
1257
|
|
|
1134
1258
|
## Blocks
|
|
1135
1259
|
|
|
1136
|
-
[Browse the blocks](https://ui.lostcoords.com/blocks
|
|
1260
|
+
[Browse the blocks](https://ui.lostcoords.com/blocks) for complete layouts assembled from the
|
|
1137
1261
|
existing components. Each block has an interactive preview and the ERB, CSS and JavaScript that
|
|
1138
1262
|
render it. Copy the files into your app and adapt the content, routes and actions.
|
|
1139
1263
|
|
|
@@ -1145,10 +1269,10 @@ The docs app lives in `test/dummy`. Run `parcela up --detach` and open https://u
|
|
|
1145
1269
|
Parcela starts Rails (with live reload through Hotwire Spark) and the Tailwind watcher.
|
|
1146
1270
|
`parcela down` stops this environment.
|
|
1147
1271
|
|
|
1148
|
-
`bin/rails kiln:build` exports every docs route to `docs
|
|
1272
|
+
`bin/rails kiln:build` exports every docs route to `docs/`, which Cloudflare serves at ui.lostcoords.com, with
|
|
1149
1273
|
[Kiln](https://github.com/davafons/kiln): pages, blocks, the token reference, the machine-readable API and
|
|
1150
1274
|
assets. Param sources for the component and block pages live in `test/dummy/config/kiln.rb`, and a route
|
|
1151
|
-
without one fails the build. `bin/rails kiln:serve` serves the export the way
|
|
1275
|
+
without one fails the build. `bin/rails kiln:serve` serves the export the way Cloudflare does. CI runs
|
|
1152
1276
|
`bin/rails kiln:build` and fails when `docs/` changes, and checks that every public rendering helper has a
|
|
1153
1277
|
runnable example.
|
|
1154
1278
|
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
|
|
25
25
|
:where([popover]) { color: inherit; }
|
|
26
26
|
|
|
27
|
-
:is(a, button, input, textarea, select, summary, [tabindex]):focus-visible,
|
|
28
|
-
label:has(input.sr-only:focus-visible) {
|
|
27
|
+
:is(a, button, input, textarea, select, summary, [tabindex]:not(dialog)):focus-visible,
|
|
28
|
+
label:has(input.sr-only:focus-visible, + input.sr-only:focus-visible) {
|
|
29
29
|
outline: calc(var(--spacing) * 0.5) solid var(--ring, color-mix(in oklab, var(--primary) 50%, transparent));
|
|
30
30
|
outline-offset: 0;
|
|
31
31
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* Tokens, foundations and the components almost every app uses: buttons,
|
|
2
|
-
badges, avatars, cards, alerts, form controls, choices, toggles, copy buttons,
|
|
2
|
+
badges, avatars and their corner badges, cards, alerts, form controls, file drops, choices, toggles, copy buttons,
|
|
3
3
|
layout, typography and navigation. Add the opt-in components in ./components/ that
|
|
4
4
|
you render, or import ../components.css for everything. */
|
|
5
5
|
@import "./theme.css";
|
|
6
|
-
@source "../../../../helpers/lostcoords/ui/{badge,button,card,choice,copy_button,description_list,feedback,form,glass,icon,layout,list_group,navigation,primitives,render_attributes,structures,tailwind,translation,typography}_helper.rb";
|
|
6
|
+
@source "../../../../helpers/lostcoords/ui/{avatar_badge,badge,button,card,choice,copy_button,description_list,feedback,file_drop,form,glass,icon,layout,list_group,navigation,primitives,render_attributes,structures,tailwind,translation,typography}_helper.rb";
|
|
7
7
|
@source "../../../../javascript/lostcoords/ui/helpers/*.js";
|
|
8
8
|
@source "../../../../javascript/lostcoords/ui/controllers/lc_{char_counter,copy,kbd,nav,scroll_keeper,selection,shortcut,tabs,toc,toggle}_controller.js";
|
|
9
9
|
@source "../../../../../lib/lostcoords/ui/parts.rb";
|
|
@@ -425,7 +425,7 @@
|
|
|
425
425
|
position: absolute;
|
|
426
426
|
inset-block: calc(100% + 8px) auto;
|
|
427
427
|
inset-inline: 0 auto;
|
|
428
|
-
inline-size: min(22rem, calc(100vw - 32px));
|
|
428
|
+
inline-size: min(var(--lc-emoji-picker-popover-width, 22rem), calc(100vw - 32px));
|
|
429
429
|
max-block-size: min(28rem, calc(100vh - 96px));
|
|
430
430
|
padding-block-end: 0;
|
|
431
431
|
border-radius: var(--radius-3xl, 1.5rem);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module Lostcoords::Ui
|
|
2
|
+
module AvatarBadgeHelper
|
|
3
|
+
AVATAR_BADGE_BASE = "absolute -bottom-1 -end-1 grid place-items-center rounded-full bg-background"
|
|
4
|
+
|
|
5
|
+
# :sm is a status mark, such as a lock; :md is the 44px control size.
|
|
6
|
+
AVATAR_BADGE_SIZES = {
|
|
7
|
+
sm: "size-7 text-muted-foreground ring-1 ring-border shadow-(--lc-shadow-sm) [&_svg]:size-4",
|
|
8
|
+
md: "size-11 text-foreground shadow-(--lc-shadow) [&_svg]:size-5"
|
|
9
|
+
}.freeze
|
|
10
|
+
|
|
11
|
+
AVATAR_BADGE_CONTROL = "cursor-pointer border-0 p-0 transition-colors hover:bg-muted"
|
|
12
|
+
AVATAR_BADGE_TAGS = %i[span button label].freeze
|
|
13
|
+
|
|
14
|
+
def lc_avatar_badge_class(size: :md, control: false, extra: nil)
|
|
15
|
+
size = lc_option!(:size, size, AVATAR_BADGE_SIZES.keys)
|
|
16
|
+
lc_tw(AVATAR_BADGE_BASE, AVATAR_BADGE_SIZES.fetch(size), (AVATAR_BADGE_CONTROL if control), extra)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# A round badge on an avatar's bottom corner. Render it after the avatar inside a `relative` wrapper.
|
|
20
|
+
# as: :span is a decorative mark (size :sm by default); :button and :label are 44px controls named by
|
|
21
|
+
# label:. A :label needs for:, and shows the focus halo while the visually hidden input after it has focus.
|
|
22
|
+
# Inside menu.trigger, splat the yielded attributes into an as: :button badge.
|
|
23
|
+
def lc_avatar_badge(icon, label: nil, as: :span, size: nil, **attributes)
|
|
24
|
+
as = lc_option!(:as, as, AVATAR_BADGE_TAGS)
|
|
25
|
+
control = as != :span
|
|
26
|
+
size = lc_option!(:size, size || (control ? :md : :sm), AVATAR_BADGE_SIZES.keys)
|
|
27
|
+
raise ArgumentError, "a #{as} badge is a 44px control; use size: :md" if control && size != :md
|
|
28
|
+
lc_label!(label, :label) if control
|
|
29
|
+
raise ArgumentError, "as: :label needs for:" if as == :label && attributes[:for].blank?
|
|
30
|
+
|
|
31
|
+
glyph = lc_icon(icon, variant: (size == :sm ? :mini : :outline), options: { "aria-hidden": true })
|
|
32
|
+
defaults = { class: lc_avatar_badge_class(size: size, control: control), data: { slot: "avatar-badge" } }
|
|
33
|
+
case as
|
|
34
|
+
when :button
|
|
35
|
+
tag.button(glyph, **lc_attributes(defaults.merge(type: "button", aria: { label: label }), attributes))
|
|
36
|
+
when :label
|
|
37
|
+
tag.label(safe_join([ glyph, tag.span(label, class: "sr-only") ]), **lc_attributes(defaults.merge(title: label), attributes))
|
|
38
|
+
else
|
|
39
|
+
tag.span(glyph, **lc_attributes(defaults.merge(aria: (label ? { label: label } : { hidden: true }), role: ("img" if label)), attributes))
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -61,6 +61,20 @@ module Lostcoords::Ui
|
|
|
61
61
|
"@sm:[--lc-avatar-size:--spacing(5.5)] @sm:[--lc-avatar-font-size:0.5rem] " \
|
|
62
62
|
"[--lc-avatar-stack-overlap:--spacing(1.25)] [--lc-avatar-stack-padding:0px]"
|
|
63
63
|
|
|
64
|
+
# A stack pins its avatars' size, so avatars rendered at another size still line up. Small stacks
|
|
65
|
+
# take a thinner cutout.
|
|
66
|
+
AVATAR_STACK_SIZES = {
|
|
67
|
+
xs: "[--lc-avatar-size:--spacing(5)] [--lc-avatar-border:--spacing(0.375)]",
|
|
68
|
+
5.5 => "[--lc-avatar-size:--spacing(5.5)] [--lc-avatar-border:--spacing(0.375)]",
|
|
69
|
+
sm: "[--lc-avatar-size:--spacing(6.5)] [--lc-avatar-border:--spacing(0.375)]",
|
|
70
|
+
md: "",
|
|
71
|
+
lg: "[--lc-avatar-size:--spacing(12)]"
|
|
72
|
+
}.freeze
|
|
73
|
+
|
|
74
|
+
# :sm tucks each avatar further under the one before and drops the row's padding, for a stack
|
|
75
|
+
# that sits in a line of text.
|
|
76
|
+
AVATAR_STACK_OVERLAPS = { md: "", sm: "[--lc-avatar-stack-overlap:--spacing(0.5)] [--lc-avatar-stack-padding:0px]" }.freeze
|
|
77
|
+
|
|
64
78
|
# dynamic_avatar_stack_controller marks the leading visible avatar with data-first as it narrows the stack.
|
|
65
79
|
AVATAR_STACK_ROW =
|
|
66
80
|
"lc-avatar-stack__row flex shrink-0 p-[var(--lc-avatar-stack-padding,--spacing(1))] " \
|
|
@@ -112,8 +126,12 @@ module Lostcoords::Ui
|
|
|
112
126
|
lc_tw(AVATAR_BASE, AVATAR_SIZES.fetch(lc_option!(:size, size, AVATAR_SIZES.keys)), (AVATAR_INK if ink), (AVATAR_LINKED if linked), extra)
|
|
113
127
|
end
|
|
114
128
|
|
|
115
|
-
def lc_avatar_stack_class(compact: false, extra: nil)
|
|
116
|
-
|
|
129
|
+
def lc_avatar_stack_class(compact: false, size: :md, overlap: :md, extra: nil)
|
|
130
|
+
size = lc_option!(:size, size, AVATAR_STACK_SIZES.keys)
|
|
131
|
+
overlap = lc_option!(:overlap, overlap, AVATAR_STACK_OVERLAPS.keys)
|
|
132
|
+
raise ArgumentError, "compact: sets its own size and overlap" if compact && (size != :md || overlap != :md)
|
|
133
|
+
|
|
134
|
+
lc_tw(AVATAR_STACK_BASE, (AVATAR_STACK_COMPACT if compact), AVATAR_STACK_SIZES.fetch(size), AVATAR_STACK_OVERLAPS.fetch(overlap), extra)
|
|
117
135
|
end
|
|
118
136
|
|
|
119
137
|
def lc_avatar_stack_row_class(extra: nil)
|
|
@@ -30,6 +30,8 @@ module Lostcoords::Ui
|
|
|
30
30
|
outline: "border border-border bg-transparent text-(--lc-button-ink,var(--foreground)) #{BUTTON_HOVER}",
|
|
31
31
|
glass: "[--lc-button-bg:var(--_lc-glass-fill)] text-(--lc-button-ink,var(--foreground)) #{BUTTON_HOVER}",
|
|
32
32
|
ghost: "border border-transparent bg-transparent text-muted-foreground not-disabled:hover:text-(--lc-button-ink,var(--foreground)) #{BUTTON_HOVER}",
|
|
33
|
+
# The page's own fill, for a quiet control sitting on a card.
|
|
34
|
+
inset: "border border-transparent [--lc-button-bg:var(--background)] bg-(--lc-button-bg) text-muted-foreground not-disabled:hover:text-(--lc-button-ink,var(--foreground)) #{BUTTON_HOVER}",
|
|
33
35
|
destructive: "border border-transparent [--lc-button-bg:color-mix(in_oklab,var(--destructive)_60%,black)] [--lc-button-ink:#fff] bg-(--lc-button-bg) text-(--lc-button-ink) #{BUTTON_HOVER}"
|
|
34
36
|
}.freeze
|
|
35
37
|
|
|
@@ -45,6 +47,7 @@ module Lostcoords::Ui
|
|
|
45
47
|
outline: "#{BUTTON_DESTRUCTIVE_INK} border-[color-mix(in_oklab,var(--destructive)_32%,var(--border))]",
|
|
46
48
|
glass: BUTTON_DESTRUCTIVE_INK,
|
|
47
49
|
ghost: "#{BUTTON_DESTRUCTIVE_INK} #{BUTTON_DESTRUCTIVE_SOFT}",
|
|
50
|
+
inset: BUTTON_DESTRUCTIVE_INK,
|
|
48
51
|
destructive: ""
|
|
49
52
|
}
|
|
50
53
|
}.freeze
|
|
@@ -95,9 +98,16 @@ module Lostcoords::Ui
|
|
|
95
98
|
}.freeze
|
|
96
99
|
|
|
97
100
|
ICON_BUTTON_SIZES = {
|
|
98
|
-
sm: "size-control-sm
|
|
99
|
-
md: "size-control-md
|
|
100
|
-
lg: "size-control-lg
|
|
101
|
+
sm: "size-control-sm",
|
|
102
|
+
md: "size-control-md",
|
|
103
|
+
lg: "size-control-lg"
|
|
104
|
+
}.freeze
|
|
105
|
+
|
|
106
|
+
# The icon keeps about the same share of the button at every size; icon_size: picks another tier.
|
|
107
|
+
ICON_BUTTON_ICON_SIZES = {
|
|
108
|
+
sm: "[&_svg]:size-4.5",
|
|
109
|
+
md: "[&_svg]:size-5",
|
|
110
|
+
lg: "[&_svg]:size-6"
|
|
101
111
|
}.freeze
|
|
102
112
|
|
|
103
113
|
# A row action that stays out of the way until it is hovered, focused or open.
|
|
@@ -129,15 +139,17 @@ module Lostcoords::Ui
|
|
|
129
139
|
end
|
|
130
140
|
|
|
131
141
|
# The base is already a ghost button, so variant: :ghost adds nothing; tone: recolours any variant.
|
|
132
|
-
def lc_icon_button_class(shape: :square, size: :md, variant: :ghost, tone: :default, extra: nil)
|
|
142
|
+
def lc_icon_button_class(shape: :square, size: :md, icon_size: size, variant: :ghost, tone: :default, extra: nil)
|
|
133
143
|
shape = lc_option!(:shape, shape, ICON_BUTTON_SHAPES.keys)
|
|
134
144
|
size = lc_option!(:size, size, ICON_BUTTON_SIZES.keys)
|
|
145
|
+
icon_size = lc_option!(:icon_size, icon_size, ICON_BUTTON_ICON_SIZES.keys)
|
|
135
146
|
variant = lc_option!(:variant, variant, BUTTON_VARIANTS.keys)
|
|
136
147
|
tone = lc_option!(:tone, tone, BUTTON_TONES.keys)
|
|
137
148
|
lc_tw(
|
|
138
149
|
ICON_BUTTON_BASE,
|
|
139
150
|
ICON_BUTTON_SHAPES.fetch(shape),
|
|
140
151
|
ICON_BUTTON_SIZES.fetch(size),
|
|
152
|
+
ICON_BUTTON_ICON_SIZES.fetch(icon_size),
|
|
141
153
|
(lc_glass_class(shape: :bar) if variant == :glass),
|
|
142
154
|
(BUTTON_VARIANTS.fetch(variant) unless variant == :ghost),
|
|
143
155
|
BUTTON_TONES.fetch(tone).fetch(variant),
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
module Lostcoords::Ui
|
|
2
2
|
module CardHelper
|
|
3
3
|
# Padding sizes set --lc-inset, so nested content that pads or gaps with inset follows the card.
|
|
4
|
+
# An unpadded card drops its border and clips to its corners, so rows inside meet its edge and
|
|
5
|
+
# their hover fills round with it. Menus and dialogs inside render in the top layer, unclipped.
|
|
4
6
|
CARD_PADDING = {
|
|
5
|
-
none: "p-0",
|
|
7
|
+
none: "p-0 border-0 overflow-clip",
|
|
6
8
|
md: "p-inset",
|
|
7
9
|
sm: "[--lc-inset:var(--spacing-content)] p-inset"
|
|
8
10
|
}.freeze
|
|
@@ -8,8 +8,7 @@ module Lostcoords::Ui
|
|
|
8
8
|
# card: true draws the whole label as a selectable tile, for plan or theme pickers.
|
|
9
9
|
CHOICE_CARD = "flex w-full rounded-2xl lc-squircle border border-transparent bg-tile p-content " \
|
|
10
10
|
"transition-[background-color,border-color] duration-(--lc-motion-quick) ease-(--lc-ease-out) hover:bg-accent " \
|
|
11
|
-
"has-checked:border-primary has-checked:bg-primary-soft
|
|
12
|
-
"has-focus-visible:outline-(--ring,color-mix(in_oklab,var(--primary)_50%,transparent))"
|
|
11
|
+
"has-checked:border-primary has-checked:bg-primary-soft"
|
|
13
12
|
|
|
14
13
|
def lc_choice_label_class(card: false, extra: nil)
|
|
15
14
|
lc_tw(CHOICE_LABEL, (CHOICE_CARD if card), extra)
|
|
@@ -8,9 +8,13 @@ module Lostcoords::Ui
|
|
|
8
8
|
|
|
9
9
|
# popover_class paints the desktop popover: the gem leaves it unpainted so the host can match
|
|
10
10
|
# its floating surfaces. picker_class and trigger_class style the wrapper and its button.
|
|
11
|
-
|
|
11
|
+
# popover_size: :lg widens the desktop popover for a roomier grid.
|
|
12
|
+
POPOVER_SIZES = { md: nil, lg: "[--lc-emoji-picker-popover-width:28rem]" }.freeze
|
|
13
|
+
|
|
14
|
+
def lc_emoji_picker(form:, field:, label:, catalog_url:, value: nil, quick: [], recent: [], recent_scope: nil, auto_submit: false, popover_size: :md, picker_class: nil, trigger_class: nil, popover_class: nil, **attributes)
|
|
12
15
|
lc_label!(label, :label)
|
|
13
16
|
lc_label!(catalog_url, :catalog_url)
|
|
17
|
+
picker_class = lc_tw(POPOVER_SIZES.fetch(lc_option!(:popover_size, popover_size, POPOVER_SIZES.keys)), picker_class)
|
|
14
18
|
render "lostcoords/ui/components/emoji_picker", form: form, field: field, label: label, catalog_url: catalog_url, value: value, quick: quick, recent: recent, recent_scope: recent_scope, auto_submit: auto_submit,
|
|
15
19
|
picker_class: picker_class, trigger_class: trigger_class, popover_class: popover_class, attributes: attributes
|
|
16
20
|
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Lostcoords::Ui
|
|
2
|
+
module FileDropHelper
|
|
3
|
+
FILE_DROP =
|
|
4
|
+
"grid min-h-45 cursor-pointer place-items-center content-center gap-2 rounded-2xl border-2 border-dashed border-border bg-muted p-4 text-center " \
|
|
5
|
+
"transition-[background-color,border-color,box-shadow] duration-150 ease-out hover:border-primary hover:bg-accent hover:shadow-(--lc-shadow-sm) sm:p-6"
|
|
6
|
+
|
|
7
|
+
def lc_file_drop_class(extra: nil)
|
|
8
|
+
lc_tw(FILE_DROP, extra)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# A dashed drop zone: a label around a visually hidden file input, so a click or a dropped file reaches the
|
|
12
|
+
# input. name: builds the input with accept:, multiple: and input: attributes, such as a controller target;
|
|
13
|
+
# a block renders your own input instead (form.file_drop passes the form's), and must give it class "sr-only".
|
|
14
|
+
# button: adds a decorative button inside the label, which the label already names.
|
|
15
|
+
def lc_file_drop(name: nil, title:, hint: nil, button: nil, icon: "arrow-up-tray", accept: nil, multiple: false, input: {}, **attributes, &block)
|
|
16
|
+
lc_label!(title, :title)
|
|
17
|
+
raise ArgumentError, "Pass name: or a block that renders the file input, not both" if name && block
|
|
18
|
+
raise ArgumentError, "lc_file_drop needs name: or a block that renders the file input" unless name || block
|
|
19
|
+
|
|
20
|
+
field = block ? capture(&block) : file_field_tag(name, **lc_attributes({ class: "sr-only", accept: accept, multiple: multiple }, input))
|
|
21
|
+
tag.label(**lc_attributes({ class: lc_file_drop_class, data: { slot: "file-drop" } }, attributes)) do
|
|
22
|
+
safe_join([
|
|
23
|
+
lc_icon_badge(icon: icon, size: :lg, shape: :circle, tone: :primary, class: "mb-2", aria: { hidden: true }),
|
|
24
|
+
tag.span(title, class: lc_heading_class(size: :subheading), data: { slot: "file-drop-title" }),
|
|
25
|
+
(lc_text(hint, as: :span, size: :small, tone: :muted, data: { slot: "file-drop-hint" }) if hint.present?),
|
|
26
|
+
(lc_button(button, as: :span, size: :sm, class: "mt-2 pointer-events-none", aria: { hidden: true }) if button.present?),
|
|
27
|
+
field
|
|
28
|
+
].compact)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|