tramway 4.0.1.2 → 4.0.1.4

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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +59 -16
  3. data/app/assets/builds/tailwind.css +1 -1
  4. data/app/assets/javascripts/tramway/tramway.js +1 -175
  5. data/app/assets/tailwind/application.css +1 -0
  6. data/app/components/tramway/containers/narrow_component.html.haml +1 -1
  7. data/app/components/tramway/containers/narrow_component.rb +1 -1
  8. data/app/components/tramway/nav/item/button_component.html.haml +4 -1
  9. data/app/components/tramway/nav/item/button_component.rb +2 -1
  10. data/app/components/tramway/nav/item/link_component.html.haml +4 -1
  11. data/app/components/tramway/nav/item/link_component.rb +4 -1
  12. data/app/components/tramway/nav/item_component.rb +10 -2
  13. data/app/components/tramway/navbar_component.html.haml +20 -11
  14. data/app/components/tramway/navbar_component.rb +5 -1
  15. data/app/components/tramway/pagination/first_page_component.html.haml +1 -6
  16. data/app/components/tramway/pagination/last_page_component.html.haml +1 -6
  17. data/app/components/tramway/pagination/next_page_component.html.haml +1 -1
  18. data/app/components/tramway/pagination/page_component.html.haml +1 -1
  19. data/app/components/tramway/pagination/prev_page_component.html.haml +1 -1
  20. data/app/components/tramway/table/cell_component.rb +5 -5
  21. data/app/components/tramway/table/grid_columns.rb +45 -0
  22. data/app/components/tramway/table/header_component.html.haml +1 -1
  23. data/app/components/tramway/table/header_component.rb +7 -6
  24. data/app/components/tramway/table/row_component.html.haml +3 -10
  25. data/app/components/tramway/table/row_component.rb +11 -9
  26. data/app/components/tramway/table_component.rb +2 -1
  27. data/app/views/tramway/entities/_list.html.haml +7 -3
  28. data/config/tailwind.config.js +17 -14
  29. data/lib/generators/tramway/install/install_generator.rb +2 -2
  30. data/lib/tramway/helpers/views_helper.rb +3 -3
  31. data/lib/tramway/navbar.rb +15 -7
  32. data/lib/tramway/version.rb +1 -1
  33. metadata +2 -3
  34. data/app/components/tramway/table/row/preview_component.html.haml +0 -34
  35. data/app/components/tramway/table/row/preview_component.rb +0 -23
@@ -7,10 +7,18 @@ module Tramway
7
7
  class ItemComponent < TailwindComponent
8
8
  def style
9
9
  @style ||= [
10
- 'tramway-navbar-item inline-flex items-center rounded-md px-4 py-3 text-base font-medium text-zinc-100',
11
- 'transition-colors hover:bg-zinc-800 hover:text-zinc-50 sm:px-3 sm:py-2 sm:text-sm'
10
+ 'tramway-navbar-item inline-flex items-center gap-2 rounded-md px-4 py-3 text-base font-medium',
11
+ 'text-zinc-100 transition-colors hover:bg-zinc-800 hover:text-zinc-50 sm:px-3 sm:py-2 sm:text-sm'
12
12
  ].join(' ')
13
13
  end
14
+
15
+ def icon?
16
+ @icon.present?
17
+ end
18
+
19
+ def icon_classes
20
+ [@icon, 'tramway-navbar-item-icon w-5 shrink-0 text-center'].join(' ')
21
+ end
14
22
  end
15
23
  end
16
24
  end
@@ -114,21 +114,16 @@
114
114
  })();
115
115
 
116
116
  :css
