keystone_ui 0.94.0 → 0.96.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: 4947e9dd58a43eddd271d963c9398e29fa2f75f1e3087eb08595bb435d1ac6ca
4
- data.tar.gz: 0e4cb6faa7d3032195f15650dfbd234c04e88f791bb9c5f118d9f7b175d07c4b
3
+ metadata.gz: 7f8538f59f354ba28a22af1978d841fa009a30c8303082fbaeaab72fe5b26aed
4
+ data.tar.gz: 4c175286b7c9d777579c37c505d86701dc6866b900f317ecbdfc5cafa2c284b1
5
5
  SHA512:
6
- metadata.gz: baa3227236068d2825147f507a553fd00461ae879c29cc73d5a1df10d7692b1da6aa23cda4273f46282cdc41a23a1f17562a0dbf2aaa47f8b17824e4cfc7ed2c
7
- data.tar.gz: 004fe496f216548caa10e552304c39ae4b2ef8c75596e8c14dcf61895f7ade0d3a0c106aacf3915c0c37d08fa10006590ed8a7d38b79727bdc4e1e934a884cb4
6
+ metadata.gz: ffe084ecc25acc64e9f21ba09714e9ccfef06861a77eaababf7705753a442a10aafa5ad6a42aad96ab3e61b68b4dc71770213d75a473971a6aeabf7a46348c0d
7
+ data.tar.gz: 661ad787b150952dfb6646eb4e7e1430aabf63334442ce47bed952d538a1dfd270d33e77f7bc463bdef9716f972a4d9753c71d35ed0f0da8244f2929441777b2
@@ -1,8 +1,14 @@
1
1
  <div class="ks-value-list">
2
2
  <% rows.each do |row| %>
3
- <%= link_to row.fetch(:href), class: ROW_CLASSES do %>
3
+ <%= link_to row.fetch(:href), **row_options(row) do %>
4
4
  <span class="<%= STACK_CLASSES %>">
5
5
  <span class="<%= TEXT_CLASSES %>">
6
+ <% if row[:top_line] %>
7
+ <span class="<%= TOP_LINE_CLASSES %>">
8
+ <%= render top_line_badge(row) %>
9
+ <span class="<%= TOP_LINE_TEXT_CLASSES %>"><%= row[:top_line][:text] %></span>
10
+ </span>
11
+ <% end %>
6
12
  <span class="<%= LABEL_CLASSES %>"><%= row.fetch(:label) %></span>
7
13
  <% if row[:subtitle] %>
8
14
  <span class="<%= SUBTITLE_CLASSES %>"><%= row[:subtitle] %></span>
@@ -15,7 +21,9 @@
15
21
  <% if row[:value] %>
16
22
  <span class="<%= VALUE_CLASSES %>"><%= row[:value] %></span>
17
23
  <% end %>
18
- <%= Keystone::Ui::SettingsLinkComponent::CHEVRON_ICON.html_safe %>
24
+ <% if chevron %>
25
+ <%= Keystone::Ui::SettingsLinkComponent::CHEVRON_ICON.html_safe %>
26
+ <% end %>
19
27
  <% end %>
20
28
  <% end %>
21
29
  </div>
@@ -4,22 +4,34 @@ module Keystone
4
4
  module Ui
5
5
  class LinkListComponent < ViewComponent::Base
6
6
  ROW_CLASSES = "ks-value-list-row items-center no-underline"
7
+ CURRENT_ROW_CLASSES = "ks-value-list-row-current"
7
8
  STACK_CLASSES = "flex min-w-0 flex-1 flex-col-reverse ks-grid-gap-sm sm:contents"
8
9
  BADGE_CLASSES = "max-sm:self-start"
9
10
  TEXT_CLASSES = "min-w-0 flex-1"
11
+ TOP_LINE_CLASSES = "flex items-center justify-between ks-grid-gap-sm whitespace-nowrap"
12
+ TOP_LINE_TEXT_CLASSES = "ks-value-list-note min-w-0 truncate"
10
13
  LABEL_CLASSES = "ks-paragraph ks-settings-link-label block"
11
14
  SUBTITLE_CLASSES = "ks-value-list-note"
12
15
  VALUE_CLASSES = "ks-value-list-value shrink-0"
13
16
 
14
- attr_reader :rows
17
+ attr_reader :rows, :chevron
15
18
 
16
- def initialize(rows:)
19
+ def initialize(rows:, chevron: true)
17
20
  @rows = rows
