tramway 0.6.0.2 → 0.6.1
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 43b27ea63deb43c9638207d611bb7d00c4418441569dff08575b0fd7d70645f9
|
|
4
|
+
data.tar.gz: a833223eb737c92d419c40f0d28a63542c307893fa4a1198f002d3f44ea22ac8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fa0fb3870ec1b95d7f8a463c388ec29867f8ac4d18b0c2e0c6819499ac557b51daf2ae3cc0eb41e5c4417a8138734e904cc29df8019fba02fe87d31eb65b4c9d
|
|
7
|
+
data.tar.gz: 847ba96f2a59e245528657f1d6e2bb546c66a8c8d63b41b454bf14c7b89d800b8efc32812acf34c75c30e54ed224d50d51a246d9adfcb9118f540fe16b7bd4b0
|
data/README.md
CHANGED
|
@@ -642,8 +642,43 @@ component applies.
|
|
|
642
642
|
|
|
643
643
|
Tramway ships with helpers for common UI patterns built on top of Tailwind components.
|
|
644
644
|
|
|
645
|
-
* `tramway_button` renders a button-styled
|
|
646
|
-
`color`, `type`, and `size`.
|
|
645
|
+
* `tramway_button` renders a button-styled form submit by default and accepts `path`, optional `text`, HTTP `method`, and styling
|
|
646
|
+
options such as `color`, `type`, and `size`. Pass `link: true` to render a button-styled link instead. All additional keyword
|
|
647
|
+
arguments are forwarded to the underlying component as HTML attributes.
|
|
648
|
+
|
|
649
|
+
The `type` option maps semantic intent to Tailwind color families. The full set of supported values is:
|
|
650
|
+
|
|
651
|
+
| Type | Color |
|
|
652
|
+
| ---- | ----- |
|
|
653
|
+
| `default`, `life` | Gray |
|
|
654
|
+
| `primary`, `hope` | Blue |
|
|
655
|
+
| `secondary` | Zinc |
|
|
656
|
+
| `success`, `will` | Green |
|
|
657
|
+
| `warning`, `greed` | Orange |
|
|
658
|
+
| `danger`, `rage` | Red |
|
|
659
|
+
| `love` | Violet |
|
|
660
|
+
| `compassion` | Indigo |
|
|
661
|
+
| `fear` | Yellow |
|
|
662
|
+
|
|
663
|
+
If none of the predefined semantic types fit your needs, you can supply a Tailwind color family directly using the `color`
|
|
664
|
+
option—for example: `color: :gray`. When you pass a custom color ensure the corresponding utility classes exist in your
|
|
665
|
+
Tailwind configuration. Add the following safelist entries (adjusting the color name as needed) to `config/tailwind.config.js`:
|
|
666
|
+
|
|
667
|
+
```js
|
|
668
|
+
// config/tailwind.config.js
|
|
669
|
+
module.exports = {
|
|
670
|
+
// ...
|
|
671
|
+
safelist: [
|
|
672
|
+
// existing entries …
|
|
673
|
+
{
|
|
674
|
+
pattern: /(bg|hover:bg|dark:bg|dark:hover:bg)-gray-(500|600|700|800)/,
|
|
675
|
+
},
|
|
676
|
+
],
|
|
677
|
+
}
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
Tailwind will then emit the `bg-gray-500`, `hover:bg-gray-700`, `dark:bg-gray-600`, and `dark:hover:bg-gray-800` classes that
|
|
681
|
+
Tramway buttons expect when you opt into a custom color.
|
|
647
682
|
|
|
648
683
|
```erb
|
|
649
684
|
<%= tramway_button path: user_path(user), text: 'View profile', color: :emerald, data: { turbo: false } %>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
- if text.present?
|
|
2
|
-
- if
|
|
2
|
+
- if link
|
|
3
3
|
= link_to text, path, class: classes, **options.except(:class)
|
|
4
4
|
- else
|
|
5
5
|
= button_to text, path, method:, class: classes, **options.except(:class)
|
|
6
6
|
- else
|
|
7
|
-
- if
|
|
7
|
+
- if link
|
|
8
8
|
= link_to path, class: classes, **options.except(:class) do
|
|
9
9
|
= content
|
|
10
10
|
- else
|
|
@@ -6,26 +6,45 @@ module Tailwinds
|
|
|
6
6
|
class ButtonComponent < BaseComponent
|
|
7
7
|
option :text, optional: true, default: -> {}
|
|
8
8
|
option :path
|
|
9
|
-
option :color,
|
|
10
|
-
option :type,
|
|
9
|
+
option :color, optional: true
|
|
10
|
+
option :type, optional: true
|
|
11
11
|
option :size, default: -> { :middle }
|
|
12
12
|
option :method, optional: true, default: -> { :get }
|
|
13
|
+
option :link, optional: true, default: -> { false }
|
|
13
14
|
option :options, optional: true, default: -> { {} }
|
|
14
15
|
|
|
15
16
|
def size_classes
|
|
16
17
|
case size
|
|
17
18
|
when :small
|
|
18
|
-
'text-sm py-1 px-
|
|
19
|
+
'text-sm py-1 px-2 rounded' # small button
|
|
19
20
|
when :middle
|
|
20
|
-
'py-2 px-4'
|
|
21
|
+
'py-2 px-4' # middle button
|
|
21
22
|
end
|
|
22
23
|
end
|
|
23
24
|
|
|
25
|
+
TYPE_COLOR_MAP = {
|
|
26
|
+
default: :gray,
|
|
27
|
+
life: :gray,
|
|
28
|
+
primary: :blue,
|
|
29
|
+
hope: :blue,
|
|
30
|
+
secondary: :zinc,
|
|
31
|
+
success: :green,
|
|
32
|
+
will: :green,
|
|
33
|
+
warning: :orange,
|
|
34
|
+
greed: :orange,
|
|
35
|
+
danger: :red,
|
|
36
|
+
rage: :red,
|
|
37
|
+
love: :violet,
|
|
38
|
+
compassion: :indigo,
|
|
39
|
+
compassio: :indigo,
|
|
40
|
+
fear: :yellow
|
|
41
|
+
}.freeze
|
|
42
|
+
|
|
24
43
|
def classes
|
|
25
44
|
(default_classes +
|
|
26
45
|
light_mode_classes +
|
|
27
46
|
dark_mode_classes +
|
|
28
|
-
(
|
|
47
|
+
(link ? %w[px-1 h-fit] : ['cursor-pointer'])).compact.join(' ')
|
|
29
48
|
end
|
|
30
49
|
|
|
31
50
|
def default_classes
|
|
@@ -43,18 +62,38 @@ module Tailwinds
|
|
|
43
62
|
|
|
44
63
|
def light_mode_classes
|
|
45
64
|
[
|
|
46
|
-
"bg-#{
|
|
47
|
-
"hover:bg-#{
|
|
65
|
+
"bg-#{resolved_color}-500",
|
|
66
|
+
"hover:bg-#{resolved_color}-700",
|
|
48
67
|
'text-white'
|
|
49
68
|
]
|
|
50
69
|
end
|
|
51
70
|
|
|
52
71
|
def dark_mode_classes
|
|
53
72
|
[
|
|
54
|
-
"dark:bg-#{
|
|
55
|
-
"dark:hover:bg-#{
|
|
73
|
+
"dark:bg-#{resolved_color}-600",
|
|
74
|
+
"dark:hover:bg-#{resolved_color}-800",
|
|
56
75
|
'dark:text-gray-300'
|
|
57
76
|
]
|
|
58
77
|
end
|
|
78
|
+
|
|
79
|
+
private
|
|
80
|
+
|
|
81
|
+
def resolved_color
|
|
82
|
+
(color || type_color).to_s
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def type_color
|
|
86
|
+
TYPE_COLOR_MAP.fetch(normalized_type, TYPE_COLOR_MAP[:default]).to_sym
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def normalized_type
|
|
90
|
+
value = type
|
|
91
|
+
value = nil if value.respond_to?(:empty?) && value.empty?
|
|
92
|
+
value ||= :default
|
|
93
|
+
value = value.downcase if value.respond_to?(:downcase)
|
|
94
|
+
value = value.to_sym if value.respond_to?(:to_sym)
|
|
95
|
+
|
|
96
|
+
TYPE_COLOR_MAP.key?(value) ? value : :default
|
|
97
|
+
end
|
|
59
98
|
end
|
|
60
99
|
end
|
data/config/tailwind.config.js
CHANGED
|
@@ -66,9 +66,11 @@ module.exports = {
|
|
|
66
66
|
'px-6',
|
|
67
67
|
'px-4',
|
|
68
68
|
'px-3',
|
|
69
|
+
'px-2',
|
|
69
70
|
'py-8',
|
|
70
71
|
'py-4',
|
|
71
72
|
'py-2',
|
|
73
|
+
'py-1',
|
|
72
74
|
'mb-2',
|
|
73
75
|
'mt-8',
|
|
74
76
|
'mt-2',
|
|
@@ -100,6 +102,44 @@ module.exports = {
|
|
|
100
102
|
'font-normal',
|
|
101
103
|
'text-xs',
|
|
102
104
|
|
|
105
|
+
// === Button color presets ===
|
|
106
|
+
'bg-gray-500',
|
|
107
|
+
'hover:bg-gray-700',
|
|
108
|
+
'dark:bg-gray-600',
|
|
109
|
+
'dark:hover:bg-gray-800',
|
|
110
|
+
'bg-blue-500',
|
|
111
|
+
'hover:bg-blue-700',
|
|
112
|
+
'dark:bg-blue-600',
|
|
113
|
+
'dark:hover:bg-blue-800',
|
|
114
|
+
'bg-zinc-500',
|
|
115
|
+
'hover:bg-zinc-700',
|
|
116
|
+
'dark:bg-zinc-600',
|
|
117
|
+
'dark:hover:bg-zinc-800',
|
|
118
|
+
'bg-green-500',
|
|
119
|
+
'hover:bg-green-700',
|
|
120
|
+
'dark:bg-green-600',
|
|
121
|
+
'dark:hover:bg-green-800',
|
|
122
|
+
'bg-orange-500',
|
|
123
|
+
'hover:bg-orange-700',
|
|
124
|
+
'dark:bg-orange-600',
|
|
125
|
+
'dark:hover:bg-orange-800',
|
|
126
|
+
'bg-red-500',
|
|
127
|
+
'hover:bg-red-700',
|
|
128
|
+
'dark:bg-red-600',
|
|
129
|
+
'dark:hover:bg-red-800',
|
|
130
|
+
'bg-violet-500',
|
|
131
|
+
'hover:bg-violet-700',
|
|
132
|
+
'dark:bg-violet-600',
|
|
133
|
+
'dark:hover:bg-violet-800',
|
|
134
|
+
'bg-indigo-500',
|
|
135
|
+
'hover:bg-indigo-700',
|
|
136
|
+
'dark:bg-indigo-600',
|
|
137
|
+
'dark:hover:bg-indigo-800',
|
|
138
|
+
'bg-yellow-500',
|
|
139
|
+
'hover:bg-yellow-700',
|
|
140
|
+
'dark:bg-yellow-600',
|
|
141
|
+
'dark:hover:bg-yellow-800',
|
|
142
|
+
|
|
103
143
|
// === Form state helpers ===
|
|
104
144
|
'disabled:bg-gray-100',
|
|
105
145
|
'disabled:text-gray-400',
|
|
@@ -21,7 +21,6 @@ module Tramway
|
|
|
21
21
|
component 'tailwinds/table/header',
|
|
22
22
|
headers:,
|
|
23
23
|
columns:,
|
|
24
|
-
options:,
|
|
25
24
|
&
|
|
26
25
|
end
|
|
27
26
|
|
|
@@ -37,11 +36,12 @@ module Tramway
|
|
|
37
36
|
component 'tailwinds/table/cell', &
|
|
38
37
|
end
|
|
39
38
|
|
|
40
|
-
def tramway_button(path:, text: nil, method: :get, **options)
|
|
39
|
+
def tramway_button(path:, text: nil, method: :get, link: false, **options)
|
|
41
40
|
component 'tailwinds/button',
|
|
42
41
|
text:,
|
|
43
42
|
path:,
|
|
44
43
|
method:,
|
|
44
|
+
link:,
|
|
45
45
|
color: options.delete(:color),
|
|
46
46
|
type: options.delete(:type),
|
|
47
47
|
size: options.delete(:size),
|
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.6.
|
|
4
|
+
version: 0.6.1
|
|
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-10-
|
|
12
|
+
date: 2025-10-28 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: anyway_config
|