lostcoords-ui 0.7.0 → 0.8.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 +338 -28
- data/app/assets/tailwind/lostcoords/ui/card.css +14 -6
- data/app/assets/tailwind/lostcoords/ui/collapsible.css +6 -0
- data/app/assets/tailwind/lostcoords/ui/components/dialog.css +2 -2
- data/app/assets/tailwind/lostcoords/ui/components/search.css +5 -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/dialog.css +17 -0
- data/app/assets/tailwind/lostcoords/ui/emoji-picker.css +2 -1
- data/app/assets/tailwind/lostcoords/ui/popover.css +6 -4
- data/app/assets/tailwind/lostcoords/ui/search.css +96 -0
- data/app/assets/tailwind/lostcoords/ui/sheet.css +41 -8
- data/app/assets/tailwind/lostcoords/ui/theme.css +18 -0
- data/app/assets/tailwind/lostcoords/ui/toast.css +34 -4
- data/app/assets/tailwind/lostcoords/ui/typography.css +10 -0
- data/app/helpers/lostcoords/ui/badge_helper.rb +33 -15
- data/app/helpers/lostcoords/ui/button_helper.rb +71 -2
- data/app/helpers/lostcoords/ui/choice_helper.rb +9 -16
- data/app/helpers/lostcoords/ui/collapsible_helper.rb +26 -4
- data/app/helpers/lostcoords/ui/dialog_helper.rb +52 -12
- data/app/helpers/lostcoords/ui/form_helper.rb +30 -10
- data/app/helpers/lostcoords/ui/glass_helper.rb +6 -0
- data/app/helpers/lostcoords/ui/layout_helper.rb +13 -5
- data/app/helpers/lostcoords/ui/list_group_helper.rb +95 -0
- data/app/helpers/lostcoords/ui/menu_helper.rb +84 -13
- data/app/helpers/lostcoords/ui/navigation_helper.rb +57 -12
- data/app/helpers/lostcoords/ui/primitives_helper.rb +128 -34
- data/app/helpers/lostcoords/ui/render_attributes_helper.rb +3 -1
- data/app/helpers/lostcoords/ui/search_helper.rb +55 -0
- data/app/helpers/lostcoords/ui/sheet_helper.rb +20 -8
- data/app/helpers/lostcoords/ui/structures_helper.rb +114 -20
- data/app/helpers/lostcoords/ui/tailwind_helper.rb +1 -1
- data/app/helpers/lostcoords/ui/toast_helper.rb +11 -4
- data/app/helpers/lostcoords/ui/typography_helper.rb +5 -3
- data/app/javascript/lostcoords/ui/controllers/lc_menu_controller.js +5 -6
- data/app/javascript/lostcoords/ui/controllers/lc_nav_controller.js +79 -0
- data/app/javascript/lostcoords/ui/controllers/lc_search_controller.js +288 -0
- data/app/javascript/lostcoords/ui/controllers/lc_selection_controller.js +1 -6
- data/app/javascript/lostcoords/ui/controllers/lc_sheet_controller.js +29 -15
- data/app/javascript/lostcoords/ui/helpers/confirm.js +57 -0
- data/app/javascript/lostcoords/ui/helpers/floating_panel.js +9 -0
- data/app/javascript/lostcoords/ui/index.js +4 -2
- data/app/views/lostcoords/ui/components/_lc_collapsible.html.erb +3 -3
- data/app/views/lostcoords/ui/components/_lc_confirm_sheet.html.erb +14 -0
- data/app/views/lostcoords/ui/components/_lc_dialog.html.erb +28 -16
- data/app/views/lostcoords/ui/components/_lc_floating_panel.html.erb +11 -6
- data/app/views/lostcoords/ui/components/_lc_search.html.erb +26 -0
- data/config/locales/en.yml +11 -0
- data/config/locales/es.yml +11 -0
- data/config/locales/ja.yml +11 -0
- data/lib/lostcoords/ui/builders.rb +1 -1
- data/lib/lostcoords/ui/form_builder.rb +27 -12
- data/lib/lostcoords/ui/parts.rb +72 -8
- data/lib/lostcoords/ui/tokens.rb +3 -1
- data/lib/lostcoords/ui/version.rb +1 -1
- metadata +10 -2
- data/app/javascript/lostcoords/ui/controllers/lc_confirm_dialog_controller.js +0 -39
|
@@ -3,9 +3,9 @@
|
|
|
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,navigation,primitives,render_attributes,structures,tailwind,translation,typography}_helper.rb";
|
|
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";
|
|
7
7
|
@source "../../../../javascript/lostcoords/ui/helpers/*.js";
|
|
8
|
-
@source "../../../../javascript/lostcoords/ui/controllers/lc_{copy,kbd,selection,shortcut,tabs,toggle}_controller.js";
|
|
8
|
+
@source "../../../../javascript/lostcoords/ui/controllers/lc_{copy,kbd,nav,selection,shortcut,tabs,toggle}_controller.js";
|
|
9
9
|
@source "../../../../../lib/lostcoords/ui/parts.rb";
|
|
10
10
|
|
|
11
11
|
@import "./glass.css";
|
|
@@ -48,6 +48,23 @@
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
/* The size scale. Content marked data-dialog-size switches the dialog to that size while it is
|
|
52
|
+
inside, so the :has() rules come after the size classes and win over them. */
|
|
53
|
+
--lc-dialog-sm: 24rem;
|
|
54
|
+
--lc-dialog-md: 32rem;
|
|
55
|
+
--lc-dialog-lg: 40rem;
|
|
56
|
+
--lc-dialog-xl: 64rem;
|
|
57
|
+
|
|
58
|
+
&.lc-dialog-context { --lc-dialog-width: 22rem; }
|
|
59
|
+
&.lc-dialog-sm { --lc-dialog-width: var(--lc-dialog-sm); }
|
|
60
|
+
&.lc-dialog-md { --lc-dialog-width: var(--lc-dialog-md); }
|
|
61
|
+
&.lc-dialog-lg { --lc-dialog-width: var(--lc-dialog-lg); }
|
|
62
|
+
&.lc-dialog-xl { --lc-dialog-width: var(--lc-dialog-xl); }
|
|
63
|
+
&:has([data-dialog-size="sm"]) { --lc-dialog-width: var(--lc-dialog-sm); }
|
|
64
|
+
&:has([data-dialog-size="md"]) { --lc-dialog-width: var(--lc-dialog-md); }
|
|
65
|
+
&:has([data-dialog-size="lg"]) { --lc-dialog-width: var(--lc-dialog-lg); }
|
|
66
|
+
&:has([data-dialog-size="xl"]) { --lc-dialog-width: var(--lc-dialog-xl); }
|
|
67
|
+
|
|
51
68
|
&.lc-dialog-context[open]::backdrop {
|
|
52
69
|
background: var(--lc-scrim-soft);
|
|
53
70
|
backdrop-filter: none;
|
|
@@ -219,9 +219,10 @@
|
|
|
219
219
|
&[aria-expanded="true"] { background: color-mix(in oklab, var(--primary) 12%, var(--background)); }
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
+
/* The tone toggle sits in the picker's top row, so the menu opens downward and stays inside the picker. */
|
|
222
223
|
.lc-emoji-picker__tone-menu {
|
|
223
224
|
position: absolute;
|
|
224
|
-
inset-block-
|
|
225
|
+
inset-block-start: calc(100% + 6px);
|
|
225
226
|
inset-inline-end: 0;
|
|
226
227
|
z-index: 4;
|
|
227
228
|
display: flex;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/* Closed is the exit pose, so closing animates too; allow-discrete holds
|
|
2
|
-
display/overlay until it ends. FloatingPanel
|
|
2
|
+
display/overlay until it ends. Open is FloatingPanel's [data-open] or a
|
|
3
|
+
native [popover]'s :popover-open. --lc-popover-from sets the closed pose;
|
|
4
|
+
origin-* utilities set where it grows from. */
|
|
3
5
|
@utility lc-popover-shell {
|
|
4
6
|
opacity: 0;
|
|
5
|
-
transform: translateY(--spacing(-1)) scale(0.98);
|
|
7
|
+
transform: var(--lc-popover-from, translateY(--spacing(-1)) scale(0.98));
|
|
6
8
|
pointer-events: none;
|
|
7
9
|
transition:
|
|
8
10
|
opacity 160ms var(--lc-ease-out-expo),
|
|
@@ -10,14 +12,14 @@
|
|
|
10
12
|
display 160ms allow-discrete,
|
|
11
13
|
overlay 160ms allow-discrete;
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
&:is([data-open], :popover-open) {
|
|
14
16
|
opacity: 1;
|
|
15
17
|
transform: translateY(0) scale(1);
|
|
16
18
|
pointer-events: auto;
|
|
17
19
|
|
|
18
20
|
@starting-style {
|
|
19
21
|
opacity: 0;
|
|
20
|
-
transform: translateY(--spacing(-1)) scale(0.98);
|
|
22
|
+
transform: var(--lc-popover-from, translateY(--spacing(-1)) scale(0.98));
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/* lc_search: a pill trigger that opens a full-screen search over a
|
|
2
|
+
blurred page. The controller animates it open and closed. */
|
|
3
|
+
@layer components {
|
|
4
|
+
.lc-search-trigger {
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
gap: var(--spacing-related);
|
|
8
|
+
min-block-size: var(--spacing-control-sm);
|
|
9
|
+
padding-inline: var(--spacing-heading);
|
|
10
|
+
border: 0;
|
|
11
|
+
border-radius: var(--radius-pill);
|
|
12
|
+
background: var(--muted);
|
|
13
|
+
color: var(--muted-foreground);
|
|
14
|
+
font-size: var(--text-label);
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
transition: background-color var(--lc-motion-control), color var(--lc-motion-control);
|
|
17
|
+
|
|
18
|
+
&:hover { background: var(--accent); color: var(--foreground); }
|
|
19
|
+
|
|
20
|
+
/* The bar grows out of the trigger, so the trigger steps aside while search is open. */
|
|
21
|
+
[data-slot="search"][data-open] & { opacity: 0; }
|
|
22
|
+
|
|
23
|
+
@media (width < 40rem) {
|
|
24
|
+
justify-content: center;
|
|
25
|
+
inline-size: var(--spacing-control-sm);
|
|
26
|
+
padding-inline: 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@media (width >= 40rem) { inline-size: calc(var(--spacing) * 64); }
|
|
30
|
+
@media (width >= 80rem) { inline-size: calc(var(--spacing) * 84); }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.lc-search {
|
|
34
|
+
position: fixed;
|
|
35
|
+
inset: 0;
|
|
36
|
+
inline-size: 100%;
|
|
37
|
+
max-inline-size: none;
|
|
38
|
+
block-size: 100%;
|
|
39
|
+
max-block-size: none;
|
|
40
|
+
margin: 0;
|
|
41
|
+
padding: 0;
|
|
42
|
+
overflow: hidden;
|
|
43
|
+
border: 0;
|
|
44
|
+
background: transparent;
|
|
45
|
+
color: var(--foreground);
|
|
46
|
+
|
|
47
|
+
/* Safari drops custom properties inside -webkit-backdrop-filter, so the blur is literal. */
|
|
48
|
+
&::backdrop {
|
|
49
|
+
background: var(--lc-scrim-veil);
|
|
50
|
+
-webkit-backdrop-filter: blur(20px) saturate(160%);
|
|
51
|
+
backdrop-filter: blur(20px) saturate(160%);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@media (prefers-reduced-transparency: reduce) {
|
|
55
|
+
&::backdrop {
|
|
56
|
+
background: var(--background);
|
|
57
|
+
-webkit-backdrop-filter: none;
|
|
58
|
+
backdrop-filter: none;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* Rows and groups carry display utilities, which outrank this layer unless it is important. */
|
|
63
|
+
[hidden] { display: none !important; }
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.lc-search-stack {
|
|
67
|
+
display: flex;
|
|
68
|
+
flex-direction: column;
|
|
69
|
+
gap: var(--spacing-heading);
|
|
70
|
+
inline-size: min(calc(var(--spacing) * 160), calc(100% - var(--spacing) * 6));
|
|
71
|
+
block-size: 100%;
|
|
72
|
+
margin-inline: auto;
|
|
73
|
+
padding-block:
|
|
74
|
+
max(var(--spacing-heading), env(safe-area-inset-top))
|
|
75
|
+
max(var(--spacing-heading), env(safe-area-inset-bottom));
|
|
76
|
+
|
|
77
|
+
@media (width >= 40rem) { padding-block-start: 14vh; }
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.lc-search-input::-webkit-search-cancel-button {
|
|
81
|
+
/* stylelint-disable-next-line property-no-vendor-prefix -- The clear button has an accessible label. */
|
|
82
|
+
-webkit-appearance: none;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.lc-search-panel {
|
|
86
|
+
--lc-glass-fill: color-mix(in oklab, var(--background) 82%, transparent);
|
|
87
|
+
|
|
88
|
+
@media (width >= 40rem) { max-block-size: min(60dvh, calc(var(--spacing) * 136)); }
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.lc-search-result {
|
|
92
|
+
color: var(--foreground);
|
|
93
|
+
|
|
94
|
+
&:is(:hover, :focus-visible) { background: color-mix(in oklab, var(--foreground) 6%, transparent); }
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
@layer components {
|
|
2
2
|
@media (width < 40rem) {
|
|
3
3
|
/* UIKit's 36×5 grabber. */
|
|
4
|
-
:is(
|
|
4
|
+
:is(
|
|
5
|
+
[data-lc-sheet-target~="handle"],
|
|
6
|
+
:is(dialog[data-controller~="lc-sheet"], .lc-sheet):not(:has([data-lc-sheet-target~="handle"]))
|
|
7
|
+
)::before {
|
|
5
8
|
content: "";
|
|
6
9
|
display: block;
|
|
7
10
|
inline-size: 2.25rem;
|
|
@@ -10,15 +13,37 @@
|
|
|
10
13
|
background: color-mix(in oklab, var(--muted-foreground) 45%, transparent);
|
|
11
14
|
}
|
|
12
15
|
}
|
|
16
|
+
|
|
17
|
+
/* From sm up an anchored sheet is a popover under its trigger, opened by a
|
|
18
|
+
FloatingPanel ([data-open]); the positioned ancestor is the caller's. */
|
|
19
|
+
@media (width >= 40rem) {
|
|
20
|
+
.lc-sheet-anchored {
|
|
21
|
+
@apply lc-popover-shell;
|
|
22
|
+
|
|
23
|
+
display: none;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
position: absolute;
|
|
26
|
+
inset-block: calc(100% + --spacing(2)) auto;
|
|
27
|
+
inset-inline: auto 0;
|
|
28
|
+
z-index: var(--lc-z-popover);
|
|
29
|
+
inline-size: min(24rem, calc(100vw - --spacing(8)));
|
|
30
|
+
max-block-size: min(28rem, calc(100vh - --spacing(24)));
|
|
31
|
+
border-radius: var(--radius-3xl);
|
|
32
|
+
|
|
33
|
+
&[data-open] { display: flex; }
|
|
34
|
+
}
|
|
35
|
+
}
|
|
13
36
|
}
|
|
14
37
|
|
|
15
38
|
@layer modules {
|
|
16
|
-
/* Phones: every modal dialog is an iOS sheet (lc-sheet)
|
|
17
|
-
inset with all corners round while it is short,
|
|
18
|
-
edges as it reaches the large detent: --lc-sheet-p
|
|
19
|
-
Lives in this layer so it out-ranks a
|
|
39
|
+
/* Phones: every modal dialog is an iOS sheet (lc-sheet), and so is any
|
|
40
|
+
.lc-sheet panel. It floats inset with all corners round while it is short,
|
|
41
|
+
and docks to the screen edges as it reaches the large detent: --lc-sheet-p
|
|
42
|
+
runs 0 → 1 between them. Lives in this layer so it out-ranks a panel's own
|
|
43
|
+
frame. A dialog is open while [open]; a .lc-sheet while :popover-open or
|
|
44
|
+
[data-open]. */
|
|
20
45
|
@media (width < 40rem) {
|
|
21
|
-
dialog[data-controller~="lc-sheet"] {
|
|
46
|
+
:is(dialog[data-controller~="lc-sheet"], .lc-sheet) {
|
|
22
47
|
--lc-sheet-p: 0;
|
|
23
48
|
--lc-sheet-inset: 0.5rem;
|
|
24
49
|
--lc-sheet-radius: 2.25rem;
|
|
@@ -54,7 +79,7 @@
|
|
|
54
79
|
display var(--lc-sheet-duration) allow-discrete,
|
|
55
80
|
overlay var(--lc-sheet-duration) allow-discrete;
|
|
56
81
|
|
|
57
|
-
|
|
82
|
+
&:is([open], :popover-open, .lc-sheet[data-open]) {
|
|
58
83
|
transform: none;
|
|
59
84
|
|
|
60
85
|
@starting-style { transform: translateY(var(--lc-sheet-offscreen)); }
|
|
@@ -78,7 +103,7 @@
|
|
|
78
103
|
overlay var(--lc-sheet-duration) allow-discrete;
|
|
79
104
|
}
|
|
80
105
|
|
|
81
|
-
|
|
106
|
+
&:is([open], :popover-open)::backdrop {
|
|
82
107
|
opacity: 1;
|
|
83
108
|
|
|
84
109
|
@starting-style { opacity: 0; }
|
|
@@ -89,6 +114,14 @@
|
|
|
89
114
|
}
|
|
90
115
|
}
|
|
91
116
|
|
|
117
|
+
.lc-sheet {
|
|
118
|
+
z-index: var(--lc-z-overlay);
|
|
119
|
+
display: none;
|
|
120
|
+
flex-direction: column;
|
|
121
|
+
|
|
122
|
+
&:is(:popover-open, [data-open]) { display: flex; }
|
|
123
|
+
}
|
|
124
|
+
|
|
92
125
|
/* Behind a large sheet the page shrinks back and rounds off, over black,
|
|
93
126
|
as UIKit's page sheet does; lc-sheet drives the variables. */
|
|
94
127
|
html[data-lc-sheet-page] {
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
|
|
71
71
|
@theme {
|
|
72
72
|
--font-display: var(--font-sans);
|
|
73
|
+
--font-eyebrow: var(--font-mono);
|
|
73
74
|
--font-japanese: "Hiragino Sans", "Yu Gothic", "YuGothic", "Meiryo", ui-sans-serif, system-ui, sans-serif;
|
|
74
75
|
|
|
75
76
|
/* Type roles. Each sets size, line height, tracking and weight together. */
|
|
@@ -98,6 +99,10 @@
|
|
|
98
99
|
--text-label--font-weight: 500;
|
|
99
100
|
--text-caption: 0.75rem;
|
|
100
101
|
--text-caption--line-height: 1rem;
|
|
102
|
+
--text-eyebrow: 0.75rem;
|
|
103
|
+
--text-eyebrow--line-height: 1rem;
|
|
104
|
+
--text-eyebrow--letter-spacing: 0.1em;
|
|
105
|
+
--text-eyebrow--font-weight: 500;
|
|
101
106
|
|
|
102
107
|
--container-page: 75rem;
|
|
103
108
|
--container-reading: 65ch;
|
|
@@ -136,6 +141,10 @@
|
|
|
136
141
|
--lc-z-overlay: 60;
|
|
137
142
|
--lc-z-toast: 70;
|
|
138
143
|
|
|
144
|
+
/* Distance from the screen edge to the toast region, on top of the safe area.
|
|
145
|
+
--lc-toast-offset-top and --lc-toast-offset-bottom override one edge. */
|
|
146
|
+
--lc-toast-offset: var(--lc-gutter);
|
|
147
|
+
|
|
139
148
|
--background: oklch(100% 0 0deg);
|
|
140
149
|
--foreground: oklch(23.1% 0 0deg);
|
|
141
150
|
|
|
@@ -148,6 +157,11 @@
|
|
|
148
157
|
--primary-foreground: #fff;
|
|
149
158
|
--secondary: var(--accent);
|
|
150
159
|
--secondary-foreground: var(--foreground);
|
|
160
|
+
|
|
161
|
+
/* Fields and secondary buttons inside a card. Point them at another fill when --card
|
|
162
|
+
matches --input or --secondary, or they vanish on cards. */
|
|
163
|
+
--card-input: var(--input);
|
|
164
|
+
--card-secondary: var(--secondary);
|
|
151
165
|
--muted: oklch(97.6% 0 0deg);
|
|
152
166
|
--muted-foreground: oklch(48% 0 0deg);
|
|
153
167
|
--accent: oklch(95.2% 0 0deg);
|
|
@@ -161,6 +175,9 @@
|
|
|
161
175
|
--lc-scrim: color-mix(in oklab, var(--foreground) 55%, transparent);
|
|
162
176
|
--lc-scrim-soft: color-mix(in oklab, var(--foreground) 12%, transparent);
|
|
163
177
|
--lc-scrim-sheet: rgb(0 0 0 / 0.28);
|
|
178
|
+
|
|
179
|
+
/* Behind full-screen search: a light veil, so the blurred page still shows through. */
|
|
180
|
+
--lc-scrim-veil: color-mix(in oklab, var(--background) 35%, transparent);
|
|
164
181
|
--lc-input-hover: color-mix(in oklab, var(--foreground) 13%, var(--accent));
|
|
165
182
|
|
|
166
183
|
--lc-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.05);
|
|
@@ -211,6 +228,7 @@
|
|
|
211
228
|
|
|
212
229
|
--lc-scrim: rgb(0 0 0 / 0.6);
|
|
213
230
|
--lc-scrim-soft: rgb(0 0 0 / 0.32);
|
|
231
|
+
--lc-scrim-veil: rgb(0 0 0 / 0.4);
|
|
214
232
|
|
|
215
233
|
--lc-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.2);
|
|
216
234
|
--lc-shadow:
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
@layer components {
|
|
2
2
|
/* lc-toast-region opens it as a popover; these rules also override the
|
|
3
|
-
popover defaults, which would centre it and hide it while closed.
|
|
3
|
+
popover defaults, which would centre it and hide it while closed. A
|
|
4
|
+
mobile placement sets every edge, so it fully replaces the desktop one. */
|
|
4
5
|
.lc-toast-region {
|
|
6
|
+
--_lc-toast-top: calc(var(--lc-toast-offset-top, var(--lc-toast-offset)) + env(safe-area-inset-top));
|
|
7
|
+
--_lc-toast-bottom: calc(var(--lc-toast-offset-bottom, var(--lc-toast-offset)) + env(safe-area-inset-bottom));
|
|
8
|
+
|
|
5
9
|
position: fixed;
|
|
6
|
-
inset: auto var(--
|
|
10
|
+
inset-block: auto var(--_lc-toast-bottom);
|
|
11
|
+
inset-inline: auto var(--lc-toast-offset);
|
|
7
12
|
z-index: var(--lc-z-toast);
|
|
8
13
|
display: flex;
|
|
9
14
|
flex-direction: column;
|
|
10
15
|
align-items: flex-end;
|
|
11
16
|
gap: var(--spacing-related);
|
|
12
|
-
|
|
17
|
+
inline-size: fit-content;
|
|
18
|
+
max-inline-size: calc(100vw - var(--lc-toast-offset) * 2);
|
|
13
19
|
margin: 0;
|
|
14
20
|
padding: 0;
|
|
15
21
|
overflow: visible;
|
|
@@ -17,7 +23,31 @@
|
|
|
17
23
|
background: none;
|
|
18
24
|
color: inherit;
|
|
19
25
|
|
|
20
|
-
|
|
26
|
+
&[data-placement^="top"] { inset-block: var(--_lc-toast-top) auto; }
|
|
27
|
+
|
|
28
|
+
&[data-placement$="center"] {
|
|
29
|
+
inset-inline: var(--lc-toast-offset);
|
|
30
|
+
margin-inline: auto;
|
|
31
|
+
align-items: center;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@media (width < 40rem) {
|
|
35
|
+
&[data-mobile-placement^="top"] { inset-block: var(--_lc-toast-top) auto; }
|
|
36
|
+
&[data-mobile-placement^="bottom"] { inset-block: auto var(--_lc-toast-bottom); }
|
|
37
|
+
|
|
38
|
+
&[data-mobile-placement$="center"] {
|
|
39
|
+
inset-inline: var(--lc-toast-offset);
|
|
40
|
+
margin-inline: auto;
|
|
41
|
+
align-items: center;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&[data-mobile-placement$="end"] {
|
|
45
|
+
inset-inline: auto var(--lc-toast-offset);
|
|
46
|
+
margin-inline: 0;
|
|
47
|
+
align-items: flex-end;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
21
51
|
&:empty { display: none; }
|
|
22
52
|
}
|
|
23
53
|
}
|
|
@@ -12,6 +12,16 @@
|
|
|
12
12
|
overflow-wrap: anywhere;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
:where(.lc-eyebrow) {
|
|
16
|
+
font-family: var(--font-eyebrow);
|
|
17
|
+
text-transform: uppercase;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
:where(.lc-eyebrow):lang(ja) {
|
|
21
|
+
font-family: var(--font-sans);
|
|
22
|
+
text-transform: none;
|
|
23
|
+
}
|
|
24
|
+
|
|
15
25
|
/* Type role utilities read --tw-tracking first, so this wins over their tracking. */
|
|
16
26
|
:where(.lc-heading, .lc-text):lang(ja) {
|
|
17
27
|
--tw-tracking: 0;
|
|
@@ -4,31 +4,44 @@ module Lostcoords::Ui
|
|
|
4
4
|
"lc-icon-badge grid place-items-center shrink-0 " \
|
|
5
5
|
"size-[var(--lc-icon-badge-size,var(--lc-icon-badge-size-default,--spacing(10)))] " \
|
|
6
6
|
"[border:var(--lc-icon-badge-border,1px_solid_transparent)] " \
|
|
7
|
-
"text-[length:var(--lc-icon-badge-font-size,var(--lc-icon-badge-
|
|
7
|
+
"text-[length:var(--lc-icon-badge-font-size,calc(var(--lc-icon-badge-size,var(--lc-icon-badge-size-default,--spacing(10)))*var(--lc-icon-badge-font-scale,var(--lc-icon-badge-font-scale-default,0.45))))] leading-none"
|
|
8
8
|
|
|
9
|
-
# Sizes set the
|
|
9
|
+
# Sizes set the defaults, so a context that pins --lc-icon-badge-size still wins and the emoji
|
|
10
|
+
# or icon follows it. --lc-icon-badge-font-scale sets the glyph's share of the badge.
|
|
10
11
|
ICON_BADGE_SIZES = {
|
|
11
|
-
sm: "[--lc-icon-badge-size-default:--spacing(6.5)] [--lc-icon-badge-font-
|
|
12
|
+
sm: "[--lc-icon-badge-size-default:--spacing(6.5)] [--lc-icon-badge-font-scale-default:0.5]",
|
|
12
13
|
md: "",
|
|
13
|
-
lg: "[--lc-icon-badge-size-default:--spacing(12)] [--lc-icon-badge-font-
|
|
14
|
-
xl: "[--lc-icon-badge-size-default:--spacing(14)] [--lc-icon-badge-font-
|
|
14
|
+
lg: "[--lc-icon-badge-size-default:--spacing(12)] [--lc-icon-badge-font-scale-default:0.5]",
|
|
15
|
+
xl: "[--lc-icon-badge-size-default:--spacing(14)] [--lc-icon-badge-font-scale-default:0.5]",
|
|
16
|
+
# Steps on the spacing scale, as in size-7, for row glyphs between the named sizes.
|
|
17
|
+
6 => "[--lc-icon-badge-size-default:--spacing(6)] [--lc-icon-badge-font-scale-default:0.5]",
|
|
18
|
+
7 => "[--lc-icon-badge-size-default:--spacing(7)] [--lc-icon-badge-font-scale-default:0.5]",
|
|
19
|
+
11 => "[--lc-icon-badge-size-default:--spacing(11)] [--lc-icon-badge-font-scale-default:0.5]"
|
|
15
20
|
}.freeze
|
|
16
21
|
|
|
17
|
-
|
|
22
|
+
# plain drops the tile: the emoji or icon is the badge, as at the start of a list row.
|
|
23
|
+
ICON_BADGE_SHAPES = { square: "lc-squircle rounded-2xl", circle: "rounded-full", plain: "rounded-none" }.freeze
|
|
24
|
+
ICON_BADGE_PLAIN = "bg-transparent [--lc-icon-badge-font-scale-default:0.875]"
|
|
18
25
|
|
|
19
26
|
AVATAR_BASE =
|
|
20
27
|
"lc-avatar grid place-items-center shrink-0 rounded-full font-medium tracking-[var(--lc-avatar-tracking,0.05em)] " \
|
|
21
28
|
"size-[var(--lc-avatar-size,var(--lc-avatar-size-default,--spacing(8)))] " \
|
|
22
|
-
"text-[length:var(--lc-avatar-font-size,var(--lc-avatar-
|
|
29
|
+
"text-[length:var(--lc-avatar-font-size,calc(var(--lc-avatar-size,var(--lc-avatar-size-default,--spacing(8)))*var(--lc-avatar-font-scale,var(--lc-avatar-font-scale-default,0.375))))] " \
|
|
23
30
|
"text-[color:var(--lc-avatar-color,var(--primary-foreground))] " \
|
|
24
31
|
"border-[length:var(--lc-avatar-border,0px)] border-[color:var(--lc-avatar-cutout,var(--background))]"
|
|
25
32
|
|
|
26
|
-
# Sizes set the
|
|
33
|
+
# Sizes set the defaults, so a context that pins --lc-avatar-size (a stack, a dialog) still wins
|
|
34
|
+
# and the initials follow it. --lc-avatar-font-scale sets their share of the avatar.
|
|
27
35
|
AVATAR_SIZES = {
|
|
36
|
+
xs: "[--lc-avatar-size-default:--spacing(5)] [--lc-avatar-font-scale-default:0.4]",
|
|
37
|
+
sm: "[--lc-avatar-size-default:--spacing(6.5)] [--lc-avatar-font-scale-default:0.385]",
|
|
28
38
|
md: "",
|
|
29
|
-
lg: "[--lc-avatar-size-default:--spacing(12)] [--lc-avatar-font-
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
lg: "[--lc-avatar-size-default:--spacing(12)] [--lc-avatar-font-scale-default:0.333]",
|
|
40
|
+
xl: "[--lc-avatar-size-default:--spacing(24)] [--lc-avatar-font-scale-default:0.208]",
|
|
41
|
+
xxl: "[--lc-avatar-size-default:--spacing(28)] [--lc-avatar-font-scale-default:0.25]",
|
|
42
|
+
# Steps on the spacing scale, as in size-7, between the named sizes.
|
|
43
|
+
7 => "[--lc-avatar-size-default:--spacing(7)]",
|
|
44
|
+
11 => "[--lc-avatar-size-default:--spacing(11)] [--lc-avatar-font-scale-default:0.35]"
|
|
32
45
|
}.freeze
|
|
33
46
|
|
|
34
47
|
AVATAR_INK = "[--lc-avatar-color:var(--foreground)]"
|
|
@@ -65,16 +78,20 @@ module Lostcoords::Ui
|
|
|
65
78
|
primary: "bg-primary-soft text-primary"
|
|
66
79
|
}.freeze
|
|
67
80
|
|
|
81
|
+
BADGE_SHAPES = { rounded: "", pill: "rounded-full px-2.5" }.freeze
|
|
82
|
+
|
|
68
83
|
TOGGLE_BASE =
|
|
69
84
|
"inline-flex items-center justify-center gap-related rounded-pill " \
|
|
70
|
-
"border border-transparent bg-input " \
|
|
85
|
+
"border border-transparent bg-(--lc-field-bg,var(--input)) " \
|
|
71
86
|
"font-sans text-muted-foreground whitespace-nowrap cursor-pointer no-underline " \
|
|
72
87
|
"transition-[background-color,border-color,color,transform] duration-(--lc-motion-quick) ease-(--lc-ease-out) " \
|
|
73
88
|
"lc-press hover:text-foreground " \
|
|
74
89
|
"aria-pressed:bg-primary-soft aria-pressed:border-primary aria-pressed:text-primary aria-pressed:shadow-none " \
|
|
90
|
+
"aria-checked:bg-primary-soft aria-checked:border-primary aria-checked:text-primary aria-checked:shadow-none " \
|
|
75
91
|
"aria-[current]:not-aria-[current=false]:bg-primary-soft aria-[current]:not-aria-[current=false]:border-primary " \
|
|
76
92
|
"aria-[current]:not-aria-[current=false]:text-primary aria-[current]:not-aria-[current=false]:shadow-none " \
|
|
77
93
|
"has-checked:bg-primary-soft has-checked:border-primary has-checked:text-primary has-checked:shadow-none " \
|
|
94
|
+
"aria-expanded:bg-primary-soft aria-expanded:border-primary aria-expanded:text-primary aria-expanded:shadow-none " \
|
|
78
95
|
"[&_svg]:size-[1.1em] [&_svg]:shrink-0"
|
|
79
96
|
|
|
80
97
|
TOGGLE_ACTIVE = "bg-primary-soft border-primary text-primary hover:text-primary shadow-none"
|
|
@@ -86,7 +103,7 @@ module Lostcoords::Ui
|
|
|
86
103
|
shape = lc_option!(:shape, shape, ICON_BADGE_SHAPES.keys)
|
|
87
104
|
tone = lc_option!(:tone, tone, BADGE_TONES.keys)
|
|
88
105
|
lc_tw(ICON_BADGE_BASE, ICON_BADGE_SIZES.fetch(size), ICON_BADGE_SHAPES.fetch(shape),
|
|
89
|
-
(tone == :neutral ? "bg-tile text-foreground" : BADGE_TONES.fetch(tone)), extra)
|
|
106
|
+
(tone == :neutral ? "bg-tile text-foreground" : BADGE_TONES.fetch(tone)), (ICON_BADGE_PLAIN if shape == :plain), extra)
|
|
90
107
|
end
|
|
91
108
|
|
|
92
109
|
def lc_avatar_class(size: :md, ink: false, linked: false, extra: nil)
|
|
@@ -101,9 +118,10 @@ module Lostcoords::Ui
|
|
|
101
118
|
lc_tw(AVATAR_STACK_ROW, extra)
|
|
102
119
|
end
|
|
103
120
|
|
|
104
|
-
def lc_badge_class(tone: :neutral, extra: nil)
|
|
121
|
+
def lc_badge_class(tone: :neutral, shape: :rounded, extra: nil)
|
|
105
122
|
tone = lc_option!(:tone, tone, BADGE_TONES.keys)
|
|
106
|
-
|
|
123
|
+
shape = lc_option!(:shape, shape, BADGE_SHAPES.keys)
|
|
124
|
+
lc_tw(BADGE_BASE, BADGE_SHAPES.fetch(shape), BADGE_TONES.fetch(tone), extra)
|
|
107
125
|
end
|
|
108
126
|
|
|
109
127
|
def lc_toggle_class(active: false, ghost: false, size: :md, extra: nil)
|
|
@@ -33,6 +33,54 @@ module Lostcoords::Ui
|
|
|
33
33
|
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
34
|
}.freeze
|
|
35
35
|
|
|
36
|
+
BUTTON_DESTRUCTIVE_INK = "text-destructive [--lc-button-ink:var(--destructive)]"
|
|
37
|
+
BUTTON_DESTRUCTIVE_SOFT = "[--lc-button-bg:color-mix(in_oklab,var(--destructive)_12%,var(--background))]"
|
|
38
|
+
|
|
39
|
+
# A tone recolours a variant without changing its emphasis, so a destructive action can stay quiet.
|
|
40
|
+
BUTTON_TONES = {
|
|
41
|
+
default: BUTTON_VARIANTS.transform_values { "" },
|
|
42
|
+
destructive: {
|
|
43
|
+
primary: "[--lc-button-bg:color-mix(in_oklab,var(--destructive)_60%,black)] [--lc-button-ink:#fff]",
|
|
44
|
+
secondary: "#{BUTTON_DESTRUCTIVE_INK} #{BUTTON_DESTRUCTIVE_SOFT}",
|
|
45
|
+
outline: "#{BUTTON_DESTRUCTIVE_INK} border-[color-mix(in_oklab,var(--destructive)_32%,var(--border))]",
|
|
46
|
+
glass: BUTTON_DESTRUCTIVE_INK,
|
|
47
|
+
ghost: "#{BUTTON_DESTRUCTIVE_INK} #{BUTTON_DESTRUCTIVE_SOFT}",
|
|
48
|
+
destructive: ""
|
|
49
|
+
}
|
|
50
|
+
}.freeze
|
|
51
|
+
|
|
52
|
+
SELECT_TRIGGER_BASE =
|
|
53
|
+
"inline-flex items-center justify-start gap-related min-w-0 max-w-full ps-4 pe-3 " \
|
|
54
|
+
"rounded-pill border border-transparent bg-(--lc-field-bg,var(--input)) " \
|
|
55
|
+
"font-sans text-base text-start text-foreground whitespace-nowrap no-underline cursor-pointer " \
|
|
56
|
+
"transition-[background-color,color] duration-(--lc-motion-quick) ease-(--lc-ease-out) " \
|
|
57
|
+
"not-disabled:hover:bg-(--lc-input-hover) aria-expanded:bg-(--lc-input-hover) " \
|
|
58
|
+
"disabled:cursor-not-allowed disabled:text-[color-mix(in_oklab,var(--foreground)_38%,transparent)] " \
|
|
59
|
+
"[&_svg]:block [&_svg]:shrink-0 " \
|
|
60
|
+
"[&>[data-icon=inline-end]]:ms-auto [&>[data-icon=inline-end]]:size-5 [&>[data-icon=inline-end]]:text-muted-foreground " \
|
|
61
|
+
"motion-safe:[&>[data-icon=inline-end]]:transition-transform motion-safe:[&>[data-icon=inline-end]]:duration-(--lc-motion-quick) " \
|
|
62
|
+
"aria-expanded:[&>[data-icon=inline-end]]:rotate-180"
|
|
63
|
+
|
|
64
|
+
SPLIT_BUTTON_BASE = "relative inline-flex max-w-full min-w-0 items-stretch"
|
|
65
|
+
|
|
66
|
+
SPLIT_BUTTON_ACTION = "min-w-0 flex-1 rounded-e-none border-e-0"
|
|
67
|
+
|
|
68
|
+
# The two halves press as one pill, so neither lifts on its own.
|
|
69
|
+
SPLIT_BUTTON_PART = "motion-safe:not-disabled:hover:translate-y-0 motion-safe:not-disabled:active:translate-y-0"
|
|
70
|
+
|
|
71
|
+
SPLIT_BUTTON_TOGGLE =
|
|
72
|
+
"shrink-0 px-0 rounded-s-none aria-expanded:bg-[color-mix(in_oklab,var(--lc-button-bg,var(--secondary))_94%,var(--lc-button-ink,var(--foreground)))] [&_svg]:size-4 " \
|
|
73
|
+
"motion-safe:[&_svg]:transition-transform motion-safe:[&_svg]:duration-(--lc-motion-quick) aria-expanded:[&_svg]:rotate-180"
|
|
74
|
+
|
|
75
|
+
SPLIT_BUTTON_TOGGLE_WIDTHS = {
|
|
76
|
+
sm: "w-control-sm",
|
|
77
|
+
md: "w-control-md",
|
|
78
|
+
lg: "w-control-lg"
|
|
79
|
+
}.freeze
|
|
80
|
+
|
|
81
|
+
# Outline halves already share a visible edge; filled and transparent halves draw one from their ink.
|
|
82
|
+
SPLIT_BUTTON_DIVIDER = "border-s border-s-[color-mix(in_oklab,currentColor_24%,transparent)]"
|
|
83
|
+
|
|
36
84
|
ICON_BUTTON_BASE =
|
|
37
85
|
"lc-press inline-grid place-items-center shrink-0 border-0 bg-transparent " \
|
|
38
86
|
"text-muted-foreground cursor-pointer no-underline " \
|
|
@@ -52,26 +100,47 @@ module Lostcoords::Ui
|
|
|
52
100
|
lg: "size-control-lg [&_svg]:size-6"
|
|
53
101
|
}.freeze
|
|
54
102
|
|
|
55
|
-
|
|
103
|
+
# A row action that stays out of the way until it is hovered, focused or open.
|
|
104
|
+
ICON_BUTTON_QUIET =
|
|
105
|
+
"focus-visible:text-foreground aria-expanded:text-foreground " \
|
|
106
|
+
"motion-safe:[&_svg]:transition-transform motion-safe:[&_svg]:duration-(--lc-motion-control) motion-safe:[&_svg]:ease-(--lc-ease-out-expo) " \
|
|
107
|
+
"motion-safe:not-disabled:hover:[&_svg]:scale-125 motion-safe:focus-visible:[&_svg]:scale-125 motion-safe:aria-expanded:[&_svg]:scale-125"
|
|
108
|
+
|
|
109
|
+
def lc_button_class(variant: :primary, tone: :default, size: :md, block: false, extra: nil)
|
|
56
110
|
variant = lc_option!(:variant, variant, BUTTON_VARIANTS.keys)
|
|
111
|
+
tone = lc_option!(:tone, tone, BUTTON_TONES.keys)
|
|
57
112
|
size = lc_option!(:size, size, BUTTON_SIZES.keys)
|
|
58
113
|
lc_tw(
|
|
59
114
|
BUTTON_BASE,
|
|
60
115
|
BUTTON_SIZES.fetch(size),
|
|
61
116
|
(lc_glass_class(shape: :bar) if variant == :glass),
|
|
62
117
|
BUTTON_VARIANTS.fetch(variant),
|
|
118
|
+
BUTTON_TONES.fetch(tone).fetch(variant),
|
|
63
119
|
("w-full" if block),
|
|
64
120
|
extra
|
|
65
121
|
)
|
|
66
122
|
end
|
|
67
123
|
|
|
68
|
-
|
|
124
|
+
# A button that reads as a select: start-aligned content and a trailing chevron that turns while
|
|
125
|
+
# aria-expanded is true. Use it for buttons that open a menu or picker.
|
|
126
|
+
def lc_select_trigger_class(size: :md, block: false, extra: nil)
|
|
127
|
+
size = lc_option!(:size, size, TailwindHelper::CONTROL_SIZES.keys)
|
|
128
|
+
lc_tw(SELECT_TRIGGER_BASE, TailwindHelper::CONTROL_SIZES.fetch(size), ("w-full" if block), extra)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# 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)
|
|
69
133
|
shape = lc_option!(:shape, shape, ICON_BUTTON_SHAPES.keys)
|
|
70
134
|
size = lc_option!(:size, size, ICON_BUTTON_SIZES.keys)
|
|
135
|
+
variant = lc_option!(:variant, variant, BUTTON_VARIANTS.keys)
|
|
136
|
+
tone = lc_option!(:tone, tone, BUTTON_TONES.keys)
|
|
71
137
|
lc_tw(
|
|
72
138
|
ICON_BUTTON_BASE,
|
|
73
139
|
ICON_BUTTON_SHAPES.fetch(shape),
|
|
74
140
|
ICON_BUTTON_SIZES.fetch(size),
|
|
141
|
+
(lc_glass_class(shape: :bar) if variant == :glass),
|
|
142
|
+
(BUTTON_VARIANTS.fetch(variant) unless variant == :ghost),
|
|
143
|
+
BUTTON_TONES.fetch(tone).fetch(variant),
|
|
75
144
|
extra
|
|
76
145
|
)
|
|
77
146
|
end
|
|
@@ -28,7 +28,8 @@ module Lostcoords::Ui
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
# A native checkbox. unchecked_value: submits a value when unchecked, like Rails' check_box; pass nil to omit it.
|
|
31
|
-
# A block adds content under the label, such as a preview inside a card: true tile.
|
|
31
|
+
# A block adds content under the label, such as a preview inside a card: true tile. A nil label renders the
|
|
32
|
+
# bare input for a row selector the row labels, which then needs aria: { label: }.
|
|
32
33
|
def lc_checkbox(label, name: nil, value: "1", checked: false, unchecked_value: "0", hint: nil, card: false, **attributes, &block)
|
|
33
34
|
lc_choice("checkbox", label, hint, card, name, unchecked_value, { type: "checkbox", name: name, value: value, checked: checked, class: lc_checkbox_class }, attributes, &block)
|
|
34
35
|
end
|
|
@@ -42,28 +43,20 @@ module Lostcoords::Ui
|
|
|
42
43
|
lc_choice("switch", label, hint, false, name, unchecked_value, { type: "checkbox", role: "switch", name: name, value: value, checked: checked, class: lc_switch_class }, attributes)
|
|
43
44
|
end
|
|
44
45
|
|
|
45
|
-
#
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
errors = Array(error).compact_blank
|
|
50
|
-
described = [ ("#{id}-hint" if id && hint.present?), ("#{id}-error" if id && errors.any?) ].compact.presence&.join(" ")
|
|
51
|
-
defaults = { id: id, class: lc_field_class(extra: "m-0 min-w-0 border-0 p-0"), aria: { invalid: (true if errors.any?), describedby: described }, data: { slot: "choice-group", invalid: (true if errors.any?) } }
|
|
52
|
-
tag.fieldset(**lc_attributes(defaults, attributes)) do
|
|
53
|
-
safe_join([
|
|
54
|
-
tag.legend(legend, class: lc_field_label_class(extra: "p-0"), data: { slot: "choice-group-legend" }),
|
|
55
|
-
tag.div(class: "flex flex-col gap-related", &block),
|
|
56
|
-
*lc_field_messages(id, hint, errors)
|
|
57
|
-
])
|
|
46
|
+
# lc_fieldset with its checkboxes, radios or switches stacked.
|
|
47
|
+
def lc_choice_group(legend:, **options, &block)
|
|
48
|
+
lc_fieldset(legend: legend, **lc_attributes({ data: { slot: "choice-group" } }, options)) do
|
|
49
|
+
tag.div(class: "flex flex-col gap-related", &block)
|
|
58
50
|
end
|
|
59
51
|
end
|
|
60
52
|
|
|
61
53
|
private
|
|
62
54
|
def lc_choice(slot, label, hint, card, name, unchecked_value, defaults, attributes, &block)
|
|
63
|
-
lc_label!(label, :label)
|
|
64
55
|
input = lc_attributes(defaults.merge(data: { slot: "#{slot}-input" }), attributes)
|
|
56
|
+
lc_label!(label || input.dig(:aria, :label), :label)
|
|
65
57
|
hidden = hidden_field_tag(name, unchecked_value, id: nil, disabled: input[:disabled]) if name && !unchecked_value.nil?
|
|
66
|
-
|
|
58
|
+
control = safe_join([ hidden, tag.input(**input) ].compact)
|
|
59
|
+
label.nil? ? control : lc_choice_label(slot, label, hint, control, card: card, &block)
|
|
67
60
|
end
|
|
68
61
|
|
|
69
62
|
# Shared with Lostcoords::Ui::FormBuilder, which renders its own inputs.
|