keystone_ui 0.48.0 → 0.50.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/bar_chart_component.html.erb +34 -13
- data/app/components/keystone/ui/bar_chart_component.rb +16 -28
- data/app/components/keystone/ui/stat_card_component.html.erb +2 -1
- data/app/components/keystone/ui/stat_card_component.rb +17 -3
- data/lib/keystone_ui/version.rb +1 -1
- data/the_local/agents/keystone_ui-develop.md +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '05930c5225692bb2da76e1b225ac33f9f55998c0a0191db3efa700debbdb63ae'
|
|
4
|
+
data.tar.gz: 3e15b80fbd141058715b2b20ea8635f36c0865adda59963dc4f3b58b8f8a0cba
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b13b8ae4504be8f2a70c26daf383f5b36187deb5629c371e5f4baedaddc0b473e3ae257424e4a4d4707fd878711916d490b51852b1f56d660ea1c87215198f18
|
|
7
|
+
data.tar.gz: a6ab8860835e55b121dec967e44f776fbb2b722991bfdfcef9a77ed72431abd05e2bb8a147ddabd48f5ef3485088472e81313930fa88b2a8db2e07924710e198
|
|
@@ -1,13 +1,34 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
<div class="<%= Keystone::Ui::BarChartComponent::FRAME_CLASSES %>" role="img">
|
|
2
|
+
<div class="<%= Keystone::Ui::BarChartComponent::PLOT_ROW_CLASSES %>">
|
|
3
|
+
<svg class="<%= Keystone::Ui::BarChartComponent::AXIS_CLASSES %>">
|
|
4
|
+
<% ticks.each do |tick| %>
|
|
5
|
+
<text class="ks-bar-chart-text" data-axis-tick x="100%" dx="-6" y="<%= tick[:y].round(2) %>%" dominant-baseline="middle" text-anchor="end"><%= tick[:label] %></text>
|
|
6
|
+
<% end %>
|
|
7
|
+
</svg>
|
|
8
|
+
<div class="<%= Keystone::Ui::BarChartComponent::PLOT_CLASSES %>">
|
|
9
|
+
<svg class="<%= Keystone::Ui::BarChartComponent::LAYER_CLASSES %>" viewBox="0 0 100 100" preserveAspectRatio="none">
|
|
10
|
+
<% ticks.each do |tick| %>
|
|
11
|
+
<line class="ks-bar-chart-grid" x1="0" x2="100" y1="<%= tick[:y].round(2) %>" y2="<%= tick[:y].round(2) %>" vector-effect="non-scaling-stroke"></line>
|
|
12
|
+
<% end %>
|
|
13
|
+
<% drawn_bars.each do |bar| %>
|
|
14
|
+
<rect class="<%= bar[:classes] %>" x="<%= bar[:x].round(2) %>" y="<%= bar[:y].round(2) %>" width="<%= bar[:width].round(2) %>" height="<%= bar[:height].round(2) %>"></rect>
|
|
15
|
+
<% end %>
|
|
16
|
+
</svg>
|
|
17
|
+
<% if show_values? %>
|
|
18
|
+
<svg class="<%= Keystone::Ui::BarChartComponent::LAYER_CLASSES %>">
|
|
19
|
+
<% drawn_bars.each do |bar| %>
|
|
20
|
+
<text class="ks-bar-chart-value" x="<%= bar[:center].round(2) %>%" y="<%= bar[:y].round(2) %>%" dy="-4" text-anchor="middle"><%= bar[:value] %></text>
|
|
21
|
+
<% end %>
|
|
22
|
+
</svg>
|
|
23
|
+
<% end %>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
<div class="<%= Keystone::Ui::BarChartComponent::LABEL_ROW_CLASSES %>">
|
|
27
|
+
<span class="<%= Keystone::Ui::BarChartComponent::LABEL_SPACER_CLASSES %>"></span>
|
|
28
|
+
<svg class="<%= Keystone::Ui::BarChartComponent::LABELS_CLASSES %>">
|
|
29
|
+
<% drawn_bars.each do |bar| %>
|
|
30
|
+
<text class="ks-bar-chart-text" data-bar-label x="<%= bar[:center].round(2) %>%" y="100%" dy="-6" text-anchor="middle"><%= bar[:label] %></text>
|
|
31
|
+
<% end %>
|
|
32
|
+
</svg>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
@@ -3,12 +3,16 @@
|
|
|
3
3
|
module Keystone
|
|
4
4
|
module Ui
|
|
5
5
|
class BarChartComponent < ViewComponent::Base
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
FRAME_CLASSES = "ks-bar-chart flex aspect-[5/2] max-h-80 w-full flex-col"
|
|
7
|
+
PLOT_ROW_CLASSES = "flex min-h-0 flex-1"
|
|
8
|
+
AXIS_CLASSES = "h-full w-10 shrink-0 overflow-visible"
|
|
9
|
+
PLOT_CLASSES = "relative min-w-0 flex-1"
|
|
10
|
+
LAYER_CLASSES = "absolute inset-0 h-full w-full overflow-visible"
|
|
11
|
+
LABEL_ROW_CLASSES = "flex h-6 shrink-0"
|
|
12
|
+
LABEL_SPACER_CLASSES = "w-10 shrink-0"
|
|
13
|
+
LABELS_CLASSES = "h-full min-w-0 flex-1 overflow-visible"
|
|
14
|
+
FULL = 100.0
|
|
15
|
+
HEADROOM = 8.0
|
|
12
16
|
BAR_SHARE = 0.7
|
|
13
17
|
TICK_COUNT = 4
|
|
14
18
|
ROUND_STEPS = [ 1, 2, 2.5, 5, 10 ].freeze
|
|
@@ -26,28 +30,20 @@ module Keystone
|
|
|
26
30
|
|
|
27
31
|
def drawn_bars
|
|
28
32
|
bars.each_with_index.map do |bar, index|
|
|
29
|
-
height = bar[:value].to_f / axis_max *
|
|
30
|
-
{ x:
|
|
31
|
-
center:
|
|
33
|
+
height = bar[:value].to_f / axis_max * (FULL - HEADROOM)
|
|
34
|
+
{ x: (index * band) + (band * (1 - BAR_SHARE) / 2), y: FULL - height, width: band * BAR_SHARE, height: height,
|
|
35
|
+
center: (index * band) + (band / 2), label: bar[:label], value: bar[:value],
|
|
32
36
|
classes: [ "ks-bar-chart-bar", ("ks-bar-chart-bar-shaded" if bar[:shaded]) ].compact.join(" ") }
|
|
33
37
|
end
|
|
34
38
|
end
|
|
35
39
|
|
|
36
40
|
def ticks
|
|
37
|
-
(0..
|
|
41
|
+
(0..(axis_max / step).round).map do |position|
|
|
38
42
|
value = (step * position).round(6)
|
|
39
|
-
{ y:
|
|
43
|
+
{ y: FULL - (value / axis_max * (FULL - HEADROOM)), label: (value % 1).zero? ? value.to_i.to_s : value.to_s }
|
|
40
44
|
end
|
|
41
45
|
end
|
|
42
46
|
|
|
43
|
-
def axis_x
|
|
44
|
-
LEFT - 6
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def label_baseline
|
|
48
|
-
HEIGHT - 6
|
|
49
|
-
end
|
|
50
|
-
|
|
51
47
|
private
|
|
52
48
|
|
|
53
49
|
def axis_max
|
|
@@ -67,15 +63,7 @@ module Keystone
|
|
|
67
63
|
end
|
|
68
64
|
|
|
69
65
|
def band
|
|
70
|
-
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def plot_width
|
|
74
|
-
WIDTH - LEFT - RIGHT
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def plot_height
|
|
78
|
-
HEIGHT - TOP - BOTTOM
|
|
66
|
+
FULL / [ bars.size, 1 ].max
|
|
79
67
|
end
|
|
80
68
|
end
|
|
81
69
|
end
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
<% end %>
|
|
13
13
|
</div>
|
|
14
14
|
<p class="<%= value_classes %>">
|
|
15
|
-
<% if link? %><a href="<%= href %>" class="<%= value_link_classes %>"><%= value %></a><% else %><%= value %><% end %><% if suffix? %><span class="<%= suffix_classes %>"> <%= suffix %></span><% end %>
|
|
15
|
+
<% if missing? %><span class="<%= Keystone::Ui::StatCardComponent::FALLBACK_CLASSES %>"><%= fallback %></span><% elsif link? %><a href="<%= href %>" class="<%= value_link_classes %>"><%= value %></a><% else %><%= value %><% end %><% if suffix? %><span class="<%= suffix_classes %>"> <%= suffix %></span><% end %>
|
|
16
16
|
</p>
|
|
17
|
+
<% if note %><p class="<%= Keystone::Ui::StatCardComponent::NOTE_CLASSES %>"><%= note %></p><% end %>
|
|
17
18
|
<p class="<%= change_row_classes %>"><%= change_label %></p>
|
|
18
19
|
</div>
|
|
@@ -6,6 +6,7 @@ module Keystone
|
|
|
6
6
|
EMPHASIS_CLASSES = "ks-stat-card-emphasis"
|
|
7
7
|
HEADER_CLASSES = "ks-stat-card-header flex items-start justify-between"
|
|
8
8
|
CARD_CLASSES = "ks-metric-card relative"
|
|
9
|
+
PLAIN_CLASSES = "ks-metric-plain relative"
|
|
9
10
|
LABEL_CLASSES = "ks-stat-card-label text-sm"
|
|
10
11
|
VALUE_BASE_CLASSES = "ks-stat-card-value text-3xl"
|
|
11
12
|
SUFFIX_CLASSES = "ks-stat-card-suffix text-lg"
|
|
@@ -13,6 +14,8 @@ module Keystone
|
|
|
13
14
|
CHANGE_ROW_CLASSES = "ks-stat-card-change h-5 text-sm"
|
|
14
15
|
VALUE_LINK_CLASSES = "hover:underline focus:outline-none focus-visible:underline"
|
|
15
16
|
INFO_BUTTON_CLASSES = "ks-stat-card-info peer shrink-0 transition"
|
|
17
|
+
NOTE_CLASSES = "ks-stat-card-note text-sm"
|
|
18
|
+
FALLBACK_CLASSES = "ks-stat-card-fallback"
|
|
16
19
|
|
|
17
20
|
INFO_ICON = <<~SVG.freeze
|
|
18
21
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>
|
|
@@ -26,10 +29,13 @@ module Keystone
|
|
|
26
29
|
info: "ks-tone-info"
|
|
27
30
|
}.freeze
|
|
28
31
|
|
|
29
|
-
attr_reader :label, :value, :suffix, :definition, :calculation, :change, :href
|
|
32
|
+
attr_reader :label, :value, :suffix, :definition, :calculation, :change, :href, :note
|
|
30
33
|
|
|
31
|
-
def initialize(label:, value:, variant: :neutral, suffix: nil, definition: nil, calculation: nil, change: nil, href: nil)
|
|
34
|
+
def initialize(label:, value:, variant: :neutral, suffix: nil, definition: nil, calculation: nil, change: nil, href: nil, note: nil, plain: false, fallback: nil)
|
|
32
35
|
@label = label
|
|
36
|
+
@fallback = fallback
|
|
37
|
+
@note = note
|
|
38
|
+
@plain = plain
|
|
33
39
|
@value = value
|
|
34
40
|
@variant = variant
|
|
35
41
|
@suffix = suffix
|
|
@@ -39,8 +45,16 @@ module Keystone
|
|
|
39
45
|
@href = href
|
|
40
46
|
end
|
|
41
47
|
|
|
48
|
+
def missing?
|
|
49
|
+
@value.to_s.empty? && !@fallback.nil?
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def fallback
|
|
53
|
+
@fallback
|
|
54
|
+
end
|
|
55
|
+
|
|
42
56
|
def classes
|
|
43
|
-
CARD_CLASSES
|
|
57
|
+
@plain ? PLAIN_CLASSES : CARD_CLASSES
|
|
44
58
|
end
|
|
45
59
|
|
|
46
60
|
def label_classes
|
data/lib/keystone_ui/version.rb
CHANGED
|
@@ -420,7 +420,7 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
|
|
|
420
420
|
|
|
421
421
|
10. Explain figures.
|
|
422
422
|
|
|
423
|
-
- `ui_stat_card(label:, value:, variant: :neutral, suffix: nil, definition: nil, calculation: nil, change: nil, href: nil)`
|
|
423
|
+
- `ui_stat_card(label:, value:, variant: :neutral, suffix: nil, definition: nil, calculation: nil, change: nil, href: nil, note: nil, plain: false, fallback: nil)`
|
|
424
424
|
— `variant:` is `:neutral` `:success` `:danger` `:warning` `:info` and
|
|
425
425
|
colours the value. `change:` is a signed number shown as `▲ 4.2%` in
|
|
426
426
|
green, `▼` in red, or plain at zero. `href:` links the value only, so
|
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.50.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.25.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.25.0
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: view_component
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|