tramway 0.5.2.1 → 0.5.3
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/README.md +2 -2
- data/app/components/tailwinds/form/builder.rb +8 -0
- data/app/components/tailwinds/form/select_component.html.haml +1 -1
- data/app/components/tailwinds/form/submit_button_component.html.haml +1 -1
- data/app/components/tailwinds/form/text_area_component.html.haml +5 -0
- data/app/components/tailwinds/form/text_area_component.rb +9 -0
- data/app/components/tailwinds/nav/item_component.rb +1 -1
- data/app/components/tailwinds/navbar_component.html.haml +1 -1
- data/app/components/tailwinds/table/row_component.html.haml +4 -16
- data/app/components/tailwinds/table/row_component.rb +1 -0
- data/app/components/tailwinds/table_component.html.haml +1 -1
- data/app/components/tailwinds/table_component.rb +1 -0
- data/app/controllers/tramway/entities_controller.rb +1 -1
- data/app/helpers/tramway/application_helper.rb +1 -0
- data/app/views/tramway/entities/_list.html.haml +7 -4
- data/config/tailwind.config.js +9 -0
- data/lib/kaminari/helpers/tag.rb +23 -0
- data/lib/tramway/base_decorator.rb +9 -0
- data/lib/tramway/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c116b7002a5f382a5b2d54704e425d6a7e2e1a5208cb2eb1f0cd060bf5852718
|
4
|
+
data.tar.gz: 6a183fa879258d651afcd2479265854139dcc8e5da69f9684a331f859274de64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7765e1c762c50ba2cb543ef79f155f6649cd5c5ac0ee38aa530f9472f0a7024ca489473ac0cf597a30a8fa2c99ce2ed8fde0d62fa34198a7903e3c90e8edfc92
|
7
|
+
data.tar.gz: d136698275286b8188609c2883756a9e338ca6c6faf118166f1374f443ae68ac7ed99849811703f6bf2f70e71d5aaadaec1433d4bec41e70568e27fea015edf1
|
data/README.md
CHANGED
@@ -26,7 +26,7 @@ gem "view_component"
|
|
26
26
|
OR
|
27
27
|
|
28
28
|
```shell
|
29
|
-
bundle add tramway view_component
|
29
|
+
bundle add tramway view_component kaminari view_component
|
30
30
|
```
|
31
31
|
|
32
32
|
## Getting Started
|
@@ -225,7 +225,7 @@ Tramway provides **convenient** form objects for Rails applications. List proper
|
|
225
225
|
class UserForm < Tramway::BaseForm
|
226
226
|
properties :email, :password, :first_name, :last_name, :phone
|
227
227
|
|
228
|
-
normalizes :email, ->(value) { value.strip.downcase }
|
228
|
+
normalizes :email, with: ->(value) { value.strip.downcase }
|
229
229
|
end
|
230
230
|
```
|
231
231
|
|
@@ -13,6 +13,14 @@ module Tailwinds
|
|
13
13
|
), &)
|
14
14
|
end
|
15
15
|
|
16
|
+
def text_area(attribute, **options, &)
|
17
|
+
render(Tailwinds::Form::TextAreaComponent.new(
|
18
|
+
input: input(:text_area),
|
19
|
+
value: get_value(attribute, options),
|
20
|
+
**default_options(attribute, options)
|
21
|
+
), &)
|
22
|
+
end
|
23
|
+
|
16
24
|
def password_field(attribute, **options, &)
|
17
25
|
render(Tailwinds::Form::TextFieldComponent.new(
|
18
26
|
input: input(:password_field),
|
@@ -2,4 +2,4 @@
|
|
2
2
|
- if @label
|
3
3
|
= component('tailwinds/form/label', for: @for) do
|
4
4
|
= @label
|
5
|
-
= @input.call(@attribute, @collection, { selected: @value }, @options.merge(class: 'bg-white border border-gray-300 text-gray-700
|
5
|
+
= @input.call(@attribute, @collection, { selected: @value }, @options.merge(class: 'bg-white border border-gray-300 text-gray-700 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent py-2 px-3'))
|
@@ -1,4 +1,4 @@
|
|
1
1
|
.flex.items-center.justify-between
|
2
|
-
%button.bg-red-500.hover:bg-red-700.text-white.font-bold.py-2.px-4.rounded.focus:outline-none.focus:shadow-outline.cursor-pointer{ type: :submit, name: :commit, **@options }
|
2
|
+
%button.bg-red-500.hover:bg-red-700.text-white.font-bold.py-2.px-4.rounded.focus:outline-none.focus:shadow-outline.cursor-pointer.dark:text-white{ type: :submit, name: :commit, **@options }
|
3
3
|
= @text
|
4
4
|
= @content
|
@@ -0,0 +1,5 @@
|
|
1
|
+
.mb-4
|
2
|
+
- if @label
|
3
|
+
= component('tailwinds/form/label', for: @for) do
|
4
|
+
= @label
|
5
|
+
= @input.call @attribute, **@options.merge(class: 'w-full bg-white px-3 py-2 border border-gray-300 rounded focus:outline-none focus:border-red-500 dark:placeholder-gray-400'), value: @value
|
@@ -8,7 +8,7 @@ module Tailwinds
|
|
8
8
|
def style
|
9
9
|
@style ||= [
|
10
10
|
'text-white', 'hover:bg-gray-300', 'hover:text-gray-800', 'px-4', 'py-2', 'rounded', 'whitespace-nowrap',
|
11
|
-
'dark:hover:bg-gray-700', 'dark:hover:text-gray-400'
|
11
|
+
'dark:hover:bg-gray-700', 'dark:hover:text-gray-400', 'dark:text-white'
|
12
12
|
].join(' ')
|
13
13
|
end
|
14
14
|
end
|
@@ -1,27 +1,15 @@
|
|
1
1
|
- if cells.any?
|
2
|
-
|
3
|
-
= row_tag class: desktop_row_classes(cells.count) do
|
2
|
+
= row_tag class: desktop_row_classes(cells.count), **options do
|
4
3
|
- cells.each do |(_, value)|
|
5
4
|
.div-table-cell.px-6.py-4.font-medium.text-gray-900.whitespace-nowrap.dark:text-white.text-xs.sm:text-base
|
6
5
|
= value
|
7
6
|
|
8
|
-
-# mobile view
|
9
|
-
.div-table-row.xl:hidden.border-b.dark:bg-gray-800.dark:border-gray-700.mb-2{ "data-action" => "click->preview#toggle", "data-controller" => "preview", "data-items" => cells.to_json }
|
10
|
-
.w-full.p-4.bg-purple-100.text-gray-700.dark:bg-gray-700.dark:text-gray-400
|
11
|
-
= cells.values.first
|
12
|
-
|
13
|
-
.flex.overflow-x-auto.whitespace-nowrap
|
14
|
-
- cells.each_with_index do |(_, value), index|
|
15
|
-
- next if index == 0
|
16
|
-
|
17
|
-
.text-gray-900.dark:text-white.p-4.text-xs.sm:text-base.inline-block.w-auto
|
18
|
-
= value
|
19
7
|
- else
|
20
|
-
- cells = Nokogiri::HTML.fragment(content).
|
8
|
+
- cells = Nokogiri::HTML.fragment(content).xpath('./*[@class and contains(concat(" ", normalize-space(@class), " "), " div-table-cell ")]')
|
21
9
|
|
22
10
|
- if href.present?
|
23
|
-
= tag.a href:, class: [desktop_row_classes(cells.count), link_row_classes].join(' ') do
|
11
|
+
= tag.a href:, class: [desktop_row_classes(cells.count), link_row_classes].join(' '), **options do
|
24
12
|
= content
|
25
13
|
- else
|
26
|
-
= tag.div class: desktop_row_classes(cells.count) do
|
14
|
+
= tag.div class: desktop_row_classes(cells.count), **options do
|
27
15
|
= content
|
@@ -4,12 +4,14 @@
|
|
4
4
|
.mt-8.w-full
|
5
5
|
- content_for :title, page_title
|
6
6
|
|
7
|
-
.flex.justify-between.items-center
|
7
|
+
.flex.justify-between.items-center
|
8
8
|
%h1.font-bold.text-4xl.dark:text-white
|
9
9
|
= content_for(:title)
|
10
10
|
|
11
11
|
- if Tramway.config.pagination[:enabled]
|
12
|
-
= paginate @entities
|
12
|
+
= paginate @entities, custom_path_method: "#{@model_class.model_name.plural}_path"
|
13
|
+
.flex.justify-end.mt-2
|
14
|
+
= decorator.constantize.index_header_content.call(@entities) if decorator.constantize.index_header_content.present?
|
13
15
|
|
14
16
|
- if list_attributes.empty?
|
15
17
|
%p.text-center.mt-10
|
@@ -21,5 +23,6 @@
|
|
21
23
|
- @entities.each do |item|
|
22
24
|
= render 'tramway/entities/entity', entity: item
|
23
25
|
|
24
|
-
.
|
25
|
-
|
26
|
+
- if Tramway.config.pagination[:enabled]
|
27
|
+
.flex.mt-4
|
28
|
+
= paginate @entities, custom_path_method: "#{@model_class.model_name.plural}_path"
|
data/config/tailwind.config.js
CHANGED
@@ -23,7 +23,11 @@ module.exports = {
|
|
23
23
|
'flex',
|
24
24
|
'bg-purple-700',
|
25
25
|
'px-6',
|
26
|
+
'px-3',
|
27
|
+
'px-4',
|
26
28
|
'py-4',
|
29
|
+
'py-2',
|
30
|
+
'mb-2',
|
27
31
|
'dark:placeholder-gray-400',
|
28
32
|
'dark:text-white',
|
29
33
|
'dark:bg-gray-800',
|
@@ -41,6 +45,11 @@ module.exports = {
|
|
41
45
|
'hover:bg-gray-100',
|
42
46
|
'hover:bg-gray-300',
|
43
47
|
'hover:text-gray-800',
|
48
|
+
'mt-8',
|
49
|
+
'justify-between',
|
50
|
+
'space-x-1',
|
51
|
+
'justify-end',
|
52
|
+
'mt-2',
|
44
53
|
// pagination
|
45
54
|
'bg-white', 'rounded-md', 'hover:bg-purple-100', 'dark:text-white', 'dark:bg-gray-800', 'dark:hover:bg-gray-700',
|
46
55
|
// multiselect styles
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kaminari
|
4
|
+
module Helpers
|
5
|
+
# Monkey patch for Kaminari::Helpers::Tag to support :custom_path_method
|
6
|
+
# :reek:InstanceVariableAssumption { enabled: false }
|
7
|
+
class Tag
|
8
|
+
def page_url_for(page)
|
9
|
+
custom_path_method = @options[:custom_path_method]
|
10
|
+
|
11
|
+
if custom_path_method.present?
|
12
|
+
Tramway::Engine.routes.url_helpers.public_send(
|
13
|
+
custom_path_method,
|
14
|
+
@params.except(:controller, :action).merge(page: page)
|
15
|
+
)
|
16
|
+
else
|
17
|
+
params = params_for(page)
|
18
|
+
@template.url_for params.merge(only_path: true)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -4,6 +4,7 @@ require 'tramway/decorators/name_builder'
|
|
4
4
|
require 'tramway/decorators/association'
|
5
5
|
require 'tramway/decorators/collection_decorator'
|
6
6
|
require 'tramway/helpers/decorate_helper'
|
7
|
+
require 'tramway/helpers/component_helper'
|
7
8
|
require 'tramway/utils/render'
|
8
9
|
require 'tramway/duck_typing'
|
9
10
|
|
@@ -15,6 +16,7 @@ module Tramway
|
|
15
16
|
include Tramway::Utils::Render
|
16
17
|
include Tramway::DuckTyping::ActiveRecordCompatibility
|
17
18
|
include Tramway::Helpers::DecorateHelper
|
19
|
+
include Tramway::Helpers::ComponentHelper
|
18
20
|
|
19
21
|
attr_reader :object
|
20
22
|
|
@@ -23,6 +25,9 @@ module Tramway
|
|
23
25
|
end
|
24
26
|
|
25
27
|
class << self
|
28
|
+
include Tramway::Helpers::ComponentHelper
|
29
|
+
include Tramway::Utils::Render
|
30
|
+
|
26
31
|
# :reek:NilCheck { enabled: false } because checking for nil is not a type-checking issue but business logic
|
27
32
|
def decorate(object_or_array)
|
28
33
|
return if object_or_array.nil?
|
@@ -47,6 +52,10 @@ module Tramway
|
|
47
52
|
[]
|
48
53
|
end
|
49
54
|
|
55
|
+
def index_header_content
|
56
|
+
nil
|
57
|
+
end
|
58
|
+
|
50
59
|
include Tramway::Decorators::AssociationClassMethods
|
51
60
|
end
|
52
61
|
|
data/lib/tramway/version.rb
CHANGED
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: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kalashnikovisme
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2025-
|
12
|
+
date: 2025-03-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: anyway_config
|
@@ -162,6 +162,8 @@ files:
|
|
162
162
|
- app/components/tailwinds/form/select_component.rb
|
163
163
|
- app/components/tailwinds/form/submit_button_component.html.haml
|
164
164
|
- app/components/tailwinds/form/submit_button_component.rb
|
165
|
+
- app/components/tailwinds/form/text_area_component.html.haml
|
166
|
+
- app/components/tailwinds/form/text_area_component.rb
|
165
167
|
- app/components/tailwinds/form/text_field_component.html.haml
|
166
168
|
- app/components/tailwinds/form/text_field_component.rb
|
167
169
|
- app/components/tailwinds/nav/item/button_component.html.haml
|
@@ -210,6 +212,7 @@ files:
|
|
210
212
|
- app/views/tramway/layouts/application.html.haml
|
211
213
|
- config/routes.rb
|
212
214
|
- config/tailwind.config.js
|
215
|
+
- lib/kaminari/helpers/tag.rb
|
213
216
|
- lib/rules/turbo_html_attributes_rules.rb
|
214
217
|
- lib/tasks/tramway_tasks.rake
|
215
218
|
- lib/tramway.rb
|