keystone_ui 0.86.0 → 0.88.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: c8ea6aa2299d863f411c5f22e46fa98df485e1667b0fda9c574da8ab1104b103
4
+ data.tar.gz: 3d66e41c286179babed63f8273d90d611d801911bdae47000db12e2504f8cff9
5
5
  SHA512:
6
- metadata.gz: a327fe7872d4c828217c2dbf33c8b6042a520771708d0b04870b2c627ad00cfa8001bfae481475575c15e156cd5a0697756c2d98fc12236b9a8dfce484c69a1c
7
- data.tar.gz: c126fda060d77148908eabb68b1d1d2ab538060ff0bc9ad2d80441a2cd09409f2d05aa2221be673fe6fae98a8d790a590fc4fb95fcf94a1d5de20532ff28a5ab
6
+ metadata.gz: 75fd1ca16b9f93ecc6daf4efe9730b8c9d655f044a680a5873ae044f48cd2e36ddd240a58898960e48f1190d468f19fc50d3c61cfbfac69dd3cbe5deb744b450
7
+ data.tar.gz: b402b759296da5e5c2102e28eb1bf2bb847c39253348b047d80a79f24f1100a5b31e46a34ce7ab710bce78ee324cc958debc6dbaab9a6d310cb134a23b2118f4
@@ -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,7 +1,7 @@
1
1
  <dl class="<%= classes %>">
2
2
  <% rows.each do |row| %>
3
3
  <div class="<%= row_classes(row) %>">
4
- <dt class="ks-value-list-label">
4
+ <dt class="<%= label_classes %>">
5
5
  <%= row[:label] %>
6
6
  <% if row[:note] %><span class="ks-value-list-note"><%= row[:note] %></span><% end %>
7
7
  </dt>
@@ -5,16 +5,20 @@ module Keystone
5
5
  class ValueListComponent < ViewComponent::Base
6
6
  ALIGN_CLASSES = { start: nil, end: "ks-value-list-end" }.freeze
7
7
  RIGHT_MARK_CLASSES = "ks-tone-success inline size-5 align-text-bottom"
8
+ COLUMNS_CLASSES = "grid grid-cols-1 sm:grid-cols-2 ks-grid-gap-sm"
9
+ PAIR_CLASSES = "flex flex-col min-w-0"
10
+ PAIR_LABEL_CLASSES = "ks-value-list-label basis-auto text-xs"
8
11
 
9
12
  attr_reader :rows
10
13
 
11
- def initialize(rows:, align: :start)
14
+ def initialize(rows:, align: :start, columns: false)
12
15
  @rows = rows
13
16
  @align = align
17
+ @columns = columns
14
18
  end
15
19
 
16
20
  def classes
17
- [ "ks-value-list", ALIGN_CLASSES.fetch(@align) ].compact.join(" ")
21
+ [ "ks-value-list", ALIGN_CLASSES.fetch(@align), (COLUMNS_CLASSES if @columns) ].compact.join(" ")
18
22
  end
19
23
 
20
24
  def shown_value(row)
@@ -25,8 +29,12 @@ module Keystone
25
29
  RIGHT_MARK_CLASSES
26
30
  end
27
31
 
32
+ def label_classes
33
+ @columns ? PAIR_LABEL_CLASSES : "ks-value-list-label"
34
+ end
35
+
28
36
  def row_classes(row)
29
- [ "ks-value-list-row", ("ks-value-list-total" if row[:total]) ].compact.join(" ")
37
+ [ @columns ? PAIR_CLASSES : "ks-value-list-row", ("ks-value-list-total" if row[:total]) ].compact.join(" ")
30
38
  end
31
39
  end
32
40
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KeystoneUi
4
- VERSION = "0.86.0"
4
+ VERSION = "0.88.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, a record's details as labelled values in rows or in two columns, 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
  ---
@@ -75,7 +75,7 @@ not available in the app yet, that is `keystone_ui-install`'s job.
75
75
  - `ui_link` — a text link in the link colour.
