tramway 3.0.4.2 → 3.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 +4 -4
- data/README.md +20 -9
- data/app/assets/javascripts/tramway/ui_checkbox_controller.js +36 -0
- data/app/components/tailwind_component.rb +21 -24
- data/app/components/tramway/button_component.rb +33 -21
- data/app/components/tramway/chat_component.html.haml +6 -6
- data/app/components/tramway/chats/message_component.html.haml +2 -2
- data/app/components/tramway/chats/message_component.rb +2 -2
- data/app/components/tramway/chats/messages/container_component.html.haml +3 -3
- data/app/components/tramway/chats/messages/container_component.rb +4 -9
- data/app/components/tramway/chats/messages/table_component.html.haml +1 -1
- data/app/components/tramway/colors_methods.rb +3 -3
- data/app/components/tramway/containers/main_component.rb +1 -1
- data/app/components/tramway/containers/narrow_component.rb +2 -2
- data/app/components/tramway/flash_component.html.haml +0 -1
- data/app/components/tramway/flash_component.rb +25 -10
- data/app/components/tramway/form/builder.rb +1 -1
- data/app/components/tramway/form/checkbox_component.html.haml +26 -4
- data/app/components/tramway/form/checkbox_component.rb +32 -1
- data/app/components/tramway/form/label_component.html.haml +1 -1
- data/app/components/tramway/form/label_component.rb +2 -3
- data/app/components/tramway/form/tramway_select/dropdown_container_component.rb +2 -5
- data/app/components/tramway/form/tramway_select/item_container_component.rb +1 -3
- data/app/components/tramway/form/tramway_select/select_as_input_component.rb +1 -4
- data/app/components/tramway/form/tramway_select/selected_item_template_component.rb +4 -4
- data/app/components/tramway/nav/item_component.rb +2 -5
- data/app/components/tramway/navbar_component.html.haml +6 -6
- data/app/components/tramway/navbar_component.rb +19 -15
- data/app/components/tramway/pagination/base.rb +6 -6
- data/app/components/tramway/pagination/gap_component.rb +1 -3
- data/app/components/tramway/pagination/page_component.rb +2 -3
- data/app/components/tramway/table/cell_component.rb +1 -3
- data/app/components/tramway/table/header_component.html.haml +1 -1
- data/app/components/tramway/table/header_component.rb +2 -4
- data/app/components/tramway/table/row_component.html.haml +1 -1
- data/app/components/tramway/table/row_component.rb +7 -12
- data/app/components/tramway/table_component.rb +1 -3
- data/app/views/tramway/entities/_form.html.haml +1 -2
- data/app/views/tramway/layouts/application.html.haml +1 -1
- data/config/tailwind.config.js +278 -70
- data/lib/generators/tramway/install/install_generator.rb +44 -4
- data/lib/tramway/engine.rb +1 -1
- data/lib/tramway/version.rb +1 -1
- metadata +2 -1
|
@@ -15,13 +15,13 @@ module Tramway
|
|
|
15
15
|
}.freeze
|
|
16
16
|
|
|
17
17
|
def selected_item_classes
|
|
18
|
-
classes = 'flex justify-center items-center font-medium py-1 px-2 rounded-
|
|
19
|
-
'text-
|
|
18
|
+
classes = 'flex justify-center items-center font-medium py-1 px-2 rounded-md ' \
|
|
19
|
+
'bg-zinc-900 text-zinc-50 shadow-sm hover:bg-zinc-800 cursor-pointer ' \
|
|
20
20
|
'space-x-1 selected-option ' + SIZE_CLASSES[size].to_s
|
|
21
21
|
|
|
22
|
-
classes += ' border border-
|
|
22
|
+
classes += ' border border-zinc-800' if multiple
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
classes
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
end
|
|
@@ -6,11 +6,8 @@ module Tramway
|
|
|
6
6
|
#
|
|
7
7
|
class ItemComponent < TailwindComponent
|
|
8
8
|
def style
|
|
9
|
-
@style ||=
|
|
10
|
-
|
|
11
|
-
classic: 'px-4 py-2 rounded-xl whitespace-nowrap hover:bg-gray-800 hover:text-gray-300 text-white'
|
|
12
|
-
)
|
|
13
|
-
].join(' ')
|
|
9
|
+
@style ||= 'inline-flex items-center rounded-md px-3 py-2 text-sm font-medium text-zinc-100 ' \
|
|
10
|
+
'transition-colors hover:bg-zinc-800 hover:text-zinc-50'
|
|
14
11
|
end
|
|
15
12
|
end
|
|
16
13
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
%nav{ class: navbar_classes }
|
|
1
|
+
%nav.bg-zinc-950.text-zinc-50{ class: navbar_classes }
|
|
2
2
|
.flex.md:justify-between.w-full.items-center.relative.min-h-8
|
|
3
|
-
.block.sm:hidden
|
|
3
|
+
.block.sm:hidden
|
|
4
4
|
%button#mobile-menu-button{ class: mobile_button_classes }
|
|
5
5
|
☰
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
.flex.items-center.absolute.transform{ class: 'left-1/2 -translate-x-1/2 md:left-auto md:translate-x-0' }
|
|
9
9
|
- if @title[:text].present?
|
|
10
10
|
= link_to @title[:link] do
|
|
11
|
-
.
|
|
11
|
+
.truncate{ class: title_classes }
|
|
12
12
|
= @title[:text]
|
|
13
13
|
- if @left_items.present?
|
|
14
14
|
%ul.flex-row.items-center.space-x-4.ml-4.hidden.md:flex
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
|
|
23
23
|
#mobile-menu{ class: mobile_menu_classes }
|
|
24
24
|
- if @left_items.present?
|
|
25
|
-
%ul.flex.flex-col.space-y-
|
|
25
|
+
%ul.flex.flex-col.space-y-1.pt-4
|
|
26
26
|
- @left_items.each do |item|
|
|
27
27
|
= item
|
|
28
28
|
|
|
29
29
|
- if @right_items.present?
|
|
30
|
-
%ul.flex.flex-col.space-y-
|
|
30
|
+
%ul.flex.flex-col.space-y-1.pt-4
|
|
31
31
|
- @right_items.each do |item|
|
|
32
32
|
= item
|
|
33
33
|
|
|
34
|
-
%button.absolute.top-4.right-
|
|
34
|
+
%button.absolute.top-4.right-4.inline-flex.items-center.justify-center.rounded-md.p-2.text-zinc-50.transition-colors.hover:bg-zinc-800.hover:text-zinc-50.focus:outline-none.focus-visible:ring-2.focus-visible:ring-zinc-400.focus-visible:ring-offset-2.focus-visible:ring-offset-zinc-950#mobile-menu-close-button{ role: :button }
|
|
35
35
|
⨯
|
|
36
36
|
|
|
37
37
|
:javascript
|
|
@@ -3,6 +3,21 @@
|
|
|
3
3
|
module Tramway
|
|
4
4
|
# Navbar component
|
|
5
5
|
class NavbarComponent < TailwindComponent
|
|
6
|
+
NAVBAR_CLASSES = %w[
|
|
7
|
+
flex items-center justify-between border-zinc-800 px-4 py-3 shadow-sm backdrop-blur sm:px-6
|
|
8
|
+
].freeze
|
|
9
|
+
|
|
10
|
+
MOBILE_BUTTON_CLASSES = %w[
|
|
11
|
+
inline-flex items-center justify-center rounded-md p-2 transition-colors hover:bg-zinc-800 hover:text-zinc-50
|
|
12
|
+
focus:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400 focus-visible:ring-offset-2
|
|
13
|
+
focus-visible:ring-offset-zinc-950
|
|
14
|
+
].freeze
|
|
15
|
+
|
|
16
|
+
MOBILE_MENU_CLASSES = %w[
|
|
17
|
+
fixed inset-0 z-50 hidden h-screen w-screen flex-col border-r border-zinc-800 bg-zinc-950 px-4 py-6 shadow-lg
|
|
18
|
+
transition-transform transform -translate-x-full duration-300 ease-in-out pt-16
|
|
19
|
+
].freeze
|
|
20
|
+
|
|
6
21
|
def initialize(**options)
|
|
7
22
|
@title = { text: options[:title], link: options[:title_link] || '/' }
|
|
8
23
|
@left_items = options[:left_items]
|
|
@@ -10,30 +25,19 @@ module Tramway
|
|
|
10
25
|
end
|
|
11
26
|
|
|
12
27
|
def navbar_classes
|
|
13
|
-
|
|
14
|
-
classic: 'py-2 px-4 sm:px-8 flex justify-between items-center bg-gray-900 shadow-md'
|
|
15
|
-
)
|
|
28
|
+
NAVBAR_CLASSES.join(' ')
|
|
16
29
|
end
|
|
17
30
|
|
|
18
31
|
def title_classes
|
|
19
|
-
|
|
20
|
-
classic: 'text-xl font-semibold text-gray-100'
|
|
21
|
-
)
|
|
32
|
+
'text-base font-semibold text-zinc-50'
|
|
22
33
|
end
|
|
23
34
|
|
|
24
35
|
def mobile_button_classes
|
|
25
|
-
|
|
26
|
-
classic: 'text-gray-200 focus:outline-none'
|
|
27
|
-
)
|
|
36
|
+
MOBILE_BUTTON_CLASSES.join(' ')
|
|
28
37
|
end
|
|
29
38
|
|
|
30
39
|
def mobile_menu_classes
|
|
31
|
-
|
|
32
|
-
classic: [
|
|
33
|
-
'hidden', 'inset-0', 'flex-col', 'bg-gray-900', 'shadow-inner', 'h-screen', 'fixed', 'z-50', 'w-screen',
|
|
34
|
-
'transition-transform', 'transform', '-translate-x-full', 'duration-300', 'ease-in-out', 'pt-16'
|
|
35
|
-
].join(' ')
|
|
36
|
-
)
|
|
40
|
+
MOBILE_MENU_CLASSES.join(' ')
|
|
37
41
|
end
|
|
38
42
|
end
|
|
39
43
|
end
|
|
@@ -9,12 +9,12 @@ module Tramway
|
|
|
9
9
|
option :remote
|
|
10
10
|
|
|
11
11
|
def pagination_classes(klass: nil)
|
|
12
|
-
default_classes =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
default_classes = %w[
|
|
13
|
+
inline-flex items-center justify-center h-10 px-3 py-2 rounded-md border border-zinc-800
|
|
14
|
+
bg-zinc-950 text-sm font-medium text-zinc-100 shadow-sm transition-colors hover:bg-zinc-800
|
|
15
|
+
hover:text-zinc-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400
|
|
16
|
+
focus-visible:ring-offset-2 focus-visible:ring-offset-zinc-950
|
|
17
|
+
]
|
|
18
18
|
|
|
19
19
|
(default_classes + [klass]).join(' ')
|
|
20
20
|
end
|
|
@@ -5,9 +5,7 @@ module Tramway
|
|
|
5
5
|
# Kaminari gap component for rendering a gap in a pagination
|
|
6
6
|
class GapComponent < Tramway::BaseComponent
|
|
7
7
|
def gap_classes
|
|
8
|
-
|
|
9
|
-
classic: 'page gap px-3 py-2 text-sm font-medium text-gray-400 sm:flex hidden'
|
|
10
|
-
)
|
|
8
|
+
'page gap hidden items-center justify-center px-3 py-2 text-sm font-medium text-zinc-500 sm:flex'
|
|
11
9
|
end
|
|
12
10
|
end
|
|
13
11
|
end
|
|
@@ -7,9 +7,8 @@ module Tramway
|
|
|
7
7
|
option :page
|
|
8
8
|
|
|
9
9
|
def current_page_classes
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
)
|
|
10
|
+
'inline-flex h-10 items-center justify-center rounded-md border border-zinc-800 bg-zinc-800 px-3 py-2 ' \
|
|
11
|
+
'text-sm font-medium text-zinc-50 shadow-inner'
|
|
13
12
|
end
|
|
14
13
|
end
|
|
15
14
|
end
|
|
@@ -5,9 +5,7 @@ module Tramway
|
|
|
5
5
|
# Component for rendering a cell in a table
|
|
6
6
|
class CellComponent < Tramway::BaseComponent
|
|
7
7
|
def cell_classes
|
|
8
|
-
|
|
9
|
-
classic: 'div-table-cell md:block first:block hidden px-6 py-4 font-medium text-gray-100 text-base'
|
|
10
|
-
)
|
|
8
|
+
'div-table-cell hidden px-6 py-4 text-base font-medium text-zinc-100 first:block md:block'
|
|
11
9
|
end
|
|
12
10
|
end
|
|
13
11
|
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
%div{ class: "#{header_row_classes} md:grid-cols-#{columns_count(parsed_cells: parsed_cells)}", aria: { label: "Table Header" }, role: "row" }
|
|
3
3
|
- if headers.any?
|
|
4
4
|
- headers.each do |header|
|
|
5
|
-
.div-table-cell{ class: header_cell_classes }
|
|
5
|
+
.div-table-cell.border-b.border-zinc-800{ class: header_cell_classes }
|
|
6
6
|
= header
|
|
7
7
|
- else
|
|
8
8
|
= content
|
|
@@ -18,13 +18,11 @@ module Tramway
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def header_row_classes
|
|
21
|
-
|
|
22
|
-
classic: 'div-table-row rounded-t-xl grid text-small gap-4 bg-gray-800 text-gray-500 grid-cols-1'
|
|
23
|
-
)
|
|
21
|
+
'div-table-row grid grid-cols-1 gap-4 rounded-t-xl border-b border-zinc-800 bg-zinc-900 text-zinc-400'
|
|
24
22
|
end
|
|
25
23
|
|
|
26
24
|
def header_cell_classes
|
|
27
|
-
'div-table-cell
|
|
25
|
+
'div-table-cell hidden px-6 py-4 first:block md:block'
|
|
28
26
|
end
|
|
29
27
|
end
|
|
30
28
|
end
|
|
@@ -6,6 +6,10 @@ module Tramway
|
|
|
6
6
|
class RowComponent < Tramway::BaseComponent
|
|
7
7
|
include ContentCells
|
|
8
8
|
|
|
9
|
+
DESKTOP_ROW_CLASSES = %w[
|
|
10
|
+
div-table-row grid grid-cols-1 gap-4 border-b border-zinc-800 bg-zinc-950 last:border-b-0
|
|
11
|
+
].freeze
|
|
12
|
+
|
|
9
13
|
option :cells, optional: true, default: -> { [] }
|
|
10
14
|
option :href, optional: true
|
|
11
15
|
option :preview, optional: true, default: -> { true }
|
|
@@ -28,24 +32,15 @@ module Tramway
|
|
|
28
32
|
end
|
|
29
33
|
|
|
30
34
|
def desktop_row_classes(cells_count)
|
|
31
|
-
|
|
32
|
-
classic: [
|
|
33
|
-
'div-table-row', 'grid', 'gap-4', 'border-b', 'last:border-b-0', 'bg-gray-900',
|
|
34
|
-
'border-gray-700', "md:grid-cols-#{cells_count}", 'grid-cols-1'
|
|
35
|
-
]
|
|
36
|
-
).join(' ')
|
|
35
|
+
(DESKTOP_ROW_CLASSES + ["md:grid-cols-#{cells_count}"]).join(' ')
|
|
37
36
|
end
|
|
38
37
|
|
|
39
38
|
def link_row_classes
|
|
40
|
-
|
|
41
|
-
classic: 'cursor-pointer hover:bg-gray-800'
|
|
42
|
-
)
|
|
39
|
+
'cursor-pointer hover:bg-zinc-900'
|
|
43
40
|
end
|
|
44
41
|
|
|
45
42
|
def cell_classes
|
|
46
|
-
|
|
47
|
-
classic: 'div-table-cell px-6 py-4 font-medium text-gray-100 text-xs sm:text-base'
|
|
48
|
-
)
|
|
43
|
+
'div-table-cell px-6 py-4 text-xs font-medium text-zinc-100 sm:text-base'
|
|
49
44
|
end
|
|
50
45
|
|
|
51
46
|
def around_render
|