velvetkit 0.4.1 → 0.5.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/CHANGELOG.md +143 -2
- data/lib/velvetkit/version.rb +1 -1
- data/registry/app/components/ui/accordion/trigger.rb +1 -1
- data/registry/app/components/ui/badge.rb +1 -1
- data/registry/app/components/ui/base.rb +2 -2
- data/registry/app/components/ui/button.rb +1 -1
- data/registry/app/components/ui/card/action.html.erb +1 -0
- data/registry/app/components/ui/card/action.rb +14 -0
- data/registry/app/components/ui/card/content.html.erb +1 -1
- data/registry/app/components/ui/card/content.rb +4 -2
- data/registry/app/components/ui/card/description.html.erb +1 -1
- data/registry/app/components/ui/card/description.rb +4 -2
- data/registry/app/components/ui/card/footer.html.erb +1 -1
- data/registry/app/components/ui/card/footer.rb +4 -2
- data/registry/app/components/ui/card/header.html.erb +1 -1
- data/registry/app/components/ui/card/header.rb +9 -2
- data/registry/app/components/ui/card/title.html.erb +1 -1
- data/registry/app/components/ui/card/title.rb +4 -2
- data/registry/app/components/ui/card.html.erb +1 -1
- data/registry/app/components/ui/card.rb +49 -3
- data/registry/app/components/ui/carousel.html.erb +7 -0
- data/registry/app/components/ui/carousel.rb +60 -0
- data/registry/app/components/ui/chart.html.erb +3 -3
- data/registry/app/components/ui/chart.rb +18 -10
- data/registry/app/components/ui/checkbox.html.erb +6 -0
- data/registry/app/components/ui/checkbox.rb +11 -4
- data/registry/app/components/ui/fieldset.html.erb +6 -0
- data/registry/app/components/ui/fieldset.rb +76 -0
- data/registry/app/components/ui/gallery/image.rb +14 -1
- data/registry/app/components/ui/gallery.html.erb +32 -3
- data/registry/app/components/ui/gallery.rb +46 -7
- data/registry/app/components/ui/link.rb +1 -1
- data/registry/app/components/ui/menu/item.rb +1 -1
- data/registry/app/components/ui/radio_group/item.html.erb +1 -1
- data/registry/app/components/ui/radio_group/item.rb +5 -1
- data/registry/app/components/ui/radio_group.html.erb +1 -1
- data/registry/app/components/ui/radio_group.rb +42 -2
- data/registry/app/components/ui/scrubber.html.erb +18 -0
- data/registry/app/components/ui/scrubber.rb +62 -0
- data/registry/app/components/ui/select.html.erb +1 -1
- data/registry/app/components/ui/select.rb +16 -1
- data/registry/app/components/ui/selection_bar.html.erb +7 -0
- data/registry/app/components/ui/selection_bar.rb +75 -0
- data/registry/app/components/ui/sidebar/group_label.rb +1 -1
- data/registry/app/components/ui/sidebar/inset.rb +5 -2
- data/registry/app/components/ui/sidebar/menu_button.rb +24 -9
- data/registry/app/components/ui/sidebar/menu_item.html.erb +1 -1
- data/registry/app/components/ui/sidebar/menu_item.rb +31 -5
- data/registry/app/components/ui/sidebar/menu_sub.rb +59 -0
- data/registry/app/components/ui/sidebar.html.erb +3 -3
- data/registry/app/components/ui/sidebar.rb +91 -13
- data/registry/app/components/ui/switch.rb +2 -2
- data/registry/app/components/ui/table/column.html.erb +1 -1
- data/registry/app/components/ui/table/column.rb +26 -2
- data/registry/app/components/ui/table/head.html.erb +1 -1
- data/registry/app/components/ui/table/head.rb +15 -2
- data/registry/app/components/ui/table/row.html.erb +1 -1
- data/registry/app/components/ui/table/row.rb +19 -5
- data/registry/app/components/ui/table.html.erb +2 -2
- data/registry/app/components/ui/table.rb +29 -4
- data/registry/app/components/ui/tabs/trigger.rb +1 -1
- data/registry/app/components/ui/toggle_group.html.erb +1 -1
- data/registry/app/components/ui/toggle_group.rb +26 -3
- data/registry/app/javascript/controllers/ui/carousel_controller.ts +63 -0
- data/registry/app/javascript/controllers/ui/file_field_controller.ts +1 -1
- data/registry/app/javascript/controllers/ui/gallery_controller.ts +52 -14
- data/registry/app/javascript/controllers/ui/scrubber_controller.ts +188 -0
- data/registry/app/javascript/controllers/ui/selection_bar_controller.ts +122 -0
- data/registry/app/javascript/controllers/ui/sidebar_controller.ts +102 -32
- data/registry/components.yml +12 -4
- data/registry/config/locales/velvetkit.en.yml +16 -0
- data/registry/icons/lucide/arrow-down.svg +16 -0
- data/registry/icons/lucide/arrow-up.svg +16 -0
- data/registry/icons/lucide/image.svg +17 -0
- data/registry/icons/lucide/star.svg +15 -0
- data/registry/icons/phosphor/arrow-down.svg +2 -0
- data/registry/icons/phosphor/arrow-up.svg +2 -0
- data/registry/icons/phosphor/image.svg +2 -0
- data/registry/icons/phosphor/star.svg +2 -0
- data/registry/icons/tabler/arrow-down.svg +18 -0
- data/registry/icons/tabler/arrow-up.svg +18 -0
- data/registry/icons/tabler/photo.svg +19 -0
- data/registry/icons/tabler/star.svg +16 -0
- data/registry/icons.yml +4 -0
- data/registry/test/components/previews/ui/card_preview/edge_to_edge.html.erb +19 -0
- data/registry/test/components/previews/ui/card_preview/image.html.erb +12 -0
- data/registry/test/components/previews/ui/card_preview/just_content.html.erb +10 -0
- data/registry/test/components/previews/ui/card_preview/open_bill.html.erb +18 -0
- data/registry/test/components/previews/ui/card_preview/playground.html.erb +17 -0
- data/registry/test/components/previews/ui/card_preview/settings_form.html.erb +15 -24
- data/registry/test/components/previews/ui/card_preview/sign_in.html.erb +23 -0
- data/registry/test/components/previews/ui/card_preview/small.html.erb +17 -0
- data/registry/test/components/previews/ui/card_preview/spacing.html.erb +13 -0
- data/registry/test/components/previews/ui/card_preview/stats.html.erb +11 -0
- data/registry/test/components/previews/ui/card_preview/team.html.erb +21 -0
- data/registry/test/components/previews/ui/card_preview.rb +42 -28
- data/registry/test/components/previews/ui/carousel_preview/highlights.html.erb +17 -0
- data/registry/test/components/previews/ui/carousel_preview.rb +22 -0
- data/registry/test/components/previews/ui/chart_preview/whole_dollars.html.erb +19 -0
- data/registry/test/components/previews/ui/chart_preview.rb +7 -1
- data/registry/test/components/previews/ui/checkbox_preview/in_form.html.erb +2 -3
- data/registry/test/components/previews/ui/fieldset_preview/block_of_fields.html.erb +18 -0
- data/registry/test/components/previews/ui/fieldset_preview/groups.html.erb +14 -0
- data/registry/test/components/previews/ui/fieldset_preview/model_errors.html.erb +22 -0
- data/registry/test/components/previews/ui/fieldset_preview/playground.html.erb +5 -0
- data/registry/test/components/previews/ui/fieldset_preview.rb +24 -0
- data/registry/test/components/previews/ui/gallery_preview/grid.html.erb +25 -0
- data/registry/test/components/previews/ui/gallery_preview.rb +3 -0
- data/registry/test/components/previews/ui/scrubber_preview/default.html.erb +24 -0
- data/registry/test/components/previews/ui/scrubber_preview.rb +6 -0
- data/registry/test/components/previews/ui/selection_bar_preview/floating.html.erb +16 -0
- data/registry/test/components/previews/ui/selection_bar_preview/table.html.erb +26 -0
- data/registry/test/components/previews/ui/selection_bar_preview.rb +9 -0
- data/registry/test/components/previews/ui/sidebar_preview/_shell.html.erb +5 -4
- data/registry/test/components/previews/ui/sidebar_preview/pill_links.html.erb +52 -0
- data/registry/test/components/previews/ui/sidebar_preview.rb +3 -0
- data/registry/test/components/previews/ui/table_preview/selectable.html.erb +26 -0
- data/registry/test/components/previews/ui/table_preview/sortable.html.erb +20 -0
- data/registry/test/components/previews/ui/table_preview/sticky_header.html.erb +13 -0
- data/registry/test/components/previews/ui/table_preview.rb +9 -0
- data/registry/test/components/ui/button_test.rb +2 -2
- data/registry/test/components/ui/card/action_test.rb +19 -0
- data/registry/test/components/ui/card/content_test.rb +1 -11
- data/registry/test/components/ui/card/footer_test.rb +3 -2
- data/registry/test/components/ui/card/header_test.rb +3 -4
- data/registry/test/components/ui/card/title_test.rb +3 -4
- data/registry/test/components/ui/card_test.rb +63 -2
- data/registry/test/components/ui/carousel_test.rb +38 -0
- data/registry/test/components/ui/chart_test.rb +20 -0
- data/registry/test/components/ui/checkbox_test.rb +11 -2
- data/registry/test/components/ui/fieldset_test.rb +119 -0
- data/registry/test/components/ui/gallery_test.rb +40 -5
- data/registry/test/components/ui/link_test.rb +1 -1
- data/registry/test/components/ui/number_input_test.rb +1 -1
- data/registry/test/components/ui/radio_group_test.rb +106 -0
- data/registry/test/components/ui/scrubber_test.rb +43 -0
- data/registry/test/components/ui/select_test.rb +21 -0
- data/registry/test/components/ui/selection_bar_test.rb +46 -0
- data/registry/test/components/ui/sidebar/menu_button_test.rb +9 -0
- data/registry/test/components/ui/sidebar_test.rb +79 -1
- data/registry/test/components/ui/switch_test.rb +4 -4
- data/registry/test/components/ui/toggle_group_test.rb +45 -0
- metadata +60 -5
- data/registry/test/components/previews/ui/card_preview/complete.html.erb +0 -31
- data/registry/test/components/previews/ui/card_preview/default.html.erb +0 -7
- data/registry/test/components/previews/ui/card_preview/with_footer.html.erb +0 -13
- data/registry/test/components/previews/ui/card_preview/with_header.html.erb +0 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0c2f8866e70934ca1e0f3ed6bb6d2d4925d7b84c11a5b8aaab89f5f3d48a69e7
|
|
4
|
+
data.tar.gz: 26320e37c7048700ebedcbbb2188cd739a3574b58fb1a624008ad5ee36d432ee
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1ac2dc774e3a3cf2593bec85d15c703b54e83d36216e24cc00cea5300a714db01ef08ee52abf8a6a4b63b97c4601b024c12abaa29a202e8252bd10a23204c381
|
|
7
|
+
data.tar.gz: 1b7c9127670e0382ddc16ef189905b8c18e7d3af126026dc8638d1b152eaea073c27d67e2844620802e70d29d60cab08fa099ae4f7943cc9f99347281639a9f4
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,100 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
New components:
|
|
6
|
+
|
|
7
|
+
- `Carousel`: a row of cards that swipes and scrolls sideways, each stopping
|
|
8
|
+
at the edge, with previous and next buttons that show only while there's
|
|
9
|
+
more to see that way.
|
|
10
|
+
- `SelectionBar`: "3 selected", a button to clear them and the actions for
|
|
11
|
+
all of them at once, over a `Table` with `selection:` or any list whose
|
|
12
|
+
boxes it can count. It keeps "select all" in step, Shift-click chooses a
|
|
13
|
+
run, and Escape clears. An "all" box inside a `data-selection-group`
|
|
14
|
+
chooses just that group, such as a day's photos.
|
|
15
|
+
- `Scrubber`: a rail down the side of a long list for jumping through it by
|
|
16
|
+
date, with years marked, the date under the pointer, dragging like a
|
|
17
|
+
scrollbar, and one tab stop whose arrow keys move between the marks.
|
|
18
|
+
|
|
19
|
+
Changes:
|
|
20
|
+
|
|
21
|
+
- `Sidebar` is a drawer on phones, opened by the same trigger, with a
|
|
22
|
+
backdrop, Escape, and focus moved in and back. It sticks to the top and
|
|
23
|
+
fits the wrapper's height, so a bar above the app no longer pushes its
|
|
24
|
+
footer out of sight. Menu items take a sub-menu (`with_sub_menu`), opened
|
|
25
|
+
from an arrow beside the link and open when one of its links is the
|
|
26
|
+
current page, and `with_menu_button` takes `shape: :pill`. `collapsible:`
|
|
27
|
+
now says what the trigger does (:icon, :offcanvas or :none) and `state:`
|
|
28
|
+
whether it starts collapsed; left out, it's what the reader last chose,
|
|
29
|
+
kept in a cookie so the page is drawn that way from the start.
|
|
30
|
+
- `Table`: headers sort with `sort_href:` and `sorted:` (and say so to
|
|
31
|
+
screen readers), `selection:` adds a checkbox to each row and one for
|
|
32
|
+
all, and `sticky_header: true` with `max_height:` keeps the header in sight.
|
|
33
|
+
- `Gallery`: `strip: false` leaves the page to show the images its own
|
|
34
|
+
way, such as a grid of photos, and `gallery.trigger(index)` opens any of
|
|
35
|
+
them in the overlay. In the overlay, `image.with_info` shows in a panel
|
|
36
|
+
beside the image and `image.with_action` adds a button to the top bar.
|
|
37
|
+
- `Chart`: `precision:` sets the decimals (0 for whole dollars), and
|
|
38
|
+
`show_data: false` leaves the table of numbers to screen readers. A pie
|
|
39
|
+
or donut sits beside its legend by its own width, not the window's, so it
|
|
40
|
+
fits a narrow card.
|
|
41
|
+
- `Checkbox` shows a dash when it's partly checked (`indeterminate`).
|
|
42
|
+
- Buttons, links, tabs, menu items, checkboxes, radios and switches show
|
|
43
|
+
their focus ring for the keyboard only (`:focus-visible`), not after a
|
|
44
|
+
mouse click. Text fields keep theirs on click.
|
|
45
|
+
- Fix: a collapsed `inset` or `floating` sidebar is wide enough for its
|
|
46
|
+
icons; they were clipped by the panel's padding.
|
|
47
|
+
- Fix: a class given to `Sidebar::Inset` replaces the one it clashes with
|
|
48
|
+
(`bg-transparent` for its background, `shadow-none` for its shadow). Both
|
|
49
|
+
used to land on the element and the inset's own often won.
|
|
50
|
+
|
|
51
|
+
Upgrading an app: re-run `velvetkit:add` for `sidebar`, `table`, `gallery`,
|
|
52
|
+
`chart` and `checkbox`. A sidebar that passed `collapsible: :icon` to start
|
|
53
|
+
collapsed now passes `state: :collapsed`; `collapsible: :none` now means it
|
|
54
|
+
can't collapse. The choice is kept in a cookie, not `localStorage`. The
|
|
55
|
+
sidebar is no longer `position: fixed`, so a `transform` added to keep it
|
|
56
|
+
inside a box can go; give the wrapper a height instead
|
|
57
|
+
(`class: "h-[calc(100svh-3rem)]"`). Phones get the drawer, so a sheet that
|
|
58
|
+
stood in for it can go too.
|
|
59
|
+
|
|
60
|
+
- Docs: two more examples. Helio, a dashboard at /examples/dashboard, is the
|
|
61
|
+
admin side of a software company: customers to search, filter, sort,
|
|
62
|
+
choose and act on in bulk, a page for each with its invoices, activity
|
|
63
|
+
and notes, and an overview whose numbers change with the period. Pinhole,
|
|
64
|
+
a photo library at /examples/photos, has highlights, photos by day, a date
|
|
65
|
+
scrubber, albums, an archive and a bin, and a viewer with an info panel.
|
|
66
|
+
|
|
67
|
+
- Docs: an Examples page, linked from the header, shows apps built with
|
|
68
|
+
VelvetKit. The first, Daily Goods, is a shop you can use at
|
|
69
|
+
/examples/store: a front page with categories, reviews and a newsletter
|
|
70
|
+
signup, filters (price, rating, colour, features) and sorting, a cart, and
|
|
71
|
+
a page for each product with photos, details and reviews, all without a
|
|
72
|
+
page reload. A sign-in flow is on the way.
|
|
73
|
+
|
|
74
|
+
- Fix: `Select` puts `aria-label` and `aria-labelledby` on its visible button.
|
|
75
|
+
They went on the hidden native select, which left the dropdown with no name
|
|
76
|
+
for screen readers. (#80)
|
|
77
|
+
|
|
78
|
+
Upgrading an app: `RadioGroup` and `ToggleGroup` now render through the new
|
|
79
|
+
`Fieldset`, so re-run `velvetkit:add radio_group toggle_group` to get it with
|
|
80
|
+
them. Without `legend:`, `hint:` or `error:` they render as before.
|
|
81
|
+
|
|
82
|
+
## 0.4.2 — 2026-11-09
|
|
83
|
+
|
|
84
|
+
Changes:
|
|
85
|
+
|
|
86
|
+
- `Card` is redesigned: a soft ring instead of a border and shadow, tighter
|
|
87
|
+
padding, a smaller title, and a tinted footer band. It gains
|
|
88
|
+
`header.with_action` for a button or badge at the top right,
|
|
89
|
+
`card.with_image` for a picture edge to edge across the top, `size: :sm`,
|
|
90
|
+
and `spacing:`. The examples are new.
|
|
91
|
+
|
|
92
|
+
Upgrading an app: re-run `velvetkit:add card`. Cards now have 16px of padding
|
|
93
|
+
where they had 24px; `spacing: 6` gets the old padding back. If you colour a
|
|
94
|
+
card's edge with a `border-*` class, use `ring-*` instead, and remove any
|
|
95
|
+
`pt-6` added to the first part of a card, which the card now handles. A card
|
|
96
|
+
with no parts, just a block, keeps its own padding as before.
|
|
97
|
+
|
|
3
98
|
## 0.4.1 — 2026-11-09
|
|
4
99
|
|
|
5
100
|
New components:
|
|
@@ -78,6 +173,8 @@ it as it is. `progress` needs the `velvetkit-progress` keyframes from the new
|
|
|
78
173
|
|
|
79
174
|
## 0.3.0 — 2026-11-03
|
|
80
175
|
|
|
176
|
+
New components:
|
|
177
|
+
|
|
81
178
|
- `Stepper`: the steps of a multi-step form, done, current or to come, with
|
|
82
179
|
dots, centred labels, panels moved between in the browser, and links back
|
|
83
180
|
to done steps.
|
|
@@ -87,33 +184,77 @@ it as it is. `progress` needs the `velvetkit-progress` keyframes from the new
|
|
|
87
184
|
radios or checkboxes.
|
|
88
185
|
- `EmptyState`: an icon, title, text and actions for a page with nothing to
|
|
89
186
|
list.
|
|
187
|
+
|
|
188
|
+
Changes:
|
|
189
|
+
|
|
90
190
|
- Icons come from Lucide, Tabler or Phosphor, chosen with
|
|
91
191
|
`velvetkit:install --icons=`, and are drawn as inline SVG.
|
|
92
192
|
|
|
93
193
|
## 0.2.2 — 2026-11-02
|
|
94
194
|
|
|
195
|
+
Changes:
|
|
196
|
+
|
|
95
197
|
- Fix: the `plus`, `search`, `ellipsis-vertical` and `grip-vertical` icons were
|
|
96
198
|
missing from installs.
|
|
97
199
|
|
|
98
200
|
## 0.2.1 — 2026-11-01
|
|
99
201
|
|
|
202
|
+
New components:
|
|
203
|
+
|
|
100
204
|
- `NavigationMenu`: site navigation with links and panels of rich links that
|
|
101
205
|
open on hover or click.
|
|
102
206
|
|
|
103
207
|
## 0.2.0 — 2026-11-01
|
|
104
208
|
|
|
209
|
+
New components:
|
|
210
|
+
|
|
105
211
|
- `Toast`: stacked messages that dismiss themselves.
|
|
106
212
|
- `SessionTabs`: tabs for open sessions, with a button to add one.
|
|
107
|
-
- `Skeleton
|
|
213
|
+
- `Skeleton`: a pulsing placeholder in a piece of content's shape while it
|
|
214
|
+
loads.
|
|
215
|
+
- `FileField`: a drag-and-drop file picker with a label, hint and error
|
|
216
|
+
message, standalone or with a form builder.
|
|
217
|
+
|
|
218
|
+
Changes:
|
|
219
|
+
|
|
108
220
|
- Fix: `Menu` content positions itself with the fixed strategy, so it isn't
|
|
109
221
|
clipped by a scrolling container.
|
|
110
222
|
- Fix: dependencies updated for security advisories in `addressable` and `rack`.
|
|
111
223
|
|
|
224
|
+
## 0.1.0 — 2026-10-29
|
|
225
|
+
|
|
226
|
+
New components:
|
|
227
|
+
|
|
228
|
+
- `FormField`: a label, a control, a hint and an error message in one. The
|
|
229
|
+
form controls take `hint:` and `error:` and wrap themselves in it.
|
|
230
|
+
- `Textarea`: a multi-line field that can grow with its text.
|
|
231
|
+
- `Collapsible`: a section that opens under its trigger.
|
|
232
|
+
- `TableOfContents`: an "On this page" list that highlights the section
|
|
233
|
+
being read.
|
|
234
|
+
|
|
235
|
+
Changes:
|
|
236
|
+
|
|
237
|
+
- The docs site has a Building forms guide.
|
|
238
|
+
- Fix: `NativeSelect` keeps the model's value when the form is rendered again.
|
|
239
|
+
- Fix: `InputGroup` shows its error border, and draws one focus ring at a time.
|
|
240
|
+
- Fix: `TableOfContents` doesn't animate its first highlight on page load.
|
|
241
|
+
|
|
112
242
|
## 0.1.0.beta — 2026-10-26
|
|
113
243
|
|
|
244
|
+
New components:
|
|
245
|
+
|
|
246
|
+
- 38 components, with their Stimulus controllers, tests and Lookbook
|
|
247
|
+
previews: `Accordion`, `Alert`, `Avatar`, `AvatarGroup`, `Badge`, `Banner`,
|
|
248
|
+
`Breadcrumb`, `Button`, `ButtonTo`, `Card`, `Checkbox`, `DataGrid`,
|
|
249
|
+
`DatePicker`, `Dialog`, `Divider`, `Icon`, `Image`, `Input`, `InputGroup`,
|
|
250
|
+
`Label`, `Link`, `Menu`, `NativeSelect`, `Pagination`, `PasswordInput`,
|
|
251
|
+
`Popover`, `RadioGroup`, `Select`, `Sheet`, `Sidebar`, `Spinner`, `Switch`,
|
|
252
|
+
`Table`, `Tabs`, `Text`, `ThemeToggle`, `Tooltip` and `Typography`.
|
|
253
|
+
|
|
254
|
+
Changes:
|
|
255
|
+
|
|
114
256
|
- First release of the component library.
|
|
115
257
|
- `velvetkit:install` and `velvetkit:add` generators, with a configurable namespace.
|
|
116
|
-
- 39 components, their Stimulus controllers, tests and Lookbook previews.
|
|
117
258
|
- `Select` is a styled dropdown (listbox, keyboard, type-ahead), with
|
|
118
259
|
`searchable:` and `multiple:`; it posts through a hidden native select, so
|
|
119
260
|
forms work unchanged. The browser's own control is now `NativeSelect`.
|
data/lib/velvetkit/version.rb
CHANGED
|
@@ -4,5 +4,5 @@ module Velvetkit
|
|
|
4
4
|
# Not the released version: the release workflow takes that from the tag
|
|
5
5
|
# (v0.3.0 publishes 0.3.0) and writes it here on the runner only, so this
|
|
6
6
|
# file can stay behind. See .github/workflows/release.yml.
|
|
7
|
-
VERSION = "0.
|
|
7
|
+
VERSION = "0.5.0"
|
|
8
8
|
end
|
|
@@ -11,7 +11,7 @@ class UI::Accordion::Trigger < UI::Base
|
|
|
11
11
|
def classes
|
|
12
12
|
cn(
|
|
13
13
|
"group flex w-full items-center gap-3 py-2 text-sm font-medium transition-all hover:underline text-left text-primary",
|
|
14
|
-
"focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1 rounded",
|
|
14
|
+
"focus:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 rounded",
|
|
15
15
|
"disabled:pointer-events-none disabled:opacity-50",
|
|
16
16
|
UI::Base::FOCUS_RING,
|
|
17
17
|
@user_class
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
class UI::Badge < UI::Base
|
|
4
4
|
variants(
|
|
5
|
-
base: "inline-flex items-center justify-center gap-1 rounded-full font-medium whitespace-nowrap border border-transparent transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1",
|
|
5
|
+
base: "inline-flex items-center justify-center gap-1 rounded-full font-medium whitespace-nowrap border border-transparent transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1",
|
|
6
6
|
variants: {
|
|
7
7
|
variant: {
|
|
8
8
|
default: "bg-primary text-primary-foreground hover:bg-primary/80",
|
|
@@ -9,8 +9,8 @@ class UI::Base < ViewComponent::Base
|
|
|
9
9
|
# includes it in its variant `base:` string. It shows on click as well as on
|
|
10
10
|
# Tab, and animates in. (The docs site keeps it on the clicked link across
|
|
11
11
|
# page visits, so a visit doesn't cut the animation off.)
|
|
12
|
-
FOCUS_RING = "transition-all focus:outline-none focus:ring-2 focus:ring-primary " \
|
|
13
|
-
"focus:ring-offset-1 ring-offset-background"
|
|
12
|
+
FOCUS_RING = "transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-primary " \
|
|
13
|
+
"focus-visible:ring-offset-1 ring-offset-background"
|
|
14
14
|
|
|
15
15
|
class_attribute :variant_config,
|
|
16
16
|
instance_writer: false,
|
|
@@ -21,7 +21,7 @@ class UI::Button < UI::Base
|
|
|
21
21
|
variants: {
|
|
22
22
|
variant: {
|
|
23
23
|
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
24
|
-
destructive: "bg-destructive text-white hover:bg-destructive/90 focus:ring-destructive",
|
|
24
|
+
destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive",
|
|
25
25
|
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground " \
|
|
26
26
|
"disabled:border-input!",
|
|
27
27
|
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= tag.div(**root_attrs) do %><%= content %><% end %>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# What goes at the top right of a card's header: a button, a badge, a link.
|
|
4
|
+
class UI::Card::Action < UI::Base
|
|
5
|
+
def initialize(class: nil, **html_attrs)
|
|
6
|
+
@user_class = binding.local_variable_get(:class)
|
|
7
|
+
@html_attrs = html_attrs
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def root_attrs
|
|
11
|
+
{ **@html_attrs, class: cn("col-start-2 row-span-2 row-start-1 self-start justify-self-end", @user_class),
|
|
12
|
+
data: { slot: "card-action", **(@html_attrs[:data] || {}) } }
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<%= tag.div
|
|
1
|
+
<%= tag.div(**root_attrs) do %><%= content %><% end %>
|
|
@@ -6,7 +6,9 @@ class UI::Card::Content < UI::Base
|
|
|
6
6
|
@html_attrs = html_attrs
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
def
|
|
10
|
-
cn("
|
|
9
|
+
def root_attrs
|
|
10
|
+
{ **@html_attrs, class: cn("px-(--card-spacing)",
|
|
11
|
+
@user_class),
|
|
12
|
+
data: { slot: "card-content", **(@html_attrs[:data] || {}) } }
|
|
11
13
|
end
|
|
12
14
|
end
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<%= tag.p
|
|
1
|
+
<%= tag.p(**root_attrs) do %><%= content %><% end %>
|
|
@@ -6,7 +6,9 @@ class UI::Card::Description < UI::Base
|
|
|
6
6
|
@html_attrs = html_attrs
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
def
|
|
10
|
-
cn("text-sm text-muted-foreground",
|
|
9
|
+
def root_attrs
|
|
10
|
+
{ **@html_attrs, class: cn("text-sm text-muted-foreground",
|
|
11
|
+
@user_class),
|
|
12
|
+
data: { slot: "card-description", **(@html_attrs[:data] || {}) } }
|
|
11
13
|
end
|
|
12
14
|
end
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<%= tag.div
|
|
1
|
+
<%= tag.div(**root_attrs) do %><%= content %><% end %>
|
|
@@ -6,7 +6,9 @@ class UI::Card::Footer < UI::Base
|
|
|
6
6
|
@html_attrs = html_attrs
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
def
|
|
10
|
-
cn("flex items-center
|
|
9
|
+
def root_attrs
|
|
10
|
+
{ **@html_attrs, class: cn("flex items-center rounded-b-xl border-t bg-muted/50 p-(--card-spacing)",
|
|
11
|
+
@user_class),
|
|
12
|
+
data: { slot: "card-footer", **(@html_attrs[:data] || {}) } }
|
|
11
13
|
end
|
|
12
14
|
end
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<%= tag.div
|
|
1
|
+
<%= tag.div(**root_attrs) do %><% if title? %><%= title %><% end %><% if description? %><%= description %><% end %><% if action? %><%= action %><% end %><%= content %><% end %>
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
class UI::Card::Header < UI::Base
|
|
4
|
+
# Two columns once there's an action, which then spans the title and
|
|
5
|
+
# description rows.
|
|
6
|
+
CLASSES = "grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) " \
|
|
7
|
+
"has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-(--card-spacing)"
|
|
8
|
+
|
|
4
9
|
renders_one :title, UI::Card::Title
|
|
5
10
|
renders_one :description, UI::Card::Description
|
|
11
|
+
renders_one :action, UI::Card::Action
|
|
6
12
|
|
|
7
13
|
def initialize(class: nil, **html_attrs)
|
|
8
14
|
@user_class = binding.local_variable_get(:class)
|
|
9
15
|
@html_attrs = html_attrs
|
|
10
16
|
end
|
|
11
17
|
|
|
12
|
-
def
|
|
13
|
-
|
|
18
|
+
def root_attrs
|
|
19
|
+
{ **@html_attrs, class: cn(CLASSES, @user_class),
|
|
20
|
+
data: { slot: "card-header", **(@html_attrs[:data] || {}) } }
|
|
14
21
|
end
|
|
15
22
|
end
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<%= tag.h3
|
|
1
|
+
<%= tag.h3(**root_attrs) do %><%= content %><% end %>
|
|
@@ -6,7 +6,9 @@ class UI::Card::Title < UI::Base
|
|
|
6
6
|
@html_attrs = html_attrs
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
def
|
|
10
|
-
cn("text-
|
|
9
|
+
def root_attrs
|
|
10
|
+
{ **@html_attrs, class: cn("text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",
|
|
11
|
+
@user_class),
|
|
12
|
+
data: { slot: "card-title", **(@html_attrs[:data] || {}) } }
|
|
11
13
|
end
|
|
12
14
|
end
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<%= tag.div
|
|
1
|
+
<%= tag.div(**root_attrs) do %><%= image if image? %><%= header if header? %><%= card_content if card_content? %><%= footer if footer? %><%= content %><% end %>
|
|
@@ -1,18 +1,64 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# A surface that groups one thing: a form, a stat, a person, an event.
|
|
4
|
+
#
|
|
5
|
+
# <%= render(UI::Card.new) do |card| %>
|
|
6
|
+
# <% card.with_header do |header| %>
|
|
7
|
+
# <% header.with_title { "Team" } %>
|
|
8
|
+
# <% header.with_description { "Who can see this project." } %>
|
|
9
|
+
# <% header.with_action { render(UI::Button.new(size: :sm)) { "Invite" } } %>
|
|
10
|
+
# <% end %>
|
|
11
|
+
# <% card.with_content { ... } %>
|
|
12
|
+
# <% card.with_footer { ... } %>
|
|
13
|
+
# <% end %>
|
|
14
|
+
#
|
|
15
|
+
# `with_action` sits at the top right of the header. `with_image(src:, alt:)`
|
|
16
|
+
# runs edge to edge across the top. The footer is a tinted band along the
|
|
17
|
+
# bottom.
|
|
18
|
+
#
|
|
19
|
+
# `size: :sm` is tighter, with a smaller title. `spacing:` sets the gap between
|
|
20
|
+
# the parts and their inset, in Tailwind's steps (4 is 16px, 6 is 24px). Inside
|
|
21
|
+
# the card it's the CSS variable --card-spacing, so content can reach the
|
|
22
|
+
# edges with `-mx-(--card-spacing)` and stay lined up with the rest.
|
|
23
|
+
#
|
|
24
|
+
# A card with no parts, just a block, is a bare surface with no padding of its
|
|
25
|
+
# own: `render(UI::Card.new(class: "p-6")) { ... }`.
|
|
26
|
+
#
|
|
27
|
+
# It doesn't clip its contents, so a menu or date picker opened inside isn't
|
|
28
|
+
# cut off at the card's edge.
|
|
3
29
|
class UI::Card < UI::Base
|
|
30
|
+
SPACING = { default: 4, sm: 3 }.freeze
|
|
31
|
+
|
|
32
|
+
# Only once the card has parts. `^=` matches card-header, card-content and
|
|
33
|
+
# so on, as direct children, which a block of the app's own never is.
|
|
34
|
+
# The footer and image reach the card's edge; those two are `!` because
|
|
35
|
+
# Tailwind's order for these variants would otherwise let py win.
|
|
36
|
+
CLASSES = "group/card rounded-xl bg-card text-card-foreground ring-1 ring-foreground/10 " \
|
|
37
|
+
"has-[>[data-slot^=card-]]:flex has-[>[data-slot^=card-]]:flex-col " \
|
|
38
|
+
"has-[>[data-slot^=card-]]:gap-(--card-spacing) has-[>[data-slot^=card-]]:py-(--card-spacing) " \
|
|
39
|
+
"has-[>[data-slot^=card-]]:text-sm has-[>[data-slot=card-footer]]:pb-0! " \
|
|
40
|
+
"has-[>[data-slot=card-image]:first-child]:pt-0!"
|
|
41
|
+
|
|
42
|
+
renders_one :image, lambda { |src:, alt:, class: nil, **attrs|
|
|
43
|
+
UI::Image.new(src: src, alt: alt, rounded: :none, data: { slot: "card-image" },
|
|
44
|
+
class: cn("aspect-video w-full rounded-t-xl object-cover", binding.local_variable_get(:class)), **attrs)
|
|
45
|
+
}
|
|
4
46
|
renders_one :header, UI::Card::Header
|
|
5
47
|
renders_one :card_content, UI::Card::Content
|
|
6
48
|
renders_one :footer, UI::Card::Footer
|
|
7
49
|
|
|
8
50
|
alias_method :with_content, :with_card_content
|
|
9
51
|
|
|
10
|
-
def initialize(class: nil, **html_attrs)
|
|
52
|
+
def initialize(size: :default, spacing: nil, class: nil, **html_attrs)
|
|
53
|
+
@size = SPACING.key?(size.to_sym) ? size.to_sym : :default
|
|
54
|
+
@spacing = spacing || SPACING[@size]
|
|
11
55
|
@user_class = binding.local_variable_get(:class)
|
|
12
56
|
@html_attrs = html_attrs
|
|
13
57
|
end
|
|
14
58
|
|
|
15
|
-
def
|
|
16
|
-
|
|
59
|
+
def root_attrs
|
|
60
|
+
{ **@html_attrs, class: cn(CLASSES, @user_class),
|
|
61
|
+
style: [ "--card-spacing: calc(var(--spacing) * #{@spacing})", @html_attrs[:style] ].compact.join("; "),
|
|
62
|
+
data: { slot: "card", size: @size, **(@html_attrs[:data] || {}) } }
|
|
17
63
|
end
|
|
18
64
|
end
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<%= tag.div(**root_attrs) do %>
|
|
2
|
+
<%= tag.ul id: track_id, class: track_classes, data: { "ui--carousel-target": "track", action: "scroll->ui--carousel#update" } do %>
|
|
3
|
+
<% items.each do |item| %><%= tag.li item, class: item_classes %><% end %>
|
|
4
|
+
<% end %>
|
|
5
|
+
<%= render(UI::Button.new(**button_attrs(:previous))) do %><%= render(UI::Icon.new(name: "chevron-left", size: :sm, class: "rtl:rotate-180")) %><% end %>
|
|
6
|
+
<%= render(UI::Button.new(**button_attrs(:next))) do %><%= render(UI::Icon.new(name: "chevron-right", size: :sm, class: "rtl:rotate-180")) %><% end %>
|
|
7
|
+
<% end %>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# A row of cards that scrolls sideways: highlights, albums, related products.
|
|
4
|
+
#
|
|
5
|
+
# <%= render(UI::Carousel.new(label: "Highlights", item_class: "w-64")) do |carousel| %>
|
|
6
|
+
# <% @highlights.each do |highlight| %>
|
|
7
|
+
# <% carousel.with_item { render(highlight) } %>
|
|
8
|
+
# <% end %>
|
|
9
|
+
# <% end %>
|
|
10
|
+
#
|
|
11
|
+
# It's a scroll-snap strip, so it swipes on a touch screen and scrolls with a
|
|
12
|
+
# trackpad with no script involved, and each card stops at the edge. Previous
|
|
13
|
+
# and next buttons scroll a strip's width at a time, and each shows only while
|
|
14
|
+
# there's more to see that way. `item_class:` sizes the cards ("w-64",
|
|
15
|
+
# "basis-1/3"); they're as wide as their content otherwise.
|
|
16
|
+
class UI::Carousel < UI::Base
|
|
17
|
+
renders_many :items
|
|
18
|
+
|
|
19
|
+
def initialize(label:, item_class: nil, gap: 3, class: nil, **html_attrs)
|
|
20
|
+
@label = label
|
|
21
|
+
@item_class = item_class
|
|
22
|
+
@gap = gap
|
|
23
|
+
@user_class = binding.local_variable_get(:class)
|
|
24
|
+
@html_attrs = html_attrs
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Written out in full so Tailwind finds them.
|
|
28
|
+
GAPS = { 2 => "gap-2", 3 => "gap-3", 4 => "gap-4", 6 => "gap-6" }.freeze
|
|
29
|
+
|
|
30
|
+
def root_attrs
|
|
31
|
+
attrs = @html_attrs.except(:data, :aria)
|
|
32
|
+
attrs[:role] = "region"
|
|
33
|
+
attrs[:class] = cn("group/carousel relative min-w-0", @user_class)
|
|
34
|
+
attrs[:aria] = { label: @label, roledescription: t("ui.carousel.roledescription", default: "carousel") }
|
|
35
|
+
.merge(@html_attrs[:aria] || {})
|
|
36
|
+
attrs[:data] = { slot: "carousel", controller: "ui--carousel",
|
|
37
|
+
action: "resize@window->ui--carousel#update" }.merge(@html_attrs[:data] || {})
|
|
38
|
+
attrs
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# The padding gives the cards' focus rings room, and the margin takes it back.
|
|
42
|
+
def track_classes
|
|
43
|
+
cn("-m-1 flex snap-x snap-mandatory scroll-px-1 overflow-x-auto scroll-smooth p-1 motion-reduce:scroll-auto",
|
|
44
|
+
"[scrollbar-width:none] [&::-webkit-scrollbar]:hidden", GAPS.fetch(@gap, GAPS[3]))
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def item_classes = cn("shrink-0 snap-start", @item_class)
|
|
48
|
+
|
|
49
|
+
def button_attrs(direction)
|
|
50
|
+
edge = direction == :previous ? "start-0 -translate-x-1/2 rtl:translate-x-1/2" : "end-0 translate-x-1/2 rtl:-translate-x-1/2"
|
|
51
|
+
{ variant: :outline, size: :icon,
|
|
52
|
+
class: cn("absolute top-1/2 z-10 hidden -translate-y-1/2 rounded-full bg-background shadow-md sm:inline-flex [&[hidden]]:hidden!", edge),
|
|
53
|
+
hidden: true,
|
|
54
|
+
aria: { label: t("ui.carousel.#{direction}", default: direction == :previous ? "Previous" : "Next"),
|
|
55
|
+
controls: track_id },
|
|
56
|
+
data: { action: "ui--carousel##{direction}", "ui--carousel-target": direction } }
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def track_id = @track_id ||= "carousel-#{SecureRandom.hex(4)}"
|
|
60
|
+
end
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
class: "pointer-events-none invisible absolute left-0 top-0 z-10 min-w-32 rounded-md border bg-popover px-3 py-2 text-xs text-popover-foreground opacity-0 shadow-md transition-[opacity,transform,visibility] duration-150 ease-out data-[shown]:visible data-[shown]:opacity-100 motion-reduce:transition-none" %>
|
|
21
21
|
<% end %>
|
|
22
22
|
<% end %>
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
<%= tag.send(show_data? ? :details : :div, class: show_data? ? "group/data text-sm" : "sr-only") do %>
|
|
24
|
+
<% if show_data? %><%= tag.summary t("ui.chart.show_data", default: "Show the data"), class: "w-fit cursor-pointer rounded-sm text-muted-foreground hover:text-foreground #{UI::Base::FOCUS_RING}" %><% end %>
|
|
25
25
|
<div class="mt-2 overflow-x-auto">
|
|
26
26
|
<table class="w-full text-sm tabular-nums">
|
|
27
27
|
<%= tag.caption label, class: "sr-only" %>
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
</tbody>
|
|
44
44
|
</table>
|
|
45
45
|
</div>
|
|
46
|
-
|
|
46
|
+
<% end %>
|
|
47
47
|
<% end %>
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
# Its legend gives each part's value and share, and a donut shows the total in
|
|
16
16
|
# its middle. `format:` is :number, :currency or :percent (values from 0 to
|
|
17
17
|
# 100), and the values are written in the app's locale: currency uses Rails'
|
|
18
|
-
# own format for it, or `unit:` ("₹"). `
|
|
18
|
+
# own format for it, or `unit:` ("₹"). `precision:` sets the decimals (0 for
|
|
19
|
+
# whole dollars). `nil` leaves a gap.
|
|
19
20
|
#
|
|
20
21
|
# Each series takes the next of five colours, `--chart-1` to `--chart-5`, which
|
|
21
22
|
# change with the theme. A series keeps its colour by its place in the list, so
|
|
@@ -26,6 +27,10 @@
|
|
|
26
27
|
# Two or more series get a legend, and a line ends with its last value. Hover,
|
|
27
28
|
# or focus the chart and use the arrow keys, for the values at each point; the
|
|
28
29
|
# numbers are also in a table under "Show the data", for screen readers too.
|
|
30
|
+
# `show_data: false` leaves the table to screen readers alone.
|
|
31
|
+
#
|
|
32
|
+
# A pie sits beside its legend when the chart is wide enough, measured by its
|
|
33
|
+
# own width rather than the window's, so it fits a narrow card.
|
|
29
34
|
# Chart.js loads when the first chart on a page appears, and each chart draws
|
|
30
35
|
# when it scrolls into view: bars grow from the baseline and a line draws
|
|
31
36
|
# itself from left to right, unless the system asks for reduced motion.
|
|
@@ -40,14 +45,16 @@ class UI::Chart < UI::Base
|
|
|
40
45
|
|
|
41
46
|
Series = Struct.new(:name, :data, :color, keyword_init: true)
|
|
42
47
|
|
|
43
|
-
def initialize(labels:, series:, type: :line, label: nil, stacked: false, format: :number, unit: nil,
|
|
44
|
-
class: nil, **html_attrs)
|
|
48
|
+
def initialize(labels:, series:, type: :line, label: nil, stacked: false, format: :number, unit: nil, precision: nil,
|
|
49
|
+
show_data: true, height: 288, class: nil, **html_attrs)
|
|
45
50
|
@labels = labels.map(&:to_s)
|
|
46
51
|
@type = TYPES.include?(type.to_sym) ? type.to_sym : :line
|
|
47
52
|
@label = label
|
|
48
53
|
@stacked = stacked && @type == :bar
|
|
49
54
|
@format = FORMATS.include?(format.to_sym) ? format.to_sym : :number
|
|
50
55
|
@unit = unit
|
|
56
|
+
@precision = precision
|
|
57
|
+
@show_data = show_data
|
|
51
58
|
@height = height
|
|
52
59
|
@user_class = binding.local_variable_get(:class)
|
|
53
60
|
@html_attrs = html_attrs
|
|
@@ -58,6 +65,7 @@ class UI::Chart < UI::Base
|
|
|
58
65
|
attr_reader :labels, :series
|
|
59
66
|
|
|
60
67
|
def legend? = circular? || @series.size > 1
|
|
68
|
+
def show_data? = @show_data
|
|
61
69
|
def line? = @type == :line
|
|
62
70
|
def circular? = CIRCULAR.include?(@type)
|
|
63
71
|
def swatch_classes(entry) = cn(SWATCHES[entry.color], line? ? "h-0.5 w-3.5 rounded-full" : "size-2.5 rounded-sm")
|
|
@@ -76,7 +84,7 @@ class UI::Chart < UI::Base
|
|
|
76
84
|
|
|
77
85
|
def legend_classes
|
|
78
86
|
if circular?
|
|
79
|
-
"flex flex-col gap-2 text-sm
|
|
87
|
+
"flex flex-col gap-2 text-sm @md:w-64 @md:shrink-0"
|
|
80
88
|
else
|
|
81
89
|
"flex flex-wrap gap-x-4 gap-y-1 text-sm text-muted-foreground"
|
|
82
90
|
end
|
|
@@ -84,12 +92,12 @@ class UI::Chart < UI::Base
|
|
|
84
92
|
|
|
85
93
|
# A pie sits beside its legend once there's room; the others keep it above.
|
|
86
94
|
def body_classes
|
|
87
|
-
circular? ? "flex flex-col-reverse gap-4
|
|
95
|
+
circular? ? "flex flex-col-reverse gap-4 @md:flex-row @md:items-center @md:gap-8" : "contents"
|
|
88
96
|
end
|
|
89
97
|
|
|
90
98
|
def root_attrs
|
|
91
99
|
attrs = @html_attrs.except(:data)
|
|
92
|
-
attrs[:class] = cn("flex w-full min-w-0 flex-col gap-3", @user_class)
|
|
100
|
+
attrs[:class] = cn("@container flex w-full min-w-0 flex-col gap-3", @user_class)
|
|
93
101
|
attrs[:data] = { slot: "chart", type: @type, controller: "ui--chart",
|
|
94
102
|
"ui--chart-config-value": config.to_json,
|
|
95
103
|
# Propshaft digests the filename, so the URL has to come from Ruby.
|
|
@@ -106,7 +114,7 @@ class UI::Chart < UI::Base
|
|
|
106
114
|
end
|
|
107
115
|
|
|
108
116
|
def frame_style = "height: #{@height.to_i}px"
|
|
109
|
-
def frame_classes = cn("relative w-full", { "
|
|
117
|
+
def frame_classes = cn("relative w-full", { "@md:flex-1" => circular? })
|
|
110
118
|
|
|
111
119
|
def label = @label || t("ui.chart.label", default: "Chart")
|
|
112
120
|
|
|
@@ -114,9 +122,9 @@ class UI::Chart < UI::Base
|
|
|
114
122
|
return t("ui.chart.missing", default: "—") if value.nil?
|
|
115
123
|
|
|
116
124
|
case @format
|
|
117
|
-
when :currency then ActiveSupport::NumberHelper.number_to_currency(value, **{ unit: @unit }.compact)
|
|
118
|
-
when :percent then ActiveSupport::NumberHelper.number_to_percentage(value, precision: 1, strip_insignificant_zeros:
|
|
119
|
-
else ActiveSupport::NumberHelper.number_to_delimited(value)
|
|
125
|
+
when :currency then ActiveSupport::NumberHelper.number_to_currency(value, **{ unit: @unit, precision: @precision }.compact)
|
|
126
|
+
when :percent then ActiveSupport::NumberHelper.number_to_percentage(value, precision: @precision || 1, strip_insignificant_zeros: @precision.nil?)
|
|
127
|
+
else ActiveSupport::NumberHelper.number_to_delimited(@precision ? value.to_f.round(@precision) : value)
|
|
120
128
|
end
|
|
121
129
|
end
|
|
122
130
|
|
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
<%= tag.span class: overlay_classes do %>
|
|
7
7
|
<%= render(UI::Icon.new(name: "check", size: icon_size, class: "stroke-[3]", aria: { hidden: true })) %>
|
|
8
8
|
<% end %>
|
|
9
|
+
<%= tag.span class: mixed_overlay_classes do %>
|
|
10
|
+
<%= render(UI::Icon.new(name: "minus", size: icon_size, class: "stroke-[3]", aria: { hidden: true })) %>
|
|
11
|
+
<% end %>
|
|
9
12
|
<% end %>
|
|
10
13
|
<%= tag.span class: label_text_classes do %><%= label %><% if required? %><%= tag.span(" *", class: "text-destructive ml-0.5") %><% end %><% end %>
|
|
11
14
|
<% end %>
|
|
@@ -15,6 +18,9 @@
|
|
|
15
18
|
<%= tag.span class: overlay_classes do %>
|
|
16
19
|
<%= render(UI::Icon.new(name: "check", size: icon_size, class: "stroke-[3]", aria: { hidden: true })) %>
|
|
17
20
|
<% end %>
|
|
21
|
+
<%= tag.span class: mixed_overlay_classes do %>
|
|
22
|
+
<%= render(UI::Icon.new(name: "minus", size: icon_size, class: "stroke-[3]", aria: { hidden: true })) %>
|
|
23
|
+
<% end %>
|
|
18
24
|
<% end %>
|
|
19
25
|
<% end %>
|
|
20
26
|
<% end %>
|