keystone_ui 0.31.0 → 0.32.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: a6c7e18e911657e41ed1a4eff2133400015bd7a58e0c437f6886d219173f01fa
4
- data.tar.gz: 91b2f652bb7313d9cda361e126e969d06b64827e80118888a73cce3840471f68
3
+ metadata.gz: 530dc14cf871e579dcccc21f769b304974a36af552e10e2a9eee6f0b90e531ae
4
+ data.tar.gz: 69ed4079d0a6fb130e50ba08afdf4b6c1ba37d8f25b035b06e686bdccdd5f1a3
5
5
  SHA512:
6
- metadata.gz: 466ea8fbb32ed4683db9537a52d7ba41d667f79dfa52aec27aaab85f5fc14b872fcc03b7d880136936133685fdc1af5f839aa4392c5ba698af62694e4a5832b0
7
- data.tar.gz: 435630df203142fa669f0d93333e6b2637b2d4ec2d25b6e8fa1a7aa00e54ba5fdace3a3416905c144f706f18373ad78b8b11c067f5d1a62ee6453655358b4b77
6
+ metadata.gz: 4d2f5fc1618dbe5b16114c4475d8b0e987f8e0516ed80aecfaace0741ccdad791214ffa758dd65c742d946285b26277c1345963ff9e1fa7175b9b1ff67d21f67
7
+ data.tar.gz: bb6877b8c6e890e4010b679ad81fa07e00bde9ccbfc73d983d666c0a97ed8182833d150c7e4535e095e1ff5d98ffe7aa3c8cab067b366e2db7c313e6b29baa00
@@ -6,10 +6,10 @@ module Keystone
6
6
  EMPTY_CELL_CLASSES = "ks-table-cell-middle text-sm"
7
7
  BODY_CLASSES = "ks-table-body"
8
8
  HEAD_CLASSES = "ks-table-head"
9
- WRAPPER_CLASSES = "ks-table overflow-hidden"
9
+ WRAPPER_CLASSES = "ks-table overflow-x-auto"
10
10
  HEADER_CLASSES_FIRST = "ks-table-header ks-table-header-first text-left text-sm"
11
11
  HEADER_CLASSES_MIDDLE = "ks-table-header ks-table-header-middle text-left text-sm"
12
- HEADER_CLASSES_LAST = "ks-table-header-last"
12
+ HEADER_CLASSES_LAST = "ks-table-header ks-table-header-last text-right text-sm"
13
13
 
14
14
  ROW_CLASSES_FIRST = "ks-table-cell-first text-sm whitespace-nowrap"
15
15
  ROW_CLASSES_MIDDLE = "ks-table-cell-middle text-sm whitespace-nowrap"
@@ -0,0 +1 @@
1
+ <span class="<%= classes %>"><%= text %></span>
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Keystone
4
+ module Ui
5
+ class FigureComponent < ViewComponent::Base
6
+ TONES = {
7
+ neutral: nil,
8
+ success: "ks-tone-success",
9
+ danger: "ks-tone-danger"
10
+ }.freeze
11
+
12
+ def initialize(text:, tone: :neutral)
13
+ @text = text
14
+ @tone = tone
15
+ end
16
+
17
+ attr_reader :text
18
+
19
+ def classes
20
+ [ "ks-figure", TONES.fetch(@tone) ].compact.join(" ")
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,4 +1,4 @@
1
- <span class="inline-flex" data-controller="info" data-action="click@window->info#hide scroll@window->info#close">
1
+ <span class="<%= wrapper_classes %>" data-controller="info" data-action="click@window->info#hide scroll@window->info#close">
2
2
  <button type="button" class="<%= button_classes %>" data-info-target="button" data-action="mouseenter->info#peek mouseleave->info#unpeek click->info#toggle" aria-label="More about this"><%= icon.html_safe %></button>
3
3
  <span class="<%= summary_classes %>" data-info-target="summary"><%= summary %></span>
4
4
  <% if content? %>
@@ -14,6 +14,12 @@ module Keystone
14
14
 
15
15
  attr_reader :summary
16
16
 
17
+ WRAPPER_CLASSES = "inline-flex align-middle"
18
+
19
+ def wrapper_classes
20
+ WRAPPER_CLASSES
21
+ end
22
+
17
23
  def summary_classes
18
24
  SUMMARY_CLASSES
19
25
  end
@@ -229,6 +229,10 @@ module KeystoneUiHelper
229
229
  render Keystone::Ui::CalculationComponent.new(**args)
230
230
  end
231
231
 
232
+ def ui_figure(**args)
233
+ render Keystone::Ui::FigureComponent.new(**args)
234
+ end
235
+
232
236
  def ui_info(**args, &block)
233
237
  render(Keystone::Ui::InfoComponent.new(**args), &block)
234
238
  end
@@ -14,6 +14,7 @@ module Keystone
14
14
  Keystone::Ui::LineChartComponent,
15
15
  Keystone::Ui::CtaBannerComponent,