117
- .tramway-navbar-desktop-vertical .tramway-navbar-item {
118
- width: 100%;
119
- }
120
-
121
- .tramway-navbar-desktop-vertical .tramway-navbar-item > a,
122
- .tramway-navbar-desktop-vertical .tramway-navbar-item > form {
117
+ .tramway-navbar-desktop-vertical li.whitespace-nowrap {
123
118
  width: 100%;
124
119
  }
125
120
 
126
- .tramway-navbar-desktop-vertical .tramway-navbar-item > form {
121
+ .tramway-navbar-desktop-vertical li.whitespace-nowrap > form {
127
122
  display: block;
123
+ width: 100%;
128
124
  }
129
125
 
130
- .tramway-navbar-desktop-vertical .tramway-navbar-item > a,
131
- .tramway-navbar-desktop-vertical .tramway-navbar-item > form > button {
126
+ .tramway-navbar-desktop-vertical .tramway-navbar-item {
132
127
  width: 100%;
133
128
  justify-content: flex-start;
134
129
  }
@@ -142,12 +137,26 @@
142
137
  padding-left: 6rem;
143
138
  }
144
139
 
145
- html[data-tramway-navbar-expanded="false"] #desktop-navbar-header,
146
- html[data-tramway-navbar-expanded="false"] #desktop-navbar-content {
140
+ html[data-tramway-navbar-expanded="false"] #desktop-navbar-header {
147
141
  opacity: 0;
148
142
  pointer-events: none;
149
143
  }
150
144
 
145
+ html[data-tramway-navbar-expanded="false"] #desktop-navbar-content {
146
+ opacity: 1;
147
+ pointer-events: auto;
148
+ }
149
+
150
+ html[data-tramway-navbar-expanded="false"] #desktop-navbar-content .tramway-navbar-item-label {
151
+ display: none;
152
+ }
153
+
154
+ html[data-tramway-navbar-expanded="false"] #desktop-navbar-content .tramway-navbar-item {
155
+ justify-content: center;
156
+ padding-left: 0;
157
+ padding-right: 0;
158
+ }
159
+
151
160
  html[data-tramway-navbar-expanded="false"] #desktop-navbar-toggle-wrapper {
152
161
  justify-content: center;
153
162
  }
@@ -7,6 +7,10 @@ module Tramway
7
7
  bg-zinc-950 text-zinc-50
8
8
  ].freeze
9
9
 
10
+ NAVBAR_FIXED_CLASSES = %w[
11
+ fixed top-0 left-0 z-40 w-screen
12
+ ].freeze
13
+
10
14
  HORIZONTAL_NAVBAR_CLASSES = %w[
11
15
  flex items-center justify-between border-zinc-800 px-4 py-3 shadow-sm backdrop-blur sm:px-6
12
16
  ].freeze
@@ -40,7 +44,7 @@ module Tramway
40
44
  end
41
45
 
42
46
  def navbar_classes
43
- classes = NAVBAR_BASE_CLASSES.dup
47
+ classes = NAVBAR_BASE_CLASSES.dup + NAVBAR_FIXED_CLASSES
44
48
  classes.concat(HORIZONTAL_NAVBAR_CLASSES) if horizontal?
45
49
  classes.concat(VERTICAL_NAVBAR_CLASSES + VERTICAL_DESKTOP_NAVBAR_CLASSES) if vertical?
46
50
 
@@ -2,9 +2,4 @@
2
2
  = link_to helpers.t('views.pagination.first').html_safe,
3
3
  url,
4
4
  remote:,
5
- class: pagination_classes(klass: 'first hidden sm:flex')
6
-
7
- = link_to '⭰',
8
- url,
9
- remote:,
10
- class: pagination_classes(klass: 'first sm:hidden flex font-bold')
5
+ class: pagination_classes(klass: 'first max-sm:hidden')
@@ -2,9 +2,4 @@
2
2
  = link_to helpers.t('views.pagination.last').html_safe,
3
3
  url,
4
4
  remote:,
5
- class: pagination_classes(klass: 'last hidden sm:flex')
6
-
7
- = link_to '⭲',
8
- url,
9
- remote:,
10
- class: pagination_classes(klass: 'last sm:hidden flex font-bold')
5
+ class: pagination_classes(klass: 'last max-sm:hidden')
@@ -3,7 +3,7 @@
3
3
  url,
4
4
  rel: 'next',
5
5
  remote:,
6
- class: pagination_classes(klass: 'next hidden sm:flex')
6
+ class: pagination_classes(klass: 'next max-sm:hidden')
7
7
 
8
8
  = link_to '🠖',
9
9
  url,
@@ -6,4 +6,4 @@
6
6
  url,
7
7
  remote:,
8
8
  rel: page.rel,
9
- class: pagination_classes(klass: 'hidden sm:flex')
9
+ class: pagination_classes(klass: 'max-sm:hidden')
@@ -3,7 +3,7 @@
3
3
  url,
4
4
  rel: 'prev',
5
5
  remote:,
6
- class: pagination_classes(klass: 'prev hidden sm:flex')
6
+ class: pagination_classes(klass: 'prev max-sm:hidden')
7
7
 
8
8
  = link_to '🠔',
