keystone_ui 0.74.0 → 0.76.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: fd495c0ec1a80aba3c029677f9af5167d739166c082ff3e8a8da6e1c114c4ee9
4
- data.tar.gz: e6bc445bc552f872e7946fd05ed90c46875b92309ffa0834845f8d7231032b42
3
+ metadata.gz: 83cb8847534e6d738d9100c1d2ac5042d481dfcfc40f04c99f108bfd155ef4ce
4
+ data.tar.gz: 1707b5be58e4b7b2a9cae7a0a3fab60a0f823e5a0fe3ae6decf8795d28dbdd53
5
5
  SHA512:
6
- metadata.gz: 32f6d18f423f495b596a2b7ae441665d233c6cf60ac2c61398c28da5ce82454f3f1d349c54a69cd2dc60c727e97553b2c026420c7e498071d5c26eec6c6f8345
7
- data.tar.gz: 06cbbccbd25af32dee5ddd9deb1b93e881029757a46c7c995547bada74af912ffab52e2f9457249c84b310a126c2cbc01b737db34d1e8374f0e49ac7d8d5dced
6
+ metadata.gz: f71a4a8d8a2b3a8d44093c7673958dfdfb64221f86fcf84460b3141a800c364525f3bca044a586cc5eaa4b16916d68a0c221f28e967a1f08c6c1d5470dfcc4fc
7
+ data.tar.gz: fa87049702215deaa3a8d44ded3171efff9f840c837f2fea09bfd293cf4c6719bc395bb791dd434cb1bae584f394eee7b943d14b9f8cc639b2bca82766501f90
@@ -18,7 +18,9 @@ module Keystone
18
18
 
19
19
  FULL_WIDTH_CLASSES = "w-full"
20
20
 
21
- def initialize(label:, href: nil, method: :get, variant: :primary, size: :md, full_width: false, type: :submit, data: nil)
21
+ TEXT_CLASSES = "ks-text-button"
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)
22
24
  @label = label
23
25
  @href = href
24
26
  @method = method.to_sym
@@ -27,9 +29,14 @@ module Keystone
27
29
  @size = size
28
30
  @type = type.to_s
29
31
  @data = data
32
+ @name = name
33
+ @value = value
34
+ @hidden = hidden
30
35
  end
31
36
 
32
37
  def classes
38
+ return TEXT_CLASSES if @variant == :text
39
+
33
40
  variant_css = if @variant == :primary
34
41
  "ks-button-primary"
35
42
  else
@@ -46,10 +53,13 @@ module Keystone
46
53
  options = { class: classes }
47
54
  if button?
48
55
  options[:type] = @type
56
+ options[:name] = @name if @name
57
+ options[:value] = @value if @value
49
58
  else
50
59
  options[:href] = @href
51
60
  end
52
61
  options[:data] = @data if @data
62
+ options[:hidden] = true if @hidden
53
63
  options
54
64
  end
55
65
 
@@ -1 +1 @@
1
- <p class="ks-caption"><%= text %></p>
1
+ <p class="<%= classes %>"><%= text %></p>
@@ -3,10 +3,17 @@
3
3
  module Keystone
4
4
  module Ui
5
5
  class CaptionComponent < ViewComponent::Base
6
+ TONE_CLASSES = { muted: "ks-caption", link: "ks-caption ks-caption-link" }.freeze
7
+
6
8
  attr_reader :text
7
9
 
8
- def initialize(text:)
10
+ def initialize(text:, tone: :muted)
9
11
  @text = text
12
+ @tone = tone
13
+ end
14
+
15
+ def classes
16
+ TONE_CLASSES.fetch(@tone)
10
17
  end
11
18
  end
12
19
  end
@@ -1,5 +1,5 @@
1
1
  <label class="<%= row_classes %> relative"<%= ' data-controller="stat-card-info"'.html_safe if info? %>>
2
- <input type="checkbox" name="<%= name %>" value="<%= value %>" <%= "checked" if checked? %> class="<%= input_classes %>">
2
+ <input type="checkbox" name="<%= name %>" value="<%= value %>" <%= "checked" if checked? %> <%= "disabled" if disabled? %> class="<%= input_classes %>">
3
3
  <span>
4
4
  <span class="<%= header_classes %>">
5
5
  <span class="<%= label_classes %>"><%= label %></span>
@@ -13,19 +13,24 @@ module Keystone
13
13
 
