keystone_ui 0.79.0 → 0.80.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: facf365bdd0f3e806b1db58e72e26b58500b8db01ea8a016c5b89b39e5739d66
4
- data.tar.gz: d098dc9c4105caa20816e8f47c2acd357697abb2e11f9918c05d4c2959fcd99b
3
+ metadata.gz: 89de110dfb32394a6012de91de4120517f04870224e7ccb13afc436d6174b9ac
4
+ data.tar.gz: 6310807810ad3de4e4021fda9bdcec1d0c3d284872a9e70799aeb9419a81425b
5
5
  SHA512:
6
- metadata.gz: 3ce67331b86779a466fcc1090400fa6b839f856fddb731a6c78a3bc78e82a6eeef590e388e24fb1a25e0a9920a05046b6db3f9f2d34bddde7a65c5995b3e5979
7
- data.tar.gz: 9807d78d7a16382b8224f61f8eadf99753e5df8de684011454b7b81261598505b11ed78e5c3b5354d724c244564380f9a34c4be04fb526f0629125d79abda39c
6
+ metadata.gz: c2b1f52471717cbe9e10a6a1ea9bf5c2e0656257f7d82cdaf1983ea94ff15a9c62261215f4fdb53e8db934c14ff37638b398451f57da0948ea113bdc54cb1f61
7
+ data.tar.gz: 91cf44f8a528063da14e2319f4d1cae925a265bb298d64588ff9102f408821c5206e3ac71bafd291ac673fb29f33ea7a468d8f959c33984654b5d4a0e008513c
@@ -1,12 +1,17 @@
1
1
  <div class="flex flex-col gap-3">
2
- <% entries.each do |entry| %>
2
+ <% rows.each do |row| %>
3
3
  <div data-timeline-row>
4
4
  <div class="<%= ROW_TEXT_CLASSES %>">
5
- <span data-timeline-label><%= entry[:label] %></span>
6
- <span data-timeline-duration><%= duration(entry) %></span>
5
+ <span data-timeline-label><%= row[:label] %></span>
6
+ <span data-timeline-duration><%= duration(row) %></span>
7
7
  </div>
8
8
  <div class="<%= TRACK_CLASSES %>">
9
- <div class="<%= BAR_CLASSES %>" data-timeline-bar style="<%= bar_style(entry) %>"></div>
9
+ <% row[:tries].each do |entry| %>
10
+ <% if entry[:queued_at] %>
11
+ <div class="<%= QUEUED_CLASSES %>" data-timeline-queued style="<%= queued_style(entry) %>"></div>
12
+ <% end %>
13
+ <div class="<%= bar_classes(entry) %>" data-timeline-bar style="<%= bar_style(entry) %>"><% if entry[:failed] %><span class="<%= SCREEN_READER_CLASSES %>">Failed</span><% end %></div>
14
+ <% end %>
10
15
  </div>
11
16
  </div>
12
17
  <% end %>
@@ -3,8 +3,11 @@
3
3
  module Keystone
4
4
  module Ui
5
5
  class TimelineComponent < ViewComponent::Base
6
- TRACK_CLASSES = "ks-progress-track relative w-full h-2 overflow-hidden"
7
- BAR_CLASSES = "ks-progress-bar absolute inset-y-0"
6
+ TRACK_CLASSES = "ks-timeline-track relative w-full h-2 overflow-hidden"
7
+ BAR_CLASSES = "ks-timeline-bar absolute inset-y-0"
8
+ FAILED_CLASSES = "ks-timeline-failed"
9
+ QUEUED_CLASSES = "ks-timeline-queued absolute inset-y-0"
10
+ SCREEN_READER_CLASSES = "sr-only"
8
11
  ROW_TEXT_CLASSES = "ks-meter-label flex justify-between text-sm"
9
12
  AXIS_CLASSES = "ks-meter-label flex justify-between text-xs"
10
13
 
@@ -18,8 +21,20 @@ module Keystone
18
21
  "left: #{percent(entry[:started_at] - axis_start)}%; width: #{percent(entry[:ended_at] - entry[:started_at])}%"
19
22
  end
20
23
 