9
9
  url,
@@ -5,11 +5,11 @@ module Tramway
5
5
  # Component for rendering a cell in a table
6
6
  class CellComponent < Tramway::BaseComponent
7
7
  SIZE_CLASSES = {
8
- small: 'div-table-cell hidden bg-transparent px-4 py-2 text-sm font-medium text-zinc-100 first:block md:block',
9
- medium: 'div-table-cell hidden bg-transparent px-6 py-4 text-base font-medium ' \
10
- 'text-zinc-100 first:block md:block',
11
- large: 'div-table-cell hidden bg-transparent px-6 py-6 text-lg font-medium ' \
12
- 'text-zinc-100 first:block md:block'
8
+ small: 'div-table-cell truncate min-w-0 bg-transparent px-4 py-2 text-sm font-medium text-zinc-100',
9
+ medium: 'div-table-cell truncate min-w-0 bg-transparent px-6 py-4 text-base font-medium ' \
10
+ 'text-zinc-100',
11
+ large: 'div-table-cell truncate min-w-0 bg-transparent px-6 py-6 text-lg font-medium ' \
12
+ 'text-zinc-100'
13
13
  }.freeze
14
14
 
15
15
  option :options, optional: true, default: -> { {} }
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tramway
4
+ module Table
5
+ # Builds the CSS grid template used by table rows/headers so that every
6
+ # column keeps a minimum readable width. When the sum of those minimums
7
+ # exceeds the viewport, the table overflows its scroll container instead
8
+ # of hiding columns, giving mobile a full, horizontally scrollable table.
9
+ module GridColumns
10
+ MIN_COLUMN_WIDTHS = {
11
+ small: '8rem',
12
+ medium: '10rem',
13
+ large: '12rem'
14
+ }.freeze
15
+
16
+ # Matches the rem value of the row/header `gap-*` class for each size, so the
17
+ # computed min-width below accounts for the gaps between grid tracks.
18
+ GAP_WIDTHS_REM = {
19
+ small: 0.5,
20
+ medium: 1,
21
+ large: 1.5
22
+ }.freeze
23
+
24
+ private
25
+
26
+ # Column widths are set via an inline style (not a Tailwind class) because the class name
27
+ # would be built dynamically from the columns count, and Tailwind's build only generates
28
+ # utilities for class names it can find literally in the source.
29
+ #
30
+ # `min-width` is set to the full content width (all column minimums plus gaps) so that,
31
+ # once the row/header no longer fits its container, the row's own box grows to match —
32
+ # keeping its background and borders aligned with the horizontally scrolled columns
33
+ # instead of clipping at the container's width.
34
+ def grid_template_style(columns_count)
35
+ size = tramway_table_size
36
+ min_width = MIN_COLUMN_WIDTHS.fetch(size) { MIN_COLUMN_WIDTHS[:medium] }
37
+ gap_width = GAP_WIDTHS_REM.fetch(size) { GAP_WIDTHS_REM[:medium] }
38
+ total_min_width = (columns_count * min_width.to_f) + ([columns_count - 1, 0].max * gap_width)
39
+
40
+ "grid-template-columns: repeat(#{columns_count}, minmax(#{min_width}, 1fr)); " \
41
+ "min-width: #{total_min_width}rem"
42
+ end
43
+ end
44
+ end
45
+ end
@@ -1,5 +1,5 @@
1
1
  - parsed_cells = headers.any? ? nil : visible_cells_from(content)
2
- %div{ class: [options[:class], "#{header_row_classes} md:grid-cols-#{columns_count(parsed_cells: parsed_cells)}"].compact.join(' '), aria: { label: "Table Header" }, role: "row", **options.except(:class) }
2
+ %div{ class: [options[:class], header_row_classes].compact.join(' '), style: grid_template_style(columns_count(parsed_cells: parsed_cells)), aria: { label: "Table Header" }, role: "row", **options.except(:class) }
3
3
  - if headers.any?
4
4
  - headers.each do |header|
5
5
  .div-table-cell.border-b.border-zinc-800{ class: header_cell_classes }
@@ -5,19 +5,20 @@ module Tramway
5
5
  # Component for rendering a header in a table
6
6
  class HeaderComponent < Tramway::BaseComponent
7
7
  include ContentCells
8
+ include GridColumns
8
9
 
