keystone_ui 0.100.0 → 0.102.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.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/app/components/keystone/ui/bar_chart_component.rb +5 -0
  3. data/app/components/keystone/ui/button_component.rb +3 -1
  4. data/app/components/keystone/ui/chip_row_component.html.erb +5 -0
  5. data/app/components/keystone/ui/chip_row_component.rb +25 -0
  6. data/app/components/keystone/ui/data_table_component.rb +11 -3
  7. data/app/components/keystone/ui/decision_bar_component.rb +29 -2
  8. data/app/components/keystone/ui/figure_component.rb +3 -1
  9. data/app/components/keystone/ui/link_component.rb +4 -2
  10. data/app/components/keystone/ui/link_list_component.html.erb +5 -1
  11. data/app/components/keystone/ui/link_list_component.rb +6 -0
  12. data/app/components/keystone/ui/mobile_action_component.rb +5 -1
  13. data/app/components/keystone/ui/mobile_header_component.rb +0 -14
  14. data/app/components/keystone/ui/review_card_component.rb +1 -1
  15. data/app/components/keystone/ui/section_component.rb +4 -0
  16. data/app/components/keystone/ui/stat_card_component.rb +6 -8
  17. data/app/components/keystone/ui/tab_switcher_component.rb +0 -9
  18. data/app/components/keystone/ui/text_diff_component.rb +52 -25
  19. data/app/components/keystone/ui/timeline_component.rb +9 -3
  20. data/app/components/keystone/ui/value_list_component.html.erb +1 -1
  21. data/app/components/keystone/ui/value_list_component.rb +11 -2
  22. data/app/helpers/keystone_ui_helper.rb +4 -0
  23. data/lib/keystone_ui/safelist.rb +1 -0
  24. data/lib/keystone_ui/version.rb +1 -1
  25. data/the_local/agents/keystone_ui-develop.md +59 -27
  26. data/the_local/agents/keystone_ui-info.md +17 -4
  27. data/the_local/interface.yml +1 -0
  28. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0040955f96b3a7ec54489372d7842d86f9b099d41c7fd6f26acd6e1b2fc6ffed'
4
- data.tar.gz: eef2890bb1a7f67dd1035b223f583d21a473aa9c126a9bc3f92f772a87a2ea5a
3
+ metadata.gz: 99dba4ba702216d0c3d6cb9a1c3c45cd69b817c372851273cb80b14bcab032be
4
+ data.tar.gz: 5a7ada13ee50ad9b73239c40e91aa49c6fe309e58a753ac37b8bc58a792c93a1
5
5
  SHA512:
6
- metadata.gz: 48abd5b626786f17663321345fddb275a4e048205cd63a365314179e7e926f0d6ef244b1b741eb665682d29af1931f3d4078e8b7e80527810fa757ab61551207
7
- data.tar.gz: f0853879c5cbae9cb200d801ac96e74b5df4c190c6cb050591ec063bf319ae720942d7d7745bc4161ddf2dd819f223d9d9ef303c5cdf26889a4b96c8d15f9538
6
+ metadata.gz: 2b8b17da50e67d6a83e01272fcc2e4e67abb5d3c0bbb56f16ca627736d83baffeab67c79b19ef86f8be71de2f552446f4e3b2a750debd02141ef5ad182e40bc2
7
+ data.tar.gz: f3587667c7fe74bdc2d78c8c19710dfd1f205ed0ae399b1ed3e00e73e31288c4c07c8ea517485972f48c9b704dec96461655390a55e380f6201a4be009208977
@@ -23,6 +23,7 @@ module Keystone
23
23
  attr_reader :bars
24
24
 
25
25
  def initialize(bars:, show_values: false, strip: false)
26
+ bars.each { |bar| check_value(bar) }
26
27
  @bars = bars
27
28
  @show_values = show_values
28
29
  @strip = strip
@@ -72,6 +73,10 @@ module Keystone
72
73
 
73
74
  private
74
75
 
76
+ def check_value(bar)
77
+ raise ArgumentError, "Bar chart bar #{bar[:label].inspect} has the negative value #{bar[:value]}, and a bar chart draws no bar below zero" if bar[:value].to_f.negative?
78
+ end
79
+
75
80
  def bar_share
76
81
  strip? ? STRIP_BAR_SHARE : BAR_SHARE
77
82
  end
@@ -20,7 +20,7 @@ module Keystone
20
20
 
21
21
  TEXT_CLASSES = "ks-text-button"
22
22
 
23
- def initialize(label:, href: nil, method: :get, variant: :primary, size: :md, full_width: false, type: :submit, data: nil, name: nil, value: nil, hidden: false, confirm: nil, disabled: false)
23
+ def initialize(label:, href: nil, method: :get, variant: :primary, size: :md, full_width: false, type: :submit, data: nil, name: nil, value: nil, hidden: false, confirm: nil, disabled: false, formaction: nil)
24
24
  @label = label
25
25
  @href = href
26
26
  @method = method.to_sym
@@ -34,6 +34,7 @@ module Keystone
34
34
  @hidden = hidden
35
35
  @confirm = confirm
36
36
  @disabled = disabled
37
+ @formaction = formaction
37
38
  end
38
39
 
39
40
  def classes
@@ -57,6 +58,7 @@ module Keystone
57
58
  options[:type] = @type
58
59
  options[:name] = @name if @name
59
60
  options[:value] = @value if @value
61
+ options[:formaction] = @formaction if @formaction
60
62
  else
61
63
  options[:href] = @href
62
64
  end
@@ -0,0 +1,5 @@
1
+ <div class="<%= ROW_CLASSES %>">
2
+ <% chips.each do |chip| %>
3
+ <span class="<%= chip_classes(chip) %>"><span><%= chip.fetch(:label) %></span> <%= tag.span(chip.fetch(:value), class: value_classes(chip)) %></span>
4
+ <% end %>
5
+ </div>
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Keystone
4
+ module Ui
5
+ class ChipRowComponent < ViewComponent::Base
6
+ ROW_CLASSES = "ks-chip-row max-sm:grid max-sm:grid-cols-3"
7
+ MONO_VALUE_CLASSES = "font-mono"
8
+ TONE_CLASSES = States::NAMES.to_h { |state| [ state, "ks-chip ks-chip-#{state}" ] }.freeze
9
+
10
+ attr_reader :chips
11
+
12
+ def initialize(chips:)
13
+ @chips = chips
14
+ end
15
+
16
+ def value_classes(chip)
17
+ MONO_VALUE_CLASSES if chip[:mono]
18
+ end
19
+
20
+ def chip_classes(chip)
21
+ TONE_CLASSES.fetch(chip.fetch(:tone))
22
+ end
23
+ end
24
+ end
25
+ end
@@ -22,6 +22,7 @@ module Keystone
22
22
  HEADER_CLASSES_FIRST = "ks-table-header ks-table-header-first text-left text-sm"
23
23
  HEADER_CLASSES_MIDDLE = "ks-table-header ks-table-header-middle text-left text-sm"
24
24
  HEADER_CLASSES_LAST = "ks-table-header ks-table-header-last text-right text-sm"
