keystone_ui 0.82.0 → 0.83.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: 466ea40680ab637e61843d16aabb6ffaf755fd4e02cb2c4ebabe6752c515da0f
4
- data.tar.gz: c46bba20299816139c945b9fe680b45b7402576a71442ce7fe611b72a700242c
3
+ metadata.gz: 67a56427f22ff9c7ae35a6c75cb9b093685ad735f4aa74d6369becb3cfd43a7c
4
+ data.tar.gz: 2d62089b40ae9778a19603c4ef693aa3a97742defe3b7d54d15dc0b46702622f
5
5
  SHA512:
6
- metadata.gz: 528af89d06fabf10ebcd476f2477fc0df0407607d6cc4879646354f372900497d320348f64cffd74e6919de846f53d597470b56f54ad4e7adb8c7da3fc595a9f
7
- data.tar.gz: 6f2973cd5fd00fedc3f71de681e2c6c8ea2e61c49f8ae3d515ad308a9207ee3b55b6f177d01ee01bcabd5a79b2253f5e53269c34c794c67ce61a405d6947d2f4
6
+ metadata.gz: d5fed99a13700d260fcfbc176eb29c4a1292711a3452524f5022b2a0865dabacccb417391a1e8594e49cae99e8ec87178c836915b955cdc61f82f3fa736fc636
7
+ data.tar.gz: a629ce6735d60acd71d5adf22fd0b03837b3b18344cc00938225762c08551e29c7fa6132d08956148fc564d48ec74884783751189c827e0f3ba3a0bfe35b87d3
@@ -1,22 +1,29 @@
1
- <div class="flex flex-col gap-3">
2
- <% rows.each do |row| %>
3
- <div data-timeline-row<% if selected?(row) %> class="<%= SELECTED_ROW_CLASSES %>" aria-current="true"<% end %>>
4
- <div class="<%= ROW_TEXT_CLASSES %>">
5
- <%= content_tag(row_href(row) ? :a : :span, row[:label], data: { timeline_label: "" }, href: row_href(row)) %>
6
- <span data-timeline-duration><%= duration(row) %></span>
7
- </div>
8
- <div class="<%= TRACK_CLASSES %>">
9
- <% row[:tries].each do |entry| %>
10
- <% if entry[:queued_at] %>
11
- <div class="<%= QUEUED_CLASSES %>" data-timeline-queued style="<%= queued_style(entry) %>"></div>
1
+ <% if entries.empty? %>
2
+ <%= render Keystone::Ui::EmptyStateComponent.new(title: "No steps") %>
3
+ <% else %>
4
+ <div class="flex flex-col gap-3">
5
+ <% rows.each do |row| %>
6
+ <div data-timeline-row<% if selected?(row) %> class="<%= SELECTED_ROW_CLASSES %>" aria-current="true"<% end %>>
7
+ <div class="<%= ROW_TEXT_CLASSES %>">
8
+ <%= content_tag(row_href(row) ? :a : :span, row[:label], data: { timeline_label: "" }, href: row_href(row)) %>
9
+ <span class="<%= ROW_STATUS_CLASSES %>">
10
+ <% if running?(row) %><%= render Keystone::Ui::StatusDotComponent.new(state: :info, label: "Running") %><% end %>
11
+ <span data-timeline-duration><%= duration(row) %></span>
12
+ </span>
13
+ </div>
14
+ <div class="<%= TRACK_CLASSES %>">
15
+ <% row[:tries].each do |entry| %>
16
+ <% if entry[:queued_at] %>
17
+ <div class="<%= QUEUED_CLASSES %>" data-timeline-queued style="<%= queued_style(entry) %>"></div>
18
+ <% end %>
19
+ <%= content_tag(bar_tag(entry), class: bar_classes(entry), data: { timeline_bar: "" }, style: bar_style(entry), href: entry[:href]) do %><% if entry[:href] %><span class="<%= SCREEN_READER_CLASSES %>"><%= entry[:label] %></span> <% end %><% if entry[:failed] %><span class="<%= SCREEN_READER_CLASSES %>">Failed</span><% end %><% end %>
12
20
  <% end %>
13
- <%= content_tag(bar_tag(entry), class: bar_classes(entry), data: { timeline_bar: "" }, style: bar_style(entry), href: entry[:href]) do %><% if entry[:href] %><span class="<%= SCREEN_READER_CLASSES %>"><%= entry[:label] %></span> <% end %><% if entry[:failed] %><span class="<%= SCREEN_READER_CLASSES %>">Failed</span><% end %><% end %>
14
- <% end %>
21
+ </div>
15
22
  </div>
