tramway 2.2.6 → 2.2.7

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: da9fb27f70518c08c00dc9b65368f3425460df6ed0b9cb7506ea1fd4140cbd64
4
- data.tar.gz: 32ec241b81c1e6120b410e62a8a22932720721be1ed34b73c64bf43fa63e5a5d
3
+ metadata.gz: 908989b8908005e2022039beec8b7b47c4a7200166c77fe33c2dd27891d2fe58
4
+ data.tar.gz: b57f2f3717522d10885d7ba83464590ff21ce87fa24af5c46deb85b0fac806cd
5
5
  SHA512:
6
- metadata.gz: 2279a03d5e72a3e5a943b22ce54b11dfab5cf6970c59e59541fe0f6be3209cef4c6b2547917ff5bcbfea1e7488a482f645b9e0b720e7f6b0daef1962d3f62b85
7
- data.tar.gz: a310b92c15be5e0bcedeab69e2bf7e512f183581acae65e9b50f4c7464129346b86e83f56b34954d86b3d7d9f50bfd7230745747974b9f1e95ffc6884db2d5fd
6
+ metadata.gz: 7824108d8dfe9a0c3da312a26d12a84fe1df9424550c6edb29b864634109cc793e883a9f13ff90a7ab40d2e9b833cc6068194055410837cb554dd0e467f802f7
7
+ data.tar.gz: befb3fe2ad460b34f002ffd58b01ab4c1f9996ff5f402e714bb54b6fa013091004b55e7ed8b558b551dd017bba4609c01072370eae034b77c51f978a8703fa4e
@@ -18,21 +18,24 @@ class TailwindComponent < Tramway::BaseComponent
18
18
  select_input: 'text-sm px-2 py-1',
19
19
  file_button: 'text-sm px-3 py-1',
20
20
  submit_button: 'text-sm px-3 py-1',
21
- multiselect_input: 'text-sm px-2 py-1 h-10'
21
+ multiselect_input: 'text-sm px-2 py-1 h-10',
22
+ checkbox_input: 'h-4 w-4'
22
23
  },
23
24
  medium: {
24
25
  text_input: 'text-base px-3 py-2',
25
26
  select_input: 'text-base px-3 py-2',
26
27
  file_button: 'text-base px-4 py-2',
27
28
  submit_button: 'text-base px-4 py-2',
28
- multiselect_input: 'text-base px-2 py-1 h-12'
29
+ multiselect_input: 'text-base px-2 py-1 h-12',
30
+ checkbox_input: 'h-5 w-5'
29
31
  },
30
32
  large: {
31
33
  text_input: 'text-xl px-4 py-3',
32
34
  select_input: 'text-xl px-4 py-3',
33
35
  file_button: 'text-xl px-5 py-3',
34
36
  submit_button: 'text-xl px-5 py-3',
35
- multiselect_input: 'text-xl px-3 py-2 h-15'
37
+ multiselect_input: 'text-xl px-3 py-2 h-15',
38
+ checkbox_input: 'h-6 w-6'
36
39
  }
37
40
  }.freeze
38
41
 
@@ -67,6 +70,13 @@ class TailwindComponent < Tramway::BaseComponent
67
70
  )
68
71
  end
69
72
 
73
+ def checkbox_base_classes
74
+ theme_classes(
75
+ classic: 'rounded-full border border-gray-700 bg-gray-900 text-gray-100 shadow-inner focus:outline-none ' \
76
+ 'focus:ring-2 focus:ring-gray-600'
77
+ )
78
+ end
79
+
70
80
  def form_label_classes
71
81
  theme_classes(
72
82
  classic: 'block text-sm font-semibold mb-2 text-gray-200'
@@ -68,6 +68,10 @@ module Tailwinds
68
68
  render(Tailwinds::Form::FileFieldComponent.new(input:, **default_options(attribute, sanitized_options)), &)
69
69
  end
70
70
 
71
+ def check_box(attribute, **, &)
72
+ common_field(:checkbox, :check_box, attribute, **, &)
73
+ end
74
+
71
75
  def select(attribute, collection, **options, &)
72
76
  sanitized_options = sanitize_options(options)
73
77
 
@@ -0,0 +1,7 @@
1
+ .flex.items-start.gap-2.mb-4
2
+ - classes = "#{size_class(:checkbox_input)} #{checkbox_base_classes}"
3
+ = @input.call @attribute, **@options.merge(class: classes)
4
+ - if @label
5
+ %div
6
+ = component('tailwinds/form/label', for: @for) do
7
+ = @label
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tailwinds
4
+ module Form
5
+ # Tailwind-styled checkbox field
6
+ class CheckboxComponent < TailwindComponent
7
+ end
8
+ end
9
+ end
data/docs/AGENTS.md CHANGED
@@ -425,6 +425,24 @@ and in a controller
425
425
  end
426
426
  ```
427
427
 
428
+ ### Rule 27
429
+ Don't create scopes for enumerated values, use `scope: :shallow` of the enumerize gem.
430
+
431
+ Do this
432
+
433
+ ```
434
+ enumerize :role, in: [:admin, :default], scope: :shallow
435
+ ```
436
+
437
+ Instead of this
438
+
439
+ ```
440
+ scope :for_role, -> (role) { where role: role }
441
+ ```
442
+
443
+ ### Rule 28
444
+ In case, you need to make a one link in tramway_table on each row. Use `tramway_row href: your_link` instead of putting the like inside a cell.
445
+
428
446
  ## Controller Patterns
429
447
 
430
448
  - Keep actions short and explicit with guard clauses.
@@ -23,8 +23,10 @@ module Tramway
23
23
 
24
24
  def field_name(field_data)
25
25
  case field_data.to_sym
26
- when :text_area, :select, :multiselect
26
+ when :text_area, :select, :multiselect, :check_box
27
27
  field_data
28
+ when :checkbox
29
+ :check_box
28
30
  else
29
31
  "#{field_data}_field"
30
32
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tramway
4
- VERSION = '2.2.6'
4
+ VERSION = '2.2.7'
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.6
4
+ version: 2.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - kalashnikovisme
@@ -156,6 +156,8 @@ files:
156
156
  - app/components/tailwinds/flash_component.html.haml
157
157
  - app/components/tailwinds/flash_component.rb
158
158
  - app/components/tailwinds/form/builder.rb
159
+ - app/components/tailwinds/form/checkbox_component.html.haml
160
+ - app/components/tailwinds/form/checkbox_component.rb
159
161
  - app/components/tailwinds/form/date_field_component.html.haml
160
162
  - app/components/tailwinds/form/date_field_component.rb
161
163
  - app/components/tailwinds/form/datetime_field_component.html.haml