lostcoords-ui 0.10.0 → 0.12.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 +155 -23
- data/app/assets/tailwind/lostcoords/ui/base.css +1 -1
- data/app/assets/tailwind/lostcoords/ui/components/hovercard.css +4 -0
- data/app/assets/tailwind/lostcoords/ui/components.css +1 -0
- data/app/assets/tailwind/lostcoords/ui/core.css +2 -2
- data/app/assets/tailwind/lostcoords/ui/emoji-picker.css +1 -1
- data/app/assets/tailwind/lostcoords/ui/hovercard.css +47 -0
- 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/hovercard_helper.rb +31 -0
- 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_hovercard_controller.js +104 -0
- data/app/javascript/lostcoords/ui/helpers/dialog.js +27 -4
- data/app/javascript/lostcoords/ui/helpers/dismiss_stack.js +1 -1
- data/app/javascript/lostcoords/ui/index.js +2 -0
- 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 +7 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d40b25262f26a57dea7b82cada5df30d683de3fb28f2c9db0046130cfb26a26f
|
|
4
|
+
data.tar.gz: 3c3b01b38a8d674bd8a59f068b6b5e7db92563cecd5d56bdeb43b08257373526
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d05b7df8c044fed6d94d2d8ff97caab7d9e589bdb2d218bf3d5a49bba27c5b7dbb7df2b7c4354e55947ef48025803167fc0d542892ce640bb50c0461efc175fb
|
|
7
|
+
data.tar.gz: 9ccbd01d8a5171657cd56e71dd6537628efed50f75fb00445226abc96999559b58fd4ba415664c17ac4820e919908cc74a8dabf2ad8c53efef6b559e6736ef86
|
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,51 @@ 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.0
|
|
174
|
+
|
|
175
|
+
One edit, and some components look different:
|
|
176
|
+
|
|
177
|
+
- **`lc_menu_option` takes `form_attributes:` for the form `method:` builds.** Before: `form:` set that
|
|
178
|
+
form's attributes. After: `form:` is the option button's own HTML `form` attribute, so an option can submit a
|
|
179
|
+
form elsewhere on the page (`type: "submit", form: "profile-form"`). Rename `form:` to `form_attributes:`
|
|
180
|
+
wherever an option passes it alongside `method:`.
|
|
181
|
+
- **A small icon button draws an 18px icon**, up from 16px; `icon_size:` picks another.
|
|
182
|
+
- **`lc_button_to` and `lc_icon_button_to` wrap their button in a `contents` form**, so the button sits in a
|
|
183
|
+
flex or grid row as if the form weren't there. A caller's `form: { class: }` still merges over it. A
|
|
184
|
+
margin or alignment class that was on the form belongs on the button now.
|
|
185
|
+
- **`lc_list_group` rounds its first and last visible child**, whatever it is, instead of each row rounding
|
|
186
|
+
itself. Non-row children and hidden rows need no corner classes.
|
|
187
|
+
- **`lc_card(padding: :none)` drops the border and clips its children** to its corners, so rows reach the
|
|
188
|
+
edge without negative margins.
|
|
189
|
+
- **A dialog's body no longer shrinks its children**, so a long body scrolls instead of squashing buttons.
|
|
190
|
+
- **The choice card uses the global focus halo** instead of its own outline.
|
|
191
|
+
|
|
192
|
+
New components and options, moved from apps that built them by hand:
|
|
193
|
+
|
|
194
|
+
- **`lc_avatar_badge`** puts an icon badge on an avatar's corner: a decorative mark, a button or a file label.
|
|
195
|
+
- **`lc_file_drop`** (and `form.file_drop`) is a dashed drop zone around a file input.
|
|
196
|
+
- **`lc_list_row(choice: :radio, name:, value:, checked:)`** is a selectable row with a trailing check.
|
|
197
|
+
- **`lc_toggle_group(layout: :inline | :stacked | :adaptive, scroll:)`** and
|
|
198
|
+
**`lc_toggle_group_item(icon:, icon_only:)`**: icons in segmented controls, stacked over their labels on
|
|
199
|
+
narrow groups, and a scrolling track with faded edges.
|
|
200
|
+
- **`lc_menu(side: :top, trigger_size:)`** opens upward and sizes its trigger; `lc_popover_class` and
|
|
201
|
+
`lc_menu_popover_class` take `side:` too.
|
|
202
|
+
- **`lc_icon_button(icon_size:)`** and the **`:inset` variant**, a page-coloured fill for buttons inside a card.
|
|
203
|
+
- **`lc_avatar_stack(size:, overlap:)`**, **`lc_emoji_picker(popover_size:)`**, **`lc_input(icon:)`**,
|
|
204
|
+
**`lc_sheet(surface: :glass)`** with pinned `sheet.header` and `sheet.footer` parts, and
|
|
205
|
+
**`lc_heading(as:)`**.
|
|
206
|
+
- **`registerDialog` takes `priority:` and `restoreFocus:`**, so a host dialog no longer registers with the
|
|
207
|
+
dismiss stack directly. A click on the dialog's own padding no longer closes it.
|
|
208
|
+
|
|
209
|
+
## Changes in 0.11.0
|
|
210
|
+
|
|
211
|
+
Nothing needs an edit. New:
|
|
212
|
+
|
|
213
|
+
- **`lc_hovercard` previews what a link points to**, such as a profile card over a name, with the
|
|
214
|
+
`lc-hovercard` controller, in the `components` entry. It opens on hover or keyboard focus, takes its card
|
|
215
|
+
as `content:` or loads it lazily from `src:`, and keeps the card out of the accessibility tree as a
|
|
216
|
+
preview of the linked page.
|
|
217
|
+
|
|
173
218
|
## Changes in 0.10.0
|
|
174
219
|
|
|
175
220
|
Nothing needs an edit, but toggles look different:
|
|
@@ -312,12 +357,13 @@ Everything else in 0.8 is additive. These changes need edits in an app built on
|
|
|
312
357
|
|
|
313
358
|
## Components
|
|
314
359
|
|
|
315
|
-
[Installation and setup](https://ui.lostcoords.com/installation
|
|
360
|
+
[Installation and setup](https://ui.lostcoords.com/installation) · [Live examples](https://ui.lostcoords.com). Each example renders the same ERB source shown
|
|
316
361
|
in its code panel. The API reference reads signatures from the helper definitions.
|
|
317
362
|
[API JSON](https://ui.lostcoords.com/api.json) and [llms.txt](https://ui.lostcoords.com/llms.txt)
|
|
318
363
|
include those signatures and the runnable examples.
|
|
319
364
|
|
|
320
|
-
Buttons use `primary`, `secondary`, `outline`, `ghost`, `glass` or `destructive`, with `sm`, `md` or `lg` sizes.
|
|
365
|
+
Buttons use `primary`, `secondary`, `outline`, `ghost`, `inset`, `glass` or `destructive`, with `sm`, `md` or `lg` sizes.
|
|
366
|
+
`inset` fills with the page colour and muted ink, for a quiet control on a card.
|
|
321
367
|
Primary, secondary and destructive buttons have visible filled surfaces. Ghost buttons and the
|
|
322
368
|
`lc_icon_button` toolbar action are transparent at rest and show their full shape on hover.
|
|
323
369
|
Primary, secondary and destructive buttons are flat. Secondary buttons use a soft neutral fill distinct from page and card backgrounds.
|
|
@@ -328,7 +374,7 @@ Button hover and press fills mix 94% of the base background with 6% of its foreg
|
|
|
328
374
|
Ghost and icon buttons stay transparent at rest and use the secondary base for that calculation.
|
|
329
375
|
Apps can override `--secondary` for the neutral base, or `--lc-button-bg` and `--lc-button-ink` on individual buttons.
|
|
330
376
|
Inputs use `--input` and `--lc-input-hover`.
|
|
331
|
-
`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.
|
|
377
|
+
`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.
|
|
332
378
|
Use `icon: "plus"` for a leading Heroicon or `icon_position: :end` for a trailing one. Custom icons and
|
|
333
379
|
spinners use `data-icon="inline-start"` or `data-icon="inline-end"`; buttons adjust that edge's padding.
|
|
334
380
|
`lc_button(expanded_icon: "x-mark")` swaps its content for that icon while `aria-expanded` is true, for a trigger
|
|
@@ -374,6 +420,7 @@ Wrap wide tables in an app-owned horizontal scroll region with an accessible nam
|
|
|
374
420
|
Use `lc_table_class` when an existing table renderer owns the markup.
|
|
375
421
|
|
|
376
422
|
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.
|
|
423
|
+
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.
|
|
377
424
|
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.
|
|
378
425
|
Add `class: "@container"` when a card owns its width and its children use container queries.
|
|
379
426
|
Use `--lc-card-bg`, `--lc-card-border`, `--lc-card-radius` and `--lc-card-shadow` for local appearance overrides.
|
|
@@ -383,8 +430,15 @@ Use `--lc-card-bg`, `--lc-card-border`, `--lc-card-radius` and `--lc-card-shadow
|
|
|
383
430
|
`lc_avatar` sizes are `xs` (20px), `sm` (26px), `md` (32px), `lg` (48px), `xl` (96px) and `xxl` (112px).
|
|
384
431
|
Between them, both take a step on the spacing scale, as in `size-7`: `lc_avatar` takes `7` (28px) and `11` (44px),
|
|
385
432
|
`lc_icon_badge` takes `6` (24px), `7` (28px) and `11` (44px).
|
|
386
|
-
Pass `as: :button` when the avatar is itself the control, such as a colour picker's trigger.
|
|
387
|
-
|
|
433
|
+
Pass `as: :button` when the avatar is itself the control, such as a colour picker's trigger.
|
|
434
|
+
`lc_avatar_badge(icon, label:, as:)` pins a round badge to an avatar's bottom corner; render it after the avatar
|
|
435
|
+
in a `relative` wrapper. `as: :span` (the default) is a 28px decorative mark, such as a lock on a gated group;
|
|
436
|
+
`as: :button` and `as: :label` are 44px controls named by `label:`, such as a camera that changes the photo. A
|
|
437
|
+
label needs `for:` and shows the focus halo while the visually hidden input after it has focus; as a menu
|
|
438
|
+
trigger, splat `menu.trigger`'s attributes into an `as: :button` badge. `lc_avatar_stack`
|
|
439
|
+
takes `row:` attributes for the inner row that overlaps the avatars, such as a controller target. Its `size:`
|
|
440
|
+
(`xs`, `5.5`, `sm`, `md` or `lg`) pins every avatar in it to one size, and `overlap: :sm` tucks them closer and
|
|
441
|
+
drops the row's padding, for a stack in a line of text. `compact: true` is a preset of both and takes neither.
|
|
388
442
|
Initials and icons scale with the size, including a size set through `--lc-avatar-size` or `--lc-icon-badge-size`;
|
|
389
443
|
set `--lc-avatar-font-scale` or `--lc-icon-badge-font-scale` to change the share, or the `-font-size` variable to pin it.
|
|
390
444
|
Badge, icon badge, Alert and Toast share `neutral`, `primary`, `success`, `warning` and `destructive` tones.
|
|
@@ -400,6 +454,9 @@ With `name:` they are native radios in labels, which bring their own arrows, sub
|
|
|
400
454
|
labelled `nav`; items take `href:` and `current:`. Otherwise they are radio buttons whose selection lives in the
|
|
401
455
|
`lc-selection` controller, which dispatches `lc-selection:change`; items take `value:` and `selected:`. An item
|
|
402
456
|
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.
|
|
457
|
+
Items take `icon:` and `icon_only:` as `lc_toggle` does. A segmented group's `layout: :stacked` puts each item's icon
|
|
458
|
+
over its label, and `layout: :adaptive` makes the group full width and stacks its items only while the group is
|
|
459
|
+
narrower than 24rem. `scroll: true` lets a track wider than its container scroll sideways, its edges fading.
|
|
403
460
|
|
|
404
461
|
```erb
|
|
405
462
|
<%= lc_toggle_group label: "Period", as: :nav do %>
|
|
@@ -412,8 +469,14 @@ given another kind's arguments raises. `variant: :pills` lays any of them out as
|
|
|
412
469
|
<% end %>
|
|
413
470
|
<%= lc_toggle "Food", aria: { pressed: false }, data: { value: "food" } %>
|
|
414
471
|
<%= lc_toggle "Bold", icon: "bold", icon_only: true, tooltip: true %>
|
|
472
|
+
<%= lc_toggle_group label: "View", as: :nav do %>
|
|
473
|
+
<%= lc_toggle_group_item "List", href: "/", current: true, icon: "list-bullet", icon_only: true %>
|
|
474
|
+
<%= lc_toggle_group_item "Calendar", href: "/calendar", icon: "calendar-days", icon_only: true %>
|
|
475
|
+
<% end %>
|
|
415
476
|
```
|
|
416
477
|
|
|
478
|
+
`lc_emoji_picker(popover_size: :lg)` widens the desktop popover from 22rem to 28rem for a roomier grid.
|
|
479
|
+
|
|
417
480
|
`lc_empty_state(title:, text:, icon:)` lays out the usual empty state: a round icon badge, a heading
|
|
418
481
|
(`level:`, 2 by default), a line of muted text, then the block, such as an action. `card: true` puts it on a card.
|
|
419
482
|
Without those options the block is the whole content, as before.
|
|
@@ -469,7 +532,8 @@ makes the summary look like that `lc_button` without the native marker, and `ind
|
|
|
469
532
|
```
|
|
470
533
|
|
|
471
534
|
`lc_list_group` draws grouped settings rows: each row is its own card-coloured panel, 2px apart, and
|
|
472
|
-
only the group's ends round.
|
|
535
|
+
only the group's ends round. The group rounds its first and last shown child, so a collapsible or any other
|
|
536
|
+
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
|
|
473
537
|
`--card-input` and `--card-secondary`. `lc_list_row` with a title lays out `icon:` (a name, or your own
|
|
474
538
|
markup such as a logo), the title, `subtitle:` and the block as trailing content; `tag:` makes it a
|
|
475
539
|
`label`, `li`, `details` or `a` (`href:`). `href:` with `tag: :li` or `:div` links the title instead
|
|
@@ -480,6 +544,18 @@ out the same icon, title and subtitle inside your own element. `lc_list_section`
|
|
|
480
544
|
footnote; with an `id:`, the heading labels the section. Put a form around `lc_list_group` inside it
|
|
481
545
|
when the rows save together.
|
|
482
546
|
|
|
547
|
+
`lc_list_row(choice: :radio, name:, value:, checked:)` makes a row one choice of a radio group: a `label` around a
|
|
548
|
+
visually hidden radio, then the title or block, then a check shown while it is checked. The checked row fills
|
|
549
|
+
with `--primary-soft` and its text turns semibold, and the focus halo rings the row while its radio has focus.
|
|
550
|
+
`input:` adds attributes to the radio, such as `required: true` or a Stimulus action.
|
|
551
|
+
|
|
552
|
+
```erb
|
|
553
|
+
<%= lc_list_group role: "radiogroup", aria: { label: "How did you hear about us?" } do %>
|
|
554
|
+
<%= lc_list_row "A friend", choice: :radio, name: :heard_about, value: "friend", checked: true %>
|
|
555
|
+
<%= lc_list_row "Search", choice: :radio, name: :heard_about, value: "search" %>
|
|
556
|
+
<% end %>
|
|
557
|
+
```
|
|
558
|
+
|
|
483
559
|
`lc_list_field` is a form row in the same group: a label column, then the block as the control. In a
|
|
484
560
|
narrow row the label folds to its `icon:`, and the text stays the accessible name. `id:` makes the label
|
|
485
561
|
a `<label>` for that control; `tag: :fieldset` names a group of controls, such as chips, with a legend.
|
|
@@ -567,6 +643,20 @@ before JavaScript runs.
|
|
|
567
643
|
<% end %>
|
|
568
644
|
```
|
|
569
645
|
|
|
646
|
+
`lc_file_drop(title:, hint:, button:, icon:)` is a dashed drop zone: a label around a visually hidden file
|
|
647
|
+
input, so a click or a dropped file reaches it. `name:` builds the input with `accept:`, `multiple:` and
|
|
648
|
+
`input:` attributes, such as a controller target; `form.file_drop :files, title: …` wraps the form's own
|
|
649
|
+
`file_field`, and its other options (`accept:`, `multiple:`, `data:`) reach the input. `button:` adds a
|
|
650
|
+
decorative button inside, which the label already names.
|
|
651
|
+
|
|
652
|
+
```erb
|
|
653
|
+
<%= form.file_drop :files, title: "Add receipts", hint: "Up to 10 MB each", button: "Browse",
|
|
654
|
+
multiple: true, accept: "image/*,application/pdf", data: { action: "change->upload#update" } %>
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
`lc_input(icon: "magnifying-glass")` draws a leading icon inside the field. The input comes wrapped in a
|
|
658
|
+
span then; `class:` and the other attributes still reach the `<input>`.
|
|
659
|
+
|
|
570
660
|
`lc_checkbox`, `lc_radio` and `lc_switch` render native inputs with a label and optional hint.
|
|
571
661
|
Checkboxes and switches submit an unchecked value like Rails' `check_box`; pass `unchecked_value: nil`
|
|
572
662
|
to omit it. A `nil` label renders the bare input, for a row selector the row labels; give it
|
|
@@ -733,7 +823,8 @@ assistive technology so the label stays the name. Leading visuals share one colu
|
|
|
733
823
|
labels line up with and without them. `hint:` adds a secondary line. `checked: true` or `false` makes
|
|
734
824
|
a `menuitemradio` with a check mark. `checkbox: true` makes a `menuitemcheckbox` that flips its
|
|
735
825
|
`aria-checked` on click, dispatches `lc-menu:check` with `{ checked }`, and leaves the menu open.
|
|
736
|
-
`method:` renders a `button_to` form and passes `params:` and `form:`
|
|
826
|
+
`method:` renders a `button_to` form and passes `params:` on, and `form_attributes:` to the form. `form:` is the
|
|
827
|
+
button's own attribute: with `type: "submit"` the option submits that form from elsewhere on the page.
|
|
737
828
|
`lc_menu_group(label, id:)` wraps options in a `role="group"` labelled by an eyebrow heading; its
|
|
738
829
|
options stay on the menu's columns.
|
|
739
830
|
`lc_menu` and `lc_popover` take `trigger: false` to render only the panel, named by `label:` (or
|
|
@@ -741,7 +832,8 @@ options stay on the menu's columns.
|
|
|
741
832
|
`trigger` targets. With `click->lc-popover#toggleFromRow` on that host, a click anywhere on it that
|
|
742
833
|
misses a control opens the panel; mark other regions `data-lc-menu-ignore`.
|
|
743
834
|
`lc_menu` and `lc_popover` take `trigger: :icon` with `icon:` for a quiet icon button named by `label:`,
|
|
744
|
-
or rendered content such as an avatar for a custom trigger. `
|
|
835
|
+
or rendered content such as an avatar for a custom trigger. `lc_menu(trigger_size: :sm)` makes either one a small control.
|
|
836
|
+
`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.
|
|
745
837
|
For any other trigger, call the yielded part's `trigger` with a block. It receives the attributes that
|
|
746
838
|
wire an element as the trigger (its id, `aria-haspopup`, `aria-expanded`, `aria-controls` and the
|
|
747
839
|
Stimulus target and action), merged with any passed to `trigger`, and the element it renders replaces
|
|
@@ -806,7 +898,29 @@ picker both work; a div you toggle yourself sets `data-open` and removes it to s
|
|
|
806
898
|
the div keeps your frame, or `anchored: true` makes it a popover under its trigger inside a positioned
|
|
807
899
|
ancestor. `detents:` takes the same stops as `lc_dialog`, and `handle: true` adds a grab strip above the
|
|
808
900
|
content. A swipe down dispatches `lc-sheet:dismiss`; unless a listener cancels it, an open popover then
|
|
809
|
-
hides.
|
|
901
|
+
hides. `surface: :glass` draws a div in the translucent menu material, as a picker that is a menu on desktop
|
|
902
|
+
and a sheet on phones. The block gets a builder: `sheet.header` and `sheet.footer` stay pinned to the top and
|
|
903
|
+
bottom of the scrolling content, painted with the sheet's surface (`--lc-sheet-bg` on phones, `--popover`
|
|
904
|
+
above), so content scrolls under them. Put the footer last in a scroller padded with `px-inset`; it bleeds to
|
|
905
|
+
the scroller's edges and clears the home indicator.
|
|
906
|
+
|
|
907
|
+
```erb
|
|
908
|
+
<%= lc_sheet tag: :dialog, size: :lg, aria: { label: "New expense" } do |sheet| %>
|
|
909
|
+
<%= sheet.header do %>…<% end %>
|
|
910
|
+
<div class="min-h-0 overflow-y-auto px-inset">
|
|
911
|
+
…
|
|
912
|
+
<%= sheet.footer do %><%= lc_button "Save" %><% end %>
|
|
913
|
+
</div>
|
|
914
|
+
<% end %>
|
|
915
|
+
```
|
|
916
|
+
|
|
917
|
+
A controller that opens a `<dialog>` itself joins it to the dismiss stack with `registerDialog` from
|
|
918
|
+
`lostcoords/ui/helpers/dialog`, so Escape, a backdrop click and a swipe close it, and the page stops scrolling
|
|
919
|
+
behind it. `registerDialog(dialog, { close, priority, restoreFocus, lockScroll })`: `close` may return `false`
|
|
920
|
+
to keep the dialog open, such as while it asks to discard changes; `priority` ranks it against panels open in
|
|
921
|
+
it (a dialog is 10, a panel 20); `restoreFocus` runs after a close; `lockScroll: false` leaves the page
|
|
922
|
+
scrollable. It returns the unregister function and ends when the dialog closes; a click on the dialog's own
|
|
923
|
+
padding does not close it.
|
|
810
924
|
|
|
811
925
|
```erb
|
|
812
926
|
<button type="button" popovertarget="filters">Filters</button>
|
|
@@ -817,6 +931,22 @@ hides.
|
|
|
817
931
|
`lc-popover-shell` gives a native `[popover]` menu the same enter and exit as FloatingPanel panels. Set
|
|
818
932
|
`--lc-popover-from` to change the closed pose and an `origin-*` utility for where it grows from.
|
|
819
933
|
|
|
934
|
+
`lc_hovercard` previews what a link points to, such as a profile over a name, with the `lc-hovercard`
|
|
935
|
+
controller. The card opens after a short hover, or at once on keyboard focus, in the top layer beside the
|
|
936
|
+
trigger, flips above it near the bottom of the screen, and stays open while the pointer crosses onto it.
|
|
937
|
+
Leaving both closes it, Escape closes it at once, and touch screens never open it, so a tap follows the
|
|
938
|
+
link. Splat the yielded attributes on the trigger. `content:` renders the card up front; `src:` loads it as
|
|
939
|
+
HTML from your endpoint the first time it opens, from the page's own origin only, so a long list of
|
|
940
|
+
triggers costs nothing until one is hovered, and a skeleton shows until then. The card is a preview: it is
|
|
941
|
+
hidden from assistive technology and its links leave the tab order, so keep everything in it reachable
|
|
942
|
+
from the page the link opens. Inside a paragraph, keep `content:` to phrasing elements such as spans.
|
|
943
|
+
|
|
944
|
+
```erb
|
|
945
|
+
<%= lc_hovercard src: card_person_path(person) do |card| %>
|
|
946
|
+
<%= link_to person.name, person, **card %>
|
|
947
|
+
<% end %>
|
|
948
|
+
```
|
|
949
|
+
|
|
820
950
|
### Search
|
|
821
951
|
|
|
822
952
|
`lc_search` renders a search trigger, a pill with the ⌘K hint that shrinks to an icon on phones, and
|
|
@@ -960,8 +1090,8 @@ Buttons include hover and press feedback. Override `--lc-motion-quick` (140ms),
|
|
|
960
1090
|
Reduced motion removes control movement and makes copy feedback immediate. Your application owns the
|
|
961
1091
|
pending, success and failure states of network actions such as saving a form.
|
|
962
1092
|
|
|
963
|
-
[Try the copy button](https://ui.lostcoords.com/components/copy_button
|
|
964
|
-
[Motion reference](https://ui.lostcoords.com/components/foundations
|
|
1093
|
+
[Try the copy button](https://ui.lostcoords.com/components/copy_button) ·
|
|
1094
|
+
[Motion reference](https://ui.lostcoords.com/components/foundations#motion)
|
|
965
1095
|
|
|
966
1096
|
### Icons
|
|
967
1097
|
|
|
@@ -1002,7 +1132,7 @@ Heading sizes are `display`, `title`, `heading` and `subheading`. Text sizes are
|
|
|
1002
1132
|
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.
|
|
1003
1133
|
Stacks and inline groups take the spacing names from [Foundations](#foundations). `lc_stack`, `lc_inline`,
|
|
1004
1134
|
`lc_text` and `lc_card` take `as:` to render a meaningful element, such as `lc_stack(as: :ul)`, `lc_text(as: :span)` or
|
|
1005
|
-
`lc_card(as: :section)`. `lc_section` leaves
|
|
1135
|
+
`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
|
|
1006
1136
|
`heading` below its title and `content` between blocks. `lc_split` lays out a main column and an aside: one
|
|
1007
1137
|
column on small screens, and from `lg` a flexible main beside an aside of `aside: :sm` (16rem), `:md` (20rem)
|
|
1008
1138
|
or `:lg` (24rem). `lc_columns(count: 2)` flows groups, such as settings sections, into balanced columns from
|
|
@@ -1011,7 +1141,7 @@ for a heading that needs more than a title, such as a lede under it. `lc_contain
|
|
|
1011
1141
|
`form` widths; only the page container adds gutters. Japanese headings inherit `lang="ja"` and use
|
|
1012
1142
|
natural letter spacing.
|
|
1013
1143
|
|
|
1014
|
-
[Browse the foundations examples](https://ui.lostcoords.com/components/foundations
|
|
1144
|
+
[Browse the foundations examples](https://ui.lostcoords.com/components/foundations).
|
|
1015
1145
|
|
|
1016
1146
|
### Reading content
|
|
1017
1147
|
|
|
@@ -1051,15 +1181,16 @@ Class helpers remain available for custom markup. The application owns its seman
|
|
|
1051
1181
|
Generated by `bin/rails lostcoords:ui:builders`; `bin/lint` checks this list against the style helpers.
|
|
1052
1182
|
|
|
1053
1183
|
<!-- builders -->
|
|
1184
|
+
- `lc_avatar_badge_class(size: :md, control: false, extra: nil)` (AvatarBadgeHelper)
|
|
1054
1185
|
- `lc_icon_badge_class(size: :md, shape: :square, tone: :neutral, extra: nil)` (BadgeHelper)
|
|
1055
1186
|
- `lc_avatar_class(size: :md, ink: false, linked: false, extra: nil)` (BadgeHelper)
|
|
1056
|
-
- `lc_avatar_stack_class(compact: false, extra: nil)` (BadgeHelper)
|
|
1187
|
+
- `lc_avatar_stack_class(compact: false, size: :md, overlap: :md, extra: nil)` (BadgeHelper)
|
|
1057
1188
|
- `lc_avatar_stack_row_class(extra: nil)` (BadgeHelper)
|
|
1058
1189
|
- `lc_badge_class(tone: :neutral, shape: :rounded, extra: nil)` (BadgeHelper)
|
|
1059
1190
|
- `lc_toggle_class(active: false, ghost: false, size: :md, extra: nil)` (BadgeHelper)
|
|
1060
1191
|
- `lc_button_class(variant: :primary, tone: :default, size: :md, block: false, extra: nil)` (ButtonHelper)
|
|
1061
1192
|
- `lc_select_trigger_class(size: :md, block: false, extra: nil)` (ButtonHelper)
|
|
1062
|
-
- `lc_icon_button_class(shape: :square, size: :md, variant: :ghost, tone: :default, extra: nil)` (ButtonHelper)
|
|
1193
|
+
- `lc_icon_button_class(shape: :square, size: :md, icon_size: size, variant: :ghost, tone: :default, extra: nil)` (ButtonHelper)
|
|
1063
1194
|
- `lc_card_class(interactive: false, padding: :md, extra: nil)` (CardHelper)
|
|
1064
1195
|
- `lc_choice_label_class(card: false, extra: nil)` (ChoiceHelper)
|
|
1065
1196
|
- `lc_checkbox_class(extra: nil)` (ChoiceHelper)
|
|
@@ -1078,8 +1209,9 @@ Generated by `bin/rails lostcoords:ui:builders`; `bin/lint` checks this list aga
|
|
|
1078
1209
|
- `lc_spinner_class(size: :md, extra: nil)` (FeedbackHelper)
|
|
1079
1210
|
- `lc_skeleton_class(extra: nil)` (FeedbackHelper)
|
|
1080
1211
|
- `lc_empty_state_class(extra: nil)` (FeedbackHelper)
|
|
1081
|
-
- `
|
|
1082
|
-
- `
|
|
1212
|
+
- `lc_file_drop_class(extra: nil)` (FileDropHelper)
|
|
1213
|
+
- `lc_toggle_group_class(layout: :inline, scroll: false, extra: nil)` (FormHelper)
|
|
1214
|
+
- `lc_toggle_group_item_class(active: false, layout: :inline, extra: nil)` (FormHelper)
|
|
1083
1215
|
- `lc_input_class(size: :md, plain: false, extra: nil)` (FormHelper)
|
|
1084
1216
|
- `lc_select_class(size: :md, extra: nil)` (FormHelper)
|
|
1085
1217
|
- `lc_textarea_class(extra: nil)` (FormHelper)
|
|
@@ -1092,8 +1224,8 @@ Generated by `bin/rails lostcoords:ui:builders`; `bin/lint` checks this list aga
|
|
|
1092
1224
|
- `lc_split_class(aside: :md, extra: nil)` (LayoutHelper)
|
|
1093
1225
|
- `lc_columns_class(count: 2, extra: nil)` (LayoutHelper)
|
|
1094
1226
|
- `lc_section_header_class(extra: nil)` (LayoutHelper)
|
|
1095
|
-
- `lc_popover_class(align: :end, extra: nil)` (MenuHelper)
|
|
1096
|
-
- `lc_menu_popover_class(align: :end, extra: nil)` (MenuHelper)
|
|
1227
|
+
- `lc_popover_class(align: :end, side: :bottom, extra: nil)` (MenuHelper)
|
|
1228
|
+
- `lc_menu_popover_class(align: :end, side: :bottom, extra: nil)` (MenuHelper)
|
|
1097
1229
|
- `lc_menu_option_class(tone: :default, extra: nil)` (MenuHelper)
|
|
1098
1230
|
- `lc_link_class(tone: :inherit, extra: nil)` (NavigationHelper)
|
|
1099
1231
|
- `lc_nav_link_class(compact: false, layout: :column, extra: nil)` (NavigationHelper)
|
|
@@ -1108,7 +1240,7 @@ Generated by `bin/rails lostcoords:ui:builders`; `bin/lint` checks this list aga
|
|
|
1108
1240
|
|
|
1109
1241
|
## Blocks
|
|
1110
1242
|
|
|
1111
|
-
[Browse the blocks](https://ui.lostcoords.com/blocks
|
|
1243
|
+
[Browse the blocks](https://ui.lostcoords.com/blocks) for complete layouts assembled from the
|
|
1112
1244
|
existing components. Each block has an interactive preview and the ERB, CSS and JavaScript that
|
|
1113
1245
|
render it. Copy the files into your app and adapt the content, routes and actions.
|
|
1114
1246
|
|
|
@@ -1120,10 +1252,10 @@ The docs app lives in `test/dummy`. Run `parcela up --detach` and open https://u
|
|
|
1120
1252
|
Parcela starts Rails (with live reload through Hotwire Spark) and the Tailwind watcher.
|
|
1121
1253
|
`parcela down` stops this environment.
|
|
1122
1254
|
|
|
1123
|
-
`bin/rails kiln:build` exports every docs route to `docs
|
|
1255
|
+
`bin/rails kiln:build` exports every docs route to `docs/`, which Cloudflare serves at ui.lostcoords.com, with
|
|
1124
1256
|
[Kiln](https://github.com/davafons/kiln): pages, blocks, the token reference, the machine-readable API and
|
|
1125
1257
|
assets. Param sources for the component and block pages live in `test/dummy/config/kiln.rb`, and a route
|
|
1126
|
-
without one fails the build. `bin/rails kiln:serve` serves the export the way
|
|
1258
|
+
without one fails the build. `bin/rails kiln:serve` serves the export the way Cloudflare does. CI runs
|
|
1127
1259
|
`bin/rails kiln:build` and fails when `docs/` changes, and checks that every public rendering helper has a
|
|
1128
1260
|
runnable example.
|
|
1129
1261
|
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
:where([popover]) { color: inherit; }
|
|
26
26
|
|
|
27
27
|
:is(a, button, input, textarea, select, summary, [tabindex]):focus-visible,
|
|
28
|
-
label:has(input.sr-only: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
|
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
@import "./components/toast.css";
|
|
7
7
|
@import "./components/search.css";
|
|
8
8
|
@import "./components/tooltip.css";
|
|
9
|
+
@import "./components/hovercard.css";
|
|
9
10
|
@import "./components/collapsible.css";
|
|
10
11
|
@import "./components/code-block.css";
|
|
11
12
|
@import "./components/emoji-picker.css";
|
|
@@ -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,47 @@
|
|
|
1
|
+
@layer components {
|
|
2
|
+
/* lc-hovercard lifts the card into the top layer while it shows. It keeps a
|
|
3
|
+
box while closed, invisible, so the lift can measure where it belongs. */
|
|
4
|
+
.lc-hovercard__content {
|
|
5
|
+
position: absolute;
|
|
6
|
+
inset-block-start: calc(100% + var(--spacing-related));
|
|
7
|
+
inset-inline-start: 0;
|
|
8
|
+
z-index: var(--lc-z-popover);
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
inline-size: min(20rem, calc(100vw - 2rem));
|
|
12
|
+
overflow: visible;
|
|
13
|
+
margin: 0;
|
|
14
|
+
padding: var(--spacing-inset);
|
|
15
|
+
color: var(--popover-foreground);
|
|
16
|
+
text-align: start;
|
|
17
|
+
white-space: normal;
|
|
18
|
+
pointer-events: none;
|
|
19
|
+
opacity: 0;
|
|
20
|
+
visibility: hidden;
|
|
21
|
+
transform: translateY(calc(var(--spacing) * -1)) scale(0.98);
|
|
22
|
+
|
|
23
|
+
/* allow-discrete keeps a lifted card in the top layer while it fades out. */
|
|
24
|
+
transition:
|
|
25
|
+
opacity 160ms var(--lc-ease-out-expo),
|
|
26
|
+
transform 160ms var(--lc-ease-out-expo),
|
|
27
|
+
visibility 160ms,
|
|
28
|
+
display 160ms allow-discrete,
|
|
29
|
+
overlay 160ms allow-discrete;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.lc-hovercard[data-side="top"] > .lc-hovercard__content {
|
|
33
|
+
inset-block: auto calc(100% + var(--spacing-related));
|
|
34
|
+
transform: translateY(var(--spacing)) scale(0.98);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.lc-hovercard[data-open] > .lc-hovercard__content {
|
|
38
|
+
pointer-events: auto;
|
|
39
|
+
opacity: 1;
|
|
40
|
+
visibility: visible;
|
|
41
|
+
transform: none;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@media (prefers-reduced-motion: reduce) {
|
|
45
|
+
.lc-hovercard__content { transform: none; }
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -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)
|