keystone_ui 0.101.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 327d7289d20de1a267d20e87c47df21d3dd8069db8c4c39b488a8ceb1cd0bb28
4
- data.tar.gz: 4a63e3aec691f256b2c2fec24694090581be4184749a39b14a529d19171c006a
3
+ metadata.gz: 99dba4ba702216d0c3d6cb9a1c3c45cd69b817c372851273cb80b14bcab032be
4
+ data.tar.gz: 5a7ada13ee50ad9b73239c40e91aa49c6fe309e58a753ac37b8bc58a792c93a1
5
5
  SHA512:
6
- metadata.gz: 283b5ecde2e04ab9d9ef7af31bc036f29d29c0a899674946a13816234512fe224c237f22d3f706c7f3df5667607022949806df2728413c658ac52a08f0716619
7
- data.tar.gz: 2a659f0c17e30f956d683f2035d60acd9326ba53cb0374b6eef07edadb7990675fec2448b8ad4ddf32014795ecaafafd191f57552c14e55aaeaa785374f63ed8
6
+ metadata.gz: 2b8b17da50e67d6a83e01272fcc2e4e67abb5d3c0bbb56f16ca627736d83baffeab67c79b19ef86f8be71de2f552446f4e3b2a750debd02141ef5ad182e40bc2
7
+ data.tar.gz: f3587667c7fe74bdc2d78c8c19710dfd1f205ed0ae399b1ed3e00e73e31288c4c07c8ea517485972f48c9b704dec96461655390a55e380f6201a4be009208977
@@ -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",
@@ -107,7 +112,7 @@ module Keystone
107
112
  end
108
113
 
109
114
  def secondary_button(action)
110
- tag.div(class: [ ACTION_CLASSES, (PHONE_ONLY_CLASSES.fetch(@breakpoint) if action[:phone_only]), phone_order_classes(action) ].compact.join(" ")) do
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
111
116
  render ButtonComponent.new(variant: :secondary, **button_options(action), label: action_label(action))
112
117
  end
113
118
  end
@@ -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
@@ -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"
@@ -30,8 +31,9 @@ module Keystone
30
31
 
31
32
  attr_reader :label, :value, :suffix, :definition, :calculation, :change, :href, :note
32
33
 
33
- 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)
34
35
  @compact = compact
36
+ @label_caps = label_caps
35
37
  @label = label
36
38
  @fallback = fallback
37
39
  @note = note
@@ -60,6 +62,8 @@ module Keystone
60
62
  end
61
63
 
62
64
  def label_classes
65
+ return CAPS_LABEL_CLASSES if @label_caps
66
+
63
67
  @compact ? COMPACT_LABEL_CLASSES : LABEL_CLASSES
64
68
  end
65
69
 
@@ -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)
@@ -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.101.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.
@@ -417,7 +418,9 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
417
418
  bar fixed to the bottom of the screen, above `ui_bottom_nav` on a page
418
419
  that has one, with the primary button at full width and 48 pixels tall
419
420
  above a row of the secondary buttons, each an equal share of the row and
420
- 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
421
424
  button, so do not shrink the buttons to keep the row even. The note
422
425
  field and hint are not shown below `sm:`. `breakpoint: :md` or
423
426
  `breakpoint: :lg` moves the switch between the phone bar and the panel
@@ -585,8 +588,9 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
585
588
 
586
589
  8. Build tables.
587
590
 
588
- - `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)`
589
- 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
590
594
  cell's value is the column key called on the item, or `item[key]`.
591
595
  `group_by:` lists rows under heading rows named by that key's value,
592
596
  `group_totals:` (`{ "Group name" => { column_key => value } }`) puts
@@ -710,8 +714,10 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
710
714
  `equal_width: :phone` does that below `sm:` only, and from `sm:` up each
711
715
  button keeps the width of its label. Use it in place of a hand-written
712
716
  flex `div` around a set of buttons.
713
- - `ui_link(label:, href:)` draws a text link in the link colour. Use it in
714
- 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.
715
721
  - With `href:` and `method:` `:post` `:patch` `:put` or `:delete`, it
