tramway 2.2.3.1 → 2.2.3.2

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: c3404f527f0941b117509108d7827d36cdf2c2d80037bdd41d6316ad040c2b95
4
- data.tar.gz: 5a2896ae1e85140de75fa5c8b7aabc50475adf6ce31edeee66cfb1dd2d9cb034
3
+ metadata.gz: 8fdcc19f72d21a32a847cbe65521d96122451e79661d56a04b91b9e24834684c
4
+ data.tar.gz: 0e24422cc70884ec8b30be9dbd1ab874d0696e0e332908032bd128318df1c0bd
5
5
  SHA512:
6
- metadata.gz: 11325a08313cf4eea578d73e5471b38339837f2f28b5af7e72a01d1eac6b72a493b12058135b8bd2f024608626ff9d84643c5d4d173c8b7fd561e41da2bd358c
7
- data.tar.gz: bbd34d3d7fe3f8a7b306a7d79b0c8a328968180a270db57b2c89c490d5a115b68ee534ea75be48c39d60da13b45402288a6a6ea6b72f0db57d7c17a6d293d88a
6
+ metadata.gz: 5baf5d3877644edc9bb9671aaf4c9fc70579a126f6dabe15af50eb7c0dbb324d17dc9bb08370b389d42190cd79952879ca36495caa9940cdb8ebd8681826d99d
7
+ data.tar.gz: b5e7db58d85f0cb419cab1c249d8478b1faed9698e0b7d34c395486976abf8ef6dcd4cd81a3ce33cbbbbe8461c029c788324751234c473d7ab2d9f0bb9fb5447
@@ -1,20 +1,27 @@
1
1
  - if text.present?
2
- - case @tag
3
- - when :a
4
- = link_to text, path, class: classes, **render_options
5
- - when :button
6
- %button{ class: classes, **render_options }
7
- = text
8
- - when :form
2
+ - if stop_cell_propagation?
9
3
  = helpers.button_to text, path, method:, form: form_options, class: classes, **render_options
4
+ - else
5
+ - case @tag
6
+ - when :a
7
+ = link_to text, path, class: classes, **render_options
8
+ - when :button
9
+ %button{ class: classes, **render_options }
10
+ = text
11
+ - when :form
12
+ = helpers.button_to text, path, method:, form: form_options, class: classes, **render_options
10
13
  - else
11
- - case @tag
12
- - when :a
13
- = link_to path, class: classes, **render_options do
14
- = content
15
- - when :button
16
- %button{ class: classes, **render_options }
17
- = content
18
- - when :form
14
+ - if stop_cell_propagation?
19
15
  = helpers.button_to path, method:, class: classes, form: form_options, **render_options do
20
16
  = content
17
+ - else
18
+ - case @tag
19
+ - when :a
20
+ = link_to path, class: classes, **render_options do
21
+ = content
22
+ - when :button
23
+ %button{ class: classes, **render_options }
24
+ = content
25
+ - when :form
26
+ = helpers.button_to path, method:, class: classes, form: form_options, **render_options do
27
+ = content
@@ -10,19 +10,20 @@ module Tailwinds
10
10
  option :type, optional: true
11
11
  option :size, default: -> { :medium }
12
12
  option :method, optional: true, default: -> { :get }
13
- option :tag, optional: true, default: -> { false }
13
+ option :tag, optional: true, default: -> {}
14
14
  option :options, optional: true, default: -> { {} }
15
15
  option :form_options, optional: true, default: -> { {} }
16
16
 
17
17
  def before_render
18
18
  return if tag.present?
19
- return @tag = :button if options[:type] == :submit
20
19
 
21
- URI.parse(path)
22
-
23
- return @tag = :a if method.to_s.downcase == 'get'
24
-
25
- @tag = :form
20
+ @tag = if tag_button?
21
+ :button
22
+ elsif tag_a?
23
+ :a
24
+ else
25
+ :form
26
+ end
26
27
  end
27
28
 
28
29
  def size_classes
@@ -94,5 +95,18 @@ module Tailwinds
94
95
  'cursor-not-allowed'
95
96
  end
96
97
  end
98
+
99
+ def tag_button?
100
+ options[:type] == :submit
101
+ end
102
+
103
+ def tag_a?
104
+ return true unless path.is_a?(String)
105
+ return false unless method.to_s.downcase == 'get'
106
+
107
+ uri = URI.parse(path)
108
+
109
+ uri.query.nil? || (uri.query && !uri.query.empty?) # rubocop:disable Rails/Present
110
+ end
97
111
  end
98
112
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tramway
4
- VERSION = '2.2.3.1'
4
+ VERSION = '2.2.3.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3.1
4
+ version: 2.2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - kalashnikovisme