shoelace-rails 0.3.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6bf02de3fbe6ef35ad4c464e666bd7ace7bf0c2e673b0767afea4d6b87522749
4
- data.tar.gz: 73abb906c86ffc3f4a945f73f3a97e3cd335c1cb4245b82362cf53c3587619d5
3
+ metadata.gz: 7a2dfd18c31e8151980211fe86c5911629f795652e2662315055695f31b7e2d6
4
+ data.tar.gz: a2c224c7c8ba4fd199d9190d77e37246650753f9c76d29156c25b4754c65018b
5
5
  SHA512:
6
- metadata.gz: 1e7a5bca7b14951f97b54c9de1be69698ceebb63a421be912cc8f692ebec8ed075ebdf58a4fbc9d9200c296e3150ae63f41f6a6a40f62fc368c1a54044905a9b
7
- data.tar.gz: 5d09b9294065025cb30762a152c3b037739790a8b16ff5e2178bcb98afc0592756447ba0273967450783e11fbfd9863be5e11027a61074ed622e35d380a95dc5
6
+ metadata.gz: 8a78a2537a9851beb4f9d7e33214e51fbff8c3539cef0d244951b6ac36d7f0837a84129a8dfe36a46f8e7eec8f474e65b9a45078abde2a508b3a3b90f5322060
7
+ data.tar.gz: 5a99554ecd05cd33ffbe41929984a82828961db94ac3f4a4c796e6685bff57c08afef96ed8d8c58e055edaada87e2e0be0ebc5761b870bec74164a476c7e36e6
data/CHANGELOG.md CHANGED
@@ -1,28 +1,49 @@
1
- ## v0.3.0
1
+ ## v0.4.1
2
2
 
3
- _<sup>released at 2023-01-05 08:47:12 UTC</sup>_
3
+ _<sup>released at 2023-03-21 05:01:50 UTC</sup>_
4
+
5
+ #### 🐞Bug Fixes
6
+
7
+ - Fixes a bug where `FormHelper` may not be defined when someone loads `ActionView` too early (d91ed3b595c01ce2dfc471b12b14311e0660d3d7)
8
+ - Fixes a bug where the Shoelace rake tasks blow up when the project does not depend on Sprockets or Propshaft (0e64cd6dc38a037171be04eaf1d3f59c3c8529eb, 75adf831b1faa7f5d1faeed26e672d4bc89b9513)
9
+
10
+ ## [v0.4.0](https://github.com/yuki24/shoelace-rails/tree/v0.4.0)
11
+
12
+ _<sup>released at 2023-01-07 07:23:50 UTC</sup>_
13
+
14
+ #### 🚨 Breaking Changes
15
+
16
+ - No longer works with `2.0.0-beta.88` and below.
17
+
18
+ #### ⭐️ Features
19
+
20
+ - Support Shoelace.style `2.0.0-beta.88`.
21
+
22
+ ## [v0.3.0](https://github.com/yuki24/shoelace-rails/tree/v0.3.0)
23
+
24
+ _<sup>released at 2023-01-05 08:49:23 UTC</sup>_
4
25
 
5
26
  #### Features
6
27
 