25
+ HEADING_CAPS_CLASSES = "ks-label-caps"
25
26
 
26
27
  ROW_CLASSES_FIRST = "ks-table-cell-first text-sm whitespace-nowrap"
27
28
  ROW_CLASSES_MIDDLE = "ks-table-cell-middle text-sm whitespace-nowrap"
@@ -46,7 +47,7 @@ module Keystone
46
47
  SORT_DESC_ICON = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 3a.75.75 0 0 1 .75.75v10.638l3.96-4.158a.75.75 0 1 1 1.08 1.04l-5.25 5.5a.75.75 0 0 1-1.08 0l-5.25-5.5a.75.75 0 0 1 1.08-1.04l3.96 4.158V3.75A.75.75 0 0 1 10 3Z" clip-rule="evenodd" /></svg>'
47
48
  SORT_NEUTRAL_ICON = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 3a.75.75 0 0 1 .55.24l3.25 3.5a.75.75 0 1 1-1.1 1.02L10 4.852 7.3 7.76a.75.75 0 0 1-1.1-1.02l3.25-3.5A.75.75 0 0 1 10 3Zm-3.76 9.2a.75.75 0 0 1 1.06.04l2.7 2.908 2.7-2.908a.75.75 0 1 1 1.1 1.02l-3.25 3.5a.75.75 0 0 1-1.1 0l-3.25-3.5a.75.75 0 0 1 .04-1.06Z" clip-rule="evenodd" /></svg>'
48
49
 
49
- def initialize(items:, columns:, empty_message: nil, sort: nil, sort_direction: nil, sort_url: nil, hidden_columns: [], key: nil, group_by: nil, group_totals: {}, total: nil, current_row: nil, phone_list: false, header: true)
50
+ def initialize(items:, columns:, empty_message: nil, sort: nil, sort_direction: nil, sort_url: nil, hidden_columns: [], key: nil, group_by: nil, group_totals: {}, total: nil, current_row: nil, phone_list: false, header: true, heading_caps: false)
50
51
  @items = items.to_a
51
52
  @current_index = @items.index(current_row) unless current_row.nil?
52
53
  @group_by = group_by
@@ -65,6 +66,7 @@ module Keystone
65
66
  @link_blocks = {}
66
67
  @phone_list = phone_list
67
68
  @header = header
69
+ @heading_caps = heading_caps
68
70
  end
69
71
 
70
72
  def before_render
@@ -162,7 +164,7 @@ module Keystone
162
164
 
163
165
  cell = {
164
166
  label: column.header_text,
165
- classes: aligned(tokens.join(" "), column),
167
+ classes: heading_classes(aligned(tokens.join(" "), column)),
166
168
  scope: "col"
167
169
  }
168
170
 
@@ -189,7 +191,7 @@ module Keystone
189
191
  if actions?
190
192
  cells << {
191
193
  label: "Actions",
192
- classes: HEADER_CLASSES_LAST,
194
+ classes: heading_classes(HEADER_CLASSES_LAST),
193
195
  scope: "col"
194
196
  }
195
197
  end
@@ -289,6 +291,12 @@ module Keystone
289
291
  end
290
292
  end
291
293
 
294
+ def heading_classes(classes)
295
+ return classes unless @heading_caps
296
+
297
+ [ *classes.split.grep_v("text-sm"), HEADING_CAPS_CLASSES ].join(" ")
298
+ end
299
+
292
300
  def aligned(classes, column)
293
301
  return classes unless column.align
294
302
 
@@ -19,6 +19,11 @@ module Keystone
19
19
  lg: "max-lg:order-first max-lg:*:w-full max-lg:*:min-h-12"
20
20
  }.freeze
21
21
  ACTION_CLASSES = "flex *:flex-1 *:min-w-0 *:wrap-break-word *:text-center"
