keystone_ui 0.86.0 → 0.87.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: c351ad6abee58f4d2001dab3cf8e299735b69bd2e09651b8c85943c169d17afc
4
- data.tar.gz: d6f4e92fde93ed1a94a49446c613707a50c2d5cb3d57aac8ee27e06f01a2edeb
3
+ metadata.gz: 94679872bb456fe1af2afe9da20383d24a17015d610a237ff0459ebc3ed30853
4
+ data.tar.gz: f75346f3b8067fd199f91d0b8e6199d6fb2b0f0044d9a82b2b7df7cfc0231dfd
5
5
  SHA512:
6
- metadata.gz: a327fe7872d4c828217c2dbf33c8b6042a520771708d0b04870b2c627ad00cfa8001bfae481475575c15e156cd5a0697756c2d98fc12236b9a8dfce484c69a1c
7
- data.tar.gz: c126fda060d77148908eabb68b1d1d2ab538060ff0bc9ad2d80441a2cd09409f2d05aa2221be673fe6fae98a8d790a590fc4fb95fcf94a1d5de20532ff28a5ab
6
+ metadata.gz: e66fe72413ad1c5afdc9355fe1da64e877c2d30d9a14f33608e811ad0d788bb3bd580f1a5e6d902e5d30057de247300781fc7aa697b05566d7374c210ca40f3d
7
+ data.tar.gz: 07cbacf662f77376e819bde19ac1da4c09852e48eed8f7568dfd24353e421aa8dd84f748b355e0f56304fd9a7461183cecf70371003a9d232ac9b3d02e8400f2
@@ -14,7 +14,7 @@
14
14
  <% status = capture do %>
15
15
  <span class="<%= status_classes %>">
16
16
  <% if running?(row) %><%= render Keystone::Ui::StatusDotComponent.new(state: :info, label: "Running") %><% end %>
17
- <span data-timeline-duration><%= duration(row) %></span>
17
+ <%= tag.span(duration(row), class: duration_classes(row), data: { timeline_duration: "" }) %>
18
18
  </span>
19
19
  <% end %>
20
20
  <% track = capture do %>
@@ -6,6 +6,7 @@ module Keystone
6
6
  TRACK_CLASSES = "ks-timeline-track relative w-full h-2 overflow-hidden"
7
7
  BAR_CLASSES = "ks-timeline-bar absolute inset-y-0"
8
8
  FAILED_CLASSES = "ks-timeline-failed"
9
+ WAITING_CLASSES = "ks-tone-warning"
9
10
  QUEUED_CLASSES = "ks-timeline-queued absolute inset-y-0"
10
11
  SCREEN_READER_CLASSES = "sr-only"
11
12
  SELECTED_ROW_CLASSES = "ks-table-row-current"
@@ -69,7 +70,7 @@ module Keystone
69
70
  end
70
71
 
71
72
  def running?(row)
72
- row[:tries].any? { |entry| entry[:ended_at].nil? }
73
+ !waiting?(row) && row[:tries].any? { |entry| entry[:ended_at].nil? }
73
74
  end
74
75
 
75
76
  def queued_style(entry)
@@ -77,6 +78,8 @@ module Keystone
77
78
  end
78
79
 
79
80
  def bar_classes(entry)
81
+ return QUEUED_CLASSES if entry[:waiting]
82
+
80
83
  [ BAR_CLASSES, (FAILED_CLASSES if entry[:failed]) ].compact.join(" ")
81
84
  end
82
85
 
@@ -84,8 +87,18 @@ module Keystone
84
87
  entry[:href] ? :a : :div
85
88
  end
86
89
 
90
+ def waiting?(row)
91
+ row[:tries].any? { |entry| entry[:waiting] }
92
+ end
93
+
94
+ def duration_classes(row)
95
+ WAITING_CLASSES if waiting?(row)
96
+ end
97
+
87
98
  def duration(row)
88
- written_duration(ended_at(row[:tries].last) - row[:tries].first[:started_at])
99
+ return "waiting" if waiting?(row)
100
+
101
+ [ written_duration(row[:tries].sum { |entry| ended_at(entry) - entry[:started_at] }), attempts(row) ].compact.join(" · ")
89
102
  end
90
103
 
91
104
  def total_duration
@@ -97,21 +110,26 @@ module Keystone
97
110
  end
98
111
 
