velvetkit 0.3.0 → 0.4.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.
Files changed (175) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +80 -0
  3. data/README.md +5 -1
  4. data/lib/generators/velvetkit/add/add_generator.rb +58 -0
  5. data/lib/velvetkit/version.rb +4 -1
  6. data/lib/velvetkit.rb +7 -0
  7. data/registry/app/assets/tailwind/velvetkit.css +90 -155
  8. data/registry/app/components/ui/chart.html.erb +47 -0
  9. data/registry/app/components/ui/chart.rb +177 -0
  10. data/registry/app/components/ui/command/group.rb +27 -0
  11. data/registry/app/components/ui/command/item.rb +64 -0
  12. data/registry/app/components/ui/command.html.erb +41 -0
  13. data/registry/app/components/ui/command.rb +122 -0
  14. data/registry/app/components/ui/date_picker.html.erb +58 -64
  15. data/registry/app/components/ui/date_picker.rb +199 -75
  16. data/registry/app/components/ui/file_field.html.erb +14 -4
  17. data/registry/app/components/ui/file_field.rb +179 -28
  18. data/registry/app/components/ui/gallery/image.rb +20 -0
  19. data/registry/app/components/ui/gallery.html.erb +52 -0
  20. data/registry/app/components/ui/gallery.rb +164 -0
  21. data/registry/app/components/ui/kbd.html.erb +27 -0
  22. data/registry/app/components/ui/kbd.rb +134 -0
  23. data/registry/app/components/ui/number_input.html.erb +11 -0
  24. data/registry/app/components/ui/number_input.rb +103 -0
  25. data/registry/app/components/ui/progress/segment.rb +25 -0
  26. data/registry/app/components/ui/progress.html.erb +25 -0
  27. data/registry/app/components/ui/progress.rb +182 -0
  28. data/registry/app/components/ui/select.html.erb +24 -5
  29. data/registry/app/components/ui/select.rb +44 -5
  30. data/registry/app/components/ui/timeline/item.html.erb +21 -0
  31. data/registry/app/components/ui/timeline/item.rb +145 -0
  32. data/registry/app/components/ui/timeline.html.erb +1 -0
  33. data/registry/app/components/ui/timeline.rb +42 -0
  34. data/registry/app/javascript/chart_js.ts +37 -0
  35. data/registry/app/javascript/controllers/ui/_internal/date_format.ts +74 -0
  36. data/registry/app/javascript/controllers/ui/_internal/shortcut.ts +80 -0
  37. data/registry/app/javascript/controllers/ui/chart_controller.ts +585 -0
  38. data/registry/app/javascript/controllers/ui/command_controller.ts +454 -0
  39. data/registry/app/javascript/controllers/ui/date_picker_controller.ts +247 -82
  40. data/registry/app/javascript/controllers/ui/file_field_controller.ts +288 -16
  41. data/registry/app/javascript/controllers/ui/gallery_controller.ts +568 -0
  42. data/registry/app/javascript/controllers/ui/kbd_controller.ts +60 -0
  43. data/registry/app/javascript/controllers/ui/number_input_controller.ts +111 -0
  44. data/registry/app/javascript/controllers/ui/progress_controller.ts +87 -0
  45. data/registry/app/javascript/controllers/ui/select_controller.ts +198 -8
  46. data/registry/app/javascript/vanilla_calendar.ts +15 -0
  47. data/registry/components.yml +19 -3
  48. data/registry/config/locales/velvetkit.en.yml +73 -0
  49. data/registry/icons/lucide/download.svg +17 -0
  50. data/registry/icons/lucide/file-plus.svg +18 -0
  51. data/registry/icons/lucide/file.svg +16 -0
  52. data/registry/icons/lucide/folder.svg +15 -0
  53. data/registry/icons/lucide/keyboard.svg +23 -0
  54. data/registry/icons/lucide/minus.svg +15 -0
  55. data/registry/icons/lucide/package.svg +18 -0
  56. data/registry/icons/lucide/pause.svg +16 -0
  57. data/registry/icons/lucide/percent.svg +17 -0
  58. data/registry/icons/lucide/printer.svg +17 -0
  59. data/registry/icons/lucide/receipt.svg +17 -0
  60. data/registry/icons/lucide/sun-moon.svg +19 -0
  61. data/registry/icons/lucide/truck.svg +19 -0
  62. data/registry/icons/lucide/user-plus.svg +18 -0
  63. data/registry/icons/lucide/zoom-in.svg +18 -0
  64. data/registry/icons/lucide/zoom-out.svg +17 -0
  65. data/registry/icons/phosphor/circle-half.svg +2 -0
  66. data/registry/icons/phosphor/download-simple.svg +2 -0
  67. data/registry/icons/phosphor/file-plus.svg +2 -0
  68. data/registry/icons/phosphor/file.svg +2 -0
  69. data/registry/icons/phosphor/folder.svg +2 -0
  70. data/registry/icons/phosphor/keyboard.svg +2 -0
  71. data/registry/icons/phosphor/magnifying-glass-minus.svg +2 -0
  72. data/registry/icons/phosphor/magnifying-glass-plus.svg +2 -0
  73. data/registry/icons/phosphor/minus.svg +2 -0
  74. data/registry/icons/phosphor/package.svg +2 -0
  75. data/registry/icons/phosphor/pause.svg +2 -0
  76. data/registry/icons/phosphor/percent.svg +2 -0
  77. data/registry/icons/phosphor/printer.svg +2 -0
  78. data/registry/icons/phosphor/receipt.svg +2 -0
  79. data/registry/icons/phosphor/truck.svg +2 -0
  80. data/registry/icons/phosphor/user-plus.svg +2 -0
  81. data/registry/icons/tabler/download.svg +18 -0
  82. data/registry/icons/tabler/file-plus.svg +19 -0
  83. data/registry/icons/tabler/file.svg +17 -0
  84. data/registry/icons/tabler/folder.svg +16 -0
  85. data/registry/icons/tabler/keyboard.svg +23 -0
  86. data/registry/icons/tabler/minus.svg +16 -0
  87. data/registry/icons/tabler/package.svg +20 -0
  88. data/registry/icons/tabler/percentage.svg +18 -0
  89. data/registry/icons/tabler/player-pause.svg +17 -0
  90. data/registry/icons/tabler/printer.svg +18 -0
  91. data/registry/icons/tabler/receipt.svg +16 -0
  92. data/registry/icons/tabler/sun-moon.svg +21 -0
  93. data/registry/icons/tabler/truck.svg +18 -0
  94. data/registry/icons/tabler/user-plus.svg +19 -0
  95. data/registry/icons/tabler/zoom-in.svg +19 -0
  96. data/registry/icons/tabler/zoom-out.svg +18 -0
  97. data/registry/icons.yml +16 -0
  98. data/registry/test/components/previews/ui/chart_preview/cash_flow.html.erb +6 -0
  99. data/registry/test/components/previews/ui/chart_preview/donut.html.erb +6 -0
  100. data/registry/test/components/previews/ui/chart_preview/margin.html.erb +6 -0
  101. data/registry/test/components/previews/ui/chart_preview/pie.html.erb +6 -0
  102. data/registry/test/components/previews/ui/chart_preview/sales.html.erb +6 -0
  103. data/registry/test/components/previews/ui/chart_preview/stock.html.erb +6 -0
  104. data/registry/test/components/previews/ui/chart_preview/takings.html.erb +8 -0
  105. data/registry/test/components/previews/ui/chart_preview.rb +46 -0
  106. data/registry/test/components/previews/ui/command_preview/_picked.html.erb +14 -0
  107. data/registry/test/components/previews/ui/command_preview/dialog.html.erb +24 -0
  108. data/registry/test/components/previews/ui/command_preview/inline.html.erb +16 -0
  109. data/registry/test/components/previews/ui/command_preview/playground.html.erb +15 -0
  110. data/registry/test/components/previews/ui/command_preview/server_search.html.erb +24 -0
  111. data/registry/test/components/previews/ui/command_preview/shortcuts.html.erb +12 -0
  112. data/registry/test/components/previews/ui/command_preview/till.html.erb +17 -0
  113. data/registry/test/components/previews/ui/command_preview.rb +25 -0
  114. data/registry/test/components/previews/ui/date_picker_preview/custom_presets.html.erb +6 -0
  115. data/registry/test/components/previews/ui/date_picker_preview/in_form.html.erb +11 -0
  116. data/registry/test/components/previews/ui/date_picker_preview/range.html.erb +5 -0
  117. data/registry/test/components/previews/ui/date_picker_preview/states.html.erb +4 -3
  118. data/registry/test/components/previews/ui/date_picker_preview.rb +26 -6
  119. data/registry/test/components/previews/ui/file_field_preview/multiple_files.html.erb +1 -1
  120. data/registry/test/components/previews/ui/file_field_preview/product_photos.html.erb +12 -0
  121. data/registry/test/components/previews/ui/file_field_preview/single_image.html.erb +4 -0
  122. data/registry/test/components/previews/ui/file_field_preview.rb +32 -5
  123. data/registry/test/components/previews/ui/gallery_preview/hover_zoom.html.erb +13 -0
  124. data/registry/test/components/previews/ui/gallery_preview/landscape.html.erb +5 -0
  125. data/registry/test/components/previews/ui/gallery_preview/product_page.html.erb +13 -0
  126. data/registry/test/components/previews/ui/gallery_preview/single.html.erb +3 -0
  127. data/registry/test/components/previews/ui/gallery_preview.rb +45 -0
  128. data/registry/test/components/previews/ui/kbd_preview/bound.html.erb +20 -0
  129. data/registry/test/components/previews/ui/kbd_preview/keys.html.erb +13 -0
  130. data/registry/test/components/previews/ui/kbd_preview/menu.html.erb +13 -0
  131. data/registry/test/components/previews/ui/kbd_preview/search_field.html.erb +8 -0
  132. data/registry/test/components/previews/ui/kbd_preview/shortcuts_list.html.erb +17 -0
  133. data/registry/test/components/previews/ui/kbd_preview/till.html.erb +23 -0
  134. data/registry/test/components/previews/ui/kbd_preview/tooltip_and_buttons.html.erb +14 -0
  135. data/registry/test/components/previews/ui/kbd_preview.rb +32 -0
  136. data/registry/test/components/previews/ui/number_input_preview/cart.html.erb +11 -0
  137. data/registry/test/components/previews/ui/number_input_preview/decimals.html.erb +4 -0
  138. data/registry/test/components/previews/ui/number_input_preview/sizes.html.erb +5 -0
  139. data/registry/test/components/previews/ui/number_input_preview/states.html.erb +7 -0
  140. data/registry/test/components/previews/ui/number_input_preview/stock_adjustment.html.erb +3 -0
  141. data/registry/test/components/previews/ui/number_input_preview.rb +36 -0
  142. data/registry/test/components/previews/ui/progress_preview/file_upload.html.erb +36 -0
  143. data/registry/test/components/previews/ui/progress_preview/free_shipping.html.erb +4 -0
  144. data/registry/test/components/previews/ui/progress_preview/indeterminate.html.erb +4 -0
  145. data/registry/test/components/previews/ui/progress_preview/sizes_and_tones.html.erb +8 -0
  146. data/registry/test/components/previews/ui/progress_preview/steps.html.erb +9 -0
  147. data/registry/test/components/previews/ui/progress_preview/storage.html.erb +8 -0
  148. data/registry/test/components/previews/ui/progress_preview/storage_by_category.html.erb +7 -0
  149. data/registry/test/components/previews/ui/progress_preview/tasks_by_status.html.erb +14 -0
  150. data/registry/test/components/previews/ui/progress_preview/traffic_by_source.html.erb +15 -0
  151. data/registry/test/components/previews/ui/progress_preview.rb +46 -0
  152. data/registry/test/components/previews/ui/select_preview/server_search.html.erb +22 -0
  153. data/registry/test/components/previews/ui/select_preview.rb +5 -0
  154. data/registry/test/components/previews/ui/timeline_preview/activity_log.html.erb +7 -0
  155. data/registry/test/components/previews/ui/timeline_preview/colored.html.erb +7 -0
  156. data/registry/test/components/previews/ui/timeline_preview/colored_by_meaning.html.erb +7 -0
  157. data/registry/test/components/previews/ui/timeline_preview/failed_delivery.html.erb +6 -0
  158. data/registry/test/components/previews/ui/timeline_preview/order_status.html.erb +9 -0
  159. data/registry/test/components/previews/ui/timeline_preview/real_dates.html.erb +5 -0
  160. data/registry/test/components/previews/ui/timeline_preview/stock_history.html.erb +6 -0
  161. data/registry/test/components/previews/ui/timeline_preview.rb +40 -0
  162. data/registry/test/components/ui/chart_test.rb +187 -0
  163. data/registry/test/components/ui/command/group_test.rb +19 -0
  164. data/registry/test/components/ui/command/item_test.rb +47 -0
  165. data/registry/test/components/ui/command_test.rb +110 -0
  166. data/registry/test/components/ui/date_picker_test.rb +129 -111
  167. data/registry/test/components/ui/file_field_test.rb +105 -9
  168. data/registry/test/components/ui/gallery_test.rb +192 -0
  169. data/registry/test/components/ui/kbd_test.rb +150 -0
  170. data/registry/test/components/ui/number_input_test.rb +155 -0
  171. data/registry/test/components/ui/progress_test.rb +188 -0
  172. data/registry/test/components/ui/select_test.rb +62 -0
  173. data/registry/test/components/ui/timeline_test.rb +175 -0
  174. metadata +147 -2
  175. data/registry/app/javascript/cally.ts +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f62bf151307c243a489390029439a9ded5f33d3b66a93749b81db24b90a33186