21
+ @chevron = chevron
22
+ end
23
+
24
+ def row_options(row)
25
+ { class: [ ROW_CLASSES, (CURRENT_ROW_CLASSES if row[:current]) ].compact.join(" "), aria: { current: ("true" if row[:current]) } }
18
26
  end
19
27
 
20
28
  def badge(row)
21
29
  BadgeComponent.new(**row[:badge], class: BADGE_CLASSES)
22
30
  end
31
+
32
+ def top_line_badge(row)
33
+ BadgeComponent.new(**row[:top_line][:badge])
34
+ end
23
35
  end
24
36
  end
25
37
  end
@@ -0,0 +1,24 @@
1
+ <article class="<%= card_classes %>">
2
+ <div class="<%= HEADER_CLASSES %>">
3
+ <span class="<%= ID_CLASSES %>"><%= @id %></span>
4
+ <% if @score %>
5
+ <span class="<%= score_classes %>"><%= @score %></span>
6
+ <% end %>
7
+ </div>
8
+ <h3 class="<%= TITLE_CLASSES %>"><%= @title %></h3>
9
+ <% if @body %>
10
+ <p class="<%= body_classes %>"><%= @body %></p>
11
+ <% end %>
12
+ <% if @cta && !@compact %>
13
+ <p class="<%= CTA_CLASSES %>"><%= @cta %></p>
14
+ <% end %>
15
+ <% if @meta && !@compact %>
16
+ <p class="<%= META_CLASSES %>"><%= @meta %></p>
17
+ <% end %>
18
+ <% if @finding %>
19
+ <p class="<%= FINDING_CLASSES %>"><%= @finding %></p>
20
+ <% end %>
21
+ <% if @actions.any? %>
22
+ <%= action_row %>
23
+ <% end %>
24
+ </article>
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Keystone
4
+ module Ui
5
+ class ReviewCardComponent < ViewComponent::Base
6
+ CARD_CLASSES = "ks-card ks-panel-padding-sm flex flex-col ks-grid-gap-sm sm:[&_.ks-button]:min-w-0 sm:[&_.ks-button]:text-xs"
7
+ WARNING_CLASSES = "ks-card-warning"
8
+ HEADER_CLASSES = "flex justify-between items-baseline ks-grid-gap-sm text-xs"
9
+ ID_CLASSES = "font-mono ks-tone-muted"
10
+ TITLE_CLASSES = "ks-card-title text-base leading-snug"
11
+ BODY_CLASSES = "ks-card-summary mt-0 text-xs leading-normal"
12
+ COMPACT_BODY_CLASSES = "truncate"
13
+ CTA_CLASSES = "ks-card-link text-xs"
14
+ META_CLASSES = "ks-card-meta font-mono text-xs ks-tone-muted"
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
17
+
18
+ def initialize(id:, title:, score: nil, score_tone: :muted, body: nil, cta: nil, meta: nil, finding: nil, actions: [], compact: false)
19
+ @id = id
20
+ @title = title
21
+ @score = score
22
+ @score_tone = score_tone
23
+ @body = body
24
+ @cta = cta
25
+ @meta = meta
26
+ @finding = finding
27
+ @actions = actions
28
+ @compact = compact
29
+ end
30
+
31
+ def action_row
32
+ render(ButtonRowComponent.new(equal_width: true)) do
33
+ safe_join(@actions.map { |action| render ButtonComponent.new(variant: :secondary, size: :sm, **action) })
34
+ end
35
+ end
36
+
37
+ def card_classes
38
+ [ CARD_CLASSES, (WARNING_CLASSES if @finding) ].compact.join(" ")
39
+ end
40
+
41
+ def body_classes
42
+ [ BODY_CLASSES, (COMPACT_BODY_CLASSES if @compact) ].compact.join(" ")
43
+ end
44
+
45
+ def score_classes
46
+ TONE_CLASSES.fetch(@score_tone)
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Keystone
4
+ module Ui
5
+ class ReviewCardGridComponent < ViewComponent::Base
6
+ COLUMNS = { default: 1, lg: 3 }.freeze
7
+
8
+ def call
9
+ render(GridComponent.new(cols: COLUMNS, gap: :sm)) { content }
10
+ end
11
+ end
12
+ end
13
+ end
@@ -65,6 +65,14 @@ module KeystoneUiHelper
65
65
  render Keystone::Ui::CardComponent.new(**args)
66
66
  end
67
67
 
