lostcoords-ui 0.14.7 → 0.14.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e59511fee6edfa9e200f7b2561e8937d9d17c3884690db48e153346031fb54b
4
- data.tar.gz: af8f42618286ed51b91f7dfcfe9f97cbf8f44bf24472a1ca1e2bb5eea603a3e6
3
+ metadata.gz: 84077c9a58c40198412c3d229e69015dabe6a80f5a25bd257e22fc18abf73020
4
+ data.tar.gz: 41782f8795d5c8c4e9dd45796ceba268a91f8bc7a427987b8006ec147b749f6f
5
5
  SHA512:
6
- metadata.gz: 8867f7a32ba7c848d3d908eabdd3bb326ae482ff3856faba090fbc3db0999f2a25c50133f5ebd3a057e7bbd0e026a926f8198f02fd0733ebd7260e5b87947398
7
- data.tar.gz: 0c7ebba325be9b795f36d5dbe6ec20ca6fc851fe09069c231c78218fa78c0402413312b31a5a6d7831768f45b4951df7b22e8df6c9bb4ed7f232ccec4d2221af
6
+ metadata.gz: 38e4ae910c25a3d000052713ec957b36c49b2f1a1f146f31f85e46974514f7c11595351bb07fdf7b874304b0ba48fc3a8b1782f015d19441024ed65fc4f584b1
7
+ data.tar.gz: 3606c135d2aa929104c5072b29c37737b5ce80dab8b471c59da29a2de1431c8101c5ef36d3c06efa362ca44077180b03c78dad9ba69041b39c52f180de74bc22
data/README.md CHANGED
@@ -170,6 +170,28 @@ Omit `only` to register every library controller. Unknown identifiers raise befo
170
170
  registered, and repeated calls on the same application keep later overrides, so register defaults
171
171
  before application overrides.
172
172
 
173
+ ## Changes in 0.14.10
174
+
175
+ Nothing needs an edit. Added:
176
+
177
+ - **Pills can scroll in one row.** `lc_toggle_group(variant: :pills, scroll: true)` keeps its pills in a
178
+ single row that scrolls sideways, its edges fading while there is more to see; `scroll: :narrow` does
179
+ so only while the nearest `@container` is under `@md`, and wraps above it. A pill's focus ring stays
180
+ visible at the scroller's edge.
181
+
182
+ ## Changes in 0.14.8
183
+
184
+ Nothing needs an edit. Changed:
185
+
186
+ - **An `lc_list_field` row rings while its plain input has focus.** It showed the accent fill alone, so
187
+ these rows were the one place a focused field had no ring. The fill stays.
188
+
189
+ Fixed:
190
+
191
+ - **A lifted panel moves in the frame it grows in.** A panel that outgrew the viewport as its content
192
+ loaded, such as the emoji picker when its catalog arrives, was painted once at the old spot before
193
+ flipping to the other side of its trigger.
194
+
173
195
  ## Changes in 0.14.7
174
196
 
175
197
  Nothing needs an edit. Fixed:
@@ -624,7 +646,7 @@ With `name:` they are native radios in labels, which bring their own arrows, sub
624
646
  `value:` and `checked:`, and the group's `value:` checks the matching item. With `as: :nav` they are links in a
625
647
  labelled `nav`; items take `href:` and `current:`. Otherwise they are radio buttons whose selection lives in the
626
648
  `lc-selection` controller, which dispatches `lc-selection:change`; items take `value:` and `selected:`. An item
627
- 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.
649
+ 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; with `scroll: true` (or `:narrow`, only inside a container under `@md`) the pills stay in one row that scrolls sideways.
628
650
  Items take `icon:` and `icon_only:` as `lc_toggle` does. A segmented group's `layout: :stacked` puts each item's icon
629
651
  over its label, and `layout: :adaptive` makes the group full width and stacks its items only while the group is
630
652
  narrower than 24rem. `scroll: true` lets a track wider than its container scroll sideways, its edges fading.
@@ -732,7 +754,7 @@ narrow row the label folds to its `icon:`, and the text stays the accessible nam
732
754
  a `<label>` for that control; `as: :fieldset` names a group of controls, such as chips, with a legend.
