keystone_ui 0.8.0 → 0.9.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9007e4cf813a277f78f01bdf10df84d28856a5eaf1e7460c51e77db5d8b13143
4
- data.tar.gz: a31771c5217f422c78000dc895be2314e9ecac0de206155f3d3a123b3da362af
3
+ metadata.gz: fc51f5315bb4315b50a98d76085bce19f48de6c9f95ded851c745fc83f46ddf2
4
+ data.tar.gz: 0a2436931ac90ccb62af03429e1be4b1b3d19fc1b0a8cf9dac2385fc12c94ea0
5
5
  SHA512:
6
- metadata.gz: d5649e25777890bf3bd01be1f42260c92038b66cef09c71f1b6e4655658f6d602102d0adcef0bd4b063edb837490818df7734c84b3f0e0198e2a859a83b2ea10
7
- data.tar.gz: 52bce90d7e68c9ead4e459f71376c16257b235b1418ef92c156bd8d7fb1bd2b33a17cf7111bcb0412d19d79e6ad0626ce8d2aa72db8fe00988fbaae41705151d
6
+ metadata.gz: b1a1fb202743e5a2fcd9312db49c202f3c0e60b5314b976a05b5584ccf80bba50dc64c169c31a6b9e6417b49913d2d6e99def606ecb7f63cd883d450e42e74e6
7
+ data.tar.gz: 1717453d259ec802e2b66e4f59db9c1d911cfa428a406da81f5546e83d78ead564214ebd41547133ca9e77f15e70b560b456b9d5dc6b85a3f99b4aa8af7ac511
@@ -0,0 +1,9 @@
1
+ <label class="<%= row_classes %>">
2
+ <input type="checkbox" name="<%= name %>" value="<%= value %>" <%= "checked" if checked? %> class="<%= input_classes %>">
3
+ <span>
4
+ <span class="<%= label_classes %>"><%= label %></span>
5
+ <% if hint? %>
6
+ <span class="<%= hint_classes %>"><%= hint %></span>
7
+ <% end %>
8
+ </span>
9
+ </label>
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Keystone
4
+ module Ui
5
+ class CheckboxRowComponent < ViewComponent::Base
6
+ ROW_CLASSES = "flex items-start gap-3 py-3 cursor-pointer"
7
+ INPUT_CLASSES = "mt-0.5 size-4 shrink-0 rounded border-surface-300 text-accent-600 checked:bg-accent-600 focus:ring-accent-500"
8
+ LABEL_CLASSES = "block text-sm font-medium text-surface-900 dark:text-surface-100"
9
+ HINT_CLASSES = "block mt-0.5 text-sm text-surface-500 dark:text-surface-400"
10
+
11
+ attr_reader :name, :value, :label, :hint
12
+
13
+ def initialize(name:, value:, label:, hint: nil, checked: false)
14
+ @name = name
15
+ @value = value
16
+ @label = label
17
+ @hint = hint
18
+ @checked = checked
19
+ end
20
+
21
+ def checked?
22
+ @checked
23
+ end
24
+
25
+ def hint?
26
+ !@hint.nil?
27
+ end
28
+
29
+ def row_classes
30
+ ROW_CLASSES
31
+ end
32
+
33
+ def input_classes
34
+ INPUT_CLASSES
35
+ end
36
+
37
+ def label_classes
38
+ LABEL_CLASSES
39
+ end
40
+
41
+ def hint_classes
42
+ HINT_CLASSES
43
+ end
44
+ end
45
+ end
46
+ end
@@ -153,6 +153,10 @@ module KeystoneUiHelper
153
153
  render Keystone::Ui::RadioCardComponent.new(**args)
154
154
  end
155
155
 
156
+ def ui_checkbox_row(**args)
157
+ render Keystone::Ui::CheckboxRowComponent.new(**args)
158
+ end
159
+
156
160
  def ui_progress(**args)
157
161
  render Keystone::Ui::ProgressComponent.new(**args)
158
162
  end
@@ -42,6 +42,7 @@ module Keystone
42
42
  Keystone::Ui::ShowPageComponent,
43
43
  Keystone::Ui::OptionCardComponent,
44
44
  Keystone::Ui::RadioCardComponent,
45
+ Keystone::Ui::CheckboxRowComponent,
45
46
  Keystone::Ui::ProgressComponent,
46
47
  Keystone::Ui::ColorPickerComponent,
47
48
  Keystone::Ui::MultiSelectComponent,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KeystoneUi
4
- VERSION = "0.8.0"
4
+ VERSION = "0.9.1"
5
5
  end
@@ -117,6 +117,11 @@ one raises at render time.
117
117
  hue/saturation panel and writes the hex into a hidden input named `name`.
118
118
  - `ui_radio_card(name:, value:, label:, hint: nil, checked: false)` — a
119
119
  selectable card backed by a real radio input; selection styling is pure CSS.
120
+ - `ui_checkbox_row(name:, value:, label:, hint: nil, checked: false)` — a real
121
+ checkbox with its label and optional hint inside one `<label>`, so a tap
122
+ anywhere on the row toggles the box. A checked row submits `value` under
123
+ `name`; give several rows the same array name, e.g. `"shown[]"`, to submit the
124
+ checked values as a list. An unchecked row submits nothing. No JavaScript.
120
125
  - `ui_option_card(name:, value:, selected: false, input_data: {}, label_data: {})`
121
126
  — takes a block. A radio whose visible body is whatever the block renders.
122
127
  `input_data:`/`label_data:` become `data-*` attributes on the input and label.
@@ -41,6 +41,7 @@ develop:
41
41
  - ui_bottom_nav_item
42
42
  - ui_option_card
43
43
  - ui_radio_card
44
+ - ui_checkbox_row
44
45
  - ui_progress
45
46
  - ui_settings_link
46
47
  - ui_color_picker
@@ -68,6 +69,8 @@ sources:
68
69
  - app/components/keystone/ui/card_component.rb
69
70
  - app/components/keystone/ui/card_link_component.rb
70
71
  - app/components/keystone/ui/chart_card_component.rb
72
+ - app/components/keystone/ui/checkbox_row_component.rb
73
+ - app/components/keystone/ui/checkbox_row_component.html.erb
71
74
  - app/components/keystone/ui/code_component.rb
72
75
  - app/components/keystone/ui/color_picker_component.rb
73
76
  - app/components/keystone/ui/column_picker_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.8.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Schneider
@@ -90,6 +90,8 @@ files:
90
90
  - app/components/keystone/ui/card_link_component.rb
91
91
  - app/components/keystone/ui/chart_card_component.html.erb
92
92
  - app/components/keystone/ui/chart_card_component.rb
93
+ - app/components/keystone/ui/checkbox_row_component.html.erb
94
+ - app/components/keystone/ui/checkbox_row_component.rb
93
95
  - app/components/keystone/ui/code_component.html.erb
94
96
  - app/components/keystone/ui/code_component.rb
95
97
  - app/components/keystone/ui/color_picker_component.html.erb