76
76
  - `ui_facts` — a row of facts, each a count in bold beside its label.
77
77
  - `ui_paragraph` — a paragraph of running text.
78
- - `ui_value_list` — rows of a label and its value, such as a ledger or a byline.
78
+ - `ui_value_list` — labelled values, as rows of a label beside its value, such as a ledger or a byline, or as columns of a label above its value.
79
79
  - `ui_alert` — a banner message, optionally dismissible.
80
80
  - `ui_link_list` — a list of links, each row with a label, an optional subtitle, badge and value, and a chevron.
81
81
  - `ui_empty_state` — what a list or section shows when it has nothing in it, with an optional message and action.
@@ -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.
@@ -689,10 +689,19 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
689
689
  - `ui_facts(facts:)` — each fact is `{ value:, label: }`, drawn as a small
690
690
  box with the count in bold beside its label, in a row that wraps.
691
691
  - `ui_paragraph(text:)` shows running text.
692
- - `ui_value_list(rows:, align: :start)` — each row is `{ label:, value: }`
693
- with optional `note:`, `total: true`, `right: true` and `fallback:`, shown
694
- when the value is `nil` or empty. `right: true` draws a green check mark
695
- after the value, read out as "Right", for an answer that was right. `align: :end` pushes values to the right, as in a ledger.
692
+ - `ui_value_list(rows:, align: :start, columns: false)` — each row is
693
+ `{ label:, value: }` with optional `note:`, `total: true`, `right: true`
694
+ and `fallback:`, shown when the value is `nil` or empty. `right: true`
695
+ draws a green check mark after the value, read out as "Right", for an
696
+ answer that was right. `align: :end` pushes values to the right, as in a
697
+ ledger.
698
+ - With the default `columns: false`, each pair is one row with its label
699
+ beside its value and a line between rows. `columns: true` draws each pair
700
+ as its label in small text directly above its value, with no line between
701
+ pairs, one pair per line below `sm:` and two side by side from `sm:` up. A
702
+ long value wraps inside its own column. Use it for a record's details,
703
+ such as its contact and address fields, and ask the developer which
704
+ layout a screen uses.
696
705
 
697
706
  10. Explain figures.
698
707
 
@@ -766,7 +775,7 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
766
775
  - `ui_bucket_series(buckets:)` takes an array of hashes with the keywords
767
776
  of `ui_bucket`, such as `[{ goal: 10, actual: 7, label: "Mon" }, ...]`.
768
777
  - `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 }, ...]`,
778
+ `[{ label:, started_at:, ended_at: nil, queued_at: nil, failed: false, waiting: false, href: nil, selected: false }, ...]`,
770
779
  with every time a `Time` value. `one_line:` picks the layout, described
771
780
  below.
772
781
  - It draws one row per label, in the order each label first appears.
@@ -781,7 +790,8 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
781
790
  running. Its bar runs to the latest `ended_at` or `started_at` of any
782
791
  entry, and its row shows an
783
792
  `: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.
793
+ "Running", unless the row is waiting. Leave `ended_at:` out only for a
794
+ try that has not finished.
785
795
  - Every bar is drawn at least 2% of the track wide, so a try that took no
786
796
  time still shows. When every entry starts and ends at one moment, every
787
797
  bar is drawn at that width at the left edge of the track.
@@ -791,6 +801,17 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
791
801
  - An entry given `failed: true` draws its bar in the danger colour, and
792
802
  screen readers read it as "Failed". Ask the developer which tries count
793
803
  as failed and whether the queued time is shown.
804
+ - An entry given `waiting: true` is a try paused before it can go on, such
805
+ as a step waiting for approval. Its bar runs from its `started_at` to the
806
+ end of the axis, which on a one-line timeline is its last mark, in the
807
+ queued colour, in place of the danger colour even
808
+ when it is also `failed: true`. Its row writes `waiting` in the warning
809
+ tone in place of the duration, and shows no "Running" dot. A row holding
810
+ any waiting entry is a waiting row.
811
+ - The timeline reads no clock, so a waiting entry's `ended_at:` only moves
812
+ the end of the axis. Pass `ended_at: Time.current` on it so the axis, and
813
+ its bar, reach the present. Ask the developer which states of a step
814
+ count as waiting.
794
815
  - An entry given `href:` draws its bar as a link to that address, read out
795
816
  by screen readers as the entry's label. A row's label links to the
796
817
  `href:` of the row's last entry that has one, and with none it is plain
@@ -802,14 +823,19 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
802
823
  page is showing, such as the try whose detail page holds the timeline,
803
824
  and on one entry at most.
804
825
  - 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`.
