velvetkit 0.3.0 → 0.4.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/CHANGELOG.md +109 -0
- data/README.md +5 -1
- data/lib/generators/velvetkit/add/add_generator.rb +58 -0
- data/lib/velvetkit/version.rb +4 -1
- data/lib/velvetkit.rb +7 -0
- data/registry/app/assets/tailwind/velvetkit.css +90 -155
- data/registry/app/components/ui/chart.html.erb +47 -0
- data/registry/app/components/ui/chart.rb +177 -0
- data/registry/app/components/ui/command/group.rb +27 -0
- data/registry/app/components/ui/command/item.rb +64 -0
- data/registry/app/components/ui/command.html.erb +41 -0
- data/registry/app/components/ui/command.rb +122 -0
- data/registry/app/components/ui/date_picker.html.erb +58 -64
- data/registry/app/components/ui/date_picker.rb +199 -75
- data/registry/app/components/ui/file_field.html.erb +14 -4
- data/registry/app/components/ui/file_field.rb +179 -28
- data/registry/app/components/ui/gallery/image.rb +20 -0
- data/registry/app/components/ui/gallery.html.erb +52 -0
- data/registry/app/components/ui/gallery.rb +164 -0
- data/registry/app/components/ui/kbd.html.erb +27 -0
- data/registry/app/components/ui/kbd.rb +134 -0
- data/registry/app/components/ui/money_input.html.erb +8 -0
- data/registry/app/components/ui/money_input.rb +153 -0
- data/registry/app/components/ui/number_input.html.erb +11 -0
- data/registry/app/components/ui/number_input.rb +103 -0
- data/registry/app/components/ui/progress/segment.rb +25 -0
- data/registry/app/components/ui/progress.html.erb +25 -0
- data/registry/app/components/ui/progress.rb +182 -0
- data/registry/app/components/ui/scan_input.html.erb +6 -0
- data/registry/app/components/ui/scan_input.rb +94 -0
- data/registry/app/components/ui/select.html.erb +24 -5
- data/registry/app/components/ui/select.rb +44 -5
- data/registry/app/components/ui/slider.html.erb +23 -0
- data/registry/app/components/ui/slider.rb +254 -0
- data/registry/app/components/ui/timeline/item.html.erb +21 -0
- data/registry/app/components/ui/timeline/item.rb +145 -0
- data/registry/app/components/ui/timeline.html.erb +1 -0
- data/registry/app/components/ui/timeline.rb +42 -0
- data/registry/app/javascript/chart_js.ts +37 -0
- data/registry/app/javascript/controllers/ui/_internal/date_format.ts +74 -0
- data/registry/app/javascript/controllers/ui/_internal/shortcut.ts +80 -0
- data/registry/app/javascript/controllers/ui/chart_controller.ts +585 -0
- data/registry/app/javascript/controllers/ui/command_controller.ts +454 -0
- data/registry/app/javascript/controllers/ui/date_picker_controller.ts +247 -82
- data/registry/app/javascript/controllers/ui/file_field_controller.ts +288 -16
- data/registry/app/javascript/controllers/ui/gallery_controller.ts +568 -0
- data/registry/app/javascript/controllers/ui/kbd_controller.ts +60 -0
- data/registry/app/javascript/controllers/ui/money_input_controller.ts +228 -0
- data/registry/app/javascript/controllers/ui/number_input_controller.ts +111 -0
- data/registry/app/javascript/controllers/ui/progress_controller.ts +87 -0
- data/registry/app/javascript/controllers/ui/scan_input_controller.ts +143 -0
- data/registry/app/javascript/controllers/ui/select_controller.ts +198 -8
- data/registry/app/javascript/controllers/ui/slider_controller.ts +216 -0
- data/registry/app/javascript/vanilla_calendar.ts +15 -0
- data/registry/components.yml +25 -3
- data/registry/config/locales/velvetkit.en.yml +79 -0
- data/registry/icons/lucide/download.svg +17 -0
- data/registry/icons/lucide/file-plus.svg +18 -0
- data/registry/icons/lucide/file.svg +16 -0
- data/registry/icons/lucide/folder.svg +15 -0
- data/registry/icons/lucide/keyboard.svg +23 -0
- data/registry/icons/lucide/minus.svg +15 -0
- data/registry/icons/lucide/package.svg +18 -0
- data/registry/icons/lucide/pause.svg +16 -0
- data/registry/icons/lucide/percent.svg +17 -0
- data/registry/icons/lucide/printer.svg +17 -0
- data/registry/icons/lucide/receipt.svg +17 -0
- data/registry/icons/lucide/scan-barcode.svg +21 -0
- data/registry/icons/lucide/sun-moon.svg +19 -0
- data/registry/icons/lucide/truck.svg +19 -0
- data/registry/icons/lucide/user-plus.svg +18 -0
- data/registry/icons/lucide/volume-2.svg +17 -0
- data/registry/icons/lucide/volume-x.svg +17 -0
- data/registry/icons/lucide/zoom-in.svg +18 -0
- data/registry/icons/lucide/zoom-out.svg +17 -0
- data/registry/icons/phosphor/barcode.svg +2 -0
- data/registry/icons/phosphor/circle-half.svg +2 -0
- data/registry/icons/phosphor/download-simple.svg +2 -0
- data/registry/icons/phosphor/file-plus.svg +2 -0
- data/registry/icons/phosphor/file.svg +2 -0
- data/registry/icons/phosphor/folder.svg +2 -0
- data/registry/icons/phosphor/keyboard.svg +2 -0
- data/registry/icons/phosphor/magnifying-glass-minus.svg +2 -0
- data/registry/icons/phosphor/magnifying-glass-plus.svg +2 -0
- data/registry/icons/phosphor/minus.svg +2 -0
- data/registry/icons/phosphor/package.svg +2 -0
- data/registry/icons/phosphor/pause.svg +2 -0
- data/registry/icons/phosphor/percent.svg +2 -0
- data/registry/icons/phosphor/printer.svg +2 -0
- data/registry/icons/phosphor/receipt.svg +2 -0
- data/registry/icons/phosphor/speaker-high.svg +2 -0
- data/registry/icons/phosphor/speaker-x.svg +2 -0
- data/registry/icons/phosphor/truck.svg +2 -0
- data/registry/icons/phosphor/user-plus.svg +2 -0
- data/registry/icons/tabler/barcode.svg +23 -0
- data/registry/icons/tabler/download.svg +18 -0
- data/registry/icons/tabler/file-plus.svg +19 -0
- data/registry/icons/tabler/file.svg +17 -0
- data/registry/icons/tabler/folder.svg +16 -0
- data/registry/icons/tabler/keyboard.svg +23 -0
- data/registry/icons/tabler/minus.svg +16 -0
- data/registry/icons/tabler/package.svg +20 -0
- data/registry/icons/tabler/percentage.svg +18 -0
- data/registry/icons/tabler/player-pause.svg +17 -0
- data/registry/icons/tabler/printer.svg +18 -0
- data/registry/icons/tabler/receipt.svg +16 -0
- data/registry/icons/tabler/sun-moon.svg +21 -0
- data/registry/icons/tabler/truck.svg +18 -0
- data/registry/icons/tabler/user-plus.svg +19 -0
- data/registry/icons/tabler/volume-3.svg +17 -0
- data/registry/icons/tabler/volume.svg +18 -0
- data/registry/icons/tabler/zoom-in.svg +19 -0
- data/registry/icons/tabler/zoom-out.svg +18 -0
- data/registry/icons.yml +19 -0
- data/registry/test/components/previews/ui/chart_preview/cash_flow.html.erb +6 -0
- data/registry/test/components/previews/ui/chart_preview/donut.html.erb +6 -0
- data/registry/test/components/previews/ui/chart_preview/margin.html.erb +6 -0
- data/registry/test/components/previews/ui/chart_preview/pie.html.erb +6 -0
- data/registry/test/components/previews/ui/chart_preview/sales.html.erb +6 -0
- data/registry/test/components/previews/ui/chart_preview/stock.html.erb +6 -0
- data/registry/test/components/previews/ui/chart_preview/takings.html.erb +8 -0
- data/registry/test/components/previews/ui/chart_preview.rb +46 -0
- data/registry/test/components/previews/ui/command_preview/_picked.html.erb +14 -0
- data/registry/test/components/previews/ui/command_preview/dialog.html.erb +24 -0
- data/registry/test/components/previews/ui/command_preview/inline.html.erb +16 -0
- data/registry/test/components/previews/ui/command_preview/playground.html.erb +15 -0
- data/registry/test/components/previews/ui/command_preview/server_search.html.erb +24 -0
- data/registry/test/components/previews/ui/command_preview/shortcuts.html.erb +12 -0
- data/registry/test/components/previews/ui/command_preview/till.html.erb +17 -0
- data/registry/test/components/previews/ui/command_preview.rb +25 -0
- data/registry/test/components/previews/ui/date_picker_preview/custom_presets.html.erb +6 -0
- data/registry/test/components/previews/ui/date_picker_preview/in_form.html.erb +11 -0
- data/registry/test/components/previews/ui/date_picker_preview/range.html.erb +5 -0
- data/registry/test/components/previews/ui/date_picker_preview/states.html.erb +4 -3
- data/registry/test/components/previews/ui/date_picker_preview.rb +26 -6
- data/registry/test/components/previews/ui/file_field_preview/multiple_files.html.erb +1 -1
- data/registry/test/components/previews/ui/file_field_preview/product_photos.html.erb +12 -0
- data/registry/test/components/previews/ui/file_field_preview/single_image.html.erb +4 -0
- data/registry/test/components/previews/ui/file_field_preview.rb +32 -5
- data/registry/test/components/previews/ui/gallery_preview/hover_zoom.html.erb +13 -0
- data/registry/test/components/previews/ui/gallery_preview/landscape.html.erb +5 -0
- data/registry/test/components/previews/ui/gallery_preview/product_page.html.erb +13 -0
- data/registry/test/components/previews/ui/gallery_preview/single.html.erb +3 -0
- data/registry/test/components/previews/ui/gallery_preview.rb +45 -0
- data/registry/test/components/previews/ui/kbd_preview/bound.html.erb +20 -0
- data/registry/test/components/previews/ui/kbd_preview/keys.html.erb +13 -0
- data/registry/test/components/previews/ui/kbd_preview/menu.html.erb +13 -0
- data/registry/test/components/previews/ui/kbd_preview/search_field.html.erb +8 -0
- data/registry/test/components/previews/ui/kbd_preview/shortcuts_list.html.erb +17 -0
- data/registry/test/components/previews/ui/kbd_preview/till.html.erb +23 -0
- data/registry/test/components/previews/ui/kbd_preview/tooltip_and_buttons.html.erb +14 -0
- data/registry/test/components/previews/ui/kbd_preview.rb +32 -0
- data/registry/test/components/previews/ui/money_input_preview/cash_tendered.html.erb +24 -0
- data/registry/test/components/previews/ui/money_input_preview/currencies.html.erb +7 -0
- data/registry/test/components/previews/ui/money_input_preview/invoice.html.erb +24 -0
- data/registry/test/components/previews/ui/money_input_preview/sizes_and_states.html.erb +9 -0
- data/registry/test/components/previews/ui/money_input_preview.rb +34 -0
- data/registry/test/components/previews/ui/number_input_preview/cart.html.erb +11 -0
- data/registry/test/components/previews/ui/number_input_preview/decimals.html.erb +4 -0
- data/registry/test/components/previews/ui/number_input_preview/sizes.html.erb +5 -0
- data/registry/test/components/previews/ui/number_input_preview/states.html.erb +7 -0
- data/registry/test/components/previews/ui/number_input_preview/stock_adjustment.html.erb +3 -0
- data/registry/test/components/previews/ui/number_input_preview.rb +36 -0
- data/registry/test/components/previews/ui/progress_preview/file_upload.html.erb +36 -0
- data/registry/test/components/previews/ui/progress_preview/free_shipping.html.erb +4 -0
- data/registry/test/components/previews/ui/progress_preview/indeterminate.html.erb +4 -0
- data/registry/test/components/previews/ui/progress_preview/sizes_and_tones.html.erb +8 -0
- data/registry/test/components/previews/ui/progress_preview/steps.html.erb +9 -0
- data/registry/test/components/previews/ui/progress_preview/storage.html.erb +8 -0
- data/registry/test/components/previews/ui/progress_preview/storage_by_category.html.erb +7 -0
- data/registry/test/components/previews/ui/progress_preview/tasks_by_status.html.erb +14 -0
- data/registry/test/components/previews/ui/progress_preview/traffic_by_source.html.erb +15 -0
- data/registry/test/components/previews/ui/progress_preview.rb +46 -0
- data/registry/test/components/previews/ui/scan_input_preview/_simulate.html.erb +20 -0
- data/registry/test/components/previews/ui/scan_input_preview/library_checkout.html.erb +30 -0
- data/registry/test/components/previews/ui/scan_input_preview/playground.html.erb +13 -0
- data/registry/test/components/previews/ui/scan_input_preview/stock_count.html.erb +24 -0
- data/registry/test/components/previews/ui/scan_input_preview/ticket_check_in.html.erb +34 -0
- data/registry/test/components/previews/ui/scan_input_preview/till.html.erb +9 -0
- data/registry/test/components/previews/ui/scan_input_preview.rb +33 -0
- data/registry/test/components/previews/ui/select_preview/server_search.html.erb +22 -0
- data/registry/test/components/previews/ui/select_preview.rb +5 -0
- data/registry/test/components/previews/ui/slider_preview/named_steps.html.erb +7 -0
- data/registry/test/components/previews/ui/slider_preview/opening_hours.html.erb +5 -0
- data/registry/test/components/previews/ui/slider_preview/price_range.html.erb +6 -0
- data/registry/test/components/previews/ui/slider_preview/sizes_and_states.html.erb +9 -0
- data/registry/test/components/previews/ui/slider_preview/text_size.html.erb +16 -0
- data/registry/test/components/previews/ui/slider_preview/tip.html.erb +22 -0
- data/registry/test/components/previews/ui/slider_preview/volume.html.erb +5 -0
- data/registry/test/components/previews/ui/slider_preview.rb +45 -0
- data/registry/test/components/previews/ui/timeline_preview/activity_log.html.erb +7 -0
- data/registry/test/components/previews/ui/timeline_preview/colored.html.erb +7 -0
- data/registry/test/components/previews/ui/timeline_preview/colored_by_meaning.html.erb +7 -0
- data/registry/test/components/previews/ui/timeline_preview/failed_delivery.html.erb +6 -0
- data/registry/test/components/previews/ui/timeline_preview/order_status.html.erb +9 -0
- data/registry/test/components/previews/ui/timeline_preview/real_dates.html.erb +5 -0
- data/registry/test/components/previews/ui/timeline_preview/stock_history.html.erb +6 -0
- data/registry/test/components/previews/ui/timeline_preview.rb +40 -0
- data/registry/test/components/ui/chart_test.rb +187 -0
- data/registry/test/components/ui/command/group_test.rb +19 -0
- data/registry/test/components/ui/command/item_test.rb +47 -0
- data/registry/test/components/ui/command_test.rb +110 -0
- data/registry/test/components/ui/date_picker_test.rb +129 -111
- data/registry/test/components/ui/file_field_test.rb +105 -9
- data/registry/test/components/ui/gallery_test.rb +192 -0
- data/registry/test/components/ui/kbd_test.rb +150 -0
- data/registry/test/components/ui/money_input_test.rb +149 -0
- data/registry/test/components/ui/number_input_test.rb +155 -0
- data/registry/test/components/ui/progress_test.rb +188 -0
- data/registry/test/components/ui/scan_input_test.rb +110 -0
- data/registry/test/components/ui/select_test.rb +62 -0
- data/registry/test/components/ui/slider_test.rb +190 -0
- data/registry/test/components/ui/timeline_test.rb +175 -0
- metadata +188 -2
- data/registry/app/javascript/cally.ts +0 -8
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<%# Stands in for a real upload: DirectUpload's progress event would set the same attribute. %>
|
|
2
|
+
<div id="progress-upload-demo" class="grid max-w-sm gap-4">
|
|
3
|
+
<%= render(UI::Progress.new(value: 0, max: 4.2, label: "quarterly-report.pdf", value_text: "%{value} of %{max} MB",
|
|
4
|
+
show_value: true, data: { demo: "bar" })) %>
|
|
5
|
+
<div class="flex items-center gap-3">
|
|
6
|
+
<%= render(UI::Button.new(size: :sm, data: { demo: "start" })) { "Upload" } %>
|
|
7
|
+
<span class="text-sm text-muted-foreground" data-demo="status" role="status"></span>
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
<script>
|
|
11
|
+
(() => {
|
|
12
|
+
const root = document.getElementById("progress-upload-demo");
|
|
13
|
+
const bar = root.querySelector('[data-demo="bar"]');
|
|
14
|
+
const status = root.querySelector('[data-demo="status"]');
|
|
15
|
+
const start = root.querySelector('[data-demo="start"]');
|
|
16
|
+
let timer;
|
|
17
|
+
|
|
18
|
+
start.addEventListener("click", () => {
|
|
19
|
+
clearInterval(timer);
|
|
20
|
+
let sent = 0;
|
|
21
|
+
start.disabled = true;
|
|
22
|
+
status.textContent = "";
|
|
23
|
+
bar.setAttribute("data-ui--progress-value-value", "0");
|
|
24
|
+
timer = setInterval(() => {
|
|
25
|
+
sent = Math.min(4.2, sent + 0.15 + Math.random() * 0.35);
|
|
26
|
+
bar.setAttribute("data-ui--progress-value-value", sent.toFixed(1));
|
|
27
|
+
}, 250);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
bar.addEventListener("ui--progress:complete", () => {
|
|
31
|
+
clearInterval(timer);
|
|
32
|
+
start.disabled = false;
|
|
33
|
+
status.textContent = "Uploaded";
|
|
34
|
+
});
|
|
35
|
+
})();
|
|
36
|
+
</script>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<div class="max-w-sm space-y-2 rounded-lg border p-4">
|
|
2
|
+
<p class="text-sm"><span class="font-medium">$12.50 more</span> for free shipping</p>
|
|
3
|
+
<%= render(UI::Progress.new(value: 37.5, max: 50, size: :sm, value_text: "$%{value} of $%{max}", aria: { label: "Towards free shipping" })) %>
|
|
4
|
+
</div>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<div class="grid max-w-sm gap-6">
|
|
2
|
+
<%= render(UI::Progress.new(value: 30, size: :sm, label: "Small", show_value: true)) %>
|
|
3
|
+
<%= render(UI::Progress.new(value: 55, label: "Default", show_value: true)) %>
|
|
4
|
+
<%= render(UI::Progress.new(value: 80, size: :lg, label: "Large", show_value: true)) %>
|
|
5
|
+
<%= render(UI::Progress.new(value: 100, tone: :success, label: "Success", show_value: true)) %>
|
|
6
|
+
<%= render(UI::Progress.new(value: 85, tone: :warning, label: "Warning", show_value: true)) %>
|
|
7
|
+
<%= render(UI::Progress.new(value: 97, tone: :destructive, label: "Destructive", show_value: true)) %>
|
|
8
|
+
</div>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<%= render(UI::Card.new(class: "max-w-sm")) do |card| %>
|
|
2
|
+
<% card.with_header do |header| %>
|
|
3
|
+
<% header.with_title { "Finish setting up your profile" } %>
|
|
4
|
+
<% header.with_description { "Profiles with a photo and a bio get more replies." } %>
|
|
5
|
+
<% end %>
|
|
6
|
+
<% card.with_content do %>
|
|
7
|
+
<%= render(UI::Progress.new(value: 3, max: 5, value_text: "%{value} of %{max} done", show_value: true, label: "Profile")) %>
|
|
8
|
+
<% end %>
|
|
9
|
+
<% end %>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<div class="grid max-w-sm gap-6">
|
|
2
|
+
<%= render(UI::Progress.new(value: 6.4, max: 15, label: "Photos", value_text: "%{value} GB of %{max} GB", show_value: true)) %>
|
|
3
|
+
<%= render(UI::Progress.new(value: 12.9, max: 15, tone: :warning, label: "Mailbox", value_text: "%{value} GB of %{max} GB", show_value: true)) %>
|
|
4
|
+
<div class="space-y-1.5">
|
|
5
|
+
<%= render(UI::Progress.new(value: 14.8, max: 15, tone: :destructive, label: "Shared drive", value_text: "%{value} GB of %{max} GB", show_value: true)) %>
|
|
6
|
+
<p class="text-sm text-muted-foreground">Almost full. New files won't sync until you free up space.</p>
|
|
7
|
+
</div>
|
|
8
|
+
</div>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<%= render(UI::Progress.new(max: 15, label: "Storage", value_text: "%{value} GB of %{max} GB", segment_text: "%{value} GB",
|
|
2
|
+
show_value: true, class: "max-w-md")) do |progress| %>
|
|
3
|
+
<% progress.with_segment(value: 6.4, label: "Photos") %>
|
|
4
|
+
<% progress.with_segment(value: 3.1, label: "Mail") %>
|
|
5
|
+
<% progress.with_segment(value: 2, label: "Documents") %>
|
|
6
|
+
<% progress.with_segment(value: 0.6, label: "Other") %>
|
|
7
|
+
<% end %>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<%# Two segments of a total, with the rest left as the track: "to do". %>
|
|
2
|
+
<%= render(UI::Card.new(class: "max-w-md")) do |card| %>
|
|
3
|
+
<% card.with_header do |header| %>
|
|
4
|
+
<% header.with_title { "Website relaunch" } %>
|
|
5
|
+
<% header.with_description { "40 tasks, due Friday" } %>
|
|
6
|
+
<% end %>
|
|
7
|
+
<% card.with_content do %>
|
|
8
|
+
<%= render(UI::Progress.new(max: 40, size: :lg, label: "Tasks", value_text: "%{value} of %{max} underway or done",
|
|
9
|
+
segment_text: "%{value} tasks", show_value: true)) do |progress| %>
|
|
10
|
+
<% progress.with_segment(value: 22, label: "Done", color: 3) %>
|
|
11
|
+
<% progress.with_segment(value: 9, label: "In review", color: 4) %>
|
|
12
|
+
<% end %>
|
|
13
|
+
<% end %>
|
|
14
|
+
<% end %>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<%# No max:, so the segments fill the bar and the legend shows each one's share. %>
|
|
2
|
+
<%= render(UI::Card.new(class: "max-w-md")) do |card| %>
|
|
3
|
+
<% card.with_header do |header| %>
|
|
4
|
+
<% header.with_title { "Where visitors came from" } %>
|
|
5
|
+
<% header.with_description { "9,500 visits in the last 30 days" } %>
|
|
6
|
+
<% end %>
|
|
7
|
+
<% card.with_content do %>
|
|
8
|
+
<%= render(UI::Progress.new(size: :lg, aria: { label: "Visits by source" })) do |progress| %>
|
|
9
|
+
<% progress.with_segment(value: 5_210, label: "Search") %>
|
|
10
|
+
<% progress.with_segment(value: 2_870, label: "Direct") %>
|
|
11
|
+
<% progress.with_segment(value: 1_045, label: "Social") %>
|
|
12
|
+
<% progress.with_segment(value: 375, label: "Email") %>
|
|
13
|
+
<% end %>
|
|
14
|
+
<% end %>
|
|
15
|
+
<% end %>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class UI::ProgressPreview < ViewComponent::Preview
|
|
4
|
+
# @label Playground
|
|
5
|
+
# @param value number
|
|
6
|
+
# @param max number
|
|
7
|
+
# @param indeterminate toggle "No value: shows work going on, without an amount"
|
|
8
|
+
# @param label text
|
|
9
|
+
# @param show_value toggle
|
|
10
|
+
# @param value_text text "Can use %{value}, %{max} and %{percent}"
|
|
11
|
+
# @param size select { choices: [sm, default, lg] }
|
|
12
|
+
# @param tone select { choices: [default, success, warning, destructive] }
|
|
13
|
+
def playground(value: 40, max: 100, indeterminate: false, label: "Uploading report.pdf", show_value: true,
|
|
14
|
+
value_text: "", size: :default, tone: :default)
|
|
15
|
+
render(UI::Progress.new(value: (value unless indeterminate), max: max, label: label.presence,
|
|
16
|
+
show_value: show_value, value_text: value_text.presence, size: size.to_sym,
|
|
17
|
+
tone: tone.to_sym, class: "max-w-sm"))
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# @label Sizes and Tones
|
|
21
|
+
def sizes_and_tones; render_with_template; end
|
|
22
|
+
|
|
23
|
+
# @label File Upload, Moving Live
|
|
24
|
+
def file_upload; render_with_template; end
|
|
25
|
+
|
|
26
|
+
# @label Storage Used
|
|
27
|
+
def storage; render_with_template; end
|
|
28
|
+
|
|
29
|
+
# @label Storage by Category
|
|
30
|
+
def storage_by_category; render_with_template; end
|
|
31
|
+
|
|
32
|
+
# @label Tasks by Status
|
|
33
|
+
def tasks_by_status; render_with_template; end
|
|
34
|
+
|
|
35
|
+
# @label Traffic by Source, Shares of a Whole
|
|
36
|
+
def traffic_by_source; render_with_template; end
|
|
37
|
+
|
|
38
|
+
# @label Steps Done
|
|
39
|
+
def steps; render_with_template; end
|
|
40
|
+
|
|
41
|
+
# @label Working, No Amount Yet
|
|
42
|
+
def indeterminate; render_with_template; end
|
|
43
|
+
|
|
44
|
+
# @label Free Shipping Threshold
|
|
45
|
+
def free_shipping; render_with_template; end
|
|
46
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<%# What a scanner does: types the code fast, then presses the suffix key. For trying the demos without one. %>
|
|
2
|
+
<div class="flex flex-wrap items-center gap-2 text-sm">
|
|
3
|
+
<span class="text-muted-foreground">Simulate a scan:</span>
|
|
4
|
+
<% codes.each do |code, label| %>
|
|
5
|
+
<%= render(UI::Button.new(variant: :outline, size: :sm, data: { simulate: code, key: local_assigns.fetch(:key, "Enter") })) { label } %>
|
|
6
|
+
<% end %>
|
|
7
|
+
</div>
|
|
8
|
+
<script>
|
|
9
|
+
(() => {
|
|
10
|
+
const root = document.currentScript.previousElementSibling;
|
|
11
|
+
root.addEventListener("click", (event) => {
|
|
12
|
+
const button = event.target.closest("[data-simulate]");
|
|
13
|
+
if (!button) return;
|
|
14
|
+
const field = root.closest("[data-demo]").querySelector("[data-ui--scan-input-target=field]");
|
|
15
|
+
field.focus();
|
|
16
|
+
field.value = button.dataset.simulate;
|
|
17
|
+
field.dispatchEvent(new KeyboardEvent("keydown", { key: button.dataset.key, bubbles: true, cancelable: true }));
|
|
18
|
+
});
|
|
19
|
+
})();
|
|
20
|
+
</script>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<%# Handled in the page: the scan event is cancelled, so nothing is submitted. %>
|
|
2
|
+
<div class="grid max-w-md gap-4" data-demo>
|
|
3
|
+
<%= render(UI::ScanInput.new(name: "isbn", label: "Scan each book's barcode", placeholder: "ISBN")) %>
|
|
4
|
+
<%= render "ui/scan_input_preview/simulate", codes: { "9780141439518" => "Pride and Prejudice", "9780262033848" => "Introduction to Algorithms", "9780000000000" => "Unknown" } %>
|
|
5
|
+
<p class="text-sm" role="status" data-out></p>
|
|
6
|
+
<ol class="divide-y rounded-md border text-sm" data-list></ol>
|
|
7
|
+
<p class="text-sm text-muted-foreground"><span data-count>0</span> books, due back in 14 days.</p>
|
|
8
|
+
</div>
|
|
9
|
+
<script>
|
|
10
|
+
(() => {
|
|
11
|
+
const root = document.currentScript.previousElementSibling;
|
|
12
|
+
const books = { "9780141439518": "Pride and Prejudice", "9780262033848": "Introduction to Algorithms", "9780316769488": "The Catcher in the Rye" };
|
|
13
|
+
const list = root.querySelector("[data-list]");
|
|
14
|
+
const say = (text) => (root.querySelector("[data-out]").textContent = text);
|
|
15
|
+
root.addEventListener("ui--scan-input:scan", (event) => {
|
|
16
|
+
event.preventDefault();
|
|
17
|
+
const { code } = event.detail;
|
|
18
|
+
const title = books[code];
|
|
19
|
+
if (!title) return say(`No book with the ISBN ${code}.`);
|
|
20
|
+
if (list.querySelector(`[data-isbn="${code}"]`)) return say(`${title} is already on this loan.`);
|
|
21
|
+
const item = document.createElement("li");
|
|
22
|
+
item.className = "px-3 py-2";
|
|
23
|
+
item.dataset.isbn = code;
|
|
24
|
+
item.textContent = title;
|
|
25
|
+
list.append(item);
|
|
26
|
+
root.querySelector("[data-count]").textContent = list.children.length;
|
|
27
|
+
say(`Added ${title}.`);
|
|
28
|
+
});
|
|
29
|
+
})();
|
|
30
|
+
</script>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<div class="grid max-w-sm gap-4" data-demo>
|
|
2
|
+
<%= render(UI::ScanInput.new(name: "code", submit: false, **options)) %>
|
|
3
|
+
<%= render "ui/scan_input_preview/simulate", codes: { "4006381333931" => "EAN-13", "TICKET-7F3K-0192" => "QR ticket" }, key: options[:suffix] == :tab ? "Tab" : "Enter" %>
|
|
4
|
+
<p class="text-sm text-muted-foreground" role="status" data-demo-out>Nothing scanned yet.</p>
|
|
5
|
+
</div>
|
|
6
|
+
<script>
|
|
7
|
+
(() => {
|
|
8
|
+
const root = document.currentScript.previousElementSibling;
|
|
9
|
+
root.addEventListener("ui--scan-input:scan", (event) => {
|
|
10
|
+
root.querySelector("[data-demo-out]").textContent = `Scanned ${event.detail.code}`;
|
|
11
|
+
});
|
|
12
|
+
})();
|
|
13
|
+
</script>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<%# capture: true sends keys typed with no field focused into this one, so a scan lands even after clicking elsewhere. %>
|
|
2
|
+
<div class="grid max-w-md gap-4" data-demo>
|
|
3
|
+
<%= render(UI::ScanInput.new(name: "sku", label: "Count shelf B-12", capture: true,
|
|
4
|
+
hint: "Click anywhere on the page, then scan: the code still lands here.")) %>
|
|
5
|
+
<%= render "ui/scan_input_preview/simulate", codes: { "SKU-1042" => "Cable ties", "SKU-2210" => "Hex bolts", "SKU-3307" => "Wall plugs" } %>
|
|
6
|
+
<table class="text-sm">
|
|
7
|
+
<thead><tr class="text-start text-muted-foreground"><th class="py-1 text-start font-normal">Item</th><th class="py-1 text-end font-normal">Counted</th><th class="py-1 text-end font-normal">Expected</th></tr></thead>
|
|
8
|
+
<tbody data-rows>
|
|
9
|
+
<tr data-sku="SKU-1042"><td class="py-1">Cable ties</td><td class="py-1 text-end tabular-nums" data-n>0</td><td class="py-1 text-end tabular-nums">3</td></tr>
|
|
10
|
+
<tr data-sku="SKU-2210"><td class="py-1">Hex bolts</td><td class="py-1 text-end tabular-nums" data-n>0</td><td class="py-1 text-end tabular-nums">2</td></tr>
|
|
11
|
+
<tr data-sku="SKU-3307"><td class="py-1">Wall plugs</td><td class="py-1 text-end tabular-nums" data-n>0</td><td class="py-1 text-end tabular-nums">4</td></tr>
|
|
12
|
+
</tbody>
|
|
13
|
+
</table>
|
|
14
|
+
</div>
|
|
15
|
+
<script>
|
|
16
|
+
(() => {
|
|
17
|
+
const root = document.currentScript.previousElementSibling;
|
|
18
|
+
root.addEventListener("ui--scan-input:scan", (event) => {
|
|
19
|
+
event.preventDefault();
|
|
20
|
+
const cell = root.querySelector(`tr[data-sku="${event.detail.code}"] [data-n]`);
|
|
21
|
+
if (cell) cell.textContent = Number(cell.textContent) + 1;
|
|
22
|
+
});
|
|
23
|
+
})();
|
|
24
|
+
</script>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<%# keyboard: false keeps a handheld's on-screen keyboard down; its trigger button does the typing. %>
|
|
2
|
+
<div class="grid max-w-sm gap-4" data-demo>
|
|
3
|
+
<%= render(UI::ScanInput.new(name: "ticket", label: "Check in", placeholder: "Scan a ticket's QR code", size: :lg, keyboard: false)) %>
|
|
4
|
+
<%= render "ui/scan_input_preview/simulate", codes: { "TKT-A-0192" => "Valid", "TKT-A-0007" => "Already used", "TKT-Z-9999" => "Not for today" } %>
|
|
5
|
+
<div class="rounded-md border p-4 text-center" role="status" data-out>
|
|
6
|
+
<p class="text-sm text-muted-foreground">Waiting for a ticket</p>
|
|
7
|
+
</div>
|
|
8
|
+
</div>
|
|
9
|
+
<script>
|
|
10
|
+
(() => {
|
|
11
|
+
const root = document.currentScript.previousElementSibling;
|
|
12
|
+
const used = new Set(["TKT-A-0007"]);
|
|
13
|
+
const out = root.querySelector("[data-out]");
|
|
14
|
+
const show = (title, line, tone) => {
|
|
15
|
+
out.className = `rounded-md border p-4 text-center ${tone}`;
|
|
16
|
+
out.innerHTML = "";
|
|
17
|
+
const strong = document.createElement("p");
|
|
18
|
+
strong.className = "text-lg font-semibold";
|
|
19
|
+
strong.textContent = title;
|
|
20
|
+
const small = document.createElement("p");
|
|
21
|
+
small.className = "text-sm";
|
|
22
|
+
small.textContent = line;
|
|
23
|
+
out.append(strong, small);
|
|
24
|
+
};
|
|
25
|
+
root.addEventListener("ui--scan-input:scan", (event) => {
|
|
26
|
+
event.preventDefault();
|
|
27
|
+
const { code } = event.detail;
|
|
28
|
+
if (!code.startsWith("TKT-A-")) return show("Not for today", `${code} is for another day.`, "border-amber-500/50 bg-amber-500/10");
|
|
29
|
+
if (used.has(code)) return show("Already checked in", `${code} was used at 18:42.`, "border-destructive/50 bg-destructive/10");
|
|
30
|
+
used.add(code);
|
|
31
|
+
show("Welcome", `${code}, general admission.`, "border-emerald-500/50 bg-emerald-500/10");
|
|
32
|
+
});
|
|
33
|
+
})();
|
|
34
|
+
</script>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<%# A real form: each code is posted, and the server answers with a Turbo Stream adding the line. The demo server answers slowly, so quick scans queue. %>
|
|
2
|
+
<div class="grid max-w-md gap-4" data-demo>
|
|
3
|
+
<%= form_with url: "/demo/scans", class: "contents", data: { demo_live: true } do %>
|
|
4
|
+
<%= render(UI::ScanInput.new(name: "code", label: "Scan items", size: :lg)) %>
|
|
5
|
+
<% end %>
|
|
6
|
+
<%= render "ui/scan_input_preview/simulate", codes: { "8901030865278" => "Rice", "8901058851298" => "Noodles", "8901719110016" => "Dal", "1111" => "Unknown" } %>
|
|
7
|
+
<p class="text-sm text-destructive" id="scan-demo-status" role="status"></p>
|
|
8
|
+
<ul id="scan-demo-lines" class="divide-y rounded-md border px-3 text-sm"></ul>
|
|
9
|
+
</div>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class UI::ScanInputPreview < ViewComponent::Preview
|
|
4
|
+
# @label Playground
|
|
5
|
+
# @param label text
|
|
6
|
+
# @param placeholder text
|
|
7
|
+
# @param size select { choices: [sm, default, lg] }
|
|
8
|
+
# @param suffix select { choices: [enter, tab] } "The key the scanner ends a code with"
|
|
9
|
+
# @param keyboard toggle "Off keeps a phone's on-screen keyboard down"
|
|
10
|
+
# @param capture toggle "Keys typed anywhere on the page go into the field"
|
|
11
|
+
# @param disabled toggle
|
|
12
|
+
# @param hint text
|
|
13
|
+
# @param error text
|
|
14
|
+
def playground(label: "Scan an item", placeholder: "", size: :default, suffix: :enter, keyboard: true,
|
|
15
|
+
capture: false, disabled: false, hint: "", error: "")
|
|
16
|
+
render_with_template(locals: { options: {
|
|
17
|
+
label: label.presence, placeholder: placeholder.presence, size: size.to_sym, suffix: suffix.to_sym,
|
|
18
|
+
keyboard: keyboard, capture: capture, disabled: disabled, hint: hint.presence, error: error.presence
|
|
19
|
+
} })
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# @label Library Checkout
|
|
23
|
+
def library_checkout; render_with_template; end
|
|
24
|
+
|
|
25
|
+
# @label Stock Count, Scanning Anywhere on the Page
|
|
26
|
+
def stock_count; render_with_template; end
|
|
27
|
+
|
|
28
|
+
# @label Ticket Check-in on a Handheld
|
|
29
|
+
def ticket_check_in; render_with_template; end
|
|
30
|
+
|
|
31
|
+
# @label Till, Sent to the Server
|
|
32
|
+
def till; render_with_template; end
|
|
33
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<%# For lists too long to send to the page. Opening it asks the url for a
|
|
2
|
+
starting list, and typing asks again with ?q=. In a slow search the
|
|
3
|
+
magnifying glass turns into a spinner. The docs site answers /demo/customers;
|
|
4
|
+
point url: at your own endpoint, which can look like this:
|
|
5
|
+
|
|
6
|
+
# config/routes.rb
|
|
7
|
+
get "customers/search", to: "customers#search"
|
|
8
|
+
|
|
9
|
+
# app/controllers/customers_controller.rb
|
|
10
|
+
def search
|
|
11
|
+
query = Customer.sanitize_sql_like(params[:q].to_s)
|
|
12
|
+
customers = Customer.where("name ILIKE ?", "%#{query}%").order(:name).limit(20)
|
|
13
|
+
render json: customers.map { |customer| { value: customer.id, label: customer.name } }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
On an edit form, pass the current choice as options:, so it's named before
|
|
17
|
+
anything is fetched. %>
|
|
18
|
+
<div class="grid max-w-xl gap-6 sm:grid-cols-2">
|
|
19
|
+
<%= render(UI::Select.new(name: "customer_id", url: "/demo/customers", label: "Customer", prompt: "Find a customer")) %>
|
|
20
|
+
<%= render(UI::Select.new(name: "customer_ids", url: "/demo/customers", label: "Copy invoices to", multiple: true,
|
|
21
|
+
options: [ [ "Aditi Rao Traders", 2001 ] ], selected: [ 2001 ])) %>
|
|
22
|
+
</div>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<div class="grid max-w-sm gap-8">
|
|
2
|
+
<%= render(UI::Slider.new(name: "digest", min: 0, max: 3, value: 1, label: "Email me about comments", show_value: true,
|
|
3
|
+
marks: { 0 => "Never", 1 => "Weekly", 2 => "Daily", 3 => "Right away" })) %>
|
|
4
|
+
<%= render(UI::Slider.new(name: "quality", min: 1, max: 3, value: 2, label: "Video quality", show_value: true,
|
|
5
|
+
marks: { 1 => "Low", 2 => "Medium", 3 => "High" },
|
|
6
|
+
hint: "Higher uses more data.")) %>
|
|
7
|
+
</div>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<div class="max-w-md">
|
|
2
|
+
<%= render(UI::Slider.new(range: true, label: "Open", min: 0, max: 24, from: 9, to: 17, from_name: "opens_at",
|
|
3
|
+
to_name: "closes_at", value_text: "%{value}:00", show_value: true,
|
|
4
|
+
marks: { 0 => "Midnight", 6 => "6:00", 12 => "Noon", 18 => "18:00", 24 => "Midnight" })) %>
|
|
5
|
+
</div>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<%# A filter form submits on change, which fires once a handle is let go, not on every step of a drag. %>
|
|
2
|
+
<form class="max-w-sm space-y-3" onsubmit="event.preventDefault()">
|
|
3
|
+
<%= render(UI::Slider.new(range: true, label: "Price", min: 0, max: 500, step: 10, from: 40, to: 260,
|
|
4
|
+
from_name: "min_price", to_name: "max_price", value_text: "$%{value}", show_value: true)) %>
|
|
5
|
+
<p class="text-sm text-muted-foreground">Handles meet but don't pass each other. Press the track to grab the nearest.</p>
|
|
6
|
+
</form>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<div class="grid max-w-sm gap-6">
|
|
2
|
+
<%= render(UI::Slider.new(name: "small", value: 30, size: :sm, label: "Small", show_value: true)) %>
|
|
3
|
+
<%= render(UI::Slider.new(name: "default", value: 50, label: "Default", show_value: true)) %>
|
|
4
|
+
<%= render(UI::Slider.new(name: "large", value: 70, size: :lg, label: "Large, for touch screens", show_value: true)) %>
|
|
5
|
+
<%= render(UI::Slider.new(name: "disabled", value: 40, label: "Disabled", disabled: true, show_value: true)) %>
|
|
6
|
+
<%= render(UI::Slider.new(name: "alert_at", value: 30, min: 50, max: 100, step: 5, label: "Warn me when storage reaches",
|
|
7
|
+
value_text: "%{value}%", show_value: true, hint: "We'll email you once a day until there's room.",
|
|
8
|
+
error: "Must be at least 50%")) %>
|
|
9
|
+
</div>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<div id="slider-text-size-demo" class="grid max-w-md gap-4">
|
|
2
|
+
<%= render(UI::Slider.new(name: "text_size", min: 12, max: 24, value: 16, label: "Text size", value_text: "%{value}px",
|
|
3
|
+
show_value: true, marks: [ 12, 16, 20, 24 ])) %>
|
|
4
|
+
<p class="rounded-md border p-4" data-demo="sample" style="font-size: 16px">
|
|
5
|
+
The quick brown fox jumps over the lazy dog.
|
|
6
|
+
</p>
|
|
7
|
+
</div>
|
|
8
|
+
<script>
|
|
9
|
+
(() => {
|
|
10
|
+
const root = document.getElementById("slider-text-size-demo");
|
|
11
|
+
const sample = root.querySelector('[data-demo="sample"]');
|
|
12
|
+
root.addEventListener("input", (event) => {
|
|
13
|
+
if (event.target.name === "text_size") sample.style.fontSize = `${event.target.value}px`;
|
|
14
|
+
});
|
|
15
|
+
})();
|
|
16
|
+
</script>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<div id="slider-tip-demo" class="max-w-xs space-y-5 rounded-lg border p-5">
|
|
2
|
+
<div class="text-center">
|
|
3
|
+
<p class="text-sm text-muted-foreground">Add a tip</p>
|
|
4
|
+
<p class="text-3xl font-semibold tabular-nums" data-demo="total">$48.30</p>
|
|
5
|
+
<p class="text-sm text-muted-foreground" data-demo="breakdown">$42.00 + $6.30 tip</p>
|
|
6
|
+
</div>
|
|
7
|
+
<%= render(UI::Slider.new(name: "tip_percent", min: 0, max: 25, step: 5, value: 15, size: :lg, label: false,
|
|
8
|
+
aria: { label: "Tip" }, value_text: "%{value}%",
|
|
9
|
+
marks: { 0 => "None", 10 => "10%", 15 => "15%", 20 => "20%", 25 => "25%" })) %>
|
|
10
|
+
</div>
|
|
11
|
+
<script>
|
|
12
|
+
(() => {
|
|
13
|
+
const root = document.getElementById("slider-tip-demo");
|
|
14
|
+
const bill = 42;
|
|
15
|
+
const money = (n) => `$${n.toFixed(2)}`;
|
|
16
|
+
root.addEventListener("input", (event) => {
|
|
17
|
+
const tip = bill * Number(event.target.value) / 100;
|
|
18
|
+
root.querySelector('[data-demo="total"]').textContent = money(bill + tip);
|
|
19
|
+
root.querySelector('[data-demo="breakdown"]').textContent = tip ? `${money(bill)} + ${money(tip)} tip` : "No tip";
|
|
20
|
+
});
|
|
21
|
+
})();
|
|
22
|
+
</script>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<div class="flex max-w-xs items-center gap-3">
|
|
2
|
+
<%= render(UI::Icon.new(name: "volume-x", size: :sm, class: "shrink-0 text-muted-foreground")) %>
|
|
3
|
+
<%= render(UI::Slider.new(name: "volume", value: 65, label: false, aria: { label: "Volume" }, value_text: "%{value}%")) %>
|
|
4
|
+
<%= render(UI::Icon.new(name: "volume-2", size: :sm, class: "shrink-0 text-muted-foreground")) %>
|
|
5
|
+
</div>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class UI::SliderPreview < ViewComponent::Preview
|
|
4
|
+
# @label Playground
|
|
5
|
+
# @param range toggle "Two handles, a low and a high"
|
|
6
|
+
# @param value number
|
|
7
|
+
# @param min number
|
|
8
|
+
# @param max number
|
|
9
|
+
# @param step number
|
|
10
|
+
# @param label text
|
|
11
|
+
# @param show_value toggle
|
|
12
|
+
# @param value_text text "Can use %{value}"
|
|
13
|
+
# @param size select { choices: [sm, default, lg] }
|
|
14
|
+
# @param disabled toggle
|
|
15
|
+
# @param hint text
|
|
16
|
+
# @param error text
|
|
17
|
+
def playground(range: false, value: 40, min: 0, max: 100, step: 1, label: "Volume", show_value: true,
|
|
18
|
+
value_text: "%{value}%", size: :default, disabled: false, hint: "", error: "")
|
|
19
|
+
render(UI::Slider.new(name: "volume", range: range, value: value, from: value, to: max, min: min, max: max,
|
|
20
|
+
step: step, label: label.presence, show_value: show_value, value_text: value_text.presence,
|
|
21
|
+
size: size.to_sym, disabled: disabled, hint: hint.presence, error: error.presence,
|
|
22
|
+
class: "max-w-sm"))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# @label Sizes and States
|
|
26
|
+
def sizes_and_states; render_with_template; end
|
|
27
|
+
|
|
28
|
+
# @label Volume, with Icons
|
|
29
|
+
def volume; render_with_template; end
|
|
30
|
+
|
|
31
|
+
# @label Price Range Filter
|
|
32
|
+
def price_range; render_with_template; end
|
|
33
|
+
|
|
34
|
+
# @label Opening Hours, with Marks
|
|
35
|
+
def opening_hours; render_with_template; end
|
|
36
|
+
|
|
37
|
+
# @label Named Steps
|
|
38
|
+
def named_steps; render_with_template; end
|
|
39
|
+
|
|
40
|
+
# @label Text Size, Following Live
|
|
41
|
+
def text_size; render_with_template; end
|
|
42
|
+
|
|
43
|
+
# @label Tip on a Card Reader
|
|
44
|
+
def tip; render_with_template; end
|
|
45
|
+
end
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<%= render(UI::Timeline.new(variant: :dot, label: "Activity", class: "max-w-md")) do |timeline| %>
|
|
2
|
+
<% timeline.with_item(title: "Sam changed the price to $24.00", time: "2 minutes ago") %>
|
|
3
|
+
<% timeline.with_item(title: "Priya added a photo", time: "1 hour ago") %>
|
|
4
|
+
<% timeline.with_item(title: "Import failed", status: :error, time: "Yesterday", description: "Row 12 has no SKU.") %>
|
|
5
|
+
<% timeline.with_item(title: "Sam edited the description", time: "Nov 2") %>
|
|
6
|
+
<% timeline.with_item(title: "Priya created this product", time: "Oct 28") %>
|
|
7
|
+
<% end %>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<%= render(UI::Timeline.new(variant: :colored, label: "Order status", class: "max-w-md")) do |timeline| %>
|
|
2
|
+
<% timeline.with_item(title: "Order placed", icon: "file-text", time: "Nov 3, 9:12 am") %>
|
|
3
|
+
<% timeline.with_item(title: "Payment received", icon: "credit-card", time: "Nov 3, 9:13 am", description: "Card ending 4242") %>
|
|
4
|
+
<% timeline.with_item(title: "Packed", icon: "package", time: "Nov 4, 2:40 pm") %>
|
|
5
|
+
<% timeline.with_item(title: "Out for delivery", icon: "truck", status: :current, time: "Nov 5, 8:05 am") %>
|
|
6
|
+
<% timeline.with_item(title: "Delivered", icon: "home", status: :upcoming, time: "Expected today") %>
|
|
7
|
+
<% end %>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<%= render(UI::Timeline.new(variant: :colored, label: "Stock history", class: "max-w-md")) do |timeline| %>
|
|
2
|
+
<% timeline.with_item(title: "Sold 2", icon: "store", color: :blue, time: "Today, 11:02 am", description: "Bill #1042. 46 left.") %>
|
|
3
|
+
<% timeline.with_item(title: "Written off 1", icon: "trash-2", color: :rose, time: "Yesterday, 6:30 pm", description: "Damaged in storage. 48 left.") %>
|
|
4
|
+
<% timeline.with_item(title: "Received 24", icon: "truck", color: :emerald, time: "Nov 2, 10:15 am", description: "From Northwind Traders. 49 left.") %>
|
|
5
|
+
<% timeline.with_item(title: "Sold 1", icon: "store", color: :blue, time: "Nov 1, 3:45 pm", description: "Bill #1017. 25 left.") %>
|
|
6
|
+
<% timeline.with_item(title: "Opening stock 26", icon: "package", color: :violet, time: "Oct 28, 9:00 am") %>
|
|
7
|
+
<% end %>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<%= render(UI::Timeline.new(label: "Order status", class: "max-w-md")) do |timeline| %>
|
|
2
|
+
<% timeline.with_item(title: "Packed", time: "Nov 4, 2:40 pm") %>
|
|
3
|
+
<% timeline.with_item(title: "Out for delivery", time: "Nov 5, 8:05 am") %>
|
|
4
|
+
<% timeline.with_item(title: "Delivery failed", status: :error, time: "Nov 5, 4:18 pm", description: "No one was home to sign for it.") %>
|
|
5
|
+
<% timeline.with_item(title: "Second attempt", status: :upcoming, time: "Expected tomorrow") %>
|
|
6
|
+
<% end %>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<%= render(UI::Timeline.new(label: "Order status", class: "max-w-md")) do |timeline| %>
|
|
2
|
+
<% timeline.with_item(title: "Order placed", icon: "file-text", time: "Nov 3, 9:12 am") %>
|
|
3
|
+
<% timeline.with_item(title: "Payment received", icon: "credit-card", time: "Nov 3, 9:13 am", description: "Card ending 4242") %>
|
|
4
|
+
<% timeline.with_item(title: "Packed", icon: "package", time: "Nov 4, 2:40 pm") %>
|
|
5
|
+
<% timeline.with_item(title: "Out for delivery", icon: "truck", status: :current, time: "Nov 5, 8:05 am") do %>
|
|
6
|
+
<%= render(UI::Link.new(href: "#")) { "Track parcel" } %>
|
|
7
|
+
<% end %>
|
|
8
|
+
<% timeline.with_item(title: "Delivered", icon: "home", status: :upcoming, time: "Expected today") %>
|
|
9
|
+
<% end %>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<%= render(UI::Timeline.new(label: "Invoice", class: "max-w-md")) do |timeline| %>
|
|
2
|
+
<% timeline.with_item(title: "Sent", time: Time.utc(2026, 11, 3, 9, 30)) %>
|
|
3
|
+
<% timeline.with_item(title: "Viewed", time: Time.utc(2026, 11, 4, 16, 5), time_label: "Yesterday") %>
|
|
4
|
+
<% timeline.with_item(title: "Paid", status: :current, time: Date.new(2026, 11, 5)) %>
|
|
5
|
+
<% end %>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<%= render(UI::Timeline.new(label: "Stock history", class: "max-w-md")) do |timeline| %>
|
|
2
|
+
<% timeline.with_item(title: "Sold 2", icon: "store", time: "Today, 11:02 am", description: "Bill #1042. 46 left.") %>
|
|
3
|
+
<% timeline.with_item(title: "Written off 1", icon: "trash-2", time: "Yesterday, 6:30 pm", description: "Damaged in storage. 48 left.") %>
|
|
4
|
+
<% timeline.with_item(title: "Received 24", icon: "truck", time: "Nov 2, 10:15 am", description: "From Northwind Traders. 49 left.") %>
|
|
5
|
+
<% timeline.with_item(title: "Opening stock 25", icon: "package", time: "Oct 28, 9:00 am") %>
|
|
6
|
+
<% end %>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class UI::TimelinePreview < ViewComponent::Preview
|
|
4
|
+
# @label Playground
|
|
5
|
+
# @param variant select { choices: [default, dot, colored] }
|
|
6
|
+
# @param status select { choices: [complete, current, upcoming, error] }
|
|
7
|
+
# @param descriptions toggle
|
|
8
|
+
def playground(variant: :default, status: :current, descriptions: true)
|
|
9
|
+
render(UI::Timeline.new(variant: variant.to_sym, label: "Order history", class: "max-w-md")) do |timeline|
|
|
10
|
+
timeline.with_item(title: "Order placed", time: "Nov 3, 9:12 am",
|
|
11
|
+
description: ("Paid by card ending 4242" if descriptions))
|
|
12
|
+
timeline.with_item(title: "Packed", time: "Nov 4, 2:40 pm",
|
|
13
|
+
description: ("Two boxes, 3.2 kg" if descriptions))
|
|
14
|
+
timeline.with_item(title: "Out for delivery", status: status.to_sym, time: "Nov 5, 8:05 am",
|
|
15
|
+
description: ("With the courier" if descriptions))
|
|
16
|
+
timeline.with_item(title: "Delivered", status: :upcoming, time: "Expected today")
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# @label Order Status
|
|
21
|
+
def order_status; render_with_template; end
|
|
22
|
+
|
|
23
|
+
# @label With a Failed Step
|
|
24
|
+
def failed_delivery; render_with_template; end
|
|
25
|
+
|
|
26
|
+
# @label Stock History
|
|
27
|
+
def stock_history; render_with_template; end
|
|
28
|
+
|
|
29
|
+
# @label Activity Log, with Dots
|
|
30
|
+
def activity_log; render_with_template; end
|
|
31
|
+
|
|
32
|
+
# @label Colored
|
|
33
|
+
def colored; render_with_template; end
|
|
34
|
+
|
|
35
|
+
# @label Colors That Mean Something
|
|
36
|
+
def colored_by_meaning; render_with_template; end
|
|
37
|
+
|
|
38
|
+
# @label Real Dates
|
|
39
|
+
def real_dates; render_with_template; end
|
|
40
|
+
end
|