14
14
  attr_reader :name, :value, :label, :hint, :info
15
15
 
16
- def initialize(name:, value:, label:, hint: nil, info: nil, checked: false)
16
+ def initialize(name:, value:, label:, hint: nil, info: nil, checked: false, disabled: false)
17
17
  @name = name
18
18
  @value = value
19
19
  @label = label
20
20
  @hint = hint
21
21
  @info = info
22
22
  @checked = checked
23
+ @disabled = disabled
23
24
  end
24
25
 
25
26
  def checked?
26
27
  @checked
27
28
  end
28
29
 
30
+ def disabled?
31
+ @disabled
32
+ end
33
+
29
34
  def hint?
30
35
  !@hint.nil?
31
36
  end
@@ -0,0 +1,5 @@
1
+ <div class="<%= facts_classes %>">
2
+ <% facts.each do |fact| %>
3
+ <span class="<%= fact_classes %>"><b class="<%= value_classes %>"><%= fact[:value] %></b> <%= fact[:label] %></span>
4
+ <% end %>
5
+ </div>
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Keystone
4
+ module Ui
5
+ class FactsComponent < ViewComponent::Base
6
+ FACTS_CLASSES = "ks-facts flex flex-wrap"
7
+ FACT_CLASSES = "ks-fact"
8
+ VALUE_CLASSES = "ks-tone-neutral"
9
+
10
+ attr_reader :facts
11
+
12
+ def initialize(facts:)
13
+ @facts = facts
14
+ end
15
+
16
+ def facts_classes
17
+ FACTS_CLASSES
18
+ end
19
+
20
+ def fact_classes
21
+ FACT_CLASSES
22
+ end
23
+
24
+ def value_classes
25
+ VALUE_CLASSES
26
+ end
27
+ end
28
+ end
29
+ end
@@ -14,6 +14,10 @@ module Keystone
14
14
  CENTERED_CLASSES = "flex flex-col items-center text-center"
15
15
 
16
16
  TITLE_BASE_CLASSES = "ks-hero-title text-4xl tracking-tight sm:text-5xl lg:text-6xl"
17
+ TITLE_SIZE_CLASSES = {
18
+ lg: TITLE_BASE_CLASSES,
19
+ sm: "ks-hero-title text-3xl tracking-tight md:text-4xl"
20
+ }.freeze
17
21
  SUBTITLE_BASE_CLASSES = "ks-hero-subtitle max-w-lg text-lg"
18
22
  BADGE_BASE_CLASSES = "ks-hero-badge inline-flex w-fit items-center text-sm"
19
23
  ACTIONS_CLASSES = "ks-hero-actions flex flex-wrap"
@@ -22,7 +26,7 @@ module Keystone
22
26
 
23
27
  attr_reader :title, :subtitle, :badge
24
28
 
25
- def initialize(title:, subtitle: nil, badge: nil, layout: :split, height: :screen)
29
+ def initialize(title:, subtitle: nil, badge: nil, layout: :split, height: :screen, title_size: :lg)
26
30
  raise ArgumentError, "a hero's height is :screen or :content, got #{height.inspect}" unless %i[screen content].include?(height)
27
31
 
28
32
  @title = title
@@ -30,6 +34,7 @@ module Keystone
30
34
  @badge = badge
31
35
  @layout = layout
32
36
  @height = height
37
+ @title_size = title_size
33
38
  end
34
39
 
35
40
  def classes
@@ -53,7 +58,7 @@ module Keystone
53
58
  end
54
59
 
55
60
  def title_classes
56
- TITLE_BASE_CLASSES
61
+ TITLE_SIZE_CLASSES.fetch(@title_size)
57
62
  end
58
63
 
59
64
  def subtitle_classes
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Keystone
4
+ module Ui
5
+ class LinkComponent < ViewComponent::Base
6
+ CLASSES = "ks-link"
7
+
8
+ def initialize(label:, href:)
9
+ @label = label
10
+ @href = href
11
+ end
12
+
13
+ def call
14
+ link_to(@label, @href, class: CLASSES)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,15 +1,23 @@
1
- <label class="inline-block cursor-pointer relative"<%= ' data-controller="stat-card-info"'.html_safe if info? %>>
2
- <input type="radio" name="<%= name %>" value="<%= value %>" <%= "checked" if checked? %> class="peer sr-only">
1
+ <label class="<%= wrapper_classes %>"<%= ' data-controller="stat-card-info"'.html_safe if info? %>>
2
+ <input type="radio" name="<%= name %>" value="<%= value %>" <%= "checked" if checked? %> class="peer sr-only"<%= ' onchange="this.form.requestSubmit()"'.html_safe if submits? %>>
3
3
  <span class="<%= classes %>">