68
+ def ui_review_card(**args)
69
+ render Keystone::Ui::ReviewCardComponent.new(**args)
70
+ end
71
+
72
+ def ui_review_card_grid(&block)
73
+ render Keystone::Ui::ReviewCardGridComponent.new, &block
74
+ end
75
+
68
76
  def ui_button(**args)
69
77
  render Keystone::Ui::ButtonComponent.new(**args)
70
78
  end
@@ -58,6 +58,8 @@ module Keystone
58
58
  Keystone::Ui::ShowPageComponent,
59
59
  Keystone::Ui::OptionCardComponent,
60
60
  Keystone::Ui::RadioCardComponent,
61
+ Keystone::Ui::ReviewCardComponent,
62
+ Keystone::Ui::ReviewCardGridComponent,
61
63
  Keystone::Ui::SearchSelectComponent,
62
64
  Keystone::Ui::CheckboxRowComponent,
63
65
  Keystone::Ui::ProgressComponent,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KeystoneUi
4
- VERSION = "0.94.0"
4
+ VERSION = "0.96.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, 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, 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, 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
  ---
@@ -35,6 +35,8 @@ not available in the app yet, that is `keystone_ui-install`'s job.
35
35
  - `ui_panel` — a bordered card surface holding any content.
36
36
  - `ui_card_link` — a panel that is one link as a whole.
37
37
  - `ui_card` — a fixed card of title, summary and call-to-action link.
38
+ - `ui_review_card` — a card for one reviewed item: id and score, title, text, call-to-action line, meta line, finding note and equal-width buttons.
39
+ - `ui_review_card_grid` — review cards three across from `lg:` up and one per row below it.
38
40
  - `ui_navbar` — a navigation bar with named slots for desktop and mobile.
39
41
  - `ui_navigation` — draws the app's declared navigation groups as a top bar or a sidebar around the page content.
40
42
  - `ui_nav_item` — one desktop navigation link.
@@ -79,7 +81,7 @@ not available in the app yet, that is `keystone_ui-install`'s job.
79
81
  - `ui_paragraph` — a paragraph of running text.
80
82
  - `ui_value_list` — labelled values, as rows of a label beside its value, such as a ledger or a byline, or as columns of a label above its value.
81
83
  - `ui_alert` — a banner message, optionally dismissible.
82
- - `ui_link_list` — a list of links, each row with a label, an optional subtitle, badge and value, and a chevron.
84
+ - `ui_link_list` — a list of links, each row with a label, an optional subtitle, badge, value and top line, an optional current-row mark, and a chevron that can be left off.
83
85
  - `ui_empty_state` — what a list or section shows when it has nothing in it, with an optional message and action.
84
86
  - `ui_progress` — a labelled progress bar.
85
87
  - `ui_stat_card` — a single metric tile with optional change, link and info button.
@@ -263,6 +265,22 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
263
265
  - `ui_card(title:, summary:, link:, cta: "Read more", edge_to_edge: false, class: nil)`
264
266
  takes no block. `edge_to_edge: true` drops the side border and corner
265
267
  rounding below `sm:` so the card spans the full width on mobile.
268
+ - `ui_review_card(id:, title:, score: nil, score_tone: :muted, body: nil, cta: nil, meta: nil, finding: nil, actions: [], compact: false)`
269
+ takes no block. Its header line shows `id:` at the left in a monospaced
270
+ font and `score:` at the right in `score_tone:`, one of `:muted`
271
+ `:neutral` `:success` `:warning` `:danger` `:info`. Then come `title:`,
272
+ `body:`, `cta:` as a line of text in the link colour (not a link),
273
+ `meta:` in a monospaced font with a divider above it, `finding:` as a
274
+ note in the warning style, and `actions:`, each a hash of `ui_button`
275
+ keywords drawn as a small secondary button taking an equal share of one
276
+ row. A `finding:` also draws the card's edge in the warning style.
277
+ `compact: true` cuts the body to one line with an ellipsis and leaves out
278
+ the call-to-action line and the meta line, for a phone list. Below `sm:` each button is at least 44 pixels
279
+ tall, and from `sm:` up the buttons are narrowed so three labels fit in a
280
+ third of the page. Use it in place of a hand-written card of these parts.
281
+ - `ui_review_card_grid` takes no keywords and a block of `ui_review_card`
282
+ calls, and sets them three across from `lg:` up and one per row below
283
+ it. Use it in place of `ui_grid` column counts for review cards.
266
284
 
267
285
  5. Wire navigation in the layout.