716
722
  renders a button inside its own small form that sends that request to
717
723
  `href:` when tapped. Do not write a form around it. It cannot sit inside
@@ -754,7 +760,10 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
754
760
  badge at the left, apart from the row's `badge:`, and short text at the
755
761
  right, such as a type and the time left. It stays on one line and cuts off
756
762
  long text, a long badge wraps without squeezing the text beside it, and
757
- 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
758
767
  row the person has open with `aria-current` and a tint and accent bar.
759
768
  `chevron: false` leaves off every row's chevron, as in a queue beside the
760
769
  open item. `new_tab: true` opens every row's link in a new browser tab
@@ -821,12 +830,14 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
821
830
  - `ui_facts(facts:)` — each fact is `{ value:, label: }`, drawn as a small
822
831
  box with the count in bold beside its label, in a row that wraps.
823
832
  - `ui_paragraph(text:)` shows running text.
824
- - `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
825
834
  `{ label:, value: }` with optional `note:`, `total: true`, `right: true`
826
835
  and `fallback:`, shown when the value is `nil` or empty. `right: true`
827
836
  draws a green check mark after the value, read out as "Right", for an
828
837
  answer that was right. `align: :end` pushes values to the right, as in a
829
- 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.
830
841
  - With the default `columns: false`, each pair is one row with its label
831
842
  beside its value and a line between rows. `columns: true` draws each pair
832
843
  as its label in small text directly above its value, with no line between
@@ -837,7 +848,7 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
837
848
 
838
849
  10. Explain figures.
839
850
 
840
- - `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)`
841
852
  — `variant:` is `:neutral` `:success` `:danger` `:warning` `:info` and
842
853
  colours the value. `change:` is a signed number shown as `▲ 4.2%` in
843
854
  green, `▼` in red, or plain at zero. `href:` links the value only, so
@@ -847,13 +858,24 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
847
858
  extra small label over a smaller value with its change or note beside
848
859
  the value, under half a default card's height. Put compact cards in
849
860
  `ui_grid(cols: { default: 1, sm: 2 }, gap: :sm)` inside a panel so they
850
- sit two across and stack on a phone.
851
- - `ui_figure(text:, tone: :neutral)` prints one amount inline. `tone:`
852
- `:neutral` uses the surrounding text colour, `:success` green and
853
- `: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
854
868
  anywhere a string is shown, such as a table cell. Use it, not a badge or
855
869
  a colour class, for a gain or a loss, and ask the developer which amounts
856
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.
857
879
  - `ui_calculation(groups:, summary: "How this is worked out")` shows the
858
880
  steps behind a figure, closed under a row reading `summary:`. `groups:`
859
881
  is `[{ title:, lines: [{ label:, working:, result: }, ...] }, ...]`.
@@ -923,10 +945,12 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
923
945
  the fill turns green with `over: :success` or amber with `over: :warning`.
924
946
  - `ui_bucket_series(buckets:)` takes an array of hashes with the keywords
925
947
  of `ui_bucket`, such as `[{ goal: 10, actual: 7, label: "Mon" }, ...]`.
926
- - `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
927
949
  `[{ label:, started_at:, ended_at: nil, queued_at: nil, failed: false, waiting: false, href: nil, selected: false }, ...]`,
928
950
  with every time a `Time` value. `one_line:` picks the layout, described
929
- 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.
930
954
  - It draws one row per label, in the order each label first appears.
931
955
  Entries that share a label, such as the tries of one step, share that
932
956
  row and each draws its own bar, so pass a step's tries one after another
@@ -211,6 +211,13 @@ One decision: is keystone_ui set up in the app?
211
211
  - **Compact stat cards.** A stat card can be drawn compact, a small tile with
212
212
  an extra small label and a smaller value, its change or note beside the
213
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.
214
221
  - **Unequal grid columns.** A grid goes up to the `xl:` breakpoint, and a
215
222
  two-column grid can make its first or its second column wider, three parts
216
223
  to two.
@@ -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.101.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