21
- def duration(entry)
22
- written_duration(entry[:ended_at] - entry[:started_at])
24
+ def rows
25
+ entries.group_by { |entry| entry[:label] }.map { |label, tries| { label: label, tries: tries } }
26
+ end
27
+
28
+ def queued_style(entry)
29
+ "left: #{percent(entry[:queued_at] - axis_start)}%; width: #{percent(entry[:started_at] - entry[:queued_at])}%"
30
+ end
31
+
32
+ def bar_classes(entry)
33
+ [ BAR_CLASSES, (FAILED_CLASSES if entry[:failed]) ].compact.join(" ")
34
+ end
35
+
36
+ def duration(row)
37
+ written_duration(row[:tries].last[:ended_at] - row[:tries].first[:started_at])
23
38
  end
24
39
 
25
40
  def total_duration
@@ -41,7 +56,7 @@ module Keystone
41
56
  end
42
57
 
43
58
  def axis_start
44
- @axis_start ||= entries.map { |entry| entry[:started_at] }.min
59
+ @axis_start ||= entries.map { |entry| entry[:queued_at] || entry[:started_at] }.min
45
60
  end
46
61
 
47
62
  def axis_end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KeystoneUi
4
- VERSION = "0.79.0"
4
+ VERSION = "0.80.0"
5
5
  end
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: keystone_ui-develop
3
- description: Use PROACTIVELY for building or editing screens in a Rails app that has keystone_ui — page shells with Back links and breadcrumbs, forms and fields, a search field that picks a record or enters a new one, data tables with saved columns, desktop navigation, sidebars and bottom tabs, a page's main action as a phone top-bar icon or a button fixed to the bottom of the screen, action menus for a record's Edit and Delete, dashboards with stat cards, charts, funnels, goal buckets and timelines of timed steps, amounts shown in green or red as a gain or loss, status dots coloured by state, pictures held to half the screen, two versions of a text compared line by line side by side, info buttons and breakdowns, marketing sections, a light/dark theme switch — MUST BE USED instead of hand-writing ERB and Tailwind for UI.
3
+ description: Use PROACTIVELY for building or editing screens in a Rails app that has keystone_ui — page shells with Back links and breadcrumbs, forms and fields, a search field that picks a record or enters a new one, data tables with saved columns, desktop navigation, sidebars and bottom tabs, a page's main action as a phone top-bar icon or a button fixed to the bottom of the screen, action menus for a record's Edit and Delete, dashboards with stat cards, charts, funnels, goal buckets and timelines of timed steps with retries, queued time and failed tries, amounts shown in green or red as a gain or loss, status dots coloured by state, pictures held to half the screen, two versions of a text compared line by line side by side, info buttons and breakdowns, marketing sections, a light/dark theme switch — MUST BE USED instead of hand-writing ERB and Tailwind for UI.
4
4
  tools: Bash, Read, Write, Edit, Grep
5
5
  scope: UI — pages, forms, tables, navigation, dashboards
6
6
  ---
@@ -98,7 +98,7 @@ not available in the app yet, that is `keystone_ui-install`'s job.
98
98
  - `ui_funnel` — a conversion funnel drawn as bars or one joined shape.
99
99
  - `ui_bucket` — an upright container filled toward a goal.
100
100
  - `ui_bucket_series` — a wrapping row of buckets.
101
- - `ui_timeline` — rows of timed steps, each a bar placed by its start and end on one shared time axis.
101
+ - `ui_timeline` — rows of timed steps on one shared time axis, each try of a step a bar on its row, with optional queued time and failed tries marked.
102
102
  - `ui_pipeline` — a staged flow diagram with buttons and breakable links that post to the app.
103
103
  - `ui_hero` — a marketing hero with title, call-to-action buttons and an aside.
104
104
  - `ui_cta_banner` — a marketing banner holding call-to-action buttons.
@@ -730,14 +730,28 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
730
730
  - `ui_bucket_series(buckets:)` takes an array of hashes with the keywords
731
731
  of `ui_bucket`, such as `[{ goal: 10, actual: 7, label: "Mon" }, ...]`.
732
732
  - `ui_timeline(entries:)` takes no block. `entries:` is
