lostcoords-ui 0.9.3 → 0.11.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 +164 -4
- data/app/assets/tailwind/lostcoords/ui/components/hovercard.css +4 -0
- data/app/assets/tailwind/lostcoords/ui/components/shell.css +2 -2
- data/app/assets/tailwind/lostcoords/ui/components.css +1 -0
- data/app/assets/tailwind/lostcoords/ui/core.css +2 -1
- data/app/assets/tailwind/lostcoords/ui/hovercard.css +47 -0
- data/app/assets/tailwind/lostcoords/ui/shell.css +66 -9
- data/app/assets/tailwind/lostcoords/ui/toggle-group.css +58 -0
- data/app/helpers/lostcoords/ui/badge_helper.rb +9 -7
- data/app/helpers/lostcoords/ui/description_list_helper.rb +39 -0
- data/app/helpers/lostcoords/ui/form_helper.rb +4 -4
- data/app/helpers/lostcoords/ui/hovercard_helper.rb +31 -0
- data/app/helpers/lostcoords/ui/layout_helper.rb +31 -0
- data/app/helpers/lostcoords/ui/navigation_helper.rb +13 -0
- data/app/helpers/lostcoords/ui/primitives_helper.rb +20 -2
- data/app/helpers/lostcoords/ui/shell_helper.rb +32 -1
- data/app/helpers/lostcoords/ui/structures_helper.rb +65 -14
- data/app/helpers/lostcoords/ui/typography_helper.rb +30 -0
- data/app/javascript/lostcoords/ui/controllers/lc_char_counter_controller.js +63 -0
- data/app/javascript/lostcoords/ui/controllers/lc_hovercard_controller.js +104 -0
- data/app/javascript/lostcoords/ui/controllers/lc_sidebar_controller.js +48 -0
- data/app/javascript/lostcoords/ui/helpers/dismiss_stack.js +1 -1
- data/app/javascript/lostcoords/ui/index.js +6 -0
- data/config/locales/en.yml +14 -0
- data/config/locales/es.yml +14 -0
- data/config/locales/ja.yml +14 -0
- data/lib/lostcoords/ui/parts.rb +86 -0
- data/lib/lostcoords/ui/version.rb +1 -1
- metadata +8 -1
data/lib/lostcoords/ui/parts.rb
CHANGED
|
@@ -195,6 +195,35 @@ module Lostcoords::Ui
|
|
|
195
195
|
end
|
|
196
196
|
end
|
|
197
197
|
|
|
198
|
+
class TabBar < Base
|
|
199
|
+
LINK = "flex justify-center px-content text-small text-muted-foreground no-underline transition-colors duration-(--lc-motion-quick) " \
|
|
200
|
+
"hover:bg-accent hover:text-foreground aria-[current=page]:font-semibold aria-[current=page]:text-foreground"
|
|
201
|
+
|
|
202
|
+
def initialize(view, fill)
|
|
203
|
+
super(view)
|
|
204
|
+
@fill = fill
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
# current: marks the tab of the page the reader is on with aria-current="page". count: shows a
|
|
208
|
+
# muted number after the label; nil shows none.
|
|
209
|
+
def link(label, url, current: false, count: nil, **attributes)
|
|
210
|
+
view.send(:lc_label!, label, :label)
|
|
211
|
+
raise ArgumentError, "tab bar link needs a URL" if url.blank?
|
|
212
|
+
|
|
213
|
+
view.tag.li(class: (@fill ? "min-w-fit flex-1" : "shrink-0"), data: { slot: "tab-bar-item" }) do
|
|
214
|
+
view.link_to(url, **merge({ class: LINK, aria: { current: ("page" if current) }, data: { slot: "tab-bar-link" } }, attributes)) do
|
|
215
|
+
view.tag.span(class: "relative flex items-center gap-tight py-content whitespace-nowrap") do
|
|
216
|
+
view.safe_join([
|
|
217
|
+
label,
|
|
218
|
+
(view.tag.span(count, class: "font-normal tabular-nums text-muted-foreground", data: { slot: "tab-bar-count" }) unless count.nil?),
|
|
219
|
+
(view.tag.span(class: "absolute inset-x-0 bottom-0 h-1 rounded-pill bg-(--lc-tab-bar-indicator,var(--primary))", aria: { hidden: true }, data: { slot: "tab-bar-indicator" }) if current)
|
|
220
|
+
].compact)
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
|
|
198
227
|
class Toc < Base
|
|
199
228
|
LINK = "relative block py-tight ps-content pe-tight text-small text-muted-foreground no-underline transition-colors " \
|
|
200
229
|
"duration-(--lc-motion-quick) hover:text-foreground aria-[current=location]:font-medium aria-[current=location]:text-foreground"
|
|
@@ -233,6 +262,63 @@ module Lostcoords::Ui
|
|
|
233
262
|
end
|
|
234
263
|
end
|
|
235
264
|
|
|
265
|
+
class Sidebar < Base
|
|
266
|
+
ACCOUNT_TRIGGER = "flex w-full min-w-0 cursor-pointer items-center gap-related rounded-xl lc-squircle px-heading py-related text-start " \
|
|
267
|
+
"transition-colors duration-(--lc-motion-quick) hover:bg-accent aria-expanded:bg-accent lc-rail:justify-center lc-rail:px-0"
|
|
268
|
+
|
|
269
|
+
def initialize(view, toggle_label, expanded)
|
|
270
|
+
super(view)
|
|
271
|
+
@toggle_label = toggle_label
|
|
272
|
+
@expanded = expanded
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
# The top row: the block, usually a wordmark linking home, then the toggle. On the rail the row
|
|
276
|
+
# stacks; show a short mark there with the lc-rail: variant. toggle: false leaves the toggle out.
|
|
277
|
+
def header(toggle: true, **attributes, &block)
|
|
278
|
+
part(:div, "sidebar-header", "flex items-center justify-between gap-related ps-heading lc-rail:flex-col lc-rail:ps-0", attributes) do
|
|
279
|
+
view.safe_join([ (view.capture(&block) if block), (self.toggle if toggle) ].compact)
|
|
280
|
+
end
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
# The button that folds the sidebar to a rail and back. Its label, title and aria-expanded follow the state.
|
|
284
|
+
def toggle(**attributes)
|
|
285
|
+
view.lc_icon_button(@toggle_label, icon: "chevron-double-left", size: :sm,
|
|
286
|
+
**merge({ class: "lc-sidebar__toggle", title: @toggle_label, aria: { expanded: @expanded },
|
|
287
|
+
data: { slot: "sidebar-toggle", action: "lc-sidebar#toggle", lc_sidebar_target: "toggle" } }, attributes))
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
# The growing middle, usually an lc_nav_list. On the rail its group titles and link labels stay
|
|
291
|
+
# for screen readers only and the links center their icons; give each link a title:.
|
|
292
|
+
def body(**attributes, &block)
|
|
293
|
+
part(:div, "sidebar-body", "flex min-h-0 flex-1 flex-col gap-content", attributes, &block)
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
def footer(**attributes, &block)
|
|
297
|
+
part(:div, "sidebar-footer", "flex min-w-0 flex-col gap-related", attributes, &block)
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
# A full-width row that opens an lc_menu of the block's lc_menu_option items: avatar:, the name and
|
|
301
|
+
# a detail line, such as an email. On the rail only the avatar shows. Attributes go to the row.
|
|
302
|
+
def account(name, detail: nil, avatar: nil, id: "sidebar-account", align: :start, **attributes, &block)
|
|
303
|
+
view.send(:lc_label!, name, :name)
|
|
304
|
+
raise ArgumentError, "sidebar account needs a block of menu options" unless block
|
|
305
|
+
|
|
306
|
+
text = view.tag.span(class: "min-w-0 grow lc-rail:sr-only", data: { slot: "sidebar-account-text" }) do
|
|
307
|
+
view.safe_join([
|
|
308
|
+
view.tag.span(name, class: "block truncate text-label"),
|
|
309
|
+
(view.tag.span(detail, class: "block truncate text-caption text-muted-foreground") if detail.present?)
|
|
310
|
+
].compact)
|
|
311
|
+
end
|
|
312
|
+
ellipsis = view.lc_icon("ellipsis-horizontal", options: { class: "size-4 shrink-0 text-muted-foreground lc-rail:hidden", "aria-hidden": true })
|
|
313
|
+
view.lc_menu(id: id, align: align, wrapper_attributes: { class: "flex w-full", data: { slot: "sidebar-account" } }) do |menu|
|
|
314
|
+
menu.trigger(**merge({ class: ACCOUNT_TRIGGER, title: name, data: { slot: "sidebar-account-trigger" } }, attributes)) do |wiring|
|
|
315
|
+
view.tag.button(view.safe_join([ avatar, text, ellipsis ].compact), type: "button", **wiring)
|
|
316
|
+
end
|
|
317
|
+
view.capture(&block)
|
|
318
|
+
end
|
|
319
|
+
end
|
|
320
|
+
end
|
|
321
|
+
|
|
236
322
|
class Dock < Base
|
|
237
323
|
# The primary destinations, icon above label; yields the lc_nav_list builder.
|
|
238
324
|
def nav(label:, **attributes, &block)
|
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.
|
|
4
|
+
version: 0.11.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lost Coordinates
|
|
@@ -96,6 +96,7 @@ files:
|
|
|
96
96
|
- app/assets/tailwind/lostcoords/ui/components/collapsible.css
|
|
97
97
|
- app/assets/tailwind/lostcoords/ui/components/dialog.css
|
|
98
98
|
- app/assets/tailwind/lostcoords/ui/components/emoji-picker.css
|
|
99
|
+
- app/assets/tailwind/lostcoords/ui/components/hovercard.css
|
|
99
100
|
- app/assets/tailwind/lostcoords/ui/components/menu.css
|
|
100
101
|
- app/assets/tailwind/lostcoords/ui/components/prose.css
|
|
101
102
|
- app/assets/tailwind/lostcoords/ui/components/search.css
|
|
@@ -109,6 +110,7 @@ files:
|
|
|
109
110
|
- app/assets/tailwind/lostcoords/ui/emoji-picker.css
|
|
110
111
|
- app/assets/tailwind/lostcoords/ui/field.css
|
|
111
112
|
- app/assets/tailwind/lostcoords/ui/glass.css
|
|
113
|
+
- app/assets/tailwind/lostcoords/ui/hovercard.css
|
|
112
114
|
- app/assets/tailwind/lostcoords/ui/layout.css
|
|
113
115
|
- app/assets/tailwind/lostcoords/ui/popover.css
|
|
114
116
|
- app/assets/tailwind/lostcoords/ui/prose.css
|
|
@@ -119,6 +121,7 @@ files:
|
|
|
119
121
|
- app/assets/tailwind/lostcoords/ui/table.css
|
|
120
122
|
- app/assets/tailwind/lostcoords/ui/theme.css
|
|
121
123
|
- app/assets/tailwind/lostcoords/ui/toast.css
|
|
124
|
+
- app/assets/tailwind/lostcoords/ui/toggle-group.css
|
|
122
125
|
- app/assets/tailwind/lostcoords/ui/tooltip.css
|
|
123
126
|
- app/assets/tailwind/lostcoords/ui/typography.css
|
|
124
127
|
- app/assets/tailwind/lostcoords/ui/ui.css
|
|
@@ -137,6 +140,7 @@ files:
|
|
|
137
140
|
- app/helpers/lostcoords/ui/feedback_helper.rb
|
|
138
141
|
- app/helpers/lostcoords/ui/form_helper.rb
|
|
139
142
|
- app/helpers/lostcoords/ui/glass_helper.rb
|
|
143
|
+
- app/helpers/lostcoords/ui/hovercard_helper.rb
|
|
140
144
|
- app/helpers/lostcoords/ui/icon_helper.rb
|
|
141
145
|
- app/helpers/lostcoords/ui/layout_helper.rb
|
|
142
146
|
- app/helpers/lostcoords/ui/list_group_helper.rb
|
|
@@ -156,12 +160,14 @@ files:
|
|
|
156
160
|
- app/helpers/lostcoords/ui/translation_helper.rb
|
|
157
161
|
- app/helpers/lostcoords/ui/typography_helper.rb
|
|
158
162
|
- app/javascript/lostcoords/ui/controllers/lc_app_header_controller.js
|
|
163
|
+
- app/javascript/lostcoords/ui/controllers/lc_char_counter_controller.js
|
|
159
164
|
- app/javascript/lostcoords/ui/controllers/lc_code_block_controller.js
|
|
160
165
|
- app/javascript/lostcoords/ui/controllers/lc_collapsible_controller.js
|
|
161
166
|
- app/javascript/lostcoords/ui/controllers/lc_copy_controller.js
|
|
162
167
|
- app/javascript/lostcoords/ui/controllers/lc_dialog_controller.js
|
|
163
168
|
- app/javascript/lostcoords/ui/controllers/lc_dock_controller.js
|
|
164
169
|
- app/javascript/lostcoords/ui/controllers/lc_emoji_picker_controller.js
|
|
170
|
+
- app/javascript/lostcoords/ui/controllers/lc_hovercard_controller.js
|
|
165
171
|
- app/javascript/lostcoords/ui/controllers/lc_kbd_controller.js
|
|
166
172
|
- app/javascript/lostcoords/ui/controllers/lc_menu_controller.js
|
|
167
173
|
- app/javascript/lostcoords/ui/controllers/lc_nav_controller.js
|
|
@@ -171,6 +177,7 @@ files:
|
|
|
171
177
|
- app/javascript/lostcoords/ui/controllers/lc_selection_controller.js
|
|
172
178
|
- app/javascript/lostcoords/ui/controllers/lc_sheet_controller.js
|
|
173
179
|
- app/javascript/lostcoords/ui/controllers/lc_shortcut_controller.js
|
|
180
|
+
- app/javascript/lostcoords/ui/controllers/lc_sidebar_controller.js
|
|
174
181
|
- app/javascript/lostcoords/ui/controllers/lc_tabs_controller.js
|
|
175
182
|
- app/javascript/lostcoords/ui/controllers/lc_toast_controller.js
|
|
176
183
|
- app/javascript/lostcoords/ui/controllers/lc_toast_region_controller.js
|