keystone_ui 0.60.0 → 0.62.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 +4 -4
- data/app/components/keystone/ui/column.rb +3 -1
- data/app/components/keystone/ui/data_table_component.html.erb +1 -1
- data/app/components/keystone/ui/data_table_component.rb +29 -1
- data/app/components/keystone/ui/empty_state_component.html.erb +9 -0
- data/app/components/keystone/ui/empty_state_component.rb +21 -0
- data/app/components/keystone/ui/link_list_component.html.erb +19 -0
- data/app/components/keystone/ui/link_list_component.rb +23 -0
- data/app/helpers/keystone_ui_helper.rb +8 -0
- data/lib/keystone_ui/safelist.rb +2 -0
- data/lib/keystone_ui/version.rb +1 -1
- data/the_local/agents/keystone_ui-develop.md +20 -1
- data/the_local/interface.yml +6 -0
- metadata +7 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ed9d023bcbe1fa1c7175f1fcd8e843687157c1b80be8ce777639d9433ffce70a
|
|
4
|
+
data.tar.gz: 38a651714ca10fd0334e31ef27df4a5e032c6d3ffb33f0ca460891f6ce7bb2a2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e24326e4bb89982a00fa1904c83501d049be460083c0daa0d0450b2c79acffd7897edbb165b9d5a2a0c363520daad1e353cbf6362d409f1ad71325abd3aeeff5
|
|
7
|
+
data.tar.gz: 67434fa06fbe9aa35a0a98a39d931306adf26443971ce816fd92c05d64c6c149481b1028c198ae2c9f284348cebd61410d9d4416441da9ab9c7fe32726f9d73d
|
|
@@ -5,9 +5,10 @@ module Keystone
|
|
|
5
5
|
class Column
|
|
6
6
|
attr_reader :key, :header_text, :align
|
|
7
7
|
|
|
8
|
-
def initialize(key, header_text, mobile_hidden: false, sortable: false, hideable: false, locked: false, align: nil)
|
|
8
|
+
def initialize(key, header_text, mobile_hidden: false, sortable: false, hideable: false, locked: false, align: nil, wrap: false)
|
|
9
9
|
@key = key
|
|
10
10
|
@align = align
|
|
11
|
+
@wrap = wrap
|
|
11
12
|
@header_text = header_text
|
|
12
13
|
@mobile_hidden = mobile_hidden
|
|
13
14
|
@sortable = sortable
|
|
@@ -19,6 +20,7 @@ module Keystone
|
|
|
19
20
|
def sortable? = @sortable
|
|
20
21
|
def hideable? = @hideable && !@locked
|
|
21
22
|
def locked? = @locked
|
|
23
|
+
def wrap? = @wrap
|
|
22
24
|
end
|
|
23
25
|
end
|
|
24
26
|
end
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
<% if actions? %><th></th><% end %>
|
|
45
45
|
</tr>
|
|
46
46
|
<% end %>
|
|
47
|
-
<tr<% if
|
|
47
|
+
<tr<% if (classes = row_classes(idx)) %> class="<%= classes %>"<% end %><% if current_row?(idx) %> aria-current="true"<% end %>>
|
|
48
48
|
<% row_cells[idx].each do |cell| %>
|
|
49
49
|
<td class="<%= cell[:classes] %>">
|
|
50
50
|
<% if cell[:href] %>
|
|
@@ -6,6 +6,12 @@ module Keystone
|
|
|
6
6
|
EMPTY_CELL_CLASSES = "ks-table-cell-middle text-sm"
|
|
7
7
|
BODY_CLASSES = "ks-table-body"
|
|
8
8
|
CURRENT_ROW_CLASSES = "ks-table-row-current"
|
|
9
|
+
ROW_COLOUR_CLASSES = {
|
|
10
|
+
danger: "ks-table-row-danger",
|
|
11
|
+
warning: "ks-table-row-warning",
|
|
12
|
+
success: "ks-table-row-success",
|
|
13
|
+
info: "ks-table-row-info"
|
|
14
|
+
}.freeze
|
|
9
15
|
HEAD_CLASSES = "ks-table-head"
|
|
10
16
|
WRAPPER_CLASSES = "ks-table overflow-x-auto"
|
|
11
17
|
TOOLBAR_CLASSES = "ks-table-toolbar flex justify-end"
|
|
@@ -63,6 +69,16 @@ module Keystone
|
|
|
63
69
|
@actions_block = block
|
|
64
70
|
end
|
|
65
71
|
|
|
72
|
+
def row_colour(&block)
|
|
73
|
+
@row_colour_block = block
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def row_classes(index)
|
|
77
|
+
classes = [ (CURRENT_ROW_CLASSES if current_row?(index)), row_colour_class(@items[index]) ].compact
|
|
78
|
+
|
|
79
|
+
classes.join(" ") unless classes.empty?
|
|
80
|
+
end
|
|
81
|
+
|
|
66
82
|
def actions?
|
|
67
83
|
!!@actions_block
|
|
68
84
|
end
|
|
@@ -133,7 +149,7 @@ module Keystone
|
|
|
133
149
|
|
|
134
150
|
cell = {
|
|
135
151
|
value: resolve_value(item, column.key),
|
|
136
|
-
classes: aligned(tokens.join(" "), column)
|
|
152
|
+
classes: wrapped(aligned(tokens.join(" "), column), column)
|
|
137
153
|
}
|
|
138
154
|
|
|
139
155
|
link_block = @link_blocks[column.key]
|
|
@@ -208,6 +224,18 @@ module Keystone
|
|
|
208
224
|
[ *classes.split.grep_v(/\Atext-(left|right)\z/), ALIGN_CLASSES.fetch(column.align) ].join(" ")
|
|
209
225
|
end
|
|
210
226
|
|
|
227
|
+
def row_colour_class(item)
|
|
228
|
+
colour = @row_colour_block&.call(item)
|
|
229
|
+
|
|
230
|
+
ROW_COLOUR_CLASSES.fetch(colour) if colour
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
def wrapped(classes, column)
|
|
234
|
+
return classes unless column.wrap?
|
|
235
|
+
|
|
236
|
+
classes.sub("whitespace-nowrap", "whitespace-normal")
|
|
237
|
+
end
|
|
238
|
+
|
|
211
239
|
def resolve_value(item, key)
|
|
212
240
|
if item.respond_to?(key)
|
|
213
241
|
item.public_send(key)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Keystone
|
|
4
|
+
module Ui
|
|
5
|
+
class EmptyStateComponent < ViewComponent::Base
|
|
6
|
+
WRAPPER_CLASSES = "ks-empty-state flex flex-col items-center text-center"
|
|
7
|
+
TITLE_CLASSES = "ks-heading-sm"
|
|
8
|
+
MESSAGE_CLASSES = "ks-paragraph ks-tone-muted"
|
|
9
|
+
|
|
10
|
+
def initialize(title:, message: nil, action: nil)
|
|
11
|
+
@title = title
|
|
12
|
+
@message = message
|
|
13
|
+
@action = action
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def action_button
|
|
17
|
+
ButtonComponent.new(label: @action.fetch(:label), href: @action.fetch(:href), variant: :secondary)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<div class="ks-value-list">
|
|
2
|
+
<% rows.each do |row| %>
|
|
3
|
+
<%= link_to row.fetch(:href), class: ROW_CLASSES do %>
|
|
4
|
+
<span class="<%= TEXT_CLASSES %>">
|
|
5
|
+
<span class="<%= LABEL_CLASSES %>"><%= row.fetch(:label) %></span>
|
|
6
|
+
<% if row[:subtitle] %>
|
|
7
|
+
<span class="<%= SUBTITLE_CLASSES %>"><%= row[:subtitle] %></span>
|
|
8
|
+
<% end %>
|
|
9
|
+
</span>
|
|
10
|
+
<% if row[:badge] %>
|
|
11
|
+
<%= render badge(row) %>
|
|
12
|
+
<% end %>
|
|
13
|
+
<% if row[:value] %>
|
|
14
|
+
<span class="<%= VALUE_CLASSES %>"><%= row[:value] %></span>
|
|
15
|
+
<% end %>
|
|
16
|
+
<%= Keystone::Ui::SettingsLinkComponent::CHEVRON_ICON.html_safe %>
|
|
17
|
+
<% end %>
|
|
18
|
+
<% end %>
|
|
19
|
+
</div>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Keystone
|
|
4
|
+
module Ui
|
|
5
|
+
class LinkListComponent < ViewComponent::Base
|
|
6
|
+
ROW_CLASSES = "ks-value-list-row items-center no-underline"
|
|
7
|
+
TEXT_CLASSES = "min-w-0 flex-1"
|
|
8
|
+
LABEL_CLASSES = "ks-paragraph ks-settings-link-label block"
|
|
9
|
+
SUBTITLE_CLASSES = "ks-value-list-note"
|
|
10
|
+
VALUE_CLASSES = "ks-value-list-value shrink-0"
|
|
11
|
+
|
|
12
|
+
attr_reader :rows
|
|
13
|
+
|
|
14
|
+
def initialize(rows:)
|
|
15
|
+
@rows = rows
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def badge(row)
|
|
19
|
+
BadgeComponent.new(**row[:badge])
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -113,6 +113,14 @@ module KeystoneUiHelper
|
|
|
113
113
|
render Keystone::Ui::AlertComponent.new(**args)
|
|
114
114
|
end
|
|
115
115
|
|
|
116
|
+
def ui_empty_state(**args)
|
|
117
|
+
render Keystone::Ui::EmptyStateComponent.new(**args)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def ui_link_list(**args)
|
|
121
|
+
render Keystone::Ui::LinkListComponent.new(**args)
|
|
122
|
+
end
|
|
123
|
+
|
|
116
124
|
def ui_form_page(**args)
|
|
117
125
|
render Keystone::Ui::FormPageComponent.new(**args)
|
|
118
126
|
end
|
data/lib/keystone_ui/safelist.rb
CHANGED
|
@@ -58,6 +58,8 @@ module Keystone
|
|
|
58
58
|
Keystone::Ui::ColorPickerComponent,
|
|
59
59
|
Keystone::Ui::MultiSelectComponent,
|
|
60
60
|
Keystone::Ui::SwipeDeckComponent,
|
|
61
|
+
Keystone::Ui::EmptyStateComponent,
|
|
62
|
+
Keystone::Ui::LinkListComponent,
|
|
61
63
|
Keystone::Ui::SortableListComponent,
|
|
62
64
|
Keystone::Ui::ColumnPickerComponent,
|
|
63
65
|
Keystone::Ui::FormComponent,
|
data/lib/keystone_ui/version.rb
CHANGED
|
@@ -72,6 +72,8 @@ not available in the app yet, that is `keystone_ui-install`'s job.
|
|
|
72
72
|
- `ui_paragraph` — a paragraph of running text.
|
|
73
73
|
- `ui_value_list` — rows of a label and its value, such as a ledger or a byline.
|
|
74
74
|
- `ui_alert` — a banner message, optionally dismissible.
|
|
75
|
+
- `ui_link_list` — a list of links, each row with a label, an optional subtitle, badge and value, and a chevron.
|
|
76
|
+
- `ui_empty_state` — what a list or section shows when it has nothing in it, with an optional message and action.
|
|
75
77
|
- `ui_progress` — a labelled progress bar.
|
|
76
78
|
- `ui_stat_card` — a single metric tile with optional change, link and info button.
|
|
77
79
|
- `ui_copy_button` — a button that copies text to the clipboard.
|
|
@@ -429,9 +431,12 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
|
|
|
429
431
|
- `columns:` takes `{ key: "Label" }` hashes when every column is plain.
|
|
430
432
|
Switch the whole set to `Keystone::Ui::Column` objects once one column
|
|
431
433
|
needs an option.
|
|
432
|
-
- `Keystone::Ui::Column.new(key, header_text, mobile_hidden: false, sortable: false, hideable: false, locked: false, align: nil)`
|
|
434
|
+
- `Keystone::Ui::Column.new(key, header_text, mobile_hidden: false, sortable: false, hideable: false, locked: false, align: nil, wrap: false)`
|
|
433
435
|
— `mobile_hidden:` hides the column below `sm:`, `sortable:` gives it a
|
|
434
436
|
sort header, and `hideable:` lets it be hidden and moved.
|
|
437
|
+
`wrap: true` lets long text in the column's cells wrap onto more lines
|
|
438
|
+
inside the cell instead of widening the table, every other cell keeps its
|
|
439
|
+
text on one line, and headings are unchanged.
|
|
435
440
|
`locked: true` on the first column keeps it in view while the rest scrolls
|
|
436
441
|
sideways, a locked column that is not first renders as an ordinary one,
|
|
437
442
|
and a locked column is never hideable. Ask the developer whether a wide
|
|
@@ -441,6 +446,13 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
|
|
|
441
446
|
actions column whose block holds only `ui_action_menu_item` calls. With no
|
|
442
447
|
actions column, the last column is right-aligned, so put a column of
|
|
443
448
|
amounts last.
|
|
449
|
+
- `table.row_colour { |item| ... }` tints a whole row. The block returns
|
|
450
|
+
`:danger`, `:warning`, `:success`, `:info` or `nil` for each item. A named
|
|
451
|
+
colour tints every cell of that row in the same colour as the badge of
|
|
452
|
+
that name, `nil` leaves the row plain, and any other value raises
|
|
453
|
+
`KeyError`. Colour alone does not reach every reader, so also make the
|
|
454
|
+
row's meaning readable as text in the row, such as a status badge or a
|
|
455
|
+
word in a cell.
|
|
444
456
|
- Sorting needs all three of `sort:` (the current column key),
|
|
445
457
|
`sort_direction:` (`:asc` or `:desc`) and `sort_url:` (a lambda taking
|
|
446
458
|
`(column_key, direction)` and returning a URL). Headers then render as
|
|
@@ -502,6 +514,13 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
|
|
|
502
514
|
- `ui_alert(message:, type: :info, title: nil, dismissible: false, class: nil)`
|
|
503
515
|
— `type:` is `:info` `:success` `:warning` `:error`, and `dismissible: true`
|
|
504
516
|
adds a close button.
|
|
517
|
+
- `ui_link_list(rows:)` — each row is `{ label:, href:, subtitle: nil,
|
|
518
|
+
badge: nil, value: nil }`, and `badge:` takes `ui_badge`'s `{ label:, variant: }`.
|
|
519
|
+
Use it for a list of records that each open their own page, in place of a
|
|
520
|
+
hand-written `<ul>` of links.
|
|
521
|
+
- `ui_empty_state(title:, message: nil, action: nil)` — `action:` is
|
|
522
|
+
`{ label:, href: }` and draws a secondary button. Use it in place of a bare
|
|
523
|
+
"Nothing yet" paragraph wherever a list or section can be empty.
|
|
505
524
|
- `ui_progress(value:, max:, label: nil)` shows `value / max` as a percent,
|
|
506
525
|
rounded and capped at 100.
|
|
507
526
|
- `ui_copy_button(text:, label: "Copy", success_message: "Copied!", error_message: "Failed!")`.
|
data/the_local/interface.yml
CHANGED
|
@@ -32,6 +32,8 @@ develop:
|
|
|
32
32
|
- ui_form_field
|
|
33
33
|
- ui_page_header
|
|
34
34
|
- ui_alert
|
|
35
|
+
- ui_empty_state
|
|
36
|
+
- ui_link_list
|
|
35
37
|
- ui_form_page
|
|
36
38
|
- ui_show_page
|
|
37
39
|
- ui_breadcrumbs
|
|
@@ -91,6 +93,10 @@ sources:
|
|
|
91
93
|
- app/helpers/keystone_ui_helper.rb
|
|
92
94
|
- app/components/keystone/ui/accordion_component.rb
|
|
93
95
|
- app/components/keystone/ui/alert_component.rb
|
|
96
|
+
- app/components/keystone/ui/empty_state_component.rb
|
|
97
|
+
- app/components/keystone/ui/empty_state_component.html.erb
|
|
98
|
+
- app/components/keystone/ui/link_list_component.rb
|
|
99
|
+
- app/components/keystone/ui/link_list_component.html.erb
|
|
94
100
|
- app/components/keystone/ui/badge_component.rb
|
|
95
101
|
- app/components/keystone/ui/bottom_nav_component.rb
|
|
96
102
|
- app/components/keystone/ui/bottom_nav_item_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.
|
|
4
|
+
version: 0.62.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.
|
|
18
|
+
version: 0.29.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.
|
|
25
|
+
version: 0.29.0
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: view_component
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -128,6 +128,8 @@ files:
|
|
|
128
128
|
- app/components/keystone/ui/desktop_back_link_component.rb
|
|
129
129
|
- app/components/keystone/ui/disclosure_component.html.erb
|
|
130
130
|
- app/components/keystone/ui/disclosure_component.rb
|
|
131
|
+
- app/components/keystone/ui/empty_state_component.html.erb
|
|
132
|
+
- app/components/keystone/ui/empty_state_component.rb
|
|
131
133
|
- app/components/keystone/ui/feature_grid_component.html.erb
|
|
132
134
|
- app/components/keystone/ui/feature_grid_component.rb
|
|
133
135
|
- app/components/keystone/ui/figure_component.html.erb
|
|
@@ -154,6 +156,8 @@ files:
|
|
|
154
156
|
- app/components/keystone/ui/input_component.rb
|
|
155
157
|
- app/components/keystone/ui/line_chart_component.html.erb
|
|
156
158
|
- app/components/keystone/ui/line_chart_component.rb
|
|
159
|
+
- app/components/keystone/ui/link_list_component.html.erb
|
|
160
|
+
- app/components/keystone/ui/link_list_component.rb
|
|
157
161
|
- app/components/keystone/ui/mobile_action_component.rb
|
|
158
162
|
- app/components/keystone/ui/mobile_actions_component.html.erb
|
|
159
163
|
- app/components/keystone/ui/mobile_actions_component.rb
|