16
16
  Keystone::Ui::FeatureGridComponent,
17
+ Keystone::Ui::FigureComponent,
17
18
  Keystone::Ui::HeroComponent,
18
19
  Keystone::Ui::ModalComponent,
19
20
  Keystone::Ui::SelectComponent,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KeystoneUi
4
- VERSION = "0.31.0"
4
+ VERSION = "0.32.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 — pages, forms, tables, navigation, action menus for a record's Edit and Delete, dashboards, charts, 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 — pages, forms, tables, navigation, action menus for a record's Edit and Delete, dashboards, charts, amounts shown in green or red as a gain or loss, marketing sections, a light/dark theme switch — MUST BE USED instead of hand-writing ERB and Tailwind for UI.
4
4
  tools: Read, Write, Edit, Grep
5
5
  scope: UI — pages, forms, tables, navigation, dashboards
6
6
  ---
@@ -213,7 +213,9 @@ outer element. See Conventions before using it.
213
213
  `columns:` accepts plain `{ key: "Label" }` hashes or `Keystone::Ui::Column`
214
214
  objects. In the block, `table.link(:column_key) { |item| url }` turns that
215
215
  column's cells into links and `table.actions { |item| ... }` appends a
216
- right-aligned actions column. Each row's actions render inside an action
216
+ right-aligned actions column. With no actions column, the last data
217
+ column's header and cells are both right-aligned, so put the column of
218
+ amounts last to line them up under their header. Each row's actions render inside an action
217
219
  menu, so the `actions` block holds `ui_action_menu_item` calls and nothing