4
- <span class="<%= header_classes %>">
5
- <span class="<%= label_classes %>"><%= label %></span>
6
- <% if info? %>
7
- <button type="button" class="<%= info_button_classes %>" data-action="click->stat-card-info#toggle" aria-label="About <%= label %>"><%= info_icon.html_safe %></button>
8
- <span class="<%= disclosure_classes %>" data-stat-card-info-target="panel"><%= info %></span>
4
+ <% body = capture do %>
5
+ <span class="<%= header_classes %>">
6
+ <span class="<%= label_classes %>"><%= label %></span>
7
+ <% if info? %>
8
+ <button type="button" class="<%= info_button_classes %>" data-action="click->stat-card-info#toggle" aria-label="About <%= label %>"><%= info_icon.html_safe %></button>
9
+ <span class="<%= disclosure_classes %>" data-stat-card-info-target="panel"><%= info %></span>
10
+ <% end %>
11
+ </span>
12
+ <% if hint? %>
13
+ <span class="<%= hint_classes %>"><%= hint %></span>
9
14
  <% end %>
10
- </span>
11
- <% if hint? %>
12
- <span class="<%= hint_classes %>"><%= hint %></span>
15
+ <% end %>
16
+ <% if show_value? %>
17
+ <span class="<%= value_classes %>"><%= value %></span>
18
+ <span><%= body %></span>
19
+ <% else %>
20
+ <%= body %>
13
21
  <% end %>
14
22
  </span>
15
23
  </label>
@@ -4,29 +4,48 @@ module Keystone
4
4
  module Ui
5
5
  class RadioCardComponent < ViewComponent::Base
6
6
  BASE_CLASSES = "ks-radio-card inline-flex flex-col cursor-pointer transition"
7
+ WRAPPER_CLASSES = "inline-block cursor-pointer relative"
8
+ FULL_WIDTH_WRAPPER_CLASSES = "block cursor-pointer relative"
9
+ FULL_WIDTH_CLASSES = "ks-radio-card ks-radio-card-block flex items-start cursor-pointer transition"
7
10
  HIGHLIGHT_CLASSES = "ks-radio-card-highlight"
8
11
  HEADER_CLASSES = "ks-radio-card-header flex items-start justify-between"
9
12
  LABEL_CLASSES = "ks-radio-card-label block"
10
13
  HINT_CLASSES = "ks-radio-card-hint block text-sm"
11
14
  INFO_BUTTON_CLASSES = "ks-radio-card-info peer shrink-0"
12
15
  DISCLOSURE_CLASSES = "ks-radio-card-disclosure hidden peer-hover:block absolute inset-x-0 top-full z-10 text-sm"
16
+ VALUE_CLASSES = "ks-radio-card-value shrink-0"
13
17
  INFO_ICON = Keystone::Ui::StatCardComponent::INFO_ICON
14
18
 
15
19
  attr_reader :name, :value, :label, :hint, :info
16
20
 
17
- def initialize(name:, value:, label:, hint: nil, info: nil, checked: false)
21
+ def initialize(name:, value:, label:, hint: nil, info: nil, checked: false, submits: false, show_value: false, full_width: false)
18
22
  @name = name
19
23
  @value = value
20
24
  @label = label
21
25
  @hint = hint
22
26
  @info = info
23
27
  @checked = checked
28
+ @submits = submits
29
+ @show_value = show_value
30
+ @full_width = full_width
31
+ end
32
+
33
+ def show_value?
34
+ @show_value
35
+ end
36
+
37
+ def value_classes
38
+ VALUE_CLASSES
24
39
  end
25
40
 
26
41
  def checked?
27
42
  @checked
28
43
  end
29
44
 
45
+ def submits?
46
+ @submits
47
+ end
48
+
30
49
  def hint?
31
50
  !@hint.nil?
32
51
  end
@@ -47,8 +66,12 @@ module Keystone
47
66
  DISCLOSURE_CLASSES
48
67
  end
49
68
 