22
+ PHONE_ACTION_TEXT_CLASSES = {
23
+ sm: "max-sm:*:text-sm",
24
+ md: "max-md:*:text-sm",
25
+ lg: "max-lg:*:text-sm"
26
+ }.freeze
22
27
  SECONDARY_ROW_CLASSES = {
23
28
  sm: "max-sm:*:flex-1 max-sm:*:min-w-0",
24
29
  md: "max-md:*:flex-1 max-md:*:min-w-0",
@@ -68,6 +73,7 @@ module Keystone
68
73
  @url = url
69
74
  @primary = primary
70
75
  @actions = actions
76
+ actions.each { |action| check_action(action) }
71
77
  @note = note
72
78
  @hint = hint
73
79
  @method = method
@@ -106,11 +112,32 @@ module Keystone
106
112
  end
107
113
 
108
114
  def secondary_button(action)
109
- tag.div(class: [ ACTION_CLASSES, (PHONE_ONLY_CLASSES.fetch(@breakpoint) if action[:phone_only]), PHONE_ORDER_CLASSES.fetch(@breakpoint)[action[:phone_order]] ].compact.join(" ")) do
110
- render ButtonComponent.new(variant: :secondary, **action.except(:phone_only, :phone_order, :phone_label), label: action_label(action))
115
+ tag.div(class: [ ACTION_CLASSES, PHONE_ACTION_TEXT_CLASSES.fetch(@breakpoint), (PHONE_ONLY_CLASSES.fetch(@breakpoint) if action[:phone_only]), phone_order_classes(action) ].compact.join(" ")) do
116
+ render ButtonComponent.new(variant: :secondary, **button_options(action), label: action_label(action))
111
117
  end
112
118
  end
113
119
 
120
+ def phone_order_classes(action)
121
+ PHONE_ORDER_CLASSES.fetch(@breakpoint).fetch(action[:phone_order]) if action.key?(:phone_order)
122
+ end
123
+
124
+ def button_options(action)
125
+ options = action.except(:phone_only, :phone_order, :phone_label)
126
+ return options unless sends_request?(action)
127
+
128
+ options.except(:href, :method).merge(formaction: action[:href], name: "_method", value: action[:method].to_s)
129
+ end
130
+
131
+ def check_action(action)
132
+ return unless sends_request?(action) && (action.key?(:name) || action.key?(:value))
133
+
134
+ raise ArgumentError, "Decision bar action #{action[:label].inspect} sends a #{action[:method]} to its own link, so it cannot send a name or value of its own"
135
+ end
136
+
137
+ def sends_request?(action)
138
+ action[:href] && action.fetch(:method, :get).to_sym != :get
139
+ end
140
+
114
141
  def action_label(action)
115
142
  return action[:label] unless action[:phone_label]
116
143
 
@@ -6,7 +6,9 @@ module Keystone
6
6
  TONES = {
7
7
  neutral: nil,
8
8
  success: "ks-tone-success",
9
- danger: "ks-tone-danger"
9
+ danger: "ks-tone-danger",
10
+ warning: "ks-tone-warning",
11
+ info: "ks-tone-info"
10
12
  }.freeze
11
13
 
12
14
  def initialize(text:, tone: :neutral)
@@ -4,14 +4,16 @@ module Keystone
4
4
  module Ui
5
5
  class LinkComponent < ViewComponent::Base
6
6
  CLASSES = "ks-link"
7
+ CENTRED_CLASSES = "ks-link block text-center"
7
8
 
8
- def initialize(label:, href:)
9
+ def initialize(label:, href:, centred: false)
9
10
  @label = label
10
11
  @href = href
12
+ @centred = centred
11
13
  end
12
14
 
13
15
  def call
14
- link_to(@label, @href, class: CLASSES)
16
+ link_to(@label, @href, class: @centred ? CENTRED_CLASSES : CLASSES)
15
17
  end
16
18
  end
17
19
  end
@@ -5,7 +5,11 @@
5
5
  <span class="<%= TEXT_CLASSES %>">
6
6
  <% if row[:top_line] %>
7
7
  <span class="<%= TOP_LINE_CLASSES %>">
8
- <%= render top_line_badge(row) %>
8
+ <% if row[:top_line][:type] %>
9
+ <span class="<%= TOP_LINE_TYPE_CLASSES %>"><span class="<%= type_tone_classes(row) %>"><%= row[:top_line][:type][:label] %></span></span>
10
+ <% else %>
11
+ <%= render top_line_badge(row) %>
12
+ <% end %>
9
13
  <span class="<%= TOP_LINE_TEXT_CLASSES %>"><%= row[:top_line][:text] %></span>
10
14
  </span>
11
15
  <% end %>
@@ -8,6 +8,8 @@ module Keystone
8
8
  STACK_CLASSES = "flex min-w-0 flex-1 flex-col-reverse ks-grid-gap-sm sm:contents"
9
9
  BADGE_CLASSES = "max-sm:self-start"
10
10
  TOP_LINE_BADGE_CLASSES = "min-w-0 whitespace-normal"
11
+ TOP_LINE_TYPE_CLASSES = "ks-label-caps min-w-0 whitespace-normal"
12
+ TYPE_TONE_CLASSES = States::NAMES.to_h { |state| [ state, "ks-tone-#{state}" ] }.freeze
11
13
  TEXT_CLASSES = "min-w-0 flex-1"
12
14
  TOP_LINE_CLASSES = "flex items-center justify-between ks-grid-gap-sm whitespace-nowrap"
13
15
  TOP_LINE_TEXT_CLASSES = "ks-value-list-note shrink-0 max-w-full truncate"
@@ -35,6 +37,10 @@ module Keystone
35
37
  BadgeComponent.new(**row[:badge], class: BADGE_CLASSES)
36
38
  end
37
39
 
40
+ def type_tone_classes(row)
41
+ TYPE_TONE_CLASSES.fetch(row[:top_line][:type][:tone])
42
+ end
43
+
38
44
  def top_line_badge(row)
39
45
  BadgeComponent.new(**row[:top_line][:badge], class: TOP_LINE_BADGE_CLASSES)
40
46
  end
@@ -18,7 +18,7 @@ module Keystone
18
18
  def call
19
19
  return link_to(PLUS_ICON.html_safe, url, **options) unless content_for?(:mobile_action_method)
20
20
 
21
- button_to(url, method: content_for(:mobile_action_method), **options) { PLUS_ICON.html_safe }
21
+ button_to(url, method: content_for(:mobile_action_method), form: form_options, **options) { PLUS_ICON.html_safe }
22
22
  end
23
23
 
24
24
  private
@@ -27,6 +27,10 @@ module Keystone
27
27
  content_for(:mobile_action_url)
28
28
  end
29
29
 
30
+ def form_options
31
+ content_for?(:mobile_action_confirm) ? { data: { turbo_confirm: content_for(:mobile_action_confirm) } } : {}
32
+ end
33
+
30
34
  def options
31
35
  { class: LINK_CLASSES, aria: { label: content_for(:mobile_action_label) } }
32
36
  end
@@ -9,12 +9,6 @@ module Keystone
9
9
  </svg>
10
10
  SVG
11
11
 
12
- ELLIPSIS_ICON = <<~SVG.freeze
13
- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
14
- <path stroke-linecap="round" stroke-linejoin="round" d="M12 6.75a.75.75 0 1 1 0-1.5.75.75 0 0 1 0 1.5ZM12 12.75a.75.75 0 1 1 0-1.5.75.75 0 0 1 0 1.5ZM12 18.75a.75.75 0 1 1 0-1.5.75.75 0 0 1 0 1.5Z" />
15
- </svg>
16
- SVG
17
-
18
12
  ROW_CLASSES = "ks-page flex items-center ks-grid-gap-sm lg:hidden print:hidden max-lg:in-[.top-nav]:contents"
19
13
  WRAPPER_CLASSES = "flex items-center lg:hidden print:hidden"
20
14
  BACK_LINK_CLASSES = "ks-mobile-header-back"
@@ -22,15 +16,7 @@ module Keystone
22
16
  SUBTITLE_CLASSES = "ks-mobile-header-subtitle block text-xs truncate"
23
17
  OVERLINE_CLASSES = "ks-mobile-header-subtitle block text-xs truncate"
24
18
  BADGE_CLASSES = "ml-auto shrink-0 self-center"
25
- DROPDOWN_CLASSES = "ks-action-menu hidden absolute right-0 z-50 w-48 origin-top-right"
26
19
 
27
- # Renders the left-side and title of the mobile header.
28
- # Call from the left side of your navbar.
29
- #
30
- # Usage in navbar:
31
- # <% if content_for?(:form_page) %>
32
- # <%= ui_mobile_header_left %>
33
- # <% end %>
34
20
  def initialize(title:, back_url:, subtitle: nil, overline: nil, badge: nil)
35
21
  @title = title
36
22
  @back_url = back_url
@@ -13,7 +13,7 @@ module Keystone
13
13
  CTA_CLASSES = "ks-card-link text-xs"
14
14
  META_CLASSES = "ks-card-meta font-mono text-xs ks-tone-muted"
15
15
  FINDING_CLASSES = "ks-alert ks-alert-warning text-xs"
16
- TONE_CLASSES = { muted: "ks-tone-muted", neutral: "ks-tone-neutral", success: "ks-tone-success", warning: "ks-tone-warning", danger: "ks-tone-danger", info: "ks-tone-info" }.freeze
16
+ TONE_CLASSES = [ :muted, *States::NAMES ].to_h { |tone| [ tone, "ks-tone-#{tone}" ] }.freeze
17
17
 
18
18
  def initialize(id:, title:, score: nil, score_tone: :muted, body: nil, cta: nil, meta: nil, finding: nil, actions: [], compact: false)
19
19
  @id = id
@@ -24,6 +24,10 @@ module Keystone
24
24
  @extra_classes = binding.local_variable_get(:class)
25
25
  end
26
26
 
27
+ def before_render
28
+ raise ArgumentError, "A section's aside needs a title" if aside? && !header?
29
+ end
30
+
27
31
  def spacing_class
28
32
  SPACING_CLASSES.fetch(@spacing)
29
33
  end
@@ -10,6 +10,7 @@ module Keystone
10
10
  COMPACT_CLASSES = "ks-metric-card ks-metric-card-compact relative"
11
11
  LABEL_CLASSES = "ks-stat-card-label text-sm"
12
12
  COMPACT_LABEL_CLASSES = "ks-stat-card-label text-xs"
13
+ CAPS_LABEL_CLASSES = "ks-stat-card-label ks-label-caps"
13
14
  VALUE_BASE_CLASSES = "ks-stat-card-value text-3xl"
14
15
  COMPACT_VALUE_CLASSES = "ks-stat-card-value ks-stat-card-value-compact flex flex-wrap items-baseline text-lg leading-6"
15
16
  SUFFIX_CLASSES = "ks-stat-card-suffix text-lg"
@@ -26,18 +27,13 @@ module Keystone
26
27
  <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>
27
28
  SVG
28
29
 
29
- VARIANT_CLASSES = {
30
- neutral: "ks-tone-neutral",
31
- success: "ks-tone-success",
32
- danger: "ks-tone-danger",
33
- warning: "ks-tone-warning",
34
- info: "ks-tone-info"
35
- }.freeze
30
+ VARIANT_CLASSES = States::NAMES.to_h { |state| [ state, "ks-tone-#{state}" ] }.freeze
36
31
 
37
32
  attr_reader :label, :value, :suffix, :definition, :calculation, :change, :href, :note
38
33
 
39
- def initialize(label:, value:, variant: :neutral, suffix: nil, definition: nil, calculation: nil, change: nil, href: nil, note: nil, plain: false, fallback: nil, compact: false)
34
+ def initialize(label:, value:, variant: :neutral, suffix: nil, definition: nil, calculation: nil, change: nil, href: nil, note: nil, plain: false, fallback: nil, compact: false, label_caps: false)
40
35
  @compact = compact
36
+ @label_caps = label_caps
41
37
  @label = label
42
38
  @fallback = fallback
43
39
  @note = note
@@ -66,6 +62,8 @@ module Keystone
66
62
  end
67
63
 
68
64
  def label_classes
65
+ return CAPS_LABEL_CLASSES if @label_caps
66
+
69
67
  @compact ? COMPACT_LABEL_CLASSES : LABEL_CLASSES
70
68
  end
71
69
 
@@ -9,7 +9,6 @@ module Keystone
9
9
  SHAPE_CLASSES = { pills: "ks-tab-bar-pills", underline: "ks-tab-bar-underline" }.freeze
10
10
  TAB_BASE_CLASSES = "ks-tab text-sm transition max-sm:shrink-0 max-sm:whitespace-nowrap"
11
11
  SHAPED_TAB_BASE_CLASSES = "ks-tab transition max-sm:shrink-0 max-sm:whitespace-nowrap"
12
- PANEL_CLASSES = "hidden"
13
12
  LAYOUT_CLASSES = "max-sm:flex max-sm:flex-col"
14
13
  SUMMARY_CLASSES = "max-sm:order-1 max-sm:[&>:first-child]:mt-0 max-sm:[&>:last-child]:mb-0"
15
14
  CONTENT_CLASSES = "max-sm:order-1"
@@ -50,14 +49,6 @@ module Keystone
50
49
 
51
50
  content_tag(:span, count, class: "ks-tab-count")
52
51
  end
53
-
54
- def panel_classes
55
- PANEL_CLASSES
56
- end
57
-
58
- def wrapper_data
59
- { controller: "tab-switcher" }
60
- end
61
52
  end
62
53
  end
63
54
  end
@@ -19,8 +19,11 @@ module Keystone
19
19
  @before = before.to_s.lines(chomp: true)
20
20
  @after = after.to_s.lines(chomp: true)
21
21
  @one_column = one_column
22
+ @comparisons = 0
22
23
  end
23
24
 
25
+ attr_reader :comparisons
26
+
24
27
  def one_column?
25
28
  @one_column
26
29
  end
@@ -60,39 +63,63 @@ module Keystone
60
63
  end
61
64
 
62
65
  def compare
63
- before_index = after_index = 0
64
- rows = []
65
- while before_index < @before.size || after_index < @after.size
66
- if before_index < @before.size && after_index < @after.size && @before[before_index] == @after[after_index]
67
- rows << [ { text: @before[before_index], number: before_index + 1 }, { text: @after[after_index], number: after_index + 1 } ]
68
- before_index += 1
69
- after_index += 1
70
- elsif before_index < @before.size && (after_index == @after.size || shared[before_index + 1][after_index] >= shared[before_index][after_index + 1])
71
- rows << [ { text: @before[before_index], number: before_index + 1, mark: "ks-diff-removed", sign: "-" }, nil ]
72
- before_index += 1
73
- else
74
- rows << [ nil, { text: @after[after_index], number: after_index + 1, mark: "ks-diff-added", sign: "+" } ]
75
- after_index += 1
66
+ edits.map do |step, before_index, after_index|
67
+ case step
68
+ when :same then [ { text: @before[before_index], number: before_index + 1 }, { text: @after[after_index], number: after_index + 1 } ]
69
+ when :remove then [ { text: @before[before_index], number: before_index + 1, mark: "ks-diff-removed", sign: "-" }, nil ]
70
+ else [ nil, { text: @after[after_index], number: after_index + 1, mark: "ks-diff-added", sign: "+" } ]
71
+ end
72
+ end
73
+ end
74
+
75
+ def edits
76
+ before_index = @before.size
77
+ after_index = @after.size
78
+ steps = []
79
+ furthest_reaches.each_with_index.reverse_each do |reach, changes|
80
+ diagonal = before_index - after_index
81
+ previous_diagonal = added_on?(reach, diagonal, changes) ? diagonal + 1 : diagonal - 1
82
+ previous_before = reach[previous_diagonal]
83
+ previous_after = previous_before - previous_diagonal
84
+ while before_index > previous_before && after_index > previous_after
85
+ before_index -= 1
86
+ after_index -= 1
87
+ steps << [ :same, before_index, after_index ]
76
88
  end
89
+ next if changes.zero?
90
+
91
+ steps << (before_index == previous_before ? [ :add, nil, after_index - 1 ] : [ :remove, before_index - 1, nil ])
92
+ before_index = previous_before
93
+ after_index = previous_after
77
94
  end
78
- rows
95
+ steps.reverse
79
96
  end
80
97
 
81
- def shared
82
- @shared ||= begin
83
- table = Array.new(@before.size + 1) { Array.new(@after.size + 1, 0) }
84
- (@before.size - 1).downto(0) do |before_index|
85
- (@after.size - 1).downto(0) do |after_index|
86
- table[before_index][after_index] = if @before[before_index] == @after[after_index]
87
- table[before_index + 1][after_index + 1] + 1
88
- else
89
- [ table[before_index + 1][after_index], table[before_index][after_index + 1] ].max
90
- end
98
+ def furthest_reaches
99
+ reach = { 1 => 0 }
100
+ (0..(@before.size + @after.size)).each_with_object([]) do |changes, reaches|
101
+ reaches << reach.dup
102
+ (-changes).step(changes, 2) do |diagonal|
103
+ before_index = added_on?(reach, diagonal, changes) ? reach[diagonal + 1] : reach[diagonal - 1] + 1
104
+ after_index = before_index - diagonal
105
+ while before_index < @before.size && after_index < @after.size && same_line?(before_index, after_index)
106
+ before_index += 1
107
+ after_index += 1
91
108
  end
109
+ reach[diagonal] = before_index
110
+ return reaches if before_index >= @before.size && after_index >= @after.size
92
111
  end
93
- table
94
112
  end
95
113
  end
114
+
115
+ def same_line?(before_index, after_index)
116
+ @comparisons += 1
117
+ @before[before_index] == @after[after_index]
118
+ end
119
+
120
+ def added_on?(reach, diagonal, changes)
121
+ diagonal == -changes || (diagonal != changes && reach[diagonal - 1] < reach[diagonal + 1])
122
+ end
96
123
  end
97
124
  end
98
125
  end
@@ -23,16 +23,19 @@ module Keystone
23
23
  PHONE_AXIS_CLASSES = "ks-meter-label flex justify-between text-xs sm:col-span-3 sm:hidden"
24
24
  ONE_LINE_AXIS_CLASSES = "ks-meter-label relative h-4 text-xs sm:col-start-2 max-sm:hidden"
25
25
  MARK_CLASSES = "absolute top-0 whitespace-nowrap"
26
+ MONO_CLASSES = "font-mono"
27
+ MONO_LABEL_CLASSES = "min-w-0 wrap-break-word font-mono"
26
28
  MINIMUM_BAR_PERCENT = 2
27
29
  MARK_STEPS = [ 1, 2, 5, 10, 15, 30, 60, 120, 300, 600, 900, 1800, 3600, 7200, 10_800, 21_600, 43_200, 86_400 ].freeze
28
30
  MAXIMUM_MARK_INTERVALS = 6
29
31
 
30
32
  attr_reader :entries, :one_line
31
33
 
32
- def initialize(entries:, one_line: false)
34
+ def initialize(entries:, one_line: false, text_mono: false)
33
35
  entries.each { |entry| check_times(entry) }
34
36
  @entries = entries
35
37
  @one_line = one_line
38
+ @text_mono = text_mono
36
39
  end
37
40
 
38
41
  def track_classes
@@ -44,7 +47,9 @@ module Keystone
44
47
  end
45
48
 
46
49
  def label_classes
47
- ONE_LINE_LABEL_CLASSES if one_line
50
+ return [ ONE_LINE_LABEL_CLASSES, (MONO_CLASSES if @text_mono) ].compact.join(" ") if one_line
51
+
52
+ MONO_LABEL_CLASSES if @text_mono
48
53
  end
49
54
 
50
55
  def status_classes
@@ -98,7 +103,7 @@ module Keystone
98
103
  end
99
104
 
100
105
  def duration_classes(row)
101
- WAITING_CLASSES if waiting?(row)
106
+ [ (WAITING_CLASSES if waiting?(row)), (MONO_CLASSES if @text_mono) ].compact.join(" ").presence
102
107
  end
103
108
 
104
109
  def duration(row)
@@ -132,6 +137,7 @@ module Keystone
132
137
  def check_times(entry)
133
138
  raise ArgumentError, "Timeline entry #{entry[:label].inspect} has no started_at" unless entry[:started_at]
134
139
  raise ArgumentError, "Timeline entry #{entry[:label].inspect} ends before it starts" if entry[:ended_at] && entry[:ended_at] < entry[:started_at]
140
+ raise ArgumentError, "Timeline entry #{entry[:label].inspect} is queued after it starts" if entry[:queued_at] && entry[:queued_at] > entry[:started_at]
135
141
  end
136
142
 
137
143
  def written_duration(seconds)
@@ -5,7 +5,7 @@
5
5
  <%= row[:label] %>
6
6
  <% if row[:note] %><span class="ks-value-list-note"><%= row[:note] %></span><% end %>
7
7
  </dt>
8
- <dd class="ks-value-list-value">
8
+ <dd class="<%= value_classes %>">
9
9
  <%= shown_value(row) %>
10
10
  <% if row[:right] %>
11
11
  <svg aria-label="Right" role="img" class="<%= right_mark_classes %>" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M16.704 4.153a.75.75 0 0 1 .143 1.052l-8 10.5a.75.75 0 0 1-1.127.075l-4.5-4.5a.75.75 0 0 1 1.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 0 1 1.05-.143Z" clip-rule="evenodd" /></svg>
@@ -8,11 +8,16 @@ module Keystone
8
8
  COLUMNS_CLASSES = "grid grid-cols-1 sm:grid-cols-2 ks-grid-gap-sm"
9
9
  PAIR_CLASSES = "flex flex-col min-w-0"
10
10
  PAIR_LABEL_CLASSES = "ks-value-list-label basis-auto text-xs"
11
+ CAPS_LABEL_CLASSES = "ks-label-caps"
12
+ VALUE_CLASSES = "ks-value-list-value"
13
+ MONO_VALUE_CLASSES = "ks-value-list-value font-mono"
11
14
 
12
15
  attr_reader :rows
13
16
 
14
- def initialize(rows:, align: :start, columns: false)
17
+ def initialize(rows:, align: :start, columns: false, label_caps: false, value_mono: false)
15
18
  @rows = rows
19
+ @value_mono = value_mono
20
+ @label_caps = label_caps
16
21
  @align = align
17
22
  @columns = columns
18
23
  end
@@ -30,7 +35,11 @@ module Keystone
30
35
  end
31
36
 
32
37
  def label_classes
33
- @columns ? PAIR_LABEL_CLASSES : "ks-value-list-label"
38
+ [ @columns ? PAIR_LABEL_CLASSES : "ks-value-list-label", (CAPS_LABEL_CLASSES if @label_caps) ].compact.join(" ")
39
+ end
40
+
41
+ def value_classes
42
+ @value_mono ? MONO_VALUE_CLASSES : VALUE_CLASSES
34
43
  end
35
44
 
36
45
  def row_classes(row)
@@ -301,6 +301,10 @@ module KeystoneUiHelper
301
301
  render Keystone::Ui::PictureComponent.new(**args)
302
302
  end
303
303
 
304
+ def ui_chip_row(**args)
305
+ render Keystone::Ui::ChipRowComponent.new(**args)
306
+ end
307
+
304
308
  def ui_heading(**args)
305
309
  render Keystone::Ui::HeadingComponent.new(**args)
306
310
  end
@@ -19,6 +19,7 @@ module Keystone
19
19
  Keystone::Ui::FactsComponent,
20
20
  Keystone::Ui::ButtonRowComponent,
21
21
  Keystone::Ui::FigureComponent,
22
+ Keystone::Ui::ChipRowComponent,
22
23
  Keystone::Ui::HeadingComponent,
23
24
  Keystone::Ui::HeroComponent,
24
25
  Keystone::Ui::ListDetailComponent,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KeystoneUi
4
- VERSION = "0.100.0"
4
+ VERSION = "0.102.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 phone header with a line above its title and a badge at its right end, a page's main action as a phone top-bar icon or a button fixed to the bottom of the screen, a decision bar of a note field and several buttons sent as one form and fixed to the bottom of a phone screen, review cards of an id, score, title, text, finding note and equal-width buttons set three across on a desktop, 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 short note or badge at the right of a section's title, a record's details as labelled values in rows or in two columns, a queue of links with a type and time above each title and the open one marked, two versions of a text compared line by line side by side or in one column, 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 phone header with a line above its title and a badge at its right end, a page's main action as a phone top-bar icon or a button fixed to the bottom of the screen, a decision bar of a note field and several buttons sent as one form and fixed to the bottom of a phone screen, review cards of an id, score, title, text, finding note and equal-width buttons set three across on a desktop, 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, summary chips coloured by tone, pictures held to half the screen, a short note or badge at the right of a section's title, a record's details as labelled values in rows or in two columns, a queue of links with a type and time above each title and the open one marked, two versions of a text compared line by line side by side or in one column, 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
  ---
@@ -72,7 +72,8 @@ not available in the app yet, that is `keystone_ui-install`'s job.
72
72
  - `ui_button_row` — a row of buttons that wraps onto further lines, optionally giving each button an equal share of its width at every width or on a phone only.
73
73
  - `ui_badge` — a coloured pill holding a short label.
74
74
  - `ui_status_dot` — a small dot coloured by state, with its label read only by screen readers.
75
- - `ui_figure` — one amount as inline text, coloured as a gain or a loss.
75
+ - `ui_figure` — one amount or short result as inline text, coloured as a gain, a loss, a warning or information.
76
+ - `ui_chip_row` — a row of summary chips, each a label and value in a tone's colour on a tinted background, three across on a phone.
76
77
  - `ui_picture` — an image never taller than half the screen, optionally opening its full-size file.
77
78
  - `ui_heading` — a heading at one of three sizes, with an optional short note on its right.
78
79
  - `ui_caption` — small uppercase muted text placed above a title or a figure, or a small muted line in normal case that can hold links.
@@ -189,10 +190,10 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
189
190
  the main action send that method: the header's button and
190
191
  `ui_mobile_action`'s icon become forms posting to `action_url:`.
191
192
  - `action_confirm:` is a question Turbo asks before the main action goes
192
- ahead, on the header's button and on `ui_bottom_action`'s button, as
193
- `ui_button`'s `confirm:` does. `ui_mobile_action`'s plus icon does not ask
194
- it, so a screen whose action needs a question shows `ui_bottom_action` on
195
- a phone, not the plus icon. It applies only with `action_url:` and is
193
+ ahead, on the header's button, on `ui_bottom_action`'s button and on
194
+ `ui_mobile_action`'s plus icon when `action_method:` is given, as
195
+ `ui_button`'s `confirm:` does. The plus icon of an action with no
196
+ `action_method:` is a link and does not ask it. It applies only with `action_url:` and is
196
197
  ignored when an `action` block is given. Ask the developer whether a
197
198
  screen's main action needs a question and how it is worded.
198
199
  - `subtitle_mono: true` draws the subtitle in a fixed-width font, such as
@@ -236,7 +237,8 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
236
237
  keywords of `ui_action_menu_item`, and renders an action menu. The link
237
238
  and the menu sit side by side at the right edge of the header, the link
238
239
  first, at every width. `spacing:` is `:sm` `:md` `:lg`. The header, with its
239
- `action:`, `menu:` and aside, renders only when `title:` is given.
240
+ `action:`, `menu:` and aside, renders only when `title:` is given, and an
241
+ aside given with no `title:` raises `ArgumentError`.
240
242
  - The block yields the section, and `section.with_aside { ... }` in it puts
241
243
  short text or a `ui_badge`, such as a sort order or a step's state, in
242
244
  small muted text at the right end of the title line, before the link and
@@ -403,8 +405,11 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
403
405
  `sm:` in its place, `phone_only: true`, which shows the action below
404
406
  `sm:` only, and `phone_order:` 1, 2 or 3, its place in the phone row, so
405
407
  one call can give a desktop row and a phone row that differ in labels,
406
- buttons and order. Do not give an action `href:` with a `method:` other than `:get`,
407
- since that draws a form inside the bar's form. `note:` takes `name:`,
408
+ buttons and order. Any other `phone_order:` raises `KeyError`. An action
409
+ with `href:` and a `method:` such as `:delete` sends the bar's form, note
410
+ included, to its own `href:` with that method, while every other button
411
+ still sends it to `url:` with the bar's `method:`. Such an action cannot
412
+ also take `name:` or `value:`, and giving either raises `ArgumentError`. `note:` takes `name:`,
408
413
  `label:` and `placeholder:` and draws a text field inside its label, sent
409
414
  with the form. `hint:` is a short line of muted text, such as keyboard
410
415
  keys. From `sm:` up it draws a panel holding the note field, the
@@ -413,7 +418,9 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
413
418
  bar fixed to the bottom of the screen, above `ui_bottom_nav` on a page
414
419
  that has one, with the primary button at full width and 48 pixels tall
415
420
  above a row of the secondary buttons, each an equal share of the row and
416
- 44 pixels tall. A label too long for its share wraps inside its
421
+ 44 pixels tall. Their labels are drawn in small text there, so a label
422
+ such as "Send back" stays on one line three across on a 390px-wide
423
+ screen. A label too long for its share wraps inside its
417
424
  button, so do not shrink the buttons to keep the row even. The note
418
425
  field and hint are not shown below `sm:`. `breakpoint: :md` or
419
426
  `breakpoint: :lg` moves the switch between the phone bar and the panel
@@ -581,8 +588,9 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
581
588
 
582
589
  8. Build tables.
583
590
 
584
- - `ui_data_table(items:, columns:, empty_message: nil, sort: nil, sort_direction: nil, sort_url: nil, hidden_columns: [], key: nil, group_by: nil, group_totals: {}, total: nil, current_row: nil, phone_list: false, header: true)`
585
- takes a block yielding the table. `items:` are records or hashes, and a
591
+ - `ui_data_table(items:, columns:, empty_message: nil, sort: nil, sort_direction: nil, sort_url: nil, hidden_columns: [], key: nil, group_by: nil, group_totals: {}, total: nil, current_row: nil, phone_list: false, header: true, heading_caps: false)`
592
+ takes a block yielding the table. `heading_caps: true` draws the column
593
+ headings in small capitals. `items:` are records or hashes, and a
586
594
  cell's value is the column key called on the item, or `item[key]`.
587
595
  `group_by:` lists rows under heading rows named by that key's value,
588
596
  `group_totals:` (`{ "Group name" => { column_key => value } }`) puts
@@ -679,7 +687,7 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
679
687
 
680
688
  9. Show content and status.
681
689
 
682
- - `ui_button(label:, href: nil, method: :get, variant: :primary, size: :md, full_width: false, type: :submit, data: nil, name: nil, value: nil, hidden: false, confirm: nil, disabled: false)`
690
+ - `ui_button(label:, href: nil, method: :get, variant: :primary, size: :md, full_width: false, type: :submit, data: nil, name: nil, value: nil, hidden: false, confirm: nil, disabled: false, formaction: nil)`
683
691
  renders a link with `href:` and a button without it. `variant:` is
684
692
  `:primary` `:secondary` `:danger` `:text`, `size:` is `:sm` `:md` `:lg`,
685
693
  and `type:`, `name:` and `value:` apply only to the button.
@@ -687,6 +695,8 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
687
695
  as a Back or Previous control under a form. A button given `name:` and
688
696
  `value:` submits them with its form when pressed. `hidden: true` draws it
689
697
  with the `hidden` attribute, for the app's own script to show.
698
+ `formaction:` makes a button without `href:` send its form to that
699
+ address in place of the form's own when pressed.
690
700
  - `disabled: true` draws a button without `href:` with the `disabled`
691
701
  attribute, so it cannot be pressed and does not submit its form. It is
692
702
  for a button without `href:`: a link ignores the attribute and stays
@@ -704,8 +714,10 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
704
714
  `equal_width: :phone` does that below `sm:` only, and from `sm:` up each
705
715
  button keeps the width of its label. Use it in place of a hand-written
706
716
  flex `div` around a set of buttons.
707
- - `ui_link(label:, href:)` draws a text link in the link colour. Use it in
708
- place of a hand-written `link_to` with colour classes.
717
+ - `ui_link(label:, href:, centred: false)` draws a text link in the link
718
+ colour. `centred: true` puts it on its own line with its label in the
719
+ middle, such as a "Finish on desktop" link under a phone page's cards.
720
+ Use it in place of a hand-written `link_to` with colour classes.
709
721
  - With `href:` and `method:` `:post` `:patch` `:put` or `:delete`, it
710
722
  renders a button inside its own small form that sends that request to
711
723
  `href:` when tapped. Do not write a form around it. It cannot sit inside
@@ -748,7 +760,10 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
748
760
  badge at the left, apart from the row's `badge:`, and short text at the
749
761
  right, such as a type and the time left. It stays on one line and cuts off
750
762
  long text, a long badge wraps without squeezing the text beside it, and
751
- the label and subtitle wrap. `current: true` marks the
763
+ the label and subtitle wrap. In place of `badge:`, `top_line:` takes
764
+ `type: { label:, tone: }`, which shows the row's type as small-capital
765
+ text in the tone's colour, such as `{ label: "Approval", tone: :warning }`
766
+ or `{ label: "Failure", tone: :danger }`. `current: true` marks the
752
767
  row the person has open with `aria-current` and a tint and accent bar.
753
768
  `chevron: false` leaves off every row's chevron, as in a queue beside the
754
769
  open item. `new_tab: true` opens every row's link in a new browser tab
@@ -815,12 +830,14 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
815
830
  - `ui_facts(facts:)` — each fact is `{ value:, label: }`, drawn as a small
816
831
  box with the count in bold beside its label, in a row that wraps.
817
832
  - `ui_paragraph(text:)` shows running text.
818
- - `ui_value_list(rows:, align: :start, columns: false)` — each row is
833
+ - `ui_value_list(rows:, align: :start, columns: false, label_caps: false, value_mono: false)` — each row is
819
834
  `{ label:, value: }` with optional `note:`, `total: true`, `right: true`
820
835
  and `fallback:`, shown when the value is `nil` or empty. `right: true`
821
836
  draws a green check mark after the value, read out as "Right", for an
822
837
  answer that was right. `align: :end` pushes values to the right, as in a
823
- ledger.
838
+ ledger. `label_caps: true` draws the labels in small capitals and
839
+ `value_mono: true` draws the values in a fixed-width font, as for ids,
840
+ model names and run numbers.
824
841
  - With the default `columns: false`, each pair is one row with its label
825
842
  beside its value and a line between rows. `columns: true` draws each pair
826
843
  as its label in small text directly above its value, with no line between
@@ -831,7 +848,7 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
831
848
 
832
849
  10. Explain figures.
833
850
 
834
- - `ui_stat_card(label:, value:, variant: :neutral, suffix: nil, definition: nil, calculation: nil, change: nil, href: nil, note: nil, plain: false, fallback: nil, compact: false)`
851
+ - `ui_stat_card(label:, value:, variant: :neutral, suffix: nil, definition: nil, calculation: nil, change: nil, href: nil, note: nil, plain: false, fallback: nil, compact: false, label_caps: false)`
835
852
  — `variant:` is `:neutral` `:success` `:danger` `:warning` `:info` and
836
853
  colours the value. `change:` is a signed number shown as `▲ 4.2%` in
837
854
  green, `▼` in red, or plain at zero. `href:` links the value only, so
@@ -841,13 +858,24 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
841
858
  extra small label over a smaller value with its change or note beside
842
859
  the value, under half a default card's height. Put compact cards in
843
860
  `ui_grid(cols: { default: 1, sm: 2 }, gap: :sm)` inside a panel so they
844
- sit two across and stack on a phone.
845
- - `ui_figure(text:, tone: :neutral)` prints one amount inline. `tone:`
846
- `:neutral` uses the surrounding text colour, `:success` green and
847
- `:danger` red, and any other symbol raises `KeyError`. Its output can go
861
+ sit two across and stack on a phone. `label_caps: true` draws the label
862
+ in small capitals.
863
+ - `ui_figure(text:, tone: :neutral)` prints one amount or short result
864
+ inline. `tone:` `:neutral` uses the surrounding text colour, `:success`
865
+ green, `:danger` red, `:warning` amber and `:info` blue, such as
866
+ "Waiting" or "Running" for a step's result, and any other symbol raises
867
+ `KeyError`. Its output can go
848
868
  anywhere a string is shown, such as a table cell. Use it, not a badge or
849
869
  a colour class, for a gain or a loss, and ask the developer which amounts
850
870
  are coloured and what counts as a gain.
871
+ - `ui_chip_row(chips:)` shows a row of summary chips. Each chip is
872
+ `{ label:, value:, tone:, mono: false }`, `tone:` one of `:neutral`
873
+ `:success` `:danger` `:warning` `:info`, and draws its label and value
874
+ in that tone's colour on a tinted background. `mono: true` draws the
875
+ value in a fixed-width font. The chips share the row's width equally,
876
+ and on a phone they sit three across with a fourth starting a new line.
877
+ Use it for a few counts or scores above the record they summarise, in
878
+ place of badges or hand-written tinted spans.
851
879
  - `ui_calculation(groups:, summary: "How this is worked out")` shows the
852
880
  steps behind a figure, closed under a row reading `summary:`. `groups:`
853
881
  is `[{ title:, lines: [{ label:, working:, result: }, ...] }, ...]`.
@@ -876,7 +904,8 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
876
904
  `height:` `:sm` `:md` `:lg`.
877
905
  - `ui_bar_chart(bars:, show_values: false, strip: false)` — `bars:` is
878
906
  `[{ label:, value:, shaded:, group: }, ...]`, where `shaded: true` draws
879
- a bar faded. It is drawn on the server as an SVG, so use it, not
907
+ a bar faded. A negative `value:` raises `ArgumentError` naming it. It
908
+ is drawn on the server as an SVG, so use it, not
880
909
  `ui_line_chart`, for a chart that must print or show without JavaScript.
881
910
  - Give bars `group:`, such as the version that produced each one, to show
882
911
  groups of bars. Groups count from oldest to newest in the order their
@@ -916,10 +945,12 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
916
945
  the fill turns green with `over: :success` or amber with `over: :warning`.
917
946
  - `ui_bucket_series(buckets:)` takes an array of hashes with the keywords
918
947
  of `ui_bucket`, such as `[{ goal: 10, actual: 7, label: "Mon" }, ...]`.
919
- - `ui_timeline(entries:, one_line: false)` takes no block. `entries:` is
948
+ - `ui_timeline(entries:, one_line: false, text_mono: false)` takes no block. `entries:` is
920
949
  `[{ label:, started_at:, ended_at: nil, queued_at: nil, failed: false, waiting: false, href: nil, selected: false }, ...]`,
921
950
  with every time a `Time` value. `one_line:` picks the layout, described
922
- below.
951
+ below. `text_mono: true` draws the step names and durations in a
952
+ fixed-width font and wraps a long step name inside its row, so a phone
953
+ page does not scroll sideways.
923
954
  - It draws one row per label, in the order each label first appears.
924
955
  Entries that share a label, such as the tries of one step, share that
925
956
  row and each draws its own bar, so pass a step's tries one after another
@@ -997,7 +1028,8 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
997
1028
  `1m 30s` or `1h 5s`.
998
1029
  - Ask the developer which layout a screen uses.
999
1030
  - An entry with no `started_at:` raises `ArgumentError` naming its label,
1000
- and so does an entry whose `ended_at:` is before its `started_at:`. Check
1031
+ and so does an entry whose `ended_at:` is before its `started_at:` or
1032
+ whose `queued_at:` is after it. Check
1001
1033
  the times before rendering rather than rescuing the error.
1002
1034
  - An empty `entries:` draws a centred "No steps" message in place of the
1003
1035
  timeline, so it can be rendered for a list that may be empty. The
@@ -135,7 +135,7 @@ One decision: is keystone_ui set up in the app?
135
135
  style at the right end of the title line, before the action and the menu.
136
136
  The aside never breaks in the middle of a word, and on wider screens a long
137
137
  title wraps beside it while it keeps its full width. Below `sm:` the aside
138
- takes a line of its own under the title and the actions. A section with no title draws no header, so its aside is not shown.
138
+ takes a line of its own under the title and the actions. A section given an aside and no title raises an error, since the header that shows the aside needs a title.
139
139
  - **Going back.** A form or show page shell needs a way back: a back link, a
140
140
  trail of earlier pages shown as breadcrumbs, or a trail the app supplies for
141
141
  the request. A nav tab's own page passes an empty trail and shows no back
@@ -201,7 +201,8 @@ One decision: is keystone_ui set up in the app?
201
201
  layout. Below `sm:` the layout can show it again as a plus icon in the top
202
202
  bar, or as a full-width button in a bar fixed to the bottom of the screen,
203
203
  above the bottom tab bar when the page has one. The bottom bar asks the
204
- header's confirmation question before sending, and the plus icon does not.
204
+ header's confirmation question before sending, and so does the plus icon
205
+ when the action sends a method other than a plain visit.
205
206
  The page leaves room under its last content so the bar does not cover it.
206
207
  A header can mark its action as belonging at the bottom, and then hides its
207
208
  own button below `sm:` so the action is not shown twice. Both forms show
@@ -210,6 +211,13 @@ One decision: is keystone_ui set up in the app?
210
211
  - **Compact stat cards.** A stat card can be drawn compact, a small tile with
211
212
  an extra small label and a smaller value, its change or note beside the
212
213
  value, for a small grid of figures inside a panel.
214
+ - **Small capitals and fixed width.** A stat card's label, a data table's
215
+ column headings, a value list's labels and a link list row's type can be
216
+ drawn in small capitals, and a value list's values, a timeline's step names
217
+ and durations and a summary chip's value in a fixed-width font. Each is an
218
+ option on its component, off by default.
219
+ - **Summary chips.** A row of summary chips shows a few labelled values, each
220
+ in a tone's colour on a tinted background, three across on a phone.
213
221
  - **Unequal grid columns.** A grid goes up to the `xl:` breakpoint, and a
214
222
  two-column grid can make its first or its second column wider, three parts
215
223
  to two.
@@ -225,7 +233,10 @@ One decision: is keystone_ui set up in the app?
225
233
  width above a row of the secondary buttons in equal shares, a long label
226
234
  wrapping inside its button, and with no note field or hint. The width at
227
235
  which it switches between the two can be moved from `sm:` to `md:` or `lg:`. Each secondary button can have a shorter label on a phone, be
228
- shown on a phone only, and take another place in the phone row. The page leaves room under its last content so the bar does
236
+ shown on a phone only, and take another place in the phone row. A
237
+ secondary button can also send its own request, such as a delete, to its
238
+ own address, while the other buttons still send the bar's form to the
239
+ bar's address. The page leaves room under its last content so the bar does
229
240
  not cover it. Unlike the main action's bottom bar, it stays shown inside a
230
241
  Hotwire Native web view.
231
242
  - **Action menus.** Each action is a label, an address and an HTTP method. A
@@ -233,7 +244,9 @@ One decision: is keystone_ui set up in the app?
233
244
  changes data is never a bare link. A delete asks for confirmation by default.
234
245
  - **Status states.** A badge and a status dot read one list of five states:
235
246
  neutral, success, danger, warning and info. A state added to that list is
236
- accepted by both, so the two never disagree about which states exist. A badge
247
+ accepted by both, so the two never disagree about which states exist. A stat
248
+ card's tones and a review card's score tones, which add a muted tone, read
249
+ the same list. A badge
237
250
  shows its label as text. A status dot shows only its state's colour, for
238
251
  places with no room for text, and its label is read only by screen readers.
239
252
  Neither accepts a state outside the list: a status dot raises `ArgumentError`
@@ -79,6 +79,7 @@ develop:
79
79
  - ui_calculation
80
80
  - ui_info
81
81
  - ui_figure
82
+ - ui_chip_row
82
83
  - ui_picture
83
84
  - ui_heading
84
85
  - ui_caption
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.100.0
4
+ version: 0.102.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Schneider
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 0.42.0
18
+ version: 0.44.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: 0.42.0
25
+ version: 0.44.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: view_component
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -115,6 +115,8 @@ files:
115
115
  - app/components/keystone/ui/chart_card_component.rb
116
116
  - app/components/keystone/ui/checkbox_row_component.html.erb
117
117
  - app/components/keystone/ui/checkbox_row_component.rb
118
+ - app/components/keystone/ui/chip_row_component.html.erb
119
+ - app/components/keystone/ui/chip_row_component.rb
118
120
  - app/components/keystone/ui/code_component.html.erb
119
121
  - app/components/keystone/ui/code_component.rb
120
122
  - app/components/keystone/ui/color_picker_component.html.erb