23
+ <% end %>
24
+ <div class="<%= AXIS_CLASSES %>">
25
+ <span data-timeline-axis-start><%= axis_start_label %></span>
26
+ <span data-timeline-axis-end><%= total_duration %></span>
16
27
  </div>
17
- <% end %>
18
- <div class="<%= AXIS_CLASSES %>">
19
- <span data-timeline-axis-start><%= axis_start_label %></span>
20
- <span data-timeline-axis-end><%= total_duration %></span>
21
28
  </div>
22
- </div>
29
+ <% end %>
@@ -11,15 +11,18 @@ module Keystone
11
11
  SELECTED_ROW_CLASSES = "ks-table-row-current"
12
12
  ROW_TEXT_CLASSES = "ks-meter-label flex justify-between text-sm"
13
13
  AXIS_CLASSES = "ks-meter-label flex justify-between text-xs"
14
+ ROW_STATUS_CLASSES = "flex items-center ks-grid-gap-sm"
15
+ MINIMUM_BAR_PERCENT = 2
14
16
 
15
17
  attr_reader :entries
16
18
 
17
19
  def initialize(entries:)
20
+ entries.each { |entry| check_times(entry) }
18
21
  @entries = entries
19
22
  end
20
23
 
21
24
  def bar_style(entry)
22
- "left: #{percent(entry[:started_at] - axis_start)}%; width: #{percent(entry[:ended_at] - entry[:started_at])}%"
25
+ "left: #{percent(entry[:started_at] - axis_start)}%; width: #{bar_width(entry)}%"
23
26
  end
24
27
 
25
28
  def rows
@@ -34,6 +37,10 @@ module Keystone
34
37
  row[:tries].any? { |entry| entry[:selected] }
35
38
  end
36
39
 
40
+ def running?(row)
41
+ row[:tries].any? { |entry| entry[:ended_at].nil? }
42
+ end
43
+
37
44
  def queued_style(entry)
38
45
  "left: #{percent(entry[:queued_at] - axis_start)}%; width: #{percent(entry[:started_at] - entry[:queued_at])}%"
39
46
  end
@@ -47,7 +54,7 @@ module Keystone
47
54
  end
48
55
 
49
56
  def duration(row)
50
- written_duration(row[:tries].last[:ended_at] - row[:tries].first[:started_at])
57
+ written_duration(ended_at(row[:tries].last) - row[:tries].first[:started_at])
51
58
  end
52
59
 
53
60
  def total_duration
@@ -60,6 +67,11 @@ module Keystone
60
67
 
61
68
  private
62
69
 
70
+ def check_times(entry)
71
+ raise ArgumentError, "Timeline entry #{entry[:label].inspect} has no started_at" unless entry[:started_at]
72
+ raise ArgumentError, "Timeline entry #{entry[:label].inspect} ends before it starts" if entry[:ended_at] && entry[:ended_at] < entry[:started_at]
73
+ end
74
+
63
75
  def written_duration(seconds)
64
76
  hours, rest = seconds.round.divmod(3600)
65
77
  minutes, seconds = rest.divmod(60)
@@ -73,11 +85,24 @@ module Keystone
73
85
  end
74
86
 
75
87
  def axis_end
76
- @axis_end ||= entries.map { |entry| entry[:ended_at] }.max
88
+ @axis_end ||= entries.map { |entry| entry[:ended_at] || entry[:started_at] }.max
89
+ end
90
+
91
+ def ended_at(entry)
92
+ entry[:ended_at] || axis_end
93
+ end
94
+
95
+ def bar_width(entry)
96
+ format("%g", [ share(ended_at(entry) - entry[:started_at]), MINIMUM_BAR_PERCENT ].max)
77
97
  end
78
98
 
79
99
  def percent(seconds)
80
- format("%g", (seconds / (axis_end - axis_start) * 100).round(2))
100
+ format("%g", share(seconds))
101
+ end
102
+
103
+ def share(seconds)
104
+ span = axis_end - axis_start
105
+ span.zero? ? 0 : (seconds / span * 100).round(2)
81
106
  end
82
107
  end
83
108
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KeystoneUi
4
- VERSION = "0.82.0"
4
+ VERSION = "0.83.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, a question asked before a button or main action goes ahead, 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, failed tries, links to each try and the current step marked, 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, a question asked before a button or main action goes ahead, 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, failed tries, steps still running, links to each try and the current step marked, 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 on one shared time axis, each try of a step a bar on its row, with optional queued time and failed tries marked, bars and row labels that open an address, and the current row marked.
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, failed tries and tries still running marked, bars and row labels that open an address, the current row marked, and a "No steps" message when there are no entries.
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.
@@ -753,7 +753,7 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
753
753
  - `ui_bucket_series(buckets:)` takes an array of hashes with the keywords