69
+ def wrapper_classes
70
+ @full_width ? FULL_WIDTH_WRAPPER_CLASSES : WRAPPER_CLASSES
71
+ end
72
+
50
73
  def classes
51
- "#{BASE_CLASSES} #{HIGHLIGHT_CLASSES}"
74
+ "#{@full_width ? FULL_WIDTH_CLASSES : BASE_CLASSES} #{HIGHLIGHT_CLASSES}"
52
75
  end
53
76
 
54
77
  def header_classes
@@ -0,0 +1,17 @@
1
+ <div class="flex flex-col gap-3">
2
+ <% entries.each do |entry| %>
3
+ <div data-timeline-row>
4
+ <div class="<%= ROW_TEXT_CLASSES %>">
5
+ <span data-timeline-label><%= entry[:label] %></span>
6
+ <span data-timeline-duration><%= duration(entry) %></span>
7
+ </div>
8
+ <div class="<%= TRACK_CLASSES %>">
9
+ <div class="<%= BAR_CLASSES %>" data-timeline-bar style="<%= bar_style(entry) %>"></div>
10
+ </div>
11
+ </div>
12
+ <% end %>
13
+ <div class="<%= AXIS_CLASSES %>">
14
+ <span data-timeline-axis-start><%= axis_start_label %></span>
15
+ <span data-timeline-axis-end><%= total_duration %></span>
16
+ </div>
17
+ </div>
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Keystone
4
+ module Ui
5
+ class TimelineComponent < ViewComponent::Base
6
+ TRACK_CLASSES = "ks-progress-track relative w-full h-2 overflow-hidden"
7
+ BAR_CLASSES = "ks-progress-bar absolute inset-y-0"
8
+ ROW_TEXT_CLASSES = "ks-meter-label flex justify-between text-sm"
9
+ AXIS_CLASSES = "ks-meter-label flex justify-between text-xs"
10
+
11
+ attr_reader :entries
12
+
13
+ def initialize(entries:)
14
+ @entries = entries
15
+ end
16
+
17
+ def bar_style(entry)
18
+ "left: #{percent(entry[:started_at] - axis_start)}%; width: #{percent(entry[:ended_at] - entry[:started_at])}%"
19
+ end
20
+
21
+ def duration(entry)
22
+ written_duration(entry[:ended_at] - entry[:started_at])
23
+ end
24
+
25
+ def total_duration
26
+ written_duration(axis_end - axis_start)
27
+ end
28
+
29
+ def axis_start_label
30
+ written_duration(0)
31
+ end
32
+
33
+ private
34
+
35
+ def written_duration(seconds)
36
+ hours, rest = seconds.round.divmod(3600)
37
+ minutes, seconds = rest.divmod(60)
38
+ parts = [ [ hours, "h" ], [ minutes, "m" ], [ seconds, "s" ] ].drop_while { |amount, _| amount.zero? }
39
+ parts = [ [ 0, "s" ] ] if parts.empty?
40
+ parts.map { |amount, unit| "#{amount}#{unit}" }.join(" ")
41
+ end
42
+
43
+ def axis_start
44
+ @axis_start ||= entries.map { |entry| entry[:started_at] }.min
45
+ end
46
+
47
+ def axis_end
48
+ @axis_end ||= entries.map { |entry| entry[:ended_at] }.max
49
+ end
50
+
51
+ def percent(seconds)
52
+ format("%g", (seconds / (axis_end - axis_start) * 100).round(2))
53
+ end
54
+ end
55
+ end
56
+ end
@@ -5,7 +5,12 @@
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"><%= shown_value(row) %></dd>
8
+ <dd class="ks-value-list-value">
9
+ <%= shown_value(row) %>
10
+ <% if row[:right] %>
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>
12
+ <% end %>
13
+ </dd>
9
14
  </div>
10
15
  <% end %>
11
16
  </dl>
@@ -4,6 +4,7 @@ module Keystone
4
4
  module Ui
5
5
  class ValueListComponent < ViewComponent::Base
6
6
  ALIGN_CLASSES = { start: nil, end: "ks-value-list-end" }.freeze
7
+ RIGHT_MARK_CLASSES = "ks-tone-success inline size-5 align-text-bottom"
7
8
 
8
9
  attr_reader :rows
9
10
 
@@ -20,6 +21,10 @@ module Keystone
20
21
  row[:value].to_s.empty? ? row[:fallback] : row[:value]
21
22
  end
22
23
 