733
755
  `as: :span, surface: false` draws the row inside another element, such as a collapsible's summary.
734
756
  `lc_input(plain: true)` drops the field's fill, border, padding and height so the text sits in the row,
735
- which tints while that input has focus. Toggles take `--lc-field-bg` like fields, so on a card or list
757
+ which tints and shows the focus ring while that input has focus. Toggles take `--lc-field-bg` like fields, so on a card or list
736
758
  row they use `--card-input`.
737
759
 
738
760
  ```erb
@@ -31,6 +31,17 @@ module Lostcoords::Ui
31
31
  }.freeze
32
32
  # A track wider than its container scrolls sideways, its edges fading while there is more to see.
33
33
  TOGGLE_GROUP_SCROLL = "lc-scroll-fade-x max-w-full overflow-x-auto [scrollbar-width:none] *:shrink-0"
34
+ # Pills that scroll sideways in one row instead of wrapping. The 2px inset keeps a pill's focus ring
35
+ # inside the scroller, which clips it otherwise. :narrow scrolls only while the nearest @container is
36
+ # under @md and wraps above it; the fade is inert whenever nothing overflows.
37
+ # Class names are written out whole so Tailwind finds them in this source.
38
+ PILLS_SCROLL = {
39
+ true => "lc-scroll-fade-x motion-safe:scroll-smooth flex-nowrap overflow-x-auto overscroll-x-contain [scrollbar-width:none] " \
40
+ "[&::-webkit-scrollbar]:hidden *:shrink-0 -my-0.5 py-0.5 -mx-0.5 px-0.5",
41
+ narrow: "lc-scroll-fade-x motion-safe:scroll-smooth @max-md:flex-nowrap @max-md:overflow-x-auto @max-md:overscroll-x-contain " \
42
+ "@max-md:[scrollbar-width:none] @max-md:[&::-webkit-scrollbar]:hidden @max-md:*:shrink-0 @max-md:-my-0.5 @max-md:py-0.5 " \
43
+ "@max-md:-mx-0.5 @max-md:px-0.5"
44
+ }.freeze
34
45
 
35
46
  INPUT_BASE =
36
47
  "w-full max-w-full min-w-0 " \
@@ -40,7 +51,7 @@ module Lostcoords::Ui
40
51
  "transition-[border-color,box-shadow] duration-(--lc-motion-quick) ease-(--lc-ease-out) " \
41
52
  "aria-invalid:border-destructive aria-invalid:shadow-[0_0_0_3px_color-mix(in_oklab,var(--destructive)_16%,transparent)]"
42
53
 
43
- # Text and nothing else: for a control inside a row that shows focus itself, such as lc_list_field.
54
+ # Text and nothing else: for a control inside a row that draws the focus ring itself, such as lc_list_field.
44
55
  INPUT_PLAIN =
45
56
  "w-full max-w-full min-w-0 min-h-9 p-0 border-0 bg-transparent font-sans text-base text-foreground " \
46
57
  "placeholder:text-muted-foreground aria-invalid:placeholder:text-destructive outline-none"
@@ -25,7 +25,7 @@ module Lostcoords::Ui
25
25
  "hover:bg-accent has-checked:bg-primary-soft has-checked:font-semibold has-lc-disabled:cursor-not-allowed has-lc-pending:cursor-progress has-lc-disabled:opacity-45"
26
26
  LIST_ROW_CHOICE_CHECK = "ms-auto size-4 shrink-0 text-primary invisible group-has-checked/choice:visible"
27
27
  LIST_FIELD_ELEMENTS = %i[div fieldset span].freeze
28
- LIST_FIELD = "@container px-content py-2.5 transition-colors duration-(--lc-motion-quick) has-[[data-plain]:focus]:bg-accent"
28
+ LIST_FIELD = "@container px-content py-2.5 transition-colors duration-(--lc-motion-quick) has-[[data-plain]:focus]:bg-accent has-[[data-plain]:focus-visible]:lc-focus-ring"
29
29
  LIST_FIELD_GRID = "grid min-h-9 grid-cols-[1.25rem_minmax(0,1fr)] items-center gap-x-heading gap-y-related @md:grid-cols-[8rem_minmax(0,1fr)]"
30
30
  LIST_FIELD_LABEL =
31
31
  "flex items-center gap-related text-label font-semibold text-muted-foreground " \
@@ -108,7 +108,8 @@ module Lostcoords::Ui
108
108
  # as: :nav makes links, the current one marked with aria-current; otherwise radio buttons whose
109
109
  # selection lives in the lc-selection controller.
110
110
  # variant: :pills lays the items out as wrapping toggle pills, sized by size:, instead of a segmented track.
111
- # layout: and scroll: shape the segmented track; see lc_toggle_group_class.
111
+ # layout: and scroll: shape the segmented track; see lc_toggle_group_class. Pills take scroll: true
112
+ # to stay one sideways-scrolling row, or scroll: :narrow to do so only inside a container under @md.
112
113
  def lc_toggle_group(label:, name: nil, value: nil, as: :div, variant: :segmented, size: :md, layout: :inline, scroll: false, **attributes, &block)
113
114
  lc_label!(label, :label)
114
115
  as = lc_option!(:as, as, %i[div nav])
@@ -116,13 +117,16 @@ module Lostcoords::Ui
116
117
  size = lc_option!(:size, size, ButtonHelper::BUTTON_SIZES.keys)
117
118
  layout = lc_option!(:layout, layout, FormHelper::TOGGLE_GROUP_LAYOUTS.keys)
118
119
  raise ArgumentError, "size: sizes pills; a segmented toggle group has one size" if variant == :segmented && size != :md
119
- raise ArgumentError, "layout: and scroll: shape a segmented track; pills wrap" if variant == :pills && (layout != :inline || scroll)
120
+ raise ArgumentError, "layout: shapes a segmented track; pills wrap" if variant == :pills && layout != :inline
121
+ scroll = scroll.to_sym if scroll.is_a?(String)
122
+ allowed_scroll = variant == :pills ? [ false, *FormHelper::PILLS_SCROLL.keys ] : [ false, true ]
123
+ raise ArgumentError, "Invalid scroll: #{scroll.inspect}. Expected one of: #{allowed_scroll.map(&:inspect).join(', ')}" unless allowed_scroll.include?(scroll)
120
124
  raise ArgumentError, "a nav toggle group marks its current link; it takes no name: or value:" if as == :nav && (name || value)
121
125
 
122
126
  mode = as == :nav ? :links : (name ? :radios : :buttons)
123
127
  content = lc_within_toggle_group({ mode: mode, name: name, value: value&.to_s, variant: variant, size: size, layout: layout }) { capture(&block) if block }
124
128
 
125
- defaults = { class: (variant == :pills ? lc_inline_class : lc_toggle_group_class(layout: layout, scroll: scroll)), data: { slot: "toggle-group" } }
129
+ defaults = { class: (variant == :pills ? lc_inline_class(extra: FormHelper::PILLS_SCROLL[scroll]) : lc_toggle_group_class(layout: layout, scroll: scroll)), data: { slot: "toggle-group" } }
126
130
  case mode
127
131
  when :links
128
132
  tag.nav(content, **lc_attributes(defaults, attributes, { aria: { label: label } }))
@@ -96,7 +96,9 @@ export function liftToTopLayer(panel, trigger) {
96
96
  const schedule = () => (frame ??= requestAnimationFrame(place))
97
97
 
98
98
  place()
99
- const resizes = new ResizeObserver(schedule)
99
+ // A resize is delivered before the frame paints, so the panel moves in the frame it grows in:
100
+ // one that outgrows the viewport as its content loads is never painted at the old spot.
101
+ const resizes = new ResizeObserver(place)
100
102
  resizes.observe(panel)
101
103
  window.addEventListener("scroll", schedule, { capture: true, passive: true })
102
104
  window.addEventListener("resize", schedule, { passive: true })
@@ -1,5 +1,5 @@
1
1
  module Lostcoords
2
2
  module Ui
3
- VERSION = "0.14.7"
3
+ VERSION = "0.14.10"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lostcoords-ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.7
4
+ version: 0.14.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lost Coordinates