9
10
  SIZE_CLASSES = {
10
11
  small: {
11
- row: 'div-table-row grid grid-cols-1 gap-2 rounded-t-xl border-b border-zinc-800 bg-zinc-900 text-zinc-400',
12
- cell: 'div-table-cell hidden px-4 py-2 first:block md:block'
12
+ row: 'div-table-row grid gap-2 rounded-t-xl border-b border-zinc-800 bg-zinc-900 text-zinc-400',
13
+ cell: 'div-table-cell truncate min-w-0 px-4 py-2'
13
14
  },
14
15
  medium: {
15
- row: 'div-table-row grid grid-cols-1 gap-4 rounded-t-xl border-b border-zinc-800 bg-zinc-900 text-zinc-400',
16
- cell: 'div-table-cell hidden px-6 py-4 first:block md:block'
16
+ row: 'div-table-row grid gap-4 rounded-t-xl border-b border-zinc-800 bg-zinc-900 text-zinc-400',
17
+ cell: 'div-table-cell truncate min-w-0 px-6 py-4'
17
18
  },
18
19
  large: {
19
- row: 'div-table-row grid grid-cols-1 gap-6 rounded-t-xl border-b border-zinc-800 bg-zinc-900 text-zinc-400',
20
- cell: 'div-table-cell hidden px-6 py-6 first:block md:block'
20
+ row: 'div-table-row grid gap-6 rounded-t-xl border-b border-zinc-800 bg-zinc-900 text-zinc-400',
21
+ cell: 'div-table-cell truncate min-w-0 px-6 py-6'
21
22
  }
22
23
  }.freeze
23
24
 
@@ -1,5 +1,5 @@
1
1
  - if cells.any?
2
- = row_tag class: desktop_row_classes(cells.count), **options do
2
+ = row_tag class: row_grid_classes, style: grid_template_style(cells.count), **options.except(:class, :style) do
3
3
  - cells.each do |(_, value)|
4
4
  %div.border-b.border-zinc-800{ class: cell_classes }
5
5
  = value
@@ -8,15 +8,8 @@
8
8
  - cells = visible_cells_from(content)
9
9
 
10
10
  - if href.present?
11
- = tag.a href:, class: [desktop_row_classes(cells.count), link_row_classes, options[:class]].join(' '), **default_attributes, **options.except(:class) do
11
+ = tag.a href:, class: [row_grid_classes, link_row_classes, options[:class]].join(' '), style: grid_template_style(cells.count), **default_attributes, **options.except(:class, :style) do
12
12
  = content
13
13
  - else
14
- - if preview
15
- = component 'tramway/table/row/preview' do
16
- - cells.each_with_index do |cell, index|
17
- - next if index.zero?
18
-
19
- = cell.to_s.html_safe
20
-
21
- = tag.div class: [desktop_row_classes(cells.count), options[:class]].join(' '), data: { action: "click->table-row-preview#toggle", controller: "table-row-preview" }, **default_attributes, **options.except(:class) do
14
+ = tag.div class: [row_grid_classes, options[:class]].join(' '), style: grid_template_style(cells.count), **default_attributes, **options.except(:class, :style) do
22
15
  = content
@@ -5,25 +5,27 @@ module Tramway
5
5
  # Component for rendering a row in a table
6
6
  class RowComponent < Tramway::BaseComponent
7
7
  include ContentCells
8
+ include GridColumns
8
9
 
9
10
  SIZE_CLASSES = {
10
11
  small: {
11
- row: 'div-table-row grid grid-cols-1 gap-2 border-b border-zinc-800 bg-transparent last:border-b-0',
12
- cell: 'div-table-cell bg-transparent px-4 py-2 text-sm font-medium text-zinc-100 sm:text-sm'
12
+ row: 'div-table-row grid gap-2 border-b border-zinc-800 bg-transparent last:border-b-0',
13
+ cell: 'div-table-cell truncate min-w-0 bg-transparent px-4 py-2 text-sm font-medium ' \
14
+ 'text-zinc-100 sm:text-sm'
13
15
  },
14
16
  medium: {
15
- row: 'div-table-row grid grid-cols-1 gap-4 border-b border-zinc-800 bg-transparent last:border-b-0',
16
- cell: 'div-table-cell bg-transparent px-6 py-4 text-xs font-medium text-zinc-100 sm:text-base'
17
+ row: 'div-table-row grid gap-4 border-b border-zinc-800 bg-transparent last:border-b-0',
18
+ cell: 'div-table-cell truncate min-w-0 bg-transparent px-6 py-4 text-xs ' \
19
+ 'font-medium text-zinc-100 sm:text-base'
17
20
  },
18
21
  large: {
19
- row: 'div-table-row grid grid-cols-1 gap-6 border-b border-zinc-800 bg-transparent last:border-b-0',
20
- cell: 'div-table-cell bg-transparent px-6 py-6 text-lg font-medium text-zinc-100'
22
+ row: 'div-table-row grid gap-6 border-b border-zinc-800 bg-transparent last:border-b-0',
23
+ cell: 'div-table-cell truncate min-w-0 bg-transparent px-6 py-6 text-lg font-medium text-zinc-100'
21
24
  }
22
25
  }.freeze