99
112
  def axis_start_label
100
- written_duration(0)
113
+ written_mark(0)
101
114
  end
102
115
 
103
116
  private
104
117
 
118
+ def attempts(row)
119
+ "#{row[:tries].size} att." if row[:tries].size > 1
120
+ end
121
+
105
122
  def check_times(entry)
106
123
  raise ArgumentError, "Timeline entry #{entry[:label].inspect} has no started_at" unless entry[:started_at]
107
124
  raise ArgumentError, "Timeline entry #{entry[:label].inspect} ends before it starts" if entry[:ended_at] && entry[:ended_at] < entry[:started_at]
108
125
  end
109
126
 
110
127
  def written_duration(seconds)
128
+ return format("%.1fs", seconds.round(1)) if seconds.round(1) < 10
129
+
111
130
  hours, rest = seconds.round.divmod(3600)
112
131
  minutes, seconds = rest.divmod(60)
113
132
  parts = [ [ hours, "h" ], [ minutes, "m" ], [ seconds, "s" ] ].drop_while { |amount, _| amount.zero? }
114
- parts = [ [ 0, "s" ] ] if parts.empty?
115
133
  parts.map { |amount, unit| "#{amount}#{unit}" }.join(" ")
116
134
  end
117
135
 
@@ -154,6 +172,8 @@ module Keystone
154
172
  end
155
173
 
156
174
  def ended_at(entry)
175
+ return axis_start + scale if entry[:waiting]
176
+
157
177
  entry[:ended_at] || axis_end
158
178
  end
159
179
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KeystoneUi
4
- VERSION = "0.86.0"
4
+ VERSION = "0.87.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, drawn one line per step with a marked time axis if wanted, 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.
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, drawn one line per step with a marked time axis if wanted, with retries and their count, queued time, failed tries, steps still running, steps waiting on approval, 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, optionally one line per row with a marked axis, 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.
101
+ - `ui_timeline` — rows of timed steps on one shared time axis, each try of a step a bar on its row, optionally one line per row with a marked axis, each row's summed try time and number of tries, with optional queued time, failed tries, tries still running and tries waiting 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.
@@ -766,7 +766,7 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
766
766
  - `ui_bucket_series(buckets:)` takes an array of hashes with the keywords
767
767
  of `ui_bucket`, such as `[{ goal: 10, actual: 7, label: "Mon" }, ...]`.
768
768
  - `ui_timeline(entries:, one_line: false)` takes no block. `entries:` is
769
- `[{ label:, started_at:, ended_at: nil, queued_at: nil, failed: false, href: nil, selected: false }, ...]`,
769
+ `[{ label:, started_at:, ended_at: nil, queued_at: nil, failed: false, waiting: false, href: nil, selected: false }, ...]`,
770
770
  with every time a `Time` value. `one_line:` picks the layout, described
771
771
  below.
772
772
  - It draws one row per label, in the order each label first appears.
@@ -781,7 +781,8 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
781
781
  running. Its bar runs to the latest `ended_at` or `started_at` of any
782
782
  entry, and its row shows an
783
783
  `:info` status dot beside its duration that screen readers read as
784
- "Running". Leave `ended_at:` out only for a try that has not finished.
784
+ "Running", unless the row is waiting. Leave `ended_at:` out only for a
785
+ try that has not finished.
785
786
  - Every bar is drawn at least 2% of the track wide, so a try that took no
786
787
  time still shows. When every entry starts and ends at one moment, every
787
788
  bar is drawn at that width at the left edge of the track.
@@ -791,6 +792,17 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
791
792
  - An entry given `failed: true` draws its bar in the danger colour, and
792
793
  screen readers read it as "Failed". Ask the developer which tries count
793
794
  as failed and whether the queued time is shown.
795
+ - An entry given `waiting: true` is a try paused before it can go on, such
796
+ as a step waiting for approval. Its bar runs from its `started_at` to the
797
+ end of the axis, which on a one-line timeline is its last mark, in the
798
+ queued colour, in place of the danger colour even
799
+ when it is also `failed: true`. Its row writes `waiting` in the warning
800
+ tone in place of the duration, and shows no "Running" dot. A row holding
801
+ any waiting entry is a waiting row.
802
+ - The timeline reads no clock, so a waiting entry's `ended_at:` only moves
803
+ the end of the axis. Pass `ended_at: Time.current` on it so the axis, and
804
+ its bar, reach the present. Ask the developer which states of a step
805
+ count as waiting.
794
806
  - An entry given `href:` draws its bar as a link to that address, read out