4
- data.tar.gz: f86a8beed40c9571617bcb3ab2c6be4b7061cf8e7425d3d7bec735ec9d4f938c
3
+ metadata.gz: 1946e018660d08bfab63d5e0a9b9e00e2e41a138bacf878e66832c0eebb0400b
4
+ data.tar.gz: 7b5ae9a20372f619449b42520d0f1d643b9b8d6094437d00715c8faebb883029
5
5
  SHA512:
6
- metadata.gz: 6e46ecf7c1c83c29d7c89b302b123156b977e7696d97758601a0060e2679a521c0557071b679b5d04cf808dcba1ebcb19785c706b2d46cef2107665402e2f0b3
7
- data.tar.gz: d59fdf785470d1bf690295b369905034545770339bc2a25031a092a3845488be66d8ee23560e43ec40d76cbcfe993c30c98cff1ee0fad689a39a49f181d38233
6
+ metadata.gz: e4cb6bacd3d8e0ccc231e5d655ac639d40df556e49d7b02f1aa0feb5d2ccb8f46aa2a99a08853f26ceb789e920d5f4a5e779c29e3a816c28296547a6b6549200
7
+ data.tar.gz: 7624a9d18314e65a4c43a883c9e42b1ac0291ba84b8c5bccb1641a594311384112933abd158ed412877b4b2252f971853ecc5b4d5fbbcbcf000dfe0aaa74aa52
data/CHANGELOG.md CHANGED
@@ -1,5 +1,85 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ New components:
6
+
7
+ - `Timeline`: dated entries down the page (order status, stock history, an
8
+ activity log), drawn as circles, dots or circles in a colour each.
9
+ - `NumberInput`: a number field with - and + buttons that keep counting while
10
+ held; `change` fires once on release, so a cart row submits once.
11
+ - `Gallery`: product photos with thumbnails and swiping, opening over the
12
+ page to zoom and pan, or `zoom: :hover` for a lens and a magnified pane.
13
+ - `Chart`: line, bar, stacked bar, pie and donut charts on Chart.js, with a
14
+ legend, tooltips, keyboard reading, a table of the numbers, and animation.
15
+ The docs site has a Charts section with a page for each.
16
+
17
+ Changes:
18
+
19
+ - `Select` searches the server as you type with `url:` (JSON back), with a
20
+ spinner when it's slow, results remembered for a minute, and choices kept
21
+ when later searches no longer list them.
22
+ - `DatePicker` moves from Cally to Vanilla Calendar Pro and takes
23
+ `range: true` for From and To, with presets such as Last 7 days, two months
24
+ side by side, and a hover preview. Typed dates take digits only, the
25
+ separators go in as you type, and the calendar opens on click or focus.
26
+ - `FileField` shows a tile for each chosen file, checks `accept:` and
27
+ `max_size:`, and with `direct_upload: true` sends each file to storage
28
+ through Active Storage as it's chosen, with a progress bar. Bound to a
29
+ form, it shows the record's attachments.
30
+ - The chart colours, `--chart-1` to `--chart-5`, are now velvet, orange,
31
+ aqua, blue and magenta, checked for colour-blind readers in both themes.
32
+ - `velvetkit:add` puts the bundles Chart, Date Picker and Data Grid load on
33
+ demand (`chart_js.ts`, `vanilla_calendar.ts`, `ag_grid.ts`) into the app's
34
+ JavaScript build: `bun.config.js`, `webpack.config.js`, or a build script
35
+ that lists `application.js`. Before, they were copied but never built, so
36
+ those components failed to load their library.
37
+
38
+ Upgrading an app: re-run `velvetkit:add` for `date_picker`, `select` and
39
+ `file_field`, and copy the new `--chart-*` values into your `velvetkit.css`.
40
+ `date_picker` now needs `vanilla-calendar-pro` instead of `cally`, and loads
41
+ `app/javascript/vanilla_calendar.ts` as its own entry point; `file_field`
42
+ needs `@rails/activestorage`. If you added `chart_js.ts`,
43
+ `vanilla_calendar.ts` or `ag_grid.ts` to your build by hand, `add` leaves
44
+ it as it is.
45
+
46
+ - Fix: Rails 8.1.4.1, for security advisories in Active Storage and Action Pack.
47
+ - Fix: the docs site shows a component added to the catalog without a server
48
+ restart.
49
+
50
+ ## 0.3.0 — 2026-11-03
51
+
52
+ - `Stepper`: the steps of a multi-step form, done, current or to come, with
53
+ dots, centred labels, panels moved between in the browser, and links back
54
+ to done steps.
55
+ - `ConfirmDialog`: a styled dialog that answers `data-turbo-confirm`, so every
56
+ existing confirm uses it.
57
+ - `ToggleGroup`: a row of buttons choosing one or several, posting like
58
+ radios or checkboxes.
59
+ - `EmptyState`: an icon, title, text and actions for a page with nothing to
60
+ list.
61
+ - Icons come from Lucide, Tabler or Phosphor, chosen with
62
+ `velvetkit:install --icons=`, and are drawn as inline SVG.
63
+
64
+ ## 0.2.2 — 2026-11-02
65
+
66
+ - Fix: the `plus`, `search`, `ellipsis-vertical` and `grip-vertical` icons were
67
+ missing from installs.
68
+
69
+ ## 0.2.1 — 2026-11-01
70
+
71
+ - `NavigationMenu`: site navigation with links and panels of rich links that
72
+ open on hover or click.
73
+
74
+ ## 0.2.0 — 2026-11-01
75
+
76
+ - `Toast`: stacked messages that dismiss themselves.
77
+ - `SessionTabs`: tabs for open sessions, with a button to add one.
78
+ - `Skeleton` and `FileField`.
79
+ - Fix: `Menu` content positions itself with the fixed strategy, so it isn't
80
+ clipped by a scrolling container.
81
+ - Fix: dependencies updated for security advisories in `addressable` and `rack`.
82
+
3
83
  ## 0.1.0.beta — 2026-10-26