24
+ def right_mark_classes
25
+ RIGHT_MARK_CLASSES
26
+ end
27
+
23
28
  def row_classes(row)
24
29
  [ "ks-value-list-row", ("ks-value-list-total" if row[:total]) ].compact.join(" ")
25
30
  end
@@ -25,6 +25,10 @@ module KeystoneUiHelper
25
25
  render Keystone::Ui::BarChartComponent.new(**args)
26
26
  end
27
27
 
28
+ def ui_timeline(**args)
29
+ render Keystone::Ui::TimelineComponent.new(**args)
30
+ end
31
+
28
32
  def ui_cta_banner(**args, &block)
29
33
  render Keystone::Ui::CtaBannerComponent.new(**args), &block
30
34
  end
@@ -277,6 +281,14 @@ module KeystoneUiHelper
277
281
  render Keystone::Ui::CaptionComponent.new(**args)
278
282
  end
279
283
 
284
+ def ui_link(**args)
285
+ render Keystone::Ui::LinkComponent.new(**args)
286
+ end
287
+
288
+ def ui_facts(**args)
289
+ render Keystone::Ui::FactsComponent.new(**args)
290
+ end
291
+
280
292
  def ui_paragraph(**args)
281
293
  render Keystone::Ui::ParagraphComponent.new(**args)
282
294
  end
@@ -15,6 +15,8 @@ module Keystone
15
15
  Keystone::Ui::CtaBannerComponent,
16
16
  Keystone::Ui::FeatureGridComponent,
17
17
  Keystone::Ui::CaptionComponent,
18
+ Keystone::Ui::LinkComponent,
19
+ Keystone::Ui::FactsComponent,
18
20
  Keystone::Ui::FigureComponent,
19
21
  Keystone::Ui::HeadingComponent,
20
22
  Keystone::Ui::HeroComponent,
@@ -72,6 +74,7 @@ module Keystone
72
74
  Keystone::Ui::CodeComponent,
73
75
  Keystone::Ui::DisclosureComponent,
74
76
  Keystone::Ui::ThemeToggleComponent,
77
+ Keystone::Ui::TimelineComponent,
75
78
  Keystone::Ui::CalculationComponent,
76
79
  Keystone::Ui::DesktopBackLinkComponent,
77
80
  Keystone::Ui::BreadcrumbsComponent,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KeystoneUi
4
- VERSION = "0.74.0"
4
+ VERSION = "0.76.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, action menus for a record's Edit and Delete, dashboards with stat cards, charts, funnels and goal buckets, amounts shown in green or red as a gain or loss, pictures held to half the screen, 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, action menus for a record's Edit and Delete, dashboards with stat cards, charts, funnels, goal buckets and timelines of timed steps, amounts shown in green or red as a gain or loss, pictures held to half the screen, 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
  ---
@@ -70,6 +70,8 @@ not available in the app yet, that is `keystone_ui-install`'s job.
70
70
  - `ui_picture` — an image never taller than half the screen, optionally opening its full-size file.
71
71
  - `ui_heading` — a heading at one of three sizes, with an optional short note on its right.
72
72
  - `ui_caption` — small uppercase muted text placed above a title or a figure.
73
+ - `ui_link` — a text link in the link colour.
74
+ - `ui_facts` — a row of facts, each a count in bold beside its label.
73
75
  - `ui_paragraph` — a paragraph of running text.
74
76
  - `ui_value_list` — rows of a label and its value, such as a ledger or a byline.
75
77
  - `ui_alert` — a banner message, optionally dismissible.
@@ -93,6 +95,7 @@ not available in the app yet, that is `keystone_ui-install`'s job.
93
95
  - `ui_funnel` — a conversion funnel drawn as bars or one joined shape.
94
96
  - `ui_bucket` — an upright container filled toward a goal.
95
97
  - `ui_bucket_series` — a wrapping row of buckets.
98
+ - `ui_timeline` — rows of timed steps, each a bar placed by its start and end on one shared time axis.
96
99
  - `ui_pipeline` — a staged flow diagram with buttons and breakable links that post to the app.
97
100
  - `ui_hero` — a marketing hero with title, call-to-action buttons and an aside.
98
101
  - `ui_cta_banner` — a marketing banner holding call-to-action buttons.
@@ -410,8 +413,8 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
410
413
  needs the enclosing form to be multipart.
411
414
  - `ui_color_picker(name:, value: "#000000", label: nil)` writes the chosen