795
807
  by screen readers as the entry's label. A row's label links to the
796
808
  `href:` of the row's last entry that has one, and with none it is plain
@@ -802,14 +814,19 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
802
814
  page is showing, such as the try whose detail page holds the timeline,
803
815
  and on one entry at most.
804
816
  - Each row shows its label, its duration and its track. The row's duration
805
- runs from its first entry's `started_at` to its last entry's `ended_at`,
806
- or to the end of the axis when that last entry is still running, so
807
- queued time before the first try is not counted. Durations are written as
808
- `1h 0m 5s`, leaving out leading zero units, and a zero duration is `0s`.
817
+ is the time from `started_at` to `ended_at` of each of its entries added
818
+ together, so queued time and the gaps between tries are not counted, and
819
+ a try still running counts up to the latest `ended_at` or `started_at` of
820
+ any entry. A duration under ten seconds is written with one decimal,
821
+ such as `8.2s`, and a zero duration is `0.0s`. A longer one is written in
822
+ whole hours, minutes and seconds, such as `1h 0m 5s` or `41s`, leaving
823
+ out leading zero units.
824
+ - A row holding more than one entry adds its number of tries after the
825
+ duration, such as `41s · 2 att.`. The wording is fixed.
809
826
  - With the default `one_line: false`, each row shows its label and its
810
827
  duration on one line with its track below them, at every width. Under
811
828
  the rows the axis reads `0s` on the left and the whole span on the right,
812
- and the bars fill the track from the start of the axis to its end.
829
+ written as a row's duration is, and the bars fill the track from the start of the axis to its end.
813
830
  - With `one_line: true`, from `sm:` up each row is one line: its label,
814
831
  then its track, then its duration. The label column is as wide as the
815
832
  longest label up to 40% of the timeline, a longer label is cut off with
@@ -901,7 +918,7 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
901
918
  others show through, a Columns menu with no greyed name for a hidden
902
919
  column, a table row whose caret does not open its detail, a text diff whose
903
920
  removed and added rows look like its shared rows, a timeline whose failed
904
- tries or queued time look like its other bars, or a status dot
921
+ tries, queued time or waiting tries look like its other bars, or a status dot
905
922
  that draws nothing — the app's Stimulus controllers or keystone_ui-styles version are
906
923
  out of date. Stop and hand that part to `keystone_ui-install`, and add no
907
924
  classes to fix it.
@@ -68,12 +68,19 @@ One decision: is keystone_ui set up in the app?
68
68
  - **Timelines.** A timeline entry is one try at a step: a label, a start time,
69
69
  an end time, and optionally the time it was queued and whether it failed.
70
70
  Entries sharing a label are drawn as several bars on one row, in the order
71
- given, and the row's duration runs from its first try's start to its last
72
- try's end. Queued time is drawn as its own segment before the bar, and a
73
- failed try is marked failed both in colour and for screen readers. The axis
71
+ given. The row's duration is the time of each try added together, so the
72
+ gaps between tries are not counted, and a row with more than one try adds the
73
+ number of tries after it, such as `· 3 att.`. A duration under ten seconds is
74
+ written with one decimal, such as `8.2s`, and a longer one in whole hours,
75
+ minutes and seconds, such as `1m 5s`. Queued time is drawn as its own
76
+ segment before the bar, and a failed try is marked failed both in colour and
77
+ for screen readers. An entry can be marked waiting, for a try that has not
78
+ started running: its bar runs from its start to the end of the axis in the
79
+ queued colour, and its row shows the word `waiting` in the warning tone in
80
+ place of a duration, with no running dot. The axis
74
81
  runs from the earliest queued or start time of any entry to the latest end
75
82
  or start time. An entry with no end time is still running: its bar runs to
76
- the end of the axis, and its row shows a status dot that screen readers read
83
+ the latest end or start time of any entry, and its row shows a status dot that screen readers read
77
84
  as "Running". Every bar is drawn at least a small visible width, so a try
78
85
  that took no time still shows. An entry with no start time, or one that ends
79
86
  before it starts, raises `ArgumentError` naming its label. A timeline with no
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.86.0
4
+ version: 0.87.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Schneider