keystone_ui 0.18.0 → 0.19.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/calculation_component.html.erb +19 -0
- data/app/components/keystone/ui/calculation_component.rb +23 -0
- data/app/helpers/keystone_ui_helper.rb +4 -0
- data/lib/keystone_ui/safelist.rb +2 -1
- data/lib/keystone_ui/version.rb +1 -1
- data/the_local/agents/keystone_ui-develop.md +12 -0
- data/the_local/agents/keystone_ui-info.md +18 -11
- data/the_local/agents/keystone_ui-install.md +2 -1
- data/the_local/interface.yml +2 -0
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 19d3d7682e2b19ea8bdeadd90f50b0668db2587e21c891c220fdbb5af56a3780
|
|
4
|
+
data.tar.gz: dafd5905c87e5723538ffd9f581b3e6edafe6d8a248a5364580191350778fe82
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0ee13705c4e25ef9c471d11005dfc081069acfb204482055198e35e1ddf131e836755769e42b26a3ec88e7f452e8ed47068b660430ad2d812eaaf72aeb734fb9
|
|
7
|
+
data.tar.gz: d48180384c5199e133b23792a0b8fdd569347f9800abe0edf49ecf18dcccad7aee3b3419133e6fb4b9ced574280e0eb7659bdf60fd920b9596008cbb0870de6b
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<%= render Keystone::Ui::DisclosureComponent.new do |disclosure| %>
|
|
2
|
+
<% disclosure.with_summary_content(summary) %>
|
|
3
|
+
<div class="<%= GROUPS_CLASSES %>">
|
|
4
|
+
<% groups.each do |group| %>
|
|
5
|
+
<div>
|
|
6
|
+
<% if group.title %>
|
|
7
|
+
<p class="<%= TITLE_CLASSES %>"><%= group.title %></p>
|
|
8
|
+
<% end %>
|
|
9
|
+
<div class="<%= LINES_CLASSES %>">
|
|
10
|
+
<% group.lines.each do |line| %>
|
|
11
|
+
<span class="<%= LINE_CLASSES %>"><%= line.label %></span>
|
|
12
|
+
<span class="<%= LINE_CLASSES %>"><%= line.working %></span>
|
|
13
|
+
<span class="<%= RESULT_CLASSES %>"><%= line.result %></span>
|
|
14
|
+
<% end %>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
<% end %>
|
|
18
|
+
</div>
|
|
19
|
+
<% end %>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Keystone
|
|
4
|
+
module Ui
|
|
5
|
+
class CalculationComponent < ViewComponent::Base
|
|
6
|
+
Group = Struct.new(:title, :lines, keyword_init: true)
|
|
7
|
+
Line = Struct.new(:label, :working, :result, keyword_init: true)
|
|
8
|
+
|
|
9
|
+
TITLE_CLASSES = "ks-label text-sm"
|
|
10
|
+
LINE_CLASSES = "ks-hint text-sm"
|
|
11
|
+
LINES_CLASSES = "grid grid-cols-[auto_1fr_auto] ks-grid-gap-sm"
|
|
12
|
+
RESULT_CLASSES = "ks-hint text-sm text-right"
|
|
13
|
+
GROUPS_CLASSES = "grid ks-grid-gap-md"
|
|
14
|
+
|
|
15
|
+
attr_reader :groups, :summary
|
|
16
|
+
|
|
17
|
+
def initialize(groups:, summary: "How this is worked out")
|
|
18
|
+
@groups = groups.map { |group| Group.new(title: group[:title], lines: group.fetch(:lines).map { |line| Line.new(**line) }) }
|
|
19
|
+
@summary = summary
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -213,6 +213,10 @@ module KeystoneUiHelper
|
|
|
213
213
|
render Keystone::Ui::DisclosureComponent.new(**args), &block
|
|
214
214
|
end
|
|
215
215
|
|
|
216
|
+
def ui_calculation(**args)
|
|
217
|
+
render Keystone::Ui::CalculationComponent.new(**args)
|
|
218
|
+
end
|
|
219
|
+
|
|
216
220
|
private
|
|
217
221
|
|
|
218
222
|
def keystone_theme_choice
|
data/lib/keystone_ui/safelist.rb
CHANGED
|
@@ -56,7 +56,8 @@ module Keystone
|
|
|
56
56
|
Keystone::Ui::PipelineComponent,
|
|
57
57
|
Keystone::Ui::CodeComponent,
|
|
58
58
|
Keystone::Ui::DisclosureComponent,
|
|
59
|
-
Keystone::Ui::ThemeToggleComponent
|
|
59
|
+
Keystone::Ui::ThemeToggleComponent,
|
|
60
|
+
Keystone::Ui::CalculationComponent
|
|
60
61
|
].freeze
|
|
61
62
|
|
|
62
63
|
# Constants that hold non-CSS values (e.g. HTML input type maps)
|
data/lib/keystone_ui/version.rb
CHANGED
|
@@ -198,6 +198,15 @@ outer element. See Conventions before using it.
|
|
|
198
198
|
- `ui_disclosure(open: false)` — takes a block yielding the component. Fill its
|
|
199
199
|
`summary` slot with the clickable header; the rest of the block is the body.
|
|
200
200
|
Native `<details>` — no JavaScript.
|
|
201
|
+
- `ui_calculation(groups:, summary: "How this is worked out")` — no block. Shows
|
|
202
|
+
how a figure was reached, closed by default under a row reading `summary:`.
|
|
203
|
+
`groups:` is `[{ title:, lines: [{ label:, working:, result: }, ...] }, ...]`;
|
|
204
|
+
`title:` is optional, `lines:` is required and a group without it raises
|
|
205
|
+
`KeyError`, and a line with any key other than those three raises
|
|
206
|
+
`ArgumentError`. Each line renders as three columns — label, working, result
|
|
207
|
+
— with the result right-aligned. Every value is printed as given, so format
|
|
208
|
+
numbers and currency before passing them. Place it directly under the figure
|
|
209
|
+
it explains, such as a `ui_stat_card`.
|
|
201
210
|
- `ui_accordion(items: [])` — a stack of independently expandable rows. `items:`
|
|
202
211
|
is `[{ question:, answer: }, ...]`.
|
|
203
212
|
- `ui_tab_switcher(tabs:)` — takes a block. `tabs:` is an array of label strings;
|
|
@@ -298,6 +307,9 @@ outer element. See Conventions before using it.
|
|
|
298
307
|
`ui_data_table` over a hand-built `<table>`, `ui_stat_card` over a panel with
|
|
299
308
|
text in it. To make a stat card clickable, pass `href:` — never wrap it in
|
|
300
309
|
`ui_card_link`, because a tap on the info button would then follow the link.
|
|
310
|
+
To show the arithmetic behind a figure, put `ui_calculation` under it rather
|
|
311
|
+
than a hand-built list. Which lines and groups to show is the app's own
|
|
312
|
+
calculation, so ask the developer which steps a reader needs to see.
|
|
301
313
|
|
|
302
314
|
6. For a table, decide how columns are declared. Use `{ key: "Label" }` hashes
|
|
303
315
|
when every column is plain. Switch the whole set to `Keystone::Ui::Column`
|
|
@@ -14,8 +14,9 @@ Keystone UI is a Rails engine gem that supplies a host app's visual layer as a
|
|
|
14
14
|
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, cards, stat tiles, charts, funnels, goal buckets, pipelines,
|
|
17
|
-
banners — instead of hand-written ERB and
|
|
18
|
-
lives inside the gem, in frozen constants,
|
|
17
|
+
banners, the calculation behind a figure — instead of hand-written ERB and
|
|
18
|
+
Tailwind. Every class the UI renders lives inside the gem, in frozen constants,
|
|
19
|
+
so the look is defined in one place.
|
|
19
20
|
|
|
20
21
|
Reach for it whenever you build or change a screen in an app that has it
|
|
21
22
|
installed. It exists to stop UI drift: two pages built from the same helpers
|
|
@@ -49,9 +50,10 @@ holds the catalog.
|
|
|
49
50
|
|
|
50
51
|
- **Helpers, not classes.** Every piece of UI is a view helper prefixed `ui_`,
|
|
51
52
|
called from ERB. The one layout helper that is not prefixed `ui_` writes the
|
|
52
|
-
theme onto the page's `html` tag, and it belongs to the install local.
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
theme onto the page's `html` tag, and it belongs to the install local.
|
|
54
|
+
Components live under the `Keystone::Ui` namespace, but a host app does not
|
|
55
|
+
name a component class directly. The one exception is the table column value
|
|
56
|
+
object, which is passed as an argument and renders nothing.
|
|
55
57
|
- **Containers take blocks, leaves take keywords.** Helpers that wrap content
|
|
56
58
|
(page shells, sections, panels, grids, forms, tables) yield a block. Helpers
|
|
57
59
|
that render one thing (a button, a badge, a field, a stat, a bucket) are
|
|
@@ -67,6 +69,11 @@ holds the catalog.
|
|
|
67
69
|
- **Figures are numbers.** Components that measure or compare values, such as
|
|
68
70
|
progress bars, funnels and buckets, do arithmetic on them. Pass a number, not
|
|
69
71
|
a formatted string such as `"9,000"`. A bucket raises on one.
|
|
72
|
+
- **A calculation is text.** The calculation behind a figure is the opposite
|
|
73
|
+
case. It is a list of groups, each with an optional title and its lines, and
|
|
74
|
+
each line is a label, the working and the result. They are passed as
|
|
75
|
+
already-formatted text and shown as written. The component does no
|
|
76
|
+
arithmetic, and it is closed by default under a quiet summary row.
|
|
70
77
|
- **Semantic color, not literal color.** The themed hue is `accent-*` and the
|
|
71
78
|
themed neutral family is `surface-*`, both CSS custom properties whose
|
|
72
79
|
defaults (blue and zinc) come from the keystone_ui-styles gem. Retheming an
|
|
@@ -82,9 +89,10 @@ holds the catalog.
|
|
|
82
89
|
theme toggle, checkbox row, radio card, option card, file upload and colour
|
|
83
90
|
picker read these variables. So do the data display components: stat card,
|
|
84
91
|
chart card, card link, CTA banner, feature grid, hero, data table, code,
|
|
85
|
-
accordion, disclosure, tab switcher, progress, funnel, bucket,
|
|
86
|
-
swipe deck. So do the navigation components: navbar, nav item,
|
|
87
|
-
bottom nav, mobile header and settings link. A host imports its
|
|
92
|
+
accordion, disclosure, calculation, tab switcher, progress, funnel, bucket,
|
|
93
|
+
pipeline and swipe deck. So do the navigation components: navbar, nav item,
|
|
94
|
+
nav dropdown, bottom nav, mobile header and settings link. A host imports its
|
|
95
|
+
look after `keystone_source.css`, and a gem ships one through
|
|
88
96
|
`tailwind_imports`, both set up through the install local.
|
|
89
97
|
- **Registered looks.** Looks can also be registered by name, and each page
|
|
90
98
|
gets one: the name another gem supplies for the request, then the configured
|
|
@@ -100,9 +108,8 @@ holds the catalog.
|
|
|
100
108
|
gem defines. The theme toggle does not offer it, so a page reaches it when
|
|
101
109
|
another gem supplies it. On a Turbo visit, the page being shown sets the
|
|
102
110
|
theme, so a change to the mode on the server shows up without a full reload.
|
|
103
|
-
Marking the layout with the theme is set up through
|
|
104
|
-
|
|
105
|
-
local.
|
|
111
|
+
Marking the layout with the theme is set up through the install local, and
|
|
112
|
+
placing the toggle on a screen goes through the develop local.
|
|
106
113
|
- **Tailwind classes are static strings.** Class names are never interpolated,
|
|
107
114
|
so Tailwind's scanner can find them. Widths and heights that depend on data,
|
|
108
115
|
such as a progress bar or a bucket's fill, are set with an inline style
|
|
@@ -151,7 +151,8 @@ built on ViewComponent; hook it in before building any screen with those helpers
|
|
|
151
151
|
checkbox row, radio card, option card, file upload and colour picker read
|
|
152
152
|
these variables. So do the data display components: stat card, chart card,
|
|
153
153
|
card link, CTA banner, feature grid, hero, data table, code, accordion,
|
|
154
|
-
disclosure, tab switcher, progress, funnel, bucket, pipeline and
|
|
154
|
+
disclosure, calculation, tab switcher, progress, funnel, bucket, pipeline and
|
|
155
|
+
swipe deck.
|
|
155
156
|
So do the navigation components: navbar, nav item, nav dropdown, bottom nav,
|
|
156
157
|
mobile header and settings link. The keystone_ui-styles README lists every
|
|
157
158
|
variable and its default.
|
data/the_local/interface.yml
CHANGED
|
@@ -57,6 +57,7 @@ develop:
|
|
|
57
57
|
- ui_pipeline
|
|
58
58
|
- ui_code
|
|
59
59
|
- ui_disclosure
|
|
60
|
+
- ui_calculation
|
|
60
61
|
- ui_theme_toggle
|
|
61
62
|
- Keystone::Ui::Column
|
|
62
63
|
|
|
@@ -85,6 +86,7 @@ sources:
|
|
|
85
86
|
- app/components/keystone/ui/cta_banner_component.rb
|
|
86
87
|
- app/components/keystone/ui/data_table_component.rb
|
|
87
88
|
- app/components/keystone/ui/disclosure_component.rb
|
|
89
|
+
- app/components/keystone/ui/calculation_component.rb
|
|
88
90
|
- app/components/keystone/ui/feature_grid_component.rb
|
|
89
91
|
- app/components/keystone/ui/file_upload_component.rb
|
|
90
92
|
- app/components/keystone/ui/form_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.19.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tyler Schneider
|
|
@@ -87,6 +87,8 @@ files:
|
|
|
87
87
|
- app/components/keystone/ui/bucket_series_component.rb
|
|
88
88
|
- app/components/keystone/ui/button_component.html.erb
|
|
89
89
|
- app/components/keystone/ui/button_component.rb
|
|
90
|
+
- app/components/keystone/ui/calculation_component.html.erb
|
|
91
|
+
- app/components/keystone/ui/calculation_component.rb
|
|
90
92
|
- app/components/keystone/ui/card_component.html.erb
|
|
91
93
|
- app/components/keystone/ui/card_component.rb
|
|
92
94
|
- app/components/keystone/ui/card_link_component.html.erb
|