4
84
 
5
85
  - First release of the component library.
data/README.md CHANGED
@@ -160,7 +160,11 @@ bin/rails generate velvetkit:add --all # everything
160
160
 
161
161
  - copies the component, its templates and sub-components
162
162
  - copies its Stimulus controllers and any lazily-loaded entry points (AG Grid
163
- for `data_grid`, Cally for `date_picker`)
163
+ for `data_grid`, Chart.js for `chart`, Vanilla Calendar Pro for `date_picker`),
164
+ and adds those to your JavaScript build: to `bun.config.js`'s `entrypoints`,
165
+ `webpack.config.js`'s `entry`, or a build script that lists `application.js`.
166
+ esbuild's default `app/javascript/*.*` already takes them; for any other setup
167
+ `add` says what to add
164
168
  - copies the SVG of every icon it draws into `app/assets/icons`, named for
165
169
  your icon library
166
170
  - copies its Minitest tests and Lookbook previews. A preview that shows
@@ -90,6 +90,27 @@ module Velvetkit
90
90
  end
91
91
  end
92
92
 
93
+ # Bundles a component loads only when it's on the page (Chart.js,
94
+ # Vanilla Calendar Pro, AG Grid) are entry points of their own, so the
95
+ # app's JavaScript build has to know about them. Added where the build
96
+ # lists its entry points; an esbuild glob already takes them; anything
97
+ # else is told what to add.
98
+ def wire_entry_points
99
+ entry_points.each do |entry|
100
+ if exists?("bun.config.js") && read("bun.config.js").match?(/entrypoints:\s*\[/)
101
+ add_to_bun_config(entry)
102
+ elsif exists?("webpack.config.js") && read("webpack.config.js").match?(/entry:\s*\{/)
103
+ add_to_webpack_config(entry)
104
+ elsif build_script&.match?(%r{app/javascript/\*})
105
+ say_status :build, "#{entry} is built by the build script's app/javascript/* already", :blue
106
+ elsif build_script&.match?(%r{app/javascript/application\.[jt]s})
107
+ add_to_build_script(entry)
108
+ else
109
+ say_status :build, "add #{entry} to your JavaScript build as an entry point of its own, like application.js", :yellow
110
+ end
111
+ end
112
+ end
113
+
93
114
  def add_gems
94
115
  gemfile = File.read(File.join(destination_root, "Gemfile"))
95
116
  resolved.flat_map { |name| registry.gems(name).to_a }.uniq.each do |name, version|
@@ -125,6 +146,43 @@ module Velvetkit
125
146
  def controllers
126
147
  resolved.flat_map { |name| registry.stimulus_controllers(name) }.uniq
127
148
  end
149
+
150
+ # app/javascript/chart_js.ts and the like: JavaScript that isn't a
151
+ # Stimulus controller or one of their shared helpers.
152
+ def entry_points
153
+ resolved.flat_map { |name| registry.javascript_files(name) }.uniq
154
+ .select { |file| file.start_with?("app/javascript/") && !file.start_with?("app/javascript/controllers/") }
155
+ end
156
+
157
+ def build_script
158
+ return nil unless exists?("package.json")
159
+
160
+ JSON.parse(read("package.json")).dig("scripts", "build")
161
+ rescue JSON::ParserError
162
+ nil
163
+ end
164
+
165
+ def add_to_bun_config(entry)
166
+ return if read("bun.config.js").include?(entry)
167
+
168
+ gsub_file "bun.config.js", /(entrypoints:\s*\[)/, %(\\1"#{entry}", )
169
+ end
170
+
171
+ def add_to_webpack_config(entry)
172
+ return if read("webpack.config.js").include?(entry)
173
+
174
+ gsub_file "webpack.config.js", /(entry:\s*\{\s*\n)/, %(\\1 #{File.basename(entry, ".*")}: "./#{entry}",\n)
175
+ end
176
+
177
+ # After application.js in the build script, written the same way ("./" or not).
178
+ def add_to_build_script(entry)
179
+ return if build_script.include?(entry)
180
+
181
+ gsub_file "package.json", %r{((?:\./)?)app/javascript/application\.[jt]s}, "\\0 \\1#{entry}"
182
+ end
183
+
184
+ def exists?(file) = File.exist?(File.join(destination_root, file))
185
+ def read(file) = File.read(File.join(destination_root, file))
128
186
  end
129
187
  end
130
188
  end
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Velvetkit
4
- VERSION = "0.3.0"
4
+ # Not the released version: the release workflow takes that from the tag
5
+ # (v0.3.0 publishes 0.3.0) and writes it here on the runner only, so this
6
+ # file can stay behind. See .github/workflows/release.yml.
7
+ VERSION = "0.4.0"
5
8
  end
data/lib/velvetkit.rb CHANGED
@@ -18,6 +18,13 @@ module Velvetkit
18
18
  @registry ||= Registry.new(File.expand_path("../registry", __dir__))
19
19
  end
20
20
 
21
+ # Forgets the catalog, so the next call reads components.yml again. The docs
22
+ # site calls it on each code reload in development, so a component added to
23
+ # the catalog shows up without restarting the server.
24
+ def self.reload_registry!
25
+ @registry = nil
26
+ end
27
+
21
28
  # Everything an AI agent needs to build UI in an app: the rules, then a
22
29
  # reference for each component, all in the app's namespace.
23
30
  def self.agent_guide(components, namespace: Namespace.new(Namespace::CANONICAL))
@@ -49,11 +49,14 @@
49
49
  --ring: var(--primary);
50
50
  --chart-pie-active: oklch(0.9137 0.1511 150.96);
51
51
  --chart-pie-inactive: oklch(0.3533 0.0096 164.42);
52
- --chart-1: oklch(0.646 0.222 41.116);
53
- --chart-2: oklch(0.6 0.118 184.704);
54
- --chart-3: oklch(0.398 0.07 227.392);
55
- --chart-4: oklch(0.828 0.189 84.429);
56
- --chart-5: oklch(0.769 0.188 70.08);
52
+ /* Chart series, in this order: velvet, orange, aqua, blue, magenta. Checked
53
+ with a colour-vision validator so neighbours stay apart for colour-blind
54
+ readers; dark mode keeps the same hues, stepped for the dark surface. */
55
+ --chart-1: #793cbb;
56
+ --chart-2: #eb6834;
57
+ --chart-3: #1baf7a;
58
+ --chart-4: #2a78d6;
59
+ --chart-5: #e87ba4;
57
60
  --sidebar: oklch(0.985 0.001 286.32);
58
61
  --sidebar-foreground: oklch(0.141 0.005 285.823);
59
62
  /* Accent for the active nav item; lighter in dark so it clears AA against
@@ -93,11 +96,11 @@
93
96
  --ring: var(--primary);
94
97
  --chart-pie-active: oklch(0.696 0.17 162.48);
95
98
  --chart-pie-inactive: oklch(0.556 0 0);
96
- --chart-1: oklch(0.488 0.243 264.376);
97
- --chart-2: oklch(0.696 0.17 162.48);
98
- --chart-3: oklch(0.769 0.188 70.08);
99
- --chart-4: oklch(0.627 0.265 303.9);
100
- --chart-5: oklch(0.645 0.246 16.439);
99
+ --chart-1: #9362d3;
100
+ --chart-2: #d95926;
101
+ --chart-3: #199e70;
102
+ --chart-4: #3987e5;
103
+ --chart-5: #d55181;
101
104
  --sidebar: oklch(0.21 0.006 285.885);
102
105
  --sidebar-foreground: oklch(0.985 0 0);
103
106
  --sidebar-primary: oklch(0.7 0.15 301.6);
@@ -184,159 +187,91 @@ select:-webkit-autofill {
184
187
  transition: background-color 100000s ease-in-out 0s;
185
188
  }
186
189
 
187
- /* The date picker calendar.
188
- *
189
- * Cally renders in a shadow root, so it is reachable only through the custom
190
- * properties and ::part() names it publishes. All of them are pointed at the
191
- * kit's tokens, which is what makes the calendar follow dark mode with no
192
- * JavaScript.
193
- *
194
- * Layout: ‹ [May ▾] [2012 ▾] › in one header row. The selects sit in Cally's
195
- * heading slot (see date_picker.html.erb), so its own heading and the month's
196
- * heading would only repeat them.
190
+ /* The date picker's calendar: Vanilla Calendar Pro, with its light theme's
191
+ * colours pointed at the kit's tokens. The theme reads every colour from a
192
+ * --vc-* variable, so these follow dark mode and any retheme with no
193
+ * JavaScript. The library's own stylesheet loads with it (vanilla_calendar.ts),
194
+ * so a page without a date picker pays nothing for these.
197
195
  */
198
- calendar-date,
199
- calendar-range {
200
- --color-accent: var(--primary);
201
- --color-text-on-accent: var(--primary-foreground);
196
+ .velvetkit-calendar {
197
+ --vc-bg: var(--popover);
198
+ --vc-color: var(--popover-foreground);
199
+ --vc-header-color: var(--popover-foreground);
200
+ --vc-title-color: var(--popover-foreground);
201
+ --vc-title-color-hover: var(--muted-foreground);
202
+ --vc-title-color-disabled: var(--muted-foreground);
203
+ --vc-focus-outline-color: var(--ring);
204
+ --vc-week-day-color: var(--muted-foreground);
205
+ --vc-week-day-color-hover: var(--foreground);
206
+ --vc-week-day-off-color: var(--muted-foreground);
207
+ --vc-week-day-off-color-hover: var(--foreground);
208
+ --vc-date-bg: transparent;
209
+ --vc-date-color: var(--popover-foreground);
210
+ --vc-date-bg-hover: var(--accent);
211
+ --vc-date-hover-bg: var(--accent);
212
+ --vc-date-hover-edge-bg: color-mix(in oklab, var(--primary) 20%, transparent);
213
+ --vc-date-outside-color: var(--muted-foreground);
214
+ --vc-date-disabled-color: color-mix(in oklab, var(--muted-foreground) 50%, transparent);
215
+ --vc-date-today-bg: var(--accent);
216
+ --vc-date-today-color: var(--primary);
217
+ --vc-date-today-outside-color: var(--muted-foreground);
218
+ --vc-date-selected-bg: var(--primary);
219
+ --vc-date-selected-color: var(--primary-foreground);
220
+ --vc-date-selected-outside-bg: color-mix(in oklab, var(--primary) 20%, transparent);
221
+ --vc-date-selected-outside-color: var(--muted-foreground);
222
+ /* The days inside a range: a tint, so the two ends stand out. */
223
+ --vc-date-range-middle-bg: color-mix(in oklab, var(--primary) 12%, transparent);
224
+ --vc-date-range-middle-color: var(--popover-foreground);
225
+ --vc-date-range-middle-outside-bg: color-mix(in oklab, var(--primary) 6%, transparent);
226
+ --vc-date-range-middle-outside-color: var(--muted-foreground);
227
+ --vc-date-range-middle-weekend-bg: var(--vc-date-range-middle-bg);
228
+ --vc-date-range-middle-weekend-color: var(--vc-date-range-middle-color);
229
+ --vc-date-range-tooltip-bg: var(--popover);
230
+ --vc-date-range-tooltip-color: var(--muted-foreground);
231
+ --vc-date-popup-bg: var(--popover);
232
+ --vc-date-popup-color: var(--popover-foreground);
233
+ /* Weekends look like any other day: in a shop, Saturday is a working day. */
234
+ --vc-date-weekend-color: var(--vc-date-color);
235
+ --vc-date-weekend-bg-hover: var(--accent);
236
+ --vc-date-weekend-hover-bg: var(--accent);
237
+ --vc-date-weekend-hover-edge-bg: var(--vc-date-hover-edge-bg);
238
+ --vc-date-weekend-selected-bg: var(--primary);
239
+ --vc-date-weekend-selected-color: var(--primary-foreground);
240
+ --vc-date-weekend-today-color: var(--primary);
241
+ --vc-date-weekend-outside-color: var(--muted-foreground);
242
+ --vc-date-weekend-outside-bg: transparent;
243
+ --vc-date-weekend-outside-bg-hover: var(--accent);
244
+ --vc-date-weekend-outside-hover-bg: var(--accent);
245
+ --vc-date-weekend-disabled-color: var(--vc-date-disabled-color);
246
+ --vc-date-weekend-disabled-outside-color: var(--vc-date-disabled-color);
247
+ --vc-date-weekend-today-disabled-color: var(--vc-date-disabled-color);
248
+ --vc-date-weekend-today-outside-color: var(--muted-foreground);
249
+ --vc-months-years-bg: transparent;
250
+ --vc-months-years-bg-hover: var(--accent);
251
+ --vc-months-years-bg-selected: var(--primary);
252
+ --vc-months-years-color: var(--popover-foreground);
253
+ --vc-months-years-color-selected: var(--primary-foreground);
254
+ --vc-months-years-color-disabled: var(--vc-date-disabled-color);
255
+ --vc-collapse-color: var(--border);
202
256
  font-family: inherit;
203
- font-size: 0.875rem;
204
- color: var(--popover-foreground);
205
- }
206
-
207
- calendar-date::part(header),
208
- calendar-range::part(header) {
209
- display: flex;
210
- align-items: center;
211
- justify-content: space-between;
212
- gap: 0.25rem;
213
- margin-bottom: 0.5rem;
214
- }
215
-
216
- /* The arrows: ghost icon buttons. */
217
- calendar-date::part(button),
218
- calendar-range::part(button) {
219
- display: inline-grid;
220
- place-items: center;
221
- width: 2rem;
222
- height: 2rem;
223
- padding: 0;
224
- border: 0;
225
- border-radius: var(--radius-md);
226
- background: transparent;
227
- color: var(--muted-foreground);
228
- cursor: pointer;
229
- }
230
-
231
- calendar-date::part(button):hover,
232
- calendar-range::part(button):hover {
233
- background: var(--accent);
234
- color: var(--accent-foreground);
235
- }
236
-
237
- calendar-date::part(button):focus-visible,
238
- calendar-range::part(button):focus-visible {
239
- outline: 2px solid var(--ring);
240
- outline-offset: 1px;
241
- }
242
-
243
- calendar-date::part(disabled),
244
- calendar-range::part(disabled) {
245
- opacity: 0.35;
246
- cursor: default;
247
- }
248
-
249
- calendar-month::part(heading) {
250
- display: none;
251
- }
252
-
253
- calendar-month::part(th) {
254
- padding-bottom: 0.25rem;
255
- font-size: 0.75rem;
256
- font-weight: 500;
257
- color: var(--muted-foreground);
258
257
  }
259
258
 
260
- /* Days. */
261
- calendar-month::part(button) {
262
- width: 2.25rem;
263
- height: 2.25rem;
264
- border: 0;
265
- border-radius: var(--radius-md);
266
- background: transparent;
267
- color: var(--popover-foreground);
268
- font-size: 0.875rem;
269
- cursor: pointer;
270
- }
271
-
272
- calendar-month::part(button):hover {
273
- background: var(--accent);
274
- color: var(--accent-foreground);
275
- }
276
-
277
- calendar-month::part(button):focus-visible {
278
- outline: 2px solid var(--ring);
279
- outline-offset: 1px;
280
- }
281
-
282
- calendar-month::part(outside) {
283
- color: var(--muted-foreground);
284
- opacity: 0.6;
285
- }
286
-
287
- /* Today: a quiet tint rather than a hard box. */
288
- calendar-month::part(today) {
289
- outline: none;
290
- background: var(--accent);
291
- color: var(--primary);
292
- font-weight: 600;
293
- }
294
-
295
- /* The chosen day, after today so it wins when they're the same. */
296
- calendar-month::part(selected) {
297
- background: var(--primary);
298
- color: var(--primary-foreground);
299
- font-weight: 600;
300
- }
301
-
302
- /* Month and year: the reason this library was chosen, since reaching a birth
303
- year is one click rather than a hundred and seventy. Styled like the kit's
304
- fields; the open list is the platform's own. */
305
- calendar-select-month::part(select),
306
- calendar-select-year::part(select) {
307
- appearance: none;
308
- height: 2rem;
309
- padding: 0 1.75rem 0 0.625rem;
310
- border: 1px solid var(--input);
311
- border-radius: var(--radius-md);
312
- background: var(--background)
313
- url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8a93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")
314
- no-repeat right 0.5rem center / 0.875rem;
315
- color: var(--foreground);
316
- font: inherit;
317
- font-size: 0.875rem;
318
- font-weight: 500;
319
- cursor: pointer;
259
+ .velvetkit-calendar .vc {
260
+ font-family: inherit;
320
261
  }
321
262
 
322
- calendar-select-month::part(select):hover,
323
- calendar-select-year::part(select):hover {
324
- background-color: var(--accent);
263
+ /* Only the two ends of a range are bold. */
264
+ .velvetkit-calendar [data-vc-date-selected="middle"] .vc-date__btn {
265
+ font-weight: 400;
325
266
  }
326
267
 
327
- calendar-select-month::part(select):focus-visible,
328
- calendar-select-year::part(select):focus-visible {
329
- outline: 2px solid var(--ring);
330
- outline-offset: 1px;
268
+ /* The arrows are drawn dark by the theme; lighten them on a dark page. */
269
+ .dark .velvetkit-calendar .vc-arrow::before {
270
+ filter: invert(1);
331
271
  }
332
272
 
333
- /* The "Month" and "Year" labels stay for screen readers only. */
334
- calendar-select-month::part(label),
335
- calendar-select-year::part(label) {
336
- position: absolute;
337
- width: 1px;
338
- height: 1px;
339
- overflow: hidden;
340
- clip-path: inset(50%);
341
- white-space: nowrap;
273
+ /* UI::Progress with no value: a short bar sliding across the track. */
274
+ @keyframes velvetkit-progress {
275
+ from { transform: translateX(-100%); }
276
+ to { transform: translateX(250%); }
342
277
  }
@@ -0,0 +1,47 @@
1
+ <%= tag.div(**root_attrs) do %>
2
+ <%= tag.div class: body_classes do %>
3
+ <% if legend? %>
4
+ <%= tag.ul class: legend_classes, aria: { hidden: true } do %>
5
+ <% if circular? %>
6
+ <% slices.each do |slice| %>
7
+ <li class="flex items-center gap-2"><%= tag.span class: slice_swatch(slice) %><span class="min-w-0 flex-1 break-words text-muted-foreground"><%= slice.label %></span><span class="font-medium tabular-nums"><%= slice.text %></span><span class="w-10 text-end tabular-nums text-muted-foreground"><%= slice.share %></span></li>
8
+ <% end %>
9
+ <% else %>
10
+ <% series.each do |entry| %>
11
+ <li class="flex items-center gap-2"><%= tag.span class: swatch_classes(entry) %><%= entry.name %></li>
12
+ <% end %>
13
+ <% end %>
14
+ <% end %>
15
+ <% end %>
16
+ <%= tag.div class: frame_classes, style: frame_style do %>
17
+ <%= tag.canvas(**canvas_attrs) %>
18
+ <%# It glides from point to point and fades in and out, rather than jumping. %>
19
+ <%= tag.div aria: { hidden: true }, data: { "ui--chart-target": "tooltip" },
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
+ <% end %>
22
+ <% end %>
23
+ <details class="group/data text-sm">
24
+ <%= 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}" %>
25
+ <div class="mt-2 overflow-x-auto">
26
+ <table class="w-full text-sm tabular-nums">
27
+ <%= tag.caption label, class: "sr-only" %>
28
+ <thead>
29
+ <tr class="border-b">
30
+ <%= tag.th t("ui.chart.category", default: "Category"), scope: "col", class: "py-2 pe-4 text-start font-medium text-muted-foreground" %>
31
+ <% series.each do |entry| %><%= tag.th entry.name, scope: "col", class: "py-2 ps-4 text-end font-medium text-muted-foreground" %><% end %>
32
+ <% if circular? %><%= tag.th t("ui.chart.share", default: "Share"), scope: "col", class: "py-2 ps-4 text-end font-medium text-muted-foreground" %><% end %>
33
+ </tr>
34
+ </thead>
35
+ <tbody>
36
+ <% labels.each_with_index do |row, index| %>
37
+ <tr class="border-b last:border-0">
38
+ <%= tag.th row, scope: "row", class: "py-2 pe-4 text-start font-normal" %>
39
+ <% series.each do |entry| %><%= tag.td formatted(entry.data[index]), class: "py-2 ps-4 text-end" %><% end %>
40
+ <% if circular? %><%= tag.td share_text(series.first.data[index]), class: "py-2 ps-4 text-end text-muted-foreground" %><% end %>
41
+ </tr>
42
+ <% end %>
43
+ </tbody>
44
+ </table>
45
+ </div>
46
+ </details>
47
+ <% end %>