733
- `[{ label:, started_at:, ended_at: }, ...]` in the order to list them,
734
- with both times as `Time` values. The axis runs from the earliest
735
- `started_at` to the latest `ended_at`. Each entry is one row: its label
736
- and its duration on one line, then a track with a bar placed at its start
737
- and as wide as its share of the axis. Under the rows the axis reads `0s`
738
- on the left and the whole span on the right. Durations are written as
739
- `1h 0m 5s`, leaving out leading zero units, and a zero duration is `0s`.
740
- It needs at least one entry and a span longer than zero, so do not render
733
+ `[{ label:, started_at:, ended_at:, queued_at: nil, failed: false }, ...]`,
734
+ with every time a `Time` value.
735
+ - It draws one row per label, in the order each label first appears.
736
+ Entries that share a label, such as the tries of one step, share that
737
+ row and each draws its own bar, so pass a step's tries one after another
738
+ in the order they ran.
739
+ - Every bar is placed by its entry's `started_at` and `ended_at` on one
740
+ axis shared by all rows. The axis runs from the earliest `queued_at` or
741
+ `started_at` of any entry to the latest `ended_at`.
742
+ - An entry given `queued_at:` also draws the time from `queued_at` to
743
+ `started_at` before its bar, in the queued colour. Leave it out when the
744
+ wait is not known.
745
+ - An entry given `failed: true` draws its bar in the danger colour, and
746
+ screen readers read it as "Failed". Ask the developer which tries count
747
+ as failed and whether the queued time is shown.
748
+ - Each row shows its label and its duration on one line, then its track.
749
+ The row's duration runs from its first entry's `started_at` to its last
750
+ entry's `ended_at`, so queued time before the first try is not counted.
751
+ - Under the rows the axis reads `0s` on the left and the whole span on the
752
+ right. Durations are written as `1h 0m 5s`, leaving out leading zero
753
+ units, and a zero duration is `0s`.
754
+ - It needs at least one entry and a span longer than zero, so do not render
741
755
  it for an empty list or for entries that all start and end at one moment.
742
756
  - `ui_pipeline(title:, boxes:, links:, subtitle: nil)` — `boxes:` is
743
757
  `[{ label:, count:, accent:, action: }, ...]`, with `accent:` one of
@@ -806,7 +820,8 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
806
820
  figure in plain colour, a joined funnel with no band, a locked column the
807
821
  others show through, a Columns menu with no greyed name for a hidden
808
822
  column, a table row whose caret does not open its detail, a text diff whose
809
- removed and added rows look like its shared rows, or a status dot
823
+ removed and added rows look like its shared rows, a timeline whose failed
824
+ tries or queued time look like its other bars, or a status dot
810
825
  that draws nothing — the app's Stimulus controllers or keystone_ui-styles version are
811
826
  out of date. Stop and hand that part to `keystone_ui-install`, and add no
812
827
  classes to fix it.
@@ -60,10 +60,18 @@ One decision: is keystone_ui set up in the app?
60
60
  symbol they do not know, so a wrong guess fails at render time.
61
61
  - **Numbers and text are different inputs.** Progress bars, funnels, buckets
62
62
  and timelines do arithmetic, so they take numbers, and a bucket raises on
63
- `"9,000"`. A timeline takes each row's start and end as times and works out
64
- every duration, bar position and its axis from them. A
63
+ `"9,000"`. A timeline takes each entry's times and works out every duration,
64
+ bar position and its axis from them. A
65
65
  breakdown, a calculation and a toned figure take already-formatted text, show
66
66
  it as written and add nothing up.
67
+ - **Timelines.** A timeline entry is one try at a step: a label, a start time,
68
+ an end time, and optionally the time it was queued and whether it failed.
69
+ Entries sharing a label are drawn as several bars on one row, in the order
70
+ given, and the row's duration runs from its first try's start to its last
71
+ try's end. Queued time is drawn as its own segment before the bar, and a
72
+ failed try is marked failed both in colour and for screen readers. The axis
73
+ runs from the earliest queued or start time of any entry to the latest end
74
+ time.
67
75
  - **Going back.** A form or show page shell needs a way back: a back link, a
68
76
  trail of earlier pages shown as breadcrumbs, or a trail the app supplies for
69
77
  the request. A nav tab's own page passes an empty trail and shows no back
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keystone_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.79.0
4
+ version: 0.80.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Schneider