826
+ is the time from `started_at` to `ended_at` of each of its entries added
827
+ together, so queued time and the gaps between tries are not counted, and
828
+ a try still running counts up to the latest `ended_at` or `started_at` of
829
+ any entry. A duration under ten seconds is written with one decimal,
830
+ such as `8.2s`, and a zero duration is `0.0s`. A longer one is written in
831
+ whole hours, minutes and seconds, such as `1h 0m 5s` or `41s`, leaving
832
+ out leading zero units.
833
+ - A row holding more than one entry adds its number of tries after the
834
+ duration, such as `41s · 2 att.`. The wording is fixed.
809
835
  - With the default `one_line: false`, each row shows its label and its
810
836
  duration on one line with its track below them, at every width. Under
811
837
  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.
838
+ written as a row's duration is, and the bars fill the track from the start of the axis to its end.
813
839
  - With `one_line: true`, from `sm:` up each row is one line: its label,
814
840
  then its track, then its duration. The label column is as wide as the
815
841
  longest label up to 40% of the timeline, a longer label is cut off with
@@ -901,7 +927,7 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
901
927
  others show through, a Columns menu with no greyed name for a hidden
902
928
  column, a table row whose caret does not open its detail, a text diff whose
903
929
  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
930
+ tries, queued time or waiting tries look like its other bars, or a status dot
905
931
  that draws nothing — the app's Stimulus controllers or keystone_ui-styles version are
906
932
  out of date. Stop and hand that part to `keystone_ui-install`, and add no
907
933
  classes to fix it.
@@ -13,7 +13,7 @@ nothing and gives no steps.
13
13
  keystone_ui is a Rails engine gem that supplies a host app's UI as view helpers
14
14
  built on ViewComponent. Screens are built from named pieces — page shells,
15
15
  sections, panels, grids, forms and fields, search dropdowns, data tables, navigation, cards,
16
- badges, status dots, stat tiles, charts, timelines, funnels, goal buckets, pipelines, breakdowns, code blocks,
16
+ badges, status dots, value lists, stat tiles, charts, timelines, funnels, goal buckets, pipelines, breakdowns, code blocks,
17
17
  text diffs and info buttons —
18
18
  instead of hand-written ERB and Tailwind. Every class the UI renders lives in the
19
19
  gem, so two pages built from the same helpers cannot disagree about spacing,
@@ -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
@@ -90,6 +97,13 @@ One decision: is keystone_ui set up in the app?
90
97
  to the address of the last entry in that row that has one. An entry can be
91
98
  marked selected, and the row holding it is drawn in the same tint as a data
92
99
  table's current row and announced to screen readers as the current item.
100
+ - **Value lists.** A value list shows labelled values, each a label and a value
101
+ with an optional note, a fallback shown when the value is empty, a total
102
+ marking and a check mark for a value that is right. By default each pair is a
103
+ row with its label beside its value and a line between rows. A value list can
104
+ lay its pairs in columns instead: one column on a phone and two from `sm:` up,
105
+ each label in small text directly above its value, a long value wrapping
106
+ inside its own column, and no line between pairs.
93
107
  - **Going back.** A form or show page shell needs a way back: a back link, a
94
108
  trail of earlier pages shown as breadcrumbs, or a trail the app supplies for
95
109
  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.86.0
4
+ version: 0.88.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Schneider