23
26
 
24
27
  option :cells, optional: true, default: -> { [] }
25
28
  option :href, optional: true
26
- option :preview, optional: true, default: -> { true }
27
29
  option :options, optional: true, default: -> { {} }
28
30
 
29
31
  def default_attributes
@@ -42,8 +44,8 @@ module Tramway
42
44
  end
43
45
  end
44
46
 
45
- def desktop_row_classes(cells_count)
46
- "#{size_classes.fetch(:row)} md:grid-cols-#{cells_count}"
47
+ def row_grid_classes
48
+ size_classes.fetch(:row)
47
49
  end
48
50
 
49
51
  def link_row_classes
@@ -9,7 +9,8 @@ module Tramway
9
9
  option :options, optional: true, default: -> { {} }
10
10
 
11
11
  def table_classes
12
- 'div-table w-full bg-zinc-950 text-left rtl:text-right text-zinc-100'
12
+ 'div-table w-full max-w-full min-w-0 overflow-x-auto tramway-scrollbar bg-zinc-950 text-left rtl:text-right ' \
13
+ 'text-zinc-100'
13
14
  end
14
15
 
15
16
  def around_render
@@ -16,7 +16,9 @@
16
16
  path: Tramway::Engine.routes.url_helpers.public_send(@entity.routes.new),
17
17
  type: :will
18
18
 
19
- = decorator.constantize.index_header_content.call(@entities) if decorator.constantize.index_header_content.present?
19
+ - if decorator.constantize.index_header_content.present?
20
+ .mt-4
21
+ = decorator.constantize.index_header_content.call(@entities)
20
22
 
21
23
  .flex.flex-row.justify-end.mt-2.gap-4
22
24
  - if @entity.page(:index).search
@@ -37,5 +39,7 @@
37
39
  - @entities.each do |item|
38
40
  = component 'tramway/entity', entity: @entity, item: item
39
41
 