268
286
 
@@ -703,9 +721,17 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
703
721
  - `ui_alert(message:, type: :info, title: nil, dismissible: false, class: nil)`
704
722
  — `type:` is `:info` `:success` `:warning` `:error`, and `dismissible: true`
705
723
  adds a close button.
706
- - `ui_link_list(rows:)` — each row is `{ label:, href:, subtitle: nil,
707
- badge: nil, value: nil }`, and `badge:` takes `ui_badge`'s `{ label:, variant: }`.
724
+ - `ui_link_list(rows:, chevron: true)` — each row is `{ label:, href:,
725
+ subtitle: nil, badge: nil, value: nil, top_line: nil, current: false }`,
726
+ and `badge:` takes `ui_badge`'s `{ label:, variant: }`.
708
727
  A row's badge sits above its label below `sm` and beside it from `sm` up.
728
+ `top_line:` is `{ badge:, text: }`, a line above the label with its own
729
+ badge at the left, apart from the row's `badge:`, and short text at the
730
+ right, such as a type and the time left. It stays on one line and cuts off
731
+ long text, while the label and subtitle wrap. `current: true` marks the
732
+ row the person has open with `aria-current` and a tint and accent bar.
733
+ `chevron: false` leaves off every row's chevron, as in a queue beside the
734
+ open item. Ask the developer which row is current on each page.
709
735
  Use it for a list of records that each open their own page, in place of a
710
736
  hand-written `<ul>` of links.
711
737
  - `ui_empty_state(title:, message: nil, action: nil)` — `action:` is
@@ -155,6 +155,17 @@ One decision: is keystone_ui set up in the app?
155
155
  of its width, keeping each label on one line, so the row wraps only when a
156
156
  label no longer fits. It can do that on a phone only, leaving each button
157
157
  the width of its label on a wider screen.
158
+ - **Review cards.** A review card shows one item someone reviews, such as
159
+ one of several variants compared side by side. A header line holds a short
160
+ id at the left and a score or status at the right, coloured by tone, above
161
+ a title, body text, an optional call-to-action line and an optional line of
162
+ short details with a divider above it. An optional finding note is drawn
163
+ in the warning style, and the card's edge is then drawn in the warning
164
+ style too. An optional row of buttons gives each button an equal share.
165
+ A compact form cuts the body text to one line with an ellipsis and leaves
166
+ out the call-to-action line and the details line, for a phone. A review card grid sets the cards three across
167
+ on a desktop and one per row on a phone, where each button is at least a
168
+ phone's tap height.
158
169
  - **Confirmation.** A button can carry a confirmation question, and the
159
170
  browser asks it before following the link or sending the form. Nothing is
160
171
  sent when the user cancels.
@@ -21,6 +21,8 @@ develop:
21
21
  - ui_status_dot
22
22
  - ui_copy_button
23
23
  - ui_card
24
+ - ui_review_card
25
+ - ui_review_card_grid
24
26
  - ui_button
25
27
  - ui_button_row
26
28
  - ui_data_table
@@ -114,6 +116,9 @@ sources:
114
116
  - app/components/keystone/ui/button_row_component.rb
115
117
  - app/components/keystone/ui/button_row_component.html.erb
116
118
  - app/components/keystone/ui/card_component.rb
119
+ - app/components/keystone/ui/review_card_component.rb
120
+ - app/components/keystone/ui/review_card_component.html.erb
121
+ - app/components/keystone/ui/review_card_grid_component.rb
117
122
  - app/components/keystone/ui/card_link_component.rb
118
123
  - app/components/keystone/ui/chart_card_component.rb
119
124
  - app/components/keystone/ui/checkbox_row_component.rb
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.94.0
4
+ version: 0.96.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.35.0
18
+ version: 0.37.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.35.0
25
+ version: 0.37.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: view_component
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -203,6 +203,9 @@ files:
203
203
  - app/components/keystone/ui/progress_component.rb
204
204
  - app/components/keystone/ui/radio_card_component.html.erb
205
205
  - app/components/keystone/ui/radio_card_component.rb
206
+ - app/components/keystone/ui/review_card_component.html.erb
207
+ - app/components/keystone/ui/review_card_component.rb
208
+ - app/components/keystone/ui/review_card_grid_component.rb
206
209
  - app/components/keystone/ui/saved_layout.rb
207
210
  - app/components/keystone/ui/search_select_component.html.erb
208
211
  - app/components/keystone/ui/search_select_component.rb