tramway 0.1.3.1 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -5
- data/app/components/tailwinds/navbar/button_component.html.haml +2 -6
- data/app/components/tailwinds/navbar/button_component.rb +15 -7
- data/lib/tramway/engine.rb +8 -0
- data/lib/tramway/helpers/tailwind_helpers.rb +21 -0
- data/lib/tramway/version.rb +1 -1
- data/lib/tramway.rb +0 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eedc7b84e9ad80ba5af66fc619af0aea5f24c17e4512e194a6069036ed00f646
|
4
|
+
data.tar.gz: 3e4ac83ede95f1c90e4346f4723551f224efb8921ce1a8802d4977198623441a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43325b31d7a7ca934f39160066dd39653767efd04589e735b1cc2cfaf8ed09c087b9e846816bb97131c11d39e6309d0ef7f9925810159acdb05e3ad77f595aef
|
7
|
+
data.tar.gz: b3da39f4acde834c8897e2ff2853a0c7cfe7cd83d04c0817c30017801010e16d03d5249bb87dd2f98b08b166f1ed594499c71b90fbf1f799b92979363706ab7f
|
data/README.md
CHANGED
@@ -17,23 +17,35 @@ Tramway use [Tailwind](https://tailwindcss.com/) by default. All UI helpers impl
|
|
17
17
|
|
18
18
|
### Navbar
|
19
19
|
|
20
|
-
####
|
20
|
+
#### tailwind_link_to
|
21
21
|
|
22
|
-
Tramway provides `
|
22
|
+
Tramway provides `tailwind_link_to` method, that uses `link_to`
|
23
23
|
|
24
24
|
```haml
|
25
|
-
=
|
25
|
+
= tailwind_link_to "/users/sign_in" do
|
26
26
|
Sign In
|
27
27
|
```
|
28
28
|
|
29
|
+
OR
|
30
|
+
|
31
|
+
```haml
|
32
|
+
= tailwind_link_to 'Sign In', "/users/sign_in"
|
33
|
+
```
|
34
|
+
|
29
35
|
will render [this](https://play.tailwindcss.com/RT3Vvauu78)
|
30
36
|
|
31
37
|
```haml
|
32
|
-
=
|
38
|
+
= tailwind_link_to "/users/sign_out", method: :delete, confirm: 'Wanna quit?' do
|
33
39
|
Sign Out
|
34
40
|
```
|
35
41
|
|
36
|
-
|
42
|
+
OR
|
43
|
+
|
44
|
+
```
|
45
|
+
= tailwind_link_to 'Sign Out', "/users/sign_out", method: :delete, confirm: 'Wanna quit?'
|
46
|
+
```
|
47
|
+
|
48
|
+
will render [this](https://play.tailwindcss.com/7qPmG4ltEU))
|
37
49
|
|
38
50
|
## Contributing
|
39
51
|
|
@@ -6,14 +6,22 @@ module Tailwinds
|
|
6
6
|
#
|
7
7
|
class ButtonComponent < TailwindComponent
|
8
8
|
def initialize(**options)
|
9
|
-
|
10
|
-
@action = options[:action]
|
11
|
-
else
|
12
|
-
@href = options[:href]
|
13
|
-
end
|
14
|
-
|
9
|
+
@href = options[:href]
|
15
10
|
@style = 'text-white hover:bg-red-300 px-4 py-2 rounded'
|
16
|
-
@options = options
|
11
|
+
@options = prepare(options:)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def prepare(options:)
|
17
|
+
options.reduce({}) do |hash, (key, value)|
|
18
|
+
case key
|
19
|
+
when :method, :confirm
|
20
|
+
hash.deep_merge data: { "turbo_#{key}".to_sym => value }
|
21
|
+
else
|
22
|
+
hash.merge key => value
|
23
|
+
end
|
24
|
+
end
|
17
25
|
end
|
18
26
|
end
|
19
27
|
end
|
data/lib/tramway/engine.rb
CHANGED
@@ -5,5 +5,13 @@ module Tramway
|
|
5
5
|
#
|
6
6
|
class Engine < ::Rails::Engine
|
7
7
|
isolate_namespace Tramway
|
8
|
+
|
9
|
+
initializer 'tramway.load_helpers' do
|
10
|
+
ActiveSupport.on_load(:action_view) do
|
11
|
+
require 'tramway/helpers/tailwind_helpers'
|
12
|
+
|
13
|
+
ActionView::Base.include Tramway::Helpers::TailwindHelpers
|
14
|
+
end
|
15
|
+
end
|
8
16
|
end
|
9
17
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tramway
|
4
|
+
module Helpers
|
5
|
+
# ActionView helpers for tailwind
|
6
|
+
#
|
7
|
+
module TailwindHelpers
|
8
|
+
def tailwind_link_to(text_or_url, url = nil, **options, &block)
|
9
|
+
raise 'You can not provide argument and code block in the same time' if url.present? && block_given?
|
10
|
+
|
11
|
+
if url.present?
|
12
|
+
options.merge! href: url
|
13
|
+
render(Tailwinds::Navbar::ButtonComponent.new(**options)) { text_or_url }
|
14
|
+
else
|
15
|
+
options.merge! href: text_or_url
|
16
|
+
render(Tailwinds::Navbar::ButtonComponent.new(**options), &block)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/tramway/version.rb
CHANGED
data/lib/tramway.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.1.
|
4
|
+
version: 0.1.4
|
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: 2023-06-
|
12
|
+
date: 2023-06-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: haml-rails
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- lib/tasks/tramway_tasks.rake
|
86
86
|
- lib/tramway.rb
|
87
87
|
- lib/tramway/engine.rb
|
88
|
+
- lib/tramway/helpers/tailwind_helpers.rb
|
88
89
|
- lib/tramway/version.rb
|
89
90
|
homepage: https://github.com/purple-magic/tramway
|
90
91
|
licenses:
|