40
- .flex.mt-4
41
- = paginate @entities, custom_path_method:
42
+ .flex.flex-col.items-center.mt-4.gap-2
43
+ = paginate @entities, custom_path_method:
44
+ %p.sm:hidden.text-xs.text-zinc-500
45
+ = page_entries_info @entities
@@ -6,6 +6,9 @@ const buildUtilities = (prefix, start, end) =>
6
6
  module.exports = {
7
7
  safelist: [
8
8
  // === Navbar ===
9
+ 'w-5',
10
+ 'shrink-0',
11
+ 'text-center',
9
12
  'ml-4',
10
13
  'text-white',
11
14
  'md:flex',
@@ -21,6 +24,8 @@ module.exports = {
21
24
  'w-72',
22
25
  'z-50',
23
26
  'inset-0',
27
+ 'sticky',
28
+ 'left-0',
24
29
  'top-0',
25
30
  'top-4',
26
31
  'right-6',
@@ -51,6 +56,7 @@ module.exports = {
51
56
  'md:overflow-hidden',
52
57
  'md:pl-72',
53
58
  'md:pl-24',
59
+ 'md:pt-0',
54
60
  'transition-all',
55
61
  'ease-in-out',
56
62
  'md:transition-[width]',
@@ -246,8 +252,9 @@ module.exports = {
246
252
  'div-table-cell',
247
253
  'sm:text-base',
248
254
  'last:border-b-0',
249
- 'md:block',
250
- 'first:block',
255
+ 'overflow-x-auto',
256
+ 'truncate',
257
+ 'min-w-0',
251
258
  'rounded-t-xl',
252
259
  'border-zinc-800',
253
260
  'bg-zinc-950',
@@ -257,24 +264,17 @@ module.exports = {
257
264
  'hover:bg-zinc-900',
258
265
  'border-b',
259
266
  'border-r',
260
- 'grid-cols-1',
267
+ 'gap-2',
261
268
  'gap-4',
269
+ 'gap-6',
270
+ 'px-4',
262
271
  'px-6',
272
+ 'py-2',
263
273
  'py-4',
274
+ 'py-6',
264
275
  'font-medium',
265
276
  'w-full',
266
277
 
267
- // === Table row preview panel ===
268
- 'bottom-0',
269
- 'left-0',
270
- 'right-0',
271
- 'h-1/2',
272
- 'bg-gray-100',
273
- 'animate-roll-up',
274
- 'hover:text-gray-700',
275
- 'pt-4',
276
- 'md:hidden',
277
-
278
278
  // === Title Component ===
279
279
  'md:text-4xl',
280
280
 
@@ -373,6 +373,7 @@ module.exports = {
373
373
  'align-center',
374
374
  'justify-center',
375
375
  'min-h-dvh',
376
+ 'min-w-full',
376
377
  'bg-zinc-950',
377
378
  'text-zinc-50',
378
379
 
@@ -392,6 +393,7 @@ module.exports = {
392
393
  // === Responsive visibility helpers ===
393
394
  'sm:hidden',
394
395
  'sm:flex',
396
+ 'max-sm:hidden',
395
397
 
396
398
  // === Sizing utilities ===
397
399
  'w-full',
@@ -417,6 +419,7 @@ module.exports = {
417
419
  'mb-4',
418
420
  'mb-2',
419
421
  'mt-8',
422
+ 'mt-4',
420
423
  'mt-2',
421
424
 
422
425
  // === Pagination styles ===
@@ -19,6 +19,7 @@ module Tramway
19
19
 
20
20
  .tramway-scrollbar::-webkit-scrollbar {
21
21
  width: 0.5rem;
22
+ height: 0.5rem;
22
23
  }
23
24
 
24
25
  .tramway-scrollbar::-webkit-scrollbar-track {
@@ -114,7 +115,7 @@ module Tramway
114
115
 
115
116
  def stimulus_controller_imports
116
117
  [
117
- 'import { Navbar, TramwaySelect, TableRowPreview, UiCheckbox, Tooltip } from "@tramway/tramway"'
118
+ 'import { Navbar, TramwaySelect, UiCheckbox, Tooltip } from "@tramway/tramway"'
118
119
  ]
119
120
  end
120
121
 
@@ -122,7 +123,6 @@ module Tramway
122
123
  [
123
124
  "application.register('tramway-navbar', Navbar)",
124
125
  "application.register('tramway-select', TramwaySelect)",
125
- "application.register('table-row-preview', TableRowPreview)",
126
126
  "application.register('ui--checkbox', UiCheckbox)",
127
127
  "application.register('tramway-tooltip', Tooltip)"
128
128
  ]
@@ -46,7 +46,6 @@ module Tramway
46
46
  component 'tramway/table/row',
47
47
  cells: options.delete(:cells),
48
48
  href: options.delete(:href),
49
- preview: options.delete(:preview),
50
49
  options:,
51
50
  &
52
51
  end
@@ -121,8 +120,9 @@ module Tramway
121
120
 
122
121
  return classes.join(' ') if @tramway_navbar_direction.nil?
123
122
 
124
- classes = classes.reject { _1.start_with?('md:pl-') || _1.start_with?('md:pr-') }
125
- classes << 'md:pl-72' if @tramway_navbar_direction == :vertical
123
+ classes = classes.reject { _1.start_with?('md:pl-') || _1.start_with?('md:pr-') || _1 == 'pt-16' }
124
+ classes << 'pt-16'
125
+ classes << 'md:pl-72' << 'md:pt-0' if @tramway_navbar_direction == :vertical
126
126
 
127
127
  classes.join(' ')
128
128
  end
@@ -35,13 +35,13 @@ module Tramway
35
35
  reset_filling
36
36
  end
37
37
 
38
- def item(text_or_url, url = nil, **, &)
38
+ def item(text_or_url, url = nil, icon: nil, **, &)
39
39
  raise 'You cannot provide an argument and a code block at the same time' if provided_url_and_block?(url, &)
40
40
 
41
41
  if url.present?
42
- render_ignoring_block(text_or_url, url, **)
42
+ render_ignoring_block(text_or_url, url, icon:, **)
43
43
  else
44
- render_using_block(text_or_url, **, &)
44
+ render_using_block(text_or_url, icon:, **, &)
45
45
  end => rendered_item
46
46
 
47
47
  @items[@filling] << rendered_item
@@ -73,8 +73,9 @@ module Tramway
73
73
  @filling = nil
74
74
  end
75
75
 
76
- def render_ignoring_block(text_or_url, url, method: nil, **options)
77
- options.merge!(href: url)
76
+ def render_ignoring_block(text_or_url, url, method: nil, icon: nil, **options)
77
+ options.merge!(href: url, icon:)
78
+ apply_icon_accessibility_attributes(options, label: text_or_url, icon:)
78
79
 
79
80
  if method.present? && method.to_sym != :get
80
81
  context.render(Tramway::Nav::Item::ButtonComponent.new(method:, **options)) { text_or_url }
@@ -83,8 +84,8 @@ module Tramway
83
84
  end
84
85
  end
85
86
 
86
- def render_using_block(text_or_url, method: nil, **options, &)
87
- options.merge!(href: text_or_url)
87
+ def render_using_block(text_or_url, method: nil, icon: nil, **options, &)
88
+ options.merge!(href: text_or_url, icon:)
88
89
 
89
90
  if method.present? && method.to_sym != :get
90
91
  context.render(Tramway::Nav::Item::ButtonComponent.new(method:, **options), &)
@@ -92,5 +93,12 @@ module Tramway
92
93
  context.render(Tramway::Nav::Item::LinkComponent.new(method:, **options), &)
93
94
  end
94
95
  end
96
+
97
+ def apply_icon_accessibility_attributes(options, label:, icon:)
98
+ return if icon.blank?
99
+
100
+ options[:title] = label if options[:title].blank?
101
+ options[:'aria-label'] = label if options[:'aria-label'].blank?
102
+ end
95
103
  end
96
104
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tramway
4
- VERSION = '4.0.1.2'
4
+ VERSION = '4.0.1.4'
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: 4.0.1.2
4
+ version: 4.0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - kalashnikovisme
@@ -267,10 +267,9 @@ files:
267
267
  - app/components/tramway/table/cell_component.html.haml
268
268
  - app/components/tramway/table/cell_component.rb
269
269
  - app/components/tramway/table/content_cells.rb
270
+ - app/components/tramway/table/grid_columns.rb
270
271
  - app/components/tramway/table/header_component.html.haml
271
272
  - app/components/tramway/table/header_component.rb
272
- - app/components/tramway/table/row/preview_component.html.haml
273
- - app/components/tramway/table/row/preview_component.rb
274
273
  - app/components/tramway/table/row_component.html.haml
275
274
  - app/components/tramway/table/row_component.rb
276
275
  - app/components/tramway/table_component.html.haml
@@ -1,34 +0,0 @@
1
- :css
2
- @keyframes roll-up {
3
- 0% {
4
- transform: translateY(100%);
5
- }
6
-
7
- 100% {
8
- transform: translateY(0%);
9
- }
10
- }
11
-
12
- .animate-roll-up {
13
- animation: roll-up 0.5s ease-in-out;
14
- }
15
-
16
- @keyframes roll-down {
17
- 0% {
18
- transform: translateY(0%);
19
- }
20
-
21
- 100% {
22
- transform: translateY(100%);
23
- }
24
- }
25
-
26
- .animate-roll-down {
27
- animation: roll-down 0.5s ease-in-out;
28
- }
29
-
30
- #roll-up{ class: preview_classes, data: { controller: 'table-row-preview' } }
31
- %button{ class: close_button_classes, "data-action" => "click->table-row-preview#close" }
32
- &#x2715;
33
-
34
- = content
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Tramway
4
- module Table
5
- module Row
6
- # Row component for rendering a row in a table
7
- class PreviewComponent < Tramway::BaseComponent
8
- def preview_classes
9
- theme_classes(
10
- classic: 'fixed hidden md:hidden bottom-0 left-0 right-0 w-screen shadow-lg z-50 bg-gray-900 ' \
11
- 'animate-roll-up h-1/2 pt-4'
12
- )
13
- end
14
-
15
- def close_button_classes
16
- theme_classes(
17
- classic: 'absolute top-4 right-4 text-gray-500 hover:text-gray-700'
18
- )
19
- end
20
- end
21
- end
22
- end
23
- end