754
754
  of `ui_bucket`, such as `[{ goal: 10, actual: 7, label: "Mon" }, ...]`.
755
755
  - `ui_timeline(entries:)` takes no block. `entries:` is
756
- `[{ label:, started_at:, ended_at:, queued_at: nil, failed: false, href: nil, selected: false }, ...]`,
756
+ `[{ label:, started_at:, ended_at: nil, queued_at: nil, failed: false, href: nil, selected: false }, ...]`,
757
757
  with every time a `Time` value.
758
758
  - It draws one row per label, in the order each label first appears.
759
759
  Entries that share a label, such as the tries of one step, share that
@@ -761,7 +761,15 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
761
761
  in the order they ran.
762
762
  - Every bar is placed by its entry's `started_at` and `ended_at` on one
763
763
  axis shared by all rows. The axis runs from the earliest `queued_at` or
764
- `started_at` of any entry to the latest `ended_at`.
764
+ `started_at` of any entry to the latest `ended_at`, or to the latest
765
+ `started_at` when that is later.
766
+ - An entry with no `ended_at:`, or `ended_at: nil`, is a try still
767
+ running. Its bar runs to the end of the axis, and its row shows an
768
+ `:info` status dot beside its duration that screen readers read as
769
+ "Running". Leave `ended_at:` out only for a try that has not finished.
770
+ - Every bar is drawn at least 2% of the track wide, so a try that took no
771
+ time still shows. When every entry starts and ends at one moment, every
772
+ bar is drawn at that width at the left edge of the track.
765
773
  - An entry given `queued_at:` also draws the time from `queued_at` to
766
774
  `started_at` before its bar, in the queued colour. Leave it out when the
767
775
  wait is not known.
@@ -780,12 +788,18 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
780
788
  and on one entry at most.
781
789
  - Each row shows its label and its duration on one line, then its track.
782
790
  The row's duration runs from its first entry's `started_at` to its last
783
- entry's `ended_at`, so queued time before the first try is not counted.
791
+ entry's `ended_at`, or to the end of the axis when that last entry is
792
+ still running, so queued time before the first try is not counted.
784
793
  - Under the rows the axis reads `0s` on the left and the whole span on the
785
794
  right. Durations are written as `1h 0m 5s`, leaving out leading zero
786
795
  units, and a zero duration is `0s`.
787
- - It needs at least one entry and a span longer than zero, so do not render
788
- it for an empty list or for entries that all start and end at one moment.
796
+ - An entry with no `started_at:` raises `ArgumentError` naming its label,
797
+ and so does an entry whose `ended_at:` is before its `started_at:`. Check
798
+ the times before rendering rather than rescuing the error.
799
+ - An empty `entries:` draws a centred "No steps" message in place of the
800
+ timeline, so it can be rendered for a list that may be empty. The
801
+ wording is fixed, so ask the developer whether it fits, and when it does
802
+ not, check for no entries and call `ui_empty_state` instead.
789
803
  - `ui_pipeline(title:, boxes:, links:, subtitle: nil)` — `boxes:` is
790
804
  `[{ label:, count:, accent:, action: }, ...]`, with `accent:` one of
791
805
  `:amber` `:emerald` `:danger` `:muted`, and `action:` is
@@ -71,7 +71,12 @@ One decision: is keystone_ui set up in the app?
71
71
  try's end. Queued time is drawn as its own segment before the bar, and a
72
72
  failed try is marked failed both in colour and for screen readers. The axis
73
73
  runs from the earliest queued or start time of any entry to the latest end
74
- time. An entry can carry an address, and then its bar is a link to it whose
74
+ or start time. An entry with no end time is still running: its bar runs to
75
+ the end of the axis, and its row shows a status dot that screen readers read
76
+ as "Running". Every bar is drawn at least a small visible width, so a try
77
+ that took no time still shows. An entry with no start time, or one that ends
78
+ before it starts, raises `ArgumentError` naming its label. A timeline with no
79
+ entries shows a message saying there are no steps. An entry can carry an address, and then its bar is a link to it whose
75
80
  name screen readers announce is the entry's label, and the row's label links
76
81
  to the address of the last entry in that row that has one. An entry can be
77
82
  marked selected, and the row holding it is drawn in the same tint as a data
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.82.0
4
+ version: 0.83.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Schneider