7
- - No longer requires the `sl-form` component (`4fdbfa15`)
8
- - The `#text_area` method now accepts a block (`5092dc1c`)
9
- - Allow overriding the value attribute for `<sl-select>` (`1f38be73`)
10
- - Auto-display labels whenever possible (`c1e3a950`)
11
- - `<sl-select>` now always has a label by default (`f9fb5f0c`)
12
- - Support Ruby 3.2 (`b286cbc1`)
13
- - Add `#sl_button_to` (`e1bdedba`)
14
- - Add `#sl_icon_tag` (`8a2187a2`)
15
- - Add `#sl_avatar_tag` (`77dccdb2`)
16
- - Allow using the `Shoelace::FormBuilder` in a cleaner way (`43dea330`)
28
+ - No longer requires the `sl-form` component ([<tt>4fdbfa1</tt>](https://github.com/yuki24/shoelace-rails/commit/4fdbfa15fa10db9e7240378ca34ebcc494d18f1a))
29
+ - The `#text_area` method now accepts a block ([<tt>5092dc1</tt>](https://github.com/yuki24/shoelace-rails/commit/5092dc1cbc7e8e74552451450804baa378ab1f11))
30
+ - Allow overriding the value attribute for `<sl-select>` ([<tt>1f38be7</tt>](https://github.com/yuki24/shoelace-rails/commit/1f38be73e3335c10e846393ebcf5155d155b00b2))
31
+ - Auto-display labels whenever possible ([<tt>c1e3a95</tt>](https://github.com/yuki24/shoelace-rails/commit/c1e3a950c3e8ac4238ed3e83e4d87467a68eb91f))
32
+ - `<sl-select>` now always has a label by default ([<tt>f9fb5f0</tt>](https://github.com/yuki24/shoelace-rails/commit/f9fb5f0cd74d179241be51510fa1c306481946c9))
33
+ - Support Ruby 3.2 ([<tt>b286cbc</tt>](https://github.com/yuki24/shoelace-rails/commit/b286cbc18930218ab5c82bd8648a51e9c6ce53db))
34
+ - Add `#sl_button_to` ([<tt>e1bdedb</tt>](https://github.com/yuki24/shoelace-rails/commit/e1bdedba4656d89a82c78641644490085da1fa37))
35
+ - Add `#sl_icon_tag` ([<tt>8a2187a</tt>](https://github.com/yuki24/shoelace-rails/commit/8a2187a2800771512fccf2c8231378a77be59df4))
36
+ - Add `#sl_avatar_tag` ([<tt>77dccdb</tt>](https://github.com/yuki24/shoelace-rails/commit/77dccdb24cfc014bd997ffb66ad89ff95afb3ef7))
37
+ - Allow using the `Shoelace::FormBuilder` in a cleaner way ([<tt>43dea33</tt>](https://github.com/yuki24/shoelace-rails/commit/43dea3309c3e0cf9d9b43b6957f6e54ad9497c9f))
17
38
 
18
39
  #### Bug Fixes
19
40
 
20
- - Fixes a bug where the gem rake tasks are not loaded (`115bfb3d`)
21
- - Fixes a bug where values are not properly passed in to `<sl-textarea>` (`3d163845`)
22
- - Make sure yarn install is always executed before copying shoelace assets (`98018a27`)
23
- - Fixes a bug where the `@object` needs to respond to `#errors` (`bb981ed0`)
24
- - Fixes a bug where the `size` attr is ignored by the `#text_area` method (`8bc4c378`)
25
- - Fixes a bug where unchecked checkbox values are not captured (`dc658bea`)
41
+ - Fixes a bug where the gem rake tasks are not loaded ([<tt>115bfb3</tt>](https://github.com/yuki24/shoelace-rails/commit/115bfb3d81ca19b5b922a5fb32f46adb1d6e8544))
42
+ - Fixes a bug where values are not properly passed in to `<sl-textarea>` ([<tt>3d16384</tt>](https://github.com/yuki24/shoelace-rails/commit/3d16384554bd4a6143e28e483f8d6bee8fb2e073))
43
+ - Make sure yarn install is always executed before copying shoelace assets ([<tt>98018a2</tt>](https://github.com/yuki24/shoelace-rails/commit/98018a27a29ddc9ff2c2fa066bbe986709803a1d))
44
+ - Fixes a bug where the `@object` needs to respond to `#errors` ([<tt>bb981ed</tt>](https://github.com/yuki24/shoelace-rails/commit/bb981ed05825707cef89d70a7d1699c12cd0ba9b))
45
+ - Fixes a bug where the `size` attr is ignored by the `#text_area` method ([<tt>8bc4c37</tt>](https://github.com/yuki24/shoelace-rails/commit/8bc4c3784a458e7fc9c18a143578b2cbf588e9e7))
46
+ - Fixes a bug where unchecked checkbox values are not captured ([<tt>dc658be</tt>](https://github.com/yuki24/shoelace-rails/commit/dc658bea9fc4d4205dacdfe133b091c5a5edf14c))
26
47
 
27
48
  ## [v0.2.0](https://github.com/yuki24/shoelace-rails/tree/v0.2.0)
28
49
 
data/README.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  The `shoelace-rails` gem adds useful helper methods for [Shoelace.style](https://shoelace.style), the design system.
4
4
 
5
+ ## Compatibility with Shoelace
6
+
7
+ * **For Shoelace version >= 2.0.0-beta.88, use the gem version `0.4.0` or above**.
8
+ * For Shoelace version <= 2.0.0-beta.87, use the gem version `0.3.0`.
9
+
5
10
  ## Installation
6
11
 
7
12
  Add this line to your application's Gemfile:
@@ -2,9 +2,6 @@
2
2
 
3
3
  module Shoelace
4
4
  module FormHelper
5
- mattr_accessor :invalid_input_class_name
6
- self.invalid_input_class_name = nil
7
-
8
5
  class ShoelaceInputField < ActionView::Helpers::Tags::TextField #:nodoc:
9
6
  attr_reader :field_type
10
7
 
@@ -21,7 +18,7 @@ module Shoelace
21
18
 
22
19
  options["size"] = options["maxlength"] unless options.key?("size")
23
20
  options["type"] ||= field_type
24
- options["class"] ||= [options["class"], Shoelace::FormHelper.invalid_input_class_name].compact.join(" ") if @object.respond_to?(:errors) && @object.errors[@method_name].present?
21
+ options["class"] ||= [options["class"], Shoelace.invalid_input_class_name].compact.join(" ") if @object.respond_to?(:errors) && @object.errors[@method_name].present?
25
22
 
26
23
  add_default_name_and_id(options)
27
24
 
@@ -274,7 +271,7 @@ module Shoelace
274
271
  content_tag('sl-input', '', { "type" => "text", "name" => name, "id" => sanitize_to_id(name), "value" => value }.update(options.stringify_keys), &block)
275
272
  end
276
273
 
277
- # Returns a string of +<sl-menu-item>+ tags, like +options_for_select+, but prepends a +<sl-menu-label>+ tag to
274
+ # Returns a string of +<sl-option>+ tags, like +options_for_select+, but prepends a +<small>+ tag to
278
275
  # each group.
279
276
  def grouped_sl_options_for_select(grouped_options, options)
280
277
  body = "".html_safe
@@ -283,14 +280,14 @@ module Shoelace
283
280
  label, values = container
284
281
 
285
282
  body.safe_concat(DIVIDER_TAG) if index > 0
286
- body.safe_concat(content_tag("sl-menu-label", label)) if label.present?
283
+ body.safe_concat(content_tag("small", label)) if label.present?
287
284
  body.safe_concat(sl_options_for_select(values, options))
288
285
  end
289
286
 
290
287
  body
291
288
  end
292
289
 
293
- # Accepts an enumerable (hash, array, enumerable, your type) and returns a string of +sl-menu-item+ tags. Given
290
+ # Accepts an enumerable (hash, array, enumerable, your type) and returns a string of +sl-option+ tags. Given
294
291
  # an enumerable where the elements respond to +first+ and +last+ (such as a two-element array), the “lasts” serve
295
292
  # as option values and the “firsts” as option text.
296
293
  def sl_options_for_select(enumerable, options = nil)
@@ -306,11 +303,11 @@ module Shoelace
306
303
  html_attributes[:disabled] ||= disabled.include?(value)
307
304
  html_attributes[:value] = value
308
305
 
309
- tag_builder.content_tag_string('sl-menu-item', text, html_attributes)
306
+ tag_builder.content_tag_string('sl-option', text, html_attributes)
310
307
  end.join("\n").html_safe
311
308
  end
312
309
 
313
- # Returns a string of +<sl-menu-item>+ tags compiled by iterating over the collection and assigning the result of
310
+ # Returns a string of +<sl-option>+ tags compiled by iterating over the collection and assigning the result of
314
311
  # a call to the +value_method+ as the option value and the +text_method+ as the option text.
315
312
  def sl_options_from_collection_for_select(collection, value_method, text_method, selected = nil)
316
313
  options = collection.map do |element|
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Shoelace
4
4
  module Rails
5
- VERSION = "0.3.0"
5
+ VERSION = "0.4.1"
6
6
  end
7
7
  end
@@ -3,6 +3,9 @@
3
3
  require 'action_dispatch/middleware/static'
4
4
 
5
5
  module Shoelace
6
+ mattr_accessor :invalid_input_class_name
7
+ self.invalid_input_class_name = nil
8
+
6
9
  # The only reason this class exists is to clarify that we have a custom static file server after
7
10
  # `ActionDispatch::Static`. We could just use `ActionDispatch::Static` directly, but it would make the result of
8
11
  # `rake middleware` more difficult to understand, as the output would look like:
@@ -43,7 +46,7 @@ module Shoelace
43
46
 
44
47
  initializer "shoelace.form_helper" do |app|
45
48
  ActiveSupport.on_load :action_view do
46
- Shoelace::FormHelper.invalid_input_class_name = app.config.shoelace.invalid_input_class_name
49
+ Shoelace.invalid_input_class_name = app.config.shoelace.invalid_input_class_name
47
50
  end
48
51
  end
49
52
 
@@ -7,7 +7,7 @@ module Shoelace
7
7
  select_element.click
8
8
 
9
9
  within select_element do
10
- find('sl-menu-item', text: option_text).click
10
+ find('sl-option', text: option_text).click
11
11
  end
12
12
 
13
13
  select_element
@@ -19,7 +19,7 @@ module Shoelace
19
19
  select_element.click
20
20
  within select_element do
21
21
  options_to_select.each do |option_text|
22
- find('sl-menu-item', text: option_text).click
22
+ find('sl-option', text: option_text).click
23
23
  end
24
24
  end
25
25
 
@@ -13,8 +13,12 @@ namespace :shoelace do
13
13
  end
14
14
 
15
15
  # Make sure `yarn install` is run before running `shoelace:icons:copy`.
16
- Rake::Task["shoelace:icons:copy"].enhance(["javascript:build"])
16
+ if Rake::Task.task_defined?("javascript:build")
17
+ Rake::Task["shoelace:icons:copy"].enhance(["javascript:build"])
18
+ end
17
19
 
18
20
  if Rake::Task.task_defined?("assets:precompile")
19
21
  Rake::Task["assets:precompile"].enhance(["shoelace:icons:copy"])
22
+ else
23
+ Rake::Task.define_task('assets:precompile' => ['shoelace:icons:copy'])
20
24
  end
@@ -21,8 +21,8 @@
21
21
  }
22
22
  </style>
23
23
 
24
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.0.0-beta.87/dist/themes/light.css">
25
- <script type="module" src="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.0.0-beta.87/dist/shoelace.js"></script>
24
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.0.0-beta.88/dist/themes/light.css">
25
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.0.0-beta.88/dist/shoelace.js"></script>
26
26
 
27
27
  <% if request.path.include?("hotwire") %>
28
28
  <%= javascript_pack_tag 'hotwire' %>
@@ -282,9 +282,9 @@ class FormHelperTest < ActionView::TestCase
282
282
  sl_form_for(User.new, url: "/") do |form|
283
283
  assert_dom_equal <<~HTML, form.select(:name, users)
284
284
  <sl-select label="Name" name="user[name]" id="user_name">
285
- <sl-menu-item value="1">Yuki Nishijima</sl-menu-item>
286
- <sl-menu-item value="2">Matz</sl-menu-item>
287
- <sl-menu-item value="3">Koichi Sasada</sl-menu-item>
285
+ <sl-option value="1">Yuki Nishijima</sl-option>
286
+ <sl-option value="2">Matz</sl-option>
287
+ <sl-option value="3">Koichi Sasada</sl-option>
288
288
  </sl-select>
289
289
  HTML
290
290
  end
@@ -300,9 +300,9 @@ class FormHelperTest < ActionView::TestCase
300
300
  sl_form_for(User.new, url: "/") do |form|
301
301
  assert_dom_equal <<~HTML, form.select(:name, users, {}, { value: 3 })
302
302
  <sl-select label="Name" value="3" name="user[name]" id="user_name">
303
- <sl-menu-item value="1">Yuki Nishijima</sl-menu-item>
304
- <sl-menu-item value="2">Matz</sl-menu-item>
305
- <sl-menu-item value="3">Koichi Sasada</sl-menu-item>
303
+ <sl-option value="1">Yuki Nishijima</sl-option>
304
+ <sl-option value="2">Matz</sl-option>
305
+ <sl-option value="3">Koichi Sasada</sl-option>
306
306
  </sl-select>
307
307
  HTML
308
308
  end
@@ -318,9 +318,9 @@ class FormHelperTest < ActionView::TestCase
318
318
  sl_form_for(User.new, url: "/") do |form|
319
319
  assert_dom_equal <<~HTML, form.select(:name, users, selected: 3, disabled: 1)
320
320
  <sl-select label="Name" name="user[name]" id="user_name">
321
- <sl-menu-item value="1" disabled="disabled">Yuki Nishijima</sl-menu-item>
322
- <sl-menu-item value="2">Matz</sl-menu-item>
323
- <sl-menu-item value="3" checked="checked">Koichi Sasada</sl-menu-item>
321
+ <sl-option value="1" disabled="disabled">Yuki Nishijima</sl-option>
322
+ <sl-option value="2">Matz</sl-option>
323
+ <sl-option value="3" checked="checked">Koichi Sasada</sl-option>
324
324
  </sl-select>
325
325
  HTML
326
326
  end
@@ -336,9 +336,9 @@ class FormHelperTest < ActionView::TestCase
336
336
  sl_form_for(User.new, url: "/") do |form|
337
337
  assert_dom_equal <<~HTML, form.select(:name, users, {}, { multiple: true })
338
338
  <sl-select label="Name" name="user[name][]" id="user_name" multiple="multiple">
339
- <sl-menu-item value="1">Yuki Nishijima</sl-menu-item>
340
- <sl-menu-item value="2">Matz</sl-menu-item>
341
- <sl-menu-item value="3">Koichi Sasada</sl-menu-item>
339
+ <sl-option value="1">Yuki Nishijima</sl-option>
340
+ <sl-option value="2">Matz</sl-option>
341
+ <sl-option value="3">Koichi Sasada</sl-option>
342
342
  </sl-select>
343
343
  HTML
344
344
  end
@@ -358,12 +358,12 @@ class FormHelperTest < ActionView::TestCase
358
358
  sl_form_for(User.new, url: "/") do |form|
359
359
  assert_dom_equal <<~HTML, form.select(:name, users)
360
360
  <sl-select label="Name" name="user[name]" id="user_name">
361
- <sl-menu-label>Main maintainers</sl-menu-label>
362
- <sl-menu-item value="2">Matz</sl-menu-item>
363
- <sl-menu-item value="3">Koichi Sasada</sl-menu-item>
361
+ <small>Main maintainers</small>
362
+ <sl-option value="2">Matz</sl-option>
363
+ <sl-option value="3">Koichi Sasada</sl-option>
364
364
  <sl-divider></sl-divider>
365
- <sl-menu-label>Default gem maintainers</sl-menu-label>
366
- <sl-menu-item value="1">Yuki Nishijima</sl-menu-item>
365
+ <small>Default gem maintainers</small>
366
+ <sl-option value="1">Yuki Nishijima</sl-option>
367
367
  </sl-select>
368
368
  HTML
369
369
  end
@@ -383,12 +383,12 @@ class FormHelperTest < ActionView::TestCase
383
383
  sl_form_for(User.new(name: 2), url: "/") do |form|
384
384
  assert_dom_equal <<~HTML, form.select(:name, users)
385
385
  <sl-select label="Name" name="user[name]" id="user_name" value="2">
386
- <sl-menu-label>Main maintainers</sl-menu-label>
387
- <sl-menu-item value="2" checked="checked">Matz</sl-menu-item>
388
- <sl-menu-item value="3">Koichi Sasada</sl-menu-item>
386
+ <small>Main maintainers</small>
387
+ <sl-option value="2" checked="checked">Matz</sl-option>
388
+ <sl-option value="3">Koichi Sasada</sl-option>
389
389
  <sl-divider></sl-divider>
390
- <sl-menu-label>Default gem maintainers</sl-menu-label>
391
- <sl-menu-item value="1">Yuki Nishijima</sl-menu-item>
390
+ <small>Default gem maintainers</small>
391
+ <sl-option value="1">Yuki Nishijima</sl-option>
392
392
  </sl-select>
393
393
  HTML
394
394
  end
@@ -404,9 +404,9 @@ class FormHelperTest < ActionView::TestCase
404
404
  sl_form_for(User.new, url: "/") do |form|
405
405
  assert_dom_equal <<~HTML, form.collection_select(:name, users, :first, :last)
406
406
  <sl-select label="Name" name="user[name]" id="user_name">
407
- <sl-menu-item value="1">Yuki Nishijima</sl-menu-item>
408
- <sl-menu-item value="2">Matz</sl-menu-item>
409
- <sl-menu-item value="3">Koichi Sasada</sl-menu-item>
407
+ <sl-option value="1">Yuki Nishijima</sl-option>
408
+ <sl-option value="2">Matz</sl-option>
409
+ <sl-option value="3">Koichi Sasada</sl-option>
410
410
  </sl-select>
411
411
  HTML
412
412
  end
@@ -422,9 +422,9 @@ class FormHelperTest < ActionView::TestCase
422
422
  sl_form_for(User.new(name: "2"), url: "/") do |form|
423
423
  assert_dom_equal <<~HTML, form.collection_select(:name, users, :first, :last)
424
424
  <sl-select label="Name" name="user[name]" id="user_name" value="2">
425
- <sl-menu-item value="1">Yuki Nishijima</sl-menu-item>
426
- <sl-menu-item value="2" checked="checked">Matz</sl-menu-item>
427
- <sl-menu-item value="3">Koichi Sasada</sl-menu-item>
425
+ <sl-option value="1">Yuki Nishijima</sl-option>
426
+ <sl-option value="2" checked="checked">Matz</sl-option>
427
+ <sl-option value="3">Koichi Sasada</sl-option>
428
428
  </sl-select>
429
429
  HTML
430
430
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shoelace-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuki Nishijima
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-05 00:00:00.000000000 Z
11
+ date: 2023-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
195
  requirements: []
196
- rubygems_version: 3.4.1
196
+ rubygems_version: 3.4.6
197
197
  signing_key:
198
198
  specification_version: 4
199
199
  summary: Rails view helpers Shoelace.style, the design system.