lostcoords-ui 0.14.8 → 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 +4 -4
- data/README.md +10 -1
- data/app/helpers/lostcoords/ui/form_helper.rb +11 -0
- data/app/helpers/lostcoords/ui/structures_helper.rb +7 -3
- data/lib/lostcoords/ui/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 84077c9a58c40198412c3d229e69015dabe6a80f5a25bd257e22fc18abf73020
|
|
4
|
+
data.tar.gz: 41782f8795d5c8c4e9dd45796ceba268a91f8bc7a427987b8006ec147b749f6f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 38e4ae910c25a3d000052713ec957b36c49b2f1a1f146f31f85e46974514f7c11595351bb07fdf7b874304b0ba48fc3a8b1782f015d19441024ed65fc4f584b1
|
|
7
|
+
data.tar.gz: 3606c135d2aa929104c5072b29c37737b5ce80dab8b471c59da29a2de1431c8101c5ef36d3c06efa362ca44077180b03c78dad9ba69041b39c52f180de74bc22
|
data/README.md
CHANGED
|
@@ -170,6 +170,15 @@ 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
|
+
|
|
173
182
|
## Changes in 0.14.8
|
|
174
183
|
|
|
175
184
|
Nothing needs an edit. Changed:
|
|
@@ -637,7 +646,7 @@ With `name:` they are native radios in labels, which bring their own arrows, sub
|
|
|
637
646
|
`value:` and `checked:`, and the group's `value:` checks the matching item. With `as: :nav` they are links in a
|
|
638
647
|
labelled `nav`; items take `href:` and `current:`. Otherwise they are radio buttons whose selection lives in the
|
|
639
648
|
`lc-selection` controller, which dispatches `lc-selection:change`; items take `value:` and `selected:`. An item
|
|
640
|
-
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.
|
|
641
650
|
Items take `icon:` and `icon_only:` as `lc_toggle` does. A segmented group's `layout: :stacked` puts each item's icon
|
|
642
651
|
over its label, and `layout: :adaptive` makes the group full width and stacks its items only while the group is
|
|
643
652
|
narrower than 24rem. `scroll: true` lets a track wider than its container scroll sideways, its edges fading.
|
|
@@ -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 " \
|
|
@@ -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:
|
|
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 } }))
|