412
415
  hex value into a hidden input named `name`.
413
- - `ui_radio_card(name:, value:, label:, hint: nil, info: nil, checked: false)`
414
- and `ui_checkbox_row(name:, value:, label:, hint: nil, info: nil, checked: false)`
416
+ - `ui_radio_card(name:, value:, label:, hint: nil, info: nil, checked: false, submits: false, show_value: false, full_width: false)`
417
+ and `ui_checkbox_row(name:, value:, label:, hint: nil, info: nil, checked: false, disabled: false)`
415
418
  share `hint:` and `info:`. `hint:` is a line always shown under the label.
416
419
  `info:` adds an info button beside the label, named "About <label>" for
417
420
  screen readers, that shows the text in a panel below while hovered and
@@ -420,6 +423,14 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
420
423
  - A checked `ui_checkbox_row` submits `value` under `name`, an unchecked one
421
424
  submits nothing, and rows sharing an array name such as `"shown[]"`
422
425
  submit the checked values as a list.
426
+ - `submits: true` on `ui_radio_card` submits its form as soon as the card
427
+ is chosen, so a question answered by one choice needs no Next button.
428
+ - `show_value: true` on `ui_radio_card` draws the answer's value in a small
429
+ tag before its label. `full_width: true` makes the card fill its row with
430
+ the tag and label side by side. Stack quiz answers with
431
+ `ui_grid(cols: 1, gap: :sm)`.
432
+ - `disabled: true` on `ui_checkbox_row` draws its checkbox disabled, and a
433
+ disabled checkbox submits nothing.
423
434
  - `ui_sortable_list(name:, label:, rows:)` is one field inside a `ui_form`,
424
435
  for putting a short list in order. `rows:` is an array of
425
436
  `{ id:, label: }` hashes, `label:` names the list for screen readers, and
@@ -550,10 +561,16 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
550
561
 
551
562
  9. Show content and status.
552
563
 
553
- - `ui_button(label:, href: nil, method: :get, variant: :primary, size: :md, full_width: false, type: :submit, data: nil)`
564
+ - `ui_button(label:, href: nil, method: :get, variant: :primary, size: :md, full_width: false, type: :submit, data: nil, name: nil, value: nil, hidden: false)`
554
565
  renders a link with `href:` and a button without it. `variant:` is
555
- `:primary` `:secondary` `:danger`, `size:` is `:sm` `:md` `:lg`, and
556
- `type:` applies only to the button.
566
+ `:primary` `:secondary` `:danger` `:text`, `size:` is `:sm` `:md` `:lg`,
567
+ and `type:`, `name:` and `value:` apply only to the button.
568
+ - `variant: :text` draws the button as small, underlined, muted text, such
569
+ as a Back or Previous control under a form. A button given `name:` and
570
+ `value:` submits them with its form when pressed. `hidden: true` draws it
571
+ with the `hidden` attribute, for the app's own script to show.
572
+ - `ui_link(label:, href:)` draws a text link in the link colour. Use it in
573
+ place of a hand-written `link_to` with colour classes.
557
574
  - With `href:` and `method:` `:post` `:patch` `:put` or `:delete`, it
558
575
  renders a button inside its own small form that sends that request to
559
576
  `href:` when tapped. Do not write a form around it. It cannot sit inside
@@ -592,11 +609,16 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
592
609
  - `ui_accordion(items: [])` — `items:` is `[{ question:, answer: }, ...]`.
593
610
  - `ui_heading(text:, size: :md, note: nil)` — `size:` is `:sm` `:md` `:lg`,
594
611
  and `note:` puts a short muted note at the right end of the heading's row.
595
- - `ui_caption(text:)` shows small uppercase muted text above a title or a figure.
612
+ - `ui_caption(text:, tone: :muted)` shows small uppercase muted text above
613
+ a title or a figure. `tone: :link` draws it in the link colour with space
614
+ under it, as the label above a quiz question.
615
+ - `ui_facts(facts:)` — each fact is `{ value:, label: }`, drawn as a small
616
+ box with the count in bold beside its label, in a row that wraps.
596
617
  - `ui_paragraph(text:)` shows running text.
597
618
  - `ui_value_list(rows:, align: :start)` — each row is `{ label:, value: }`