218
220
  else, never buttons or bare links. Sorting requires all three of `sort:` (the
219
221
  current column key), `sort_direction:` (`:asc`/`:desc`), and `sort_url:` (a
@@ -238,6 +240,13 @@ outer element. See Conventions before using it.
238
240
  only to the button form.
239
241
  - `ui_badge(label:, variant: :neutral, class: nil)` — a pill. `variant:`
240
242
  `:neutral` `:success` `:danger` `:warning` `:info`.
243
+ - `ui_figure(text:, tone: :neutral)` — no block. One figure, such as an amount,
244
+ as inline text with no pill or box around it. `tone:` `:neutral` prints it in
245
+ the surrounding text colour, `:success` in green and `:danger` in red; any
246
+ other symbol raises `KeyError`. `text:` is printed as given, so format
247
+ numbers, currency and any minus sign before passing it. Its output can be
248
+ passed anywhere a string is shown, such as a `ui_data_table` cell value or
249
+ column label.
241
250
  - `ui_alert(message:, type: :info, title: nil, dismissible: false, class: nil)` —
242
251
  a banner.
243
252
  `type:` `:info` `:success` `:warning` `:error`. `dismissible: true` adds a
@@ -270,7 +279,8 @@ outer element. See Conventions before using it.
270
279
  numbers and currency before passing them. Place it directly under the figure
271
280
  it explains, such as a `ui_stat_card`.
272
281
  - `ui_info(summary:)` — an info button, named "More about this" for screen
273
- readers, placed inline beside the thing it explains. `summary:` is a short
282
+ readers, placed inline beside the thing it explains, and sits level with the
283
+ middle of the text beside it. `summary:` is a short
274
284
  line of text shown in a floating panel while the button is hovered. The block
275
285
  is optional and holds the full detail. With a block, tapping or clicking the
276
286
  button toggles a second floating panel holding the block's content, and the
@@ -453,6 +463,13 @@ outer element. See Conventions before using it.
453
463
  text with no columns and no separate total, the app's keystone_ui-styles
454
464
  version does not define the `ks-breakdown` classes, so stop and hand that
455
465
  part to `keystone_ui-install` as well, and add no classes to fix it.
466
+ To show an amount as a gain or a loss, use `ui_figure` with `tone:` rather
467
+ than a `ui_badge` or a colour class. Which amounts are coloured, and whether
468
+ a value counts as a gain or a loss, is the app's own rule, so ask the
469
+ developer rather than pick. If a figure with `:success` or `:danger` shows in
470
+ the plain text colour, the app's keystone_ui-styles version does not define
471
+ the `ks-figure` and `ks-tone-*` classes, so stop and hand that part to
472
+ `keystone_ui-install`, and add no classes to fix it.
456
473
  A field whose value must be one of a fixed list is a `:select` with
457
474
  `options:`, and a field that accepts any text and offers common values is a
458
475
  text field with `suggestions:`. Which one a field is, and which values it
@@ -15,7 +15,7 @@ library of view helpers built on ViewComponent. Screens are built from named
15
15
  pieces — page shells, sections, panels, grids, form fields, data tables,
16
16
  navigation bars, breadcrumbs, cards, stat tiles, charts, funnels, goal buckets, pipelines,
17
17
  banners, the calculation behind a figure, a breakdown of amounts and their
18
- total, an info button — instead of hand-written ERB and
18
+ total, a figure coloured as a gain or a loss, an info button — instead of hand-written ERB and
19
19
  Tailwind. Every class the UI renders lives inside the gem, in frozen constants,
20
20
  so the look is defined in one place.
21
21
 
@@ -88,7 +88,8 @@ holds the catalog.
88
88
  extra text about themselves. Given that text, the piece shows an info button,
89
89
  and the text stays hidden until the button is hovered or tapped. A piece
90
90
  given no such text shows no button. On a radio card and a checkbox row the
91
- button sits on the line with the label.
91
+ button sits on the line with the label. Wherever it is placed, the button
92
+ sits level with the text beside it.
92
93
  - **Standalone info button.** The same info button can be placed on its own,
93
94
  beside anything. It takes a short summary, which is required, and shows it
94
95
  when the button is hovered. Given nothing more, a tap shows the summary too.
@@ -113,6 +114,15 @@ holds the catalog.
113
114
  of its own, so a breakdown looks right only with a keystone_ui-styles version
114
115
  that defines those classes. It has no button and no hidden state of
115
116
  its own, and it can be placed inside an info button's detail.
117
+ - **A toned figure is text.** A figure shows one amount inline, in plain text
118
+ or in the success or danger colour, so it reads as a gain or a loss without a
119
+ badge around it. The amount is passed as already-formatted text and shown as
120
+ written, and the tone is chosen by name. An unknown tone raises at render
121
+ time. The colours come from keystone_ui-styles, so a figure shows its tone
122
+ only with a keystone_ui-styles version that defines those classes.
123
+ - **The last table column is right-aligned.** In a data table with no actions
124
+ column, the last column's header is right-aligned like the cells beneath it,
125
+ so a figure or total placed in that header lines up with the figures below.
116
126
  - **Suggestions.** A form field can carry a list of suggested values. The
117
127
  browser offers them while the field's text is typed, and the user can still
118
128
  enter a value that is not on the list. This applies to a field with a typed
@@ -126,7 +136,7 @@ holds the catalog.
126
136
  different symbols, and the develop local carries the real values. Most
127
137
  components raise on a symbol they do not know, so a wrong guess fails at
128
138
  render time.
129
- - **Figures are numbers.** Components that measure or compare values, such as
139
+ - **Measured values are numbers.** Components that measure or compare values, such as
130
140
  progress bars, funnels and buckets, do arithmetic on them. Pass a number, not
131
141
  a formatted string such as `"9,000"`. A bucket raises on one.
132
142
  - **A funnel has two shapes.** Both size each step against the first step and
@@ -40,7 +40,7 @@ built on ViewComponent; hook it in before building any screen with those helpers
40
40
  ## How to use it
41
41
 
42
42
  1. Confirm the prerequisites: Ruby >= 3.2 and **tailwindcss-rails v4+** in the
43
- host app. The gem brings ViewComponent and keystone_ui-styles 0.9.0 or later with it.
43
+ host app. The gem brings ViewComponent and keystone_ui-styles 0.10.0 or later with it.
44
44
  Tailwind does not have to be initialized first, because the generator creates
45
45
  the stylesheet if it is missing.
46
46
 
@@ -153,7 +153,7 @@ built on ViewComponent; hook it in before building any screen with those helpers
153
153
  checkbox row, radio card, option card, file upload and colour picker read
154
154
  these variables. So do the data display components: stat card, chart card,
155
155
  card link, CTA banner, feature grid, hero, data table, code, accordion,
156
- disclosure, calculation, info button, breakdown, tab switcher, progress,
156
+ disclosure, calculation, info button, breakdown, figure, tab switcher, progress,
157
157
  funnel, bucket, pipeline and swipe deck.
158
158
  So do the navigation components: navbar, nav item, nav dropdown, bottom nav,
159
159
  mobile header and settings link. The desktop "Back" link and the breadcrumbs
@@ -62,11 +62,13 @@ develop:
62
62
  - ui_disclosure
63
63
  - ui_calculation
64
64
  - ui_info
65
+ - ui_figure
65
66
  - ui_breakdown
66
67
  - ui_theme_toggle
67
68
  - Keystone::Ui::Column
68
69
 
69
70
  sources:
71
+ - app/components/keystone/ui/figure_component.rb
70
72
  - lib/generators/keystone/install_generator.rb
71
73
  - lib/keystone_ui/configuration.rb
72
74
  - lib/keystone_ui/missing_back_link.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.31.0
4
+ version: 0.32.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Schneider
@@ -125,6 +125,8 @@ files:
125
125
  - app/components/keystone/ui/disclosure_component.rb
126
126
  - app/components/keystone/ui/feature_grid_component.html.erb
127
127
  - app/components/keystone/ui/feature_grid_component.rb
128
+ - app/components/keystone/ui/figure_component.html.erb
129
+ - app/components/keystone/ui/figure_component.rb
128
130
  - app/components/keystone/ui/file_upload_component.html.erb
129
131
  - app/components/keystone/ui/file_upload_component.rb
130
132
  - app/components/keystone/ui/form_component.html.erb