keystone_ui 0.75.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 +4 -4
- data/app/components/keystone/ui/timeline_component.html.erb +17 -0
- data/app/components/keystone/ui/timeline_component.rb +56 -0
- data/app/helpers/keystone_ui_helper.rb +4 -0
- data/lib/keystone_ui/safelist.rb +1 -0
- data/lib/keystone_ui/version.rb +1 -1
- data/the_local/agents/keystone_ui-develop.md +12 -1
- data/the_local/agents/keystone_ui-info.md +6 -4
- data/the_local/agents/keystone_ui-install.md +2 -2
- data/the_local/interface.yml +3 -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: 83cb8847534e6d738d9100c1d2ac5042d481dfcfc40f04c99f108bfd155ef4ce
|
|
4
|
+
data.tar.gz: 1707b5be58e4b7b2a9cae7a0a3fab60a0f823e5a0fe3ae6decf8795d28dbdd53
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f71a4a8d8a2b3a8d44093c7673958dfdfb64221f86fcf84460b3141a800c364525f3bca044a586cc5eaa4b16916d68a0c221f28e967a1f08c6c1d5470dfcc4fc
|
|
7
|
+
data.tar.gz: fa87049702215deaa3a8d44ded3171efff9f840c837f2fea09bfd293cf4c6719bc395bb791dd434cb1bae584f394eee7b943d14b9f8cc639b2bca82766501f90
|
|
@@ -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
|
|
@@ -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
|
data/lib/keystone_ui/safelist.rb
CHANGED
|
@@ -74,6 +74,7 @@ module Keystone
|
|
|
74
74
|
Keystone::Ui::CodeComponent,
|
|
75
75
|
Keystone::Ui::DisclosureComponent,
|
|
76
76
|
Keystone::Ui::ThemeToggleComponent,
|
|
77
|
+
Keystone::Ui::TimelineComponent,
|
|
77
78
|
Keystone::Ui::CalculationComponent,
|
|
78
79
|
Keystone::Ui::DesktopBackLinkComponent,
|
|
79
80
|
Keystone::Ui::BreadcrumbsComponent,
|
data/lib/keystone_ui/version.rb
CHANGED
|
@@ -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
|
|
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
|
---
|
|
@@ -95,6 +95,7 @@ not available in the app yet, that is `keystone_ui-install`'s job.
|
|
|
95
95
|
- `ui_funnel` — a conversion funnel drawn as bars or one joined shape.
|
|
96
96
|
- `ui_bucket` — an upright container filled toward a goal.
|
|
97
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.
|
|
98
99
|
- `ui_pipeline` — a staged flow diagram with buttons and breakable links that post to the app.
|
|
99
100
|
- `ui_hero` — a marketing hero with title, call-to-action buttons and an aside.
|
|
100
101
|
- `ui_cta_banner` — a marketing banner holding call-to-action buttons.
|
|
@@ -690,6 +691,16 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
|
|
|
690
691
|
the fill turns green with `over: :success` or amber with `over: :warning`.
|
|
691
692
|
- `ui_bucket_series(buckets:)` takes an array of hashes with the keywords
|
|
692
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.
|
|
693
704
|
- `ui_pipeline(title:, boxes:, links:, subtitle: nil)` — `boxes:` is
|
|
694
705
|
`[{ label:, count:, accent:, action: }, ...]`, with `accent:` one of
|
|
695
706
|
`:amber` `:emerald` `:danger` `:muted`, and `action:` 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
|
|
61
|
-
do arithmetic, so they take numbers, and a bucket raises on
|
|
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.
|
|
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.
|
|
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
|
data/the_local/interface.yml
CHANGED
|
@@ -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
|
|
@@ -184,3 +185,5 @@ sources:
|
|
|
184
185
|
- app/components/keystone/ui/swipe_deck_component.rb
|
|
185
186
|
- app/components/keystone/ui/tab_switcher_component.rb
|
|
186
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.
|
|
4
|
+
version: 0.76.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tyler Schneider
|
|
@@ -221,6 +221,8 @@ files:
|
|
|
221
221
|
- app/components/keystone/ui/textarea_component.rb
|
|
222
222
|
- app/components/keystone/ui/theme_toggle_component.html.erb
|
|
223
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
|
|
224
226
|
- app/components/keystone/ui/value_list_component.html.erb
|
|
225
227
|
- app/components/keystone/ui/value_list_component.rb
|
|
226
228
|
- app/helpers/keystone_ui_helper.rb
|