598
- with optional `note:`, `total: true` and `fallback:`, shown when the value
599
- is `nil` or empty. `align: :end` pushes values to the right, as in a ledger.
619
+ with optional `note:`, `total: true`, `right: true` and `fallback:`, shown
620
+ when the value is `nil` or empty. `right: true` draws a green check mark
621
+ after the value, read out as "Right", for an answer that was right. `align: :end` pushes values to the right, as in a ledger.
600
622
 
601
623
  10. Explain figures.
602
624
 
@@ -669,6 +691,16 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
669
691
  the fill turns green with `over: :success` or amber with `over: :warning`.
670
692
  - `ui_bucket_series(buckets:)` takes an array of hashes with the keywords
671
693
  of `ui_bucket`, such as `[{ goal: 10, actual: 7, label: "Mon" }, ...]`.
694
+ - `ui_timeline(entries:)` takes no block. `entries:` is
695
+ `[{ label:, started_at:, ended_at: }, ...]` in the order to list them,
696
+ with both times as `Time` values. The axis runs from the earliest
697
+ `started_at` to the latest `ended_at`. Each entry is one row: its label
698
+ and its duration on one line, then a track with a bar placed at its start
699
+ and as wide as its share of the axis. Under the rows the axis reads `0s`
700
+ on the left and the whole span on the right. Durations are written as
701
+ `1h 0m 5s`, leaving out leading zero units, and a zero duration is `0s`.
702
+ It needs at least one entry and a span longer than zero, so do not render
703
+ it for an empty list or for entries that all start and end at one moment.
672
704
  - `ui_pipeline(title:, boxes:, links:, subtitle: nil)` — `boxes:` is
673
705
  `[{ label:, count:, accent:, action: }, ...]`, with `accent:` one of
674
706
  `:amber` `:emerald` `:danger` `:muted`, and `action:` is
@@ -714,12 +746,13 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
714
746
  13. Build marketing sections.
715
747
 
