keystone_ui 0.42.0 → 0.44.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/assets/javascripts/keystone_ui/color_picker_controller.js +17 -3
- data/app/components/keystone/ui/color_picker_component.html.erb +1 -1
- data/app/components/keystone/ui/color_picker_component.rb +2 -0
- data/app/components/keystone/ui/value_list_component.html.erb +11 -0
- data/app/components/keystone/ui/value_list_component.rb +28 -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 +4 -0
- data/the_local/interface.yml +1 -0
- metadata +5 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 399e1a496d6abbf8fc37149cbf05ea62223222c1cf6b5678dc400b286a17f06a
|
|
4
|
+
data.tar.gz: 5d7566e89343b57e8a35a6693e4fe6107184203299a880d58eab541b6ff16d81
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e0e0ab5ac2704a8612ec78bd80987d61ddfaee104cf0eedf976075e8ea28b4d64ac26990e061055165d334f06c8951b0eb8083b6005cb666dd8d47fec7ec5a7f
|
|
7
|
+
data.tar.gz: 8de679cd46c03c8c8856196fc1d73d87def5ab3910c7b142d744ab7fca02c8b011f0cea93a2a2b42979d677b84c7448c32880d2ab6783851506188622bba7c30
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Controller } from "@hotwired/stimulus"
|
|
2
2
|
|
|
3
3
|
export default class extends Controller {
|
|
4
|
-
static targets = ["swatch", "
|
|
4
|
+
static targets = ["swatch", "text", "input", "panel", "svArea", "svGradient", "svCursor", "hueSlider"]
|
|
5
5
|
static values = { value: String }
|
|
6
6
|
|
|
7
7
|
connect() {
|
|
@@ -10,7 +10,7 @@ export default class extends Controller {
|
|
|
10
10
|
this.val = 1
|
|
11
11
|
this.dragging = false
|
|
12
12
|
|
|
13
|
-
if (this.valueValue) {
|
|
13
|
+
if (this.isSixDigitHex(this.valueValue)) {
|
|
14
14
|
this.setFromHex(this.valueValue)
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -55,6 +55,16 @@ export default class extends Controller {
|
|
|
55
55
|
this.updateColor()
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
textChanged() {
|
|
59
|
+
const colour = this.textTarget.value
|
|
60
|
+
if (!CSS.supports("color", colour)) return
|
|
61
|
+
|
|
62
|
+
if (this.isSixDigitHex(colour)) this.setFromHex(colour)
|
|
63
|
+
this.swatchTarget.style.backgroundColor = colour
|
|
64
|
+
this.inputTarget.value = colour
|
|
65
|
+
this.inputTarget.dispatchEvent(new Event("change", { bubbles: true }))
|
|
66
|
+
}
|
|
67
|
+
|
|
58
68
|
svDown(event) {
|
|
59
69
|
event.preventDefault()
|
|
60
70
|
this.dragging = true
|
|
@@ -92,7 +102,7 @@ export default class extends Controller {
|
|
|
92
102
|
updateColor() {
|
|
93
103
|
const hex = this.hsvToHex(this.hue, this.sat, this.val)
|
|
94
104
|
this.swatchTarget.style.backgroundColor = hex
|
|
95
|
-
this.
|
|
105
|
+
this.textTarget.value = hex
|
|
96
106
|
this.inputTarget.value = hex
|
|
97
107
|
|
|
98
108
|
this.inputTarget.dispatchEvent(new Event("change", { bubbles: true }))
|
|
@@ -118,6 +128,10 @@ export default class extends Controller {
|
|
|
118
128
|
}
|
|
119
129
|
}
|
|
120
130
|
|
|
131
|
+
isSixDigitHex(colour) {
|
|
132
|
+
return /^#[0-9a-f]{6}$/i.test(colour)
|
|
133
|
+
}
|
|
134
|
+
|
|
121
135
|
hsvToHex(h, s, v) {
|
|
122
136
|
const c = v * s
|
|
123
137
|
const x = c * (1 - Math.abs(((h / 60) % 2) - 1))
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
data-color-picker-target="swatch"
|
|
11
11
|
data-action="color-picker#toggle">
|
|
12
12
|
</button>
|
|
13
|
-
<
|
|
13
|
+
<input type="text" class="<%= TEXT_FIELD_CLASSES %>" value="<%= value %>" data-color-picker-target="text" data-action="input->color-picker#textChanged">
|
|
14
14
|
</div>
|
|
15
15
|
|
|
16
16
|
<input type="hidden" name="<%= name %>" value="<%= value %>" data-color-picker-target="input">
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<dl class="<%= classes %>">
|
|
2
|
+
<% rows.each do |row| %>
|
|
3
|
+
<div class="<%= row_classes(row) %>">
|
|
4
|
+
<dt class="ks-value-list-label">
|
|
5
|
+
<%= row[:label] %>
|
|
6
|
+
<% if row[:note] %><span class="ks-value-list-note"><%= row[:note] %></span><% end %>
|
|
7
|
+
</dt>
|
|
8
|
+
<dd class="ks-value-list-value"><%= shown_value(row) %></dd>
|
|
9
|
+
</div>
|
|
10
|
+
<% end %>
|
|
11
|
+
</dl>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Keystone
|
|
4
|
+
module Ui
|
|
5
|
+
class ValueListComponent < ViewComponent::Base
|
|
6
|
+
ALIGN_CLASSES = { start: nil, end: "ks-value-list-end" }.freeze
|
|
7
|
+
|
|
8
|
+
attr_reader :rows
|
|
9
|
+
|
|
10
|
+
def initialize(rows:, align: :start)
|
|
11
|
+
@rows = rows
|
|
12
|
+
@align = align
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def classes
|
|
16
|
+
[ "ks-value-list", ALIGN_CLASSES.fetch(@align) ].compact.join(" ")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def shown_value(row)
|
|
20
|
+
row[:value].to_s.empty? ? row[:fallback] : row[:value]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def row_classes(row)
|
|
24
|
+
[ "ks-value-list-row", ("ks-value-list-total" if row[:total]) ].compact.join(" ")
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -249,6 +249,10 @@ module KeystoneUiHelper
|
|
|
249
249
|
render Keystone::Ui::ParagraphComponent.new(**args)
|
|
250
250
|
end
|
|
251
251
|
|
|
252
|
+
def ui_value_list(**args)
|
|
253
|
+
render Keystone::Ui::ValueListComponent.new(**args)
|
|
254
|
+
end
|
|
255
|
+
|
|
252
256
|
def ui_info(**args, &block)
|
|
253
257
|
render(Keystone::Ui::InfoComponent.new(**args), &block)
|
|
254
258
|
end
|
data/lib/keystone_ui/safelist.rb
CHANGED
|
@@ -32,6 +32,7 @@ module Keystone
|
|
|
32
32
|
Keystone::Ui::CardLinkComponent,
|
|
33
33
|
Keystone::Ui::InputComponent,
|
|
34
34
|
Keystone::Ui::TextareaComponent,
|
|
35
|
+
Keystone::Ui::ValueListComponent,
|
|
35
36
|
Keystone::Ui::FormFieldComponent,
|
|
36
37
|
Keystone::Ui::PageHeaderComponent,
|
|
37
38
|
Keystone::Ui::ParagraphComponent,
|
data/lib/keystone_ui/version.rb
CHANGED
|
@@ -66,6 +66,7 @@ not available in the app yet, that is `keystone_ui-install`'s job.
|
|
|
66
66
|
- `ui_heading` — a heading at one of three sizes, with an optional short note on its right.
|
|
67
67
|
- `ui_caption` — small uppercase muted text placed above a title or a figure.
|
|
68
68
|
- `ui_paragraph` — a paragraph of running text.
|
|
69
|
+
- `ui_value_list` — rows of a label and its value, such as a ledger or a byline.
|
|
69
70
|
- `ui_alert` — a banner message, optionally dismissible.
|
|
70
71
|
- `ui_progress` — a labelled progress bar.
|
|
71
72
|
- `ui_stat_card` — a single metric tile with optional change, link and info button.
|
|
@@ -404,6 +405,9 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
|
|
|
404
405
|
and `note:` puts a short muted note at the right end of the heading's row.
|
|
405
406
|
- `ui_caption(text:)` shows small uppercase muted text above a title or a figure.
|
|
406
407
|
- `ui_paragraph(text:)` shows running text.
|
|
408
|
+
- `ui_value_list(rows:, align: :start)` — each row is `{ label:, value: }`
|
|
409
|
+
with optional `note:`, `total: true` and `fallback:`, shown when the value
|
|
410
|
+
is `nil` or empty. `align: :end` pushes values to the right, as in a ledger.
|
|
407
411
|
|
|
408
412
|
10. Explain figures.
|
|
409
413
|
|
data/the_local/interface.yml
CHANGED
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.44.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.20.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.20.0
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: view_component
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -202,6 +202,8 @@ files:
|
|
|
202
202
|
- app/components/keystone/ui/textarea_component.rb
|
|
203
203
|
- app/components/keystone/ui/theme_toggle_component.html.erb
|
|
204
204
|
- app/components/keystone/ui/theme_toggle_component.rb
|
|
205
|
+
- app/components/keystone/ui/value_list_component.html.erb
|
|
206
|
+
- app/components/keystone/ui/value_list_component.rb
|
|
205
207
|
- app/helpers/keystone_ui_helper.rb
|
|
206
208
|
- config/importmap.rb
|
|
207
209
|
- lib/generators/keystone/install_generator.rb
|