716
748
  - `ui_hero(title:, subtitle: nil, badge: nil, layout: :split,
717
- height: :screen)` takes a block holding the call-to-action buttons and
749
+ height: :screen, title_size: :lg)` takes a block holding the call-to-action buttons and
718
750
  yields the component, so its `aside` slot can hold an image or panel.
719
751
  `layout:` is `:split` or `:centered`. `height: :screen` keeps the hero at
720
752
  least the full screen height, and `height: :content` draws it only as
721
753
  tall as its content and its padding, for a page with more sections
722
- after it.
754
+ after it. `title_size: :sm` draws the title smaller, as on a quiz's
755
+ intro page.
723
756
  - `ui_cta_banner(title:, subtitle: nil)` takes a block holding the
724
757
  buttons.
725
758
  - `ui_feature_grid(title:, features:, subtitle: nil)` — `features:` is
@@ -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, stat
16
- tiles, charts, funnels, goal buckets, pipelines, breakdowns and info buttons —
16
+ tiles, charts, timelines, funnels, goal buckets, pipelines, breakdowns and info buttons —
17
17
  instead of hand-written ERB and Tailwind. Every class the UI renders lives in the
18
18
  gem, so two pages built from the same helpers cannot disagree about spacing,
19
19
  colour or dark-mode treatment, and a change to a component reaches every page
@@ -57,8 +57,10 @@ One decision: is keystone_ui set up in the app?
57
57
  - **Options are symbols.** Appearance is chosen by name, such as `variant:`,
58
58
  `size:` or `padding:`, and each component accepts its own set. Most raise on a
59
59
  symbol they do not know, so a wrong guess fails at render time.
60
- - **Numbers and text are different inputs.** Progress bars, funnels and buckets
61
- do arithmetic, so they take numbers, and a bucket raises on `"9,000"`. A
60
+ - **Numbers and text are different inputs.** Progress bars, funnels, buckets
61
+ and timelines do arithmetic, so they take numbers, and a bucket raises on
62
+ `"9,000"`. A timeline takes each row's start and end as times and works out
63
+ every duration, bar position and its axis from them. A
62
64
  breakdown, a calculation and a toned figure take already-formatted text, show
63
65
  it as written and add nothing up.
64
66
  - **Going back.** A form or show page shell needs a way back: a back link, a
@@ -117,4 +119,4 @@ One decision: is keystone_ui set up in the app?
117
119
  Stimulus controllers, so a host writes no JavaScript. Components that post,
118
120
  such as the column picker and the pipeline, post to endpoints the host or
119
121
  another gem owns.
120
- - Ruby >= 3.2, ViewComponent >= 2.0 and < 5, keystone_ui-styles >= 0.29.0.
122
+ - Ruby >= 3.2, ViewComponent >= 2.0 and < 5, keystone_ui-styles >= 0.33.0.
@@ -50,7 +50,7 @@ built on ViewComponent; hook it in before building any screen with those helpers
50
50
  ## How to use it
51
51
 
52
52
  1. Confirm the prerequisites: Ruby >= 3.2 and **tailwindcss-rails v4+** in the
53
- host app. The gem brings ViewComponent and keystone_ui-styles 0.29.0 or later with it.
53
+ host app. The gem brings ViewComponent and keystone_ui-styles 0.33.0 or later with it.
54
54
  Tailwind does not have to be initialized first, because the generator creates
55
55
  the stylesheet if it is missing.
56
56
 
@@ -166,7 +166,7 @@ built on ViewComponent; hook it in before building any screen with those helpers
166
166
  these variables. So do the data display components: stat card, chart card,
167
167
  card link, CTA banner, feature grid, hero, data table, code, accordion,
168
168
  disclosure, calculation, info button, breakdown, figure, tab switcher, progress,
169
- funnel, bucket, pipeline and swipe deck.
169
+ timeline, funnel, bucket, pipeline and swipe deck.
170
170
  So do the navigation components: navbar, nav item, nav dropdown, bottom nav,
171
171
  mobile header and settings link. The desktop "Back" link and the breadcrumbs
172
172
  on form and show pages use the mobile header's back link variables. The
@@ -12,6 +12,7 @@ develop:
12
12
  - ui_chart_card
13
13
  - ui_line_chart
14
14
  - ui_bar_chart
15
+ - ui_timeline
15
16
  - ui_cta_banner
16
17
  - ui_feature_grid
17
18
  - ui_hero
@@ -74,6 +75,8 @@ develop:
74
75
  - ui_picture
75
76
  - ui_heading
76
77
  - ui_caption
78
+ - ui_link
79
+ - ui_facts
77
80
  - ui_paragraph
78
81
  - ui_value_list
79
82
  - ui_breakdown
@@ -182,3 +185,5 @@ sources:
182
185
  - app/components/keystone/ui/swipe_deck_component.rb
183
186
  - app/components/keystone/ui/tab_switcher_component.rb
184
187
  - app/components/keystone/ui/textarea_component.rb
188
+ - app/components/keystone/ui/timeline_component.rb
189
+ - app/components/keystone/ui/timeline_component.html.erb
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.74.0
4
+ version: 0.76.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.32.0
18
+ version: 0.33.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.32.0
25
+ version: 0.33.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: view_component
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -131,6 +131,8 @@ files:
131
131
  - app/components/keystone/ui/disclosure_component.rb
132
132
  - app/components/keystone/ui/empty_state_component.html.erb
133
133
  - app/components/keystone/ui/empty_state_component.rb
134
+ - app/components/keystone/ui/facts_component.html.erb
135
+ - app/components/keystone/ui/facts_component.rb
134
136
  - app/components/keystone/ui/feature_grid_component.html.erb
135
137
  - app/components/keystone/ui/feature_grid_component.rb
136
138
  - app/components/keystone/ui/figure_component.html.erb
@@ -157,6 +159,7 @@ files:
157
159
  - app/components/keystone/ui/input_component.rb
158
160
  - app/components/keystone/ui/line_chart_component.html.erb
159
161
  - app/components/keystone/ui/line_chart_component.rb
162
+ - app/components/keystone/ui/link_component.rb
160
163
  - app/components/keystone/ui/link_list_component.html.erb
161
164
  - app/components/keystone/ui/link_list_component.rb
162
165
  - app/components/keystone/ui/list_detail_component.html.erb
@@ -218,6 +221,8 @@ files:
218
221
  - app/components/keystone/ui/textarea_component.rb
219
222
  - app/components/keystone/ui/theme_toggle_component.html.erb
220
223
  - app/components/keystone/ui/theme_toggle_component.rb
224
+ - app/components/keystone/ui/timeline_component.html.erb
225
+ - app/components/keystone/ui/timeline_component.rb
221
226
  - app/components/keystone/ui/value_list_component.html.erb
222
227
  - app/components/keystone/ui/value_list_component.rb
223
228
  - app/helpers/keystone_ui_helper.rb