railsboot 0.1.0

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 (102) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +45 -0
  4. data/Rakefile +14 -0
  5. data/app/assets/config/railsboot_manifest.js +1 -0
  6. data/app/assets/stylesheets/railsboot/application.css +15 -0
  7. data/app/components/railsboot/accordion/item_component.html.erb +10 -0
  8. data/app/components/railsboot/accordion/item_component.rb +21 -0
  9. data/app/components/railsboot/accordion_component.html.erb +5 -0
  10. data/app/components/railsboot/accordion_component.rb +15 -0
  11. data/app/components/railsboot/alert_component.html.erb +4 -0
  12. data/app/components/railsboot/alert_component.rb +21 -0
  13. data/app/components/railsboot/badge_component.html.erb +3 -0
  14. data/app/components/railsboot/badge_component.rb +15 -0
  15. data/app/components/railsboot/base_component.html.erb +3 -0
  16. data/app/components/railsboot/base_component.rb +6 -0
  17. data/app/components/railsboot/breadcrumb/item_component.html.erb +11 -0
  18. data/app/components/railsboot/breadcrumb/item_component.rb +21 -0
  19. data/app/components/railsboot/breadcrumb_component.html.erb +7 -0
  20. data/app/components/railsboot/breadcrumb_component.rb +25 -0
  21. data/app/components/railsboot/button/button_component.rb +5 -0
  22. data/app/components/railsboot/button/input_component.rb +5 -0
  23. data/app/components/railsboot/button/link_component.rb +5 -0
  24. data/app/components/railsboot/button_component.html.erb +21 -0
  25. data/app/components/railsboot/button_component.rb +49 -0
  26. data/app/components/railsboot/button_group_component.html.erb +3 -0
  27. data/app/components/railsboot/button_group_component.rb +24 -0
  28. data/app/components/railsboot/card/body_component.rb +14 -0
  29. data/app/components/railsboot/card/footer_component.rb +14 -0
  30. data/app/components/railsboot/card/header_component.rb +14 -0
  31. data/app/components/railsboot/card_component.html.erb +11 -0
  32. data/app/components/railsboot/card_component.rb +17 -0
  33. data/app/components/railsboot/carousel/item_component.html.erb +3 -0
  34. data/app/components/railsboot/carousel/item_component.rb +14 -0
  35. data/app/components/railsboot/carousel_component.html.erb +15 -0
  36. data/app/components/railsboot/carousel_component.rb +14 -0
  37. data/app/components/railsboot/close_button_component.html.erb +1 -0
  38. data/app/components/railsboot/close_button_component.rb +18 -0
  39. data/app/components/railsboot/component.rb +23 -0
  40. data/app/components/railsboot/dropdown/action_component.html.erb +5 -0
  41. data/app/components/railsboot/dropdown/action_component.rb +31 -0
  42. data/app/components/railsboot/dropdown/divider_component.html.erb +3 -0
  43. data/app/components/railsboot/dropdown/divider_component.rb +10 -0
  44. data/app/components/railsboot/dropdown/header_component.html.erb +3 -0
  45. data/app/components/railsboot/dropdown/header_component.rb +11 -0
  46. data/app/components/railsboot/dropdown/link_component.html.erb +3 -0
  47. data/app/components/railsboot/dropdown/link_component.rb +23 -0
  48. data/app/components/railsboot/dropdown_component.html.erb +9 -0
  49. data/app/components/railsboot/dropdown_component.rb +18 -0
  50. data/app/components/railsboot/heading_component.html.erb +3 -0
  51. data/app/components/railsboot/heading_component.rb +21 -0
  52. data/app/components/railsboot/list_group/item_component.rb +28 -0
  53. data/app/components/railsboot/list_group_component.html.erb +5 -0
  54. data/app/components/railsboot/list_group_component.rb +14 -0
  55. data/app/components/railsboot/modal/body_component.rb +14 -0
  56. data/app/components/railsboot/modal/footer_component.rb +14 -0
  57. data/app/components/railsboot/modal/header_component.html.erb +4 -0
  58. data/app/components/railsboot/modal/header_component.rb +10 -0
  59. data/app/components/railsboot/modal_component.html.erb +9 -0
  60. data/app/components/railsboot/modal_component.rb +27 -0
  61. data/app/components/railsboot/nav/item_component.html.erb +19 -0
  62. data/app/components/railsboot/nav/item_component.rb +32 -0
  63. data/app/components/railsboot/nav_component.html.erb +5 -0
  64. data/app/components/railsboot/nav_component.rb +23 -0
  65. data/app/components/railsboot/navbar/brand_component.rb +16 -0
  66. data/app/components/railsboot/navbar/nav_component.html.erb +5 -0
  67. data/app/components/railsboot/navbar/nav_component.rb +14 -0
  68. data/app/components/railsboot/navbar/toggler_component.html.erb +3 -0
  69. data/app/components/railsboot/navbar/toggler_component.rb +22 -0
  70. data/app/components/railsboot/navbar_component.html.erb +3 -0
  71. data/app/components/railsboot/navbar_component.rb +15 -0
  72. data/app/components/railsboot/offcanvas/body_component.rb +15 -0
  73. data/app/components/railsboot/offcanvas/header_component.html.erb +5 -0
  74. data/app/components/railsboot/offcanvas/header_component.rb +11 -0
  75. data/app/components/railsboot/offcanvas_component.html.erb +4 -0
  76. data/app/components/railsboot/offcanvas_component.rb +25 -0
  77. data/app/components/railsboot/pagination_component.html.erb +1 -0
  78. data/app/components/railsboot/pagination_component.rb +9 -0
  79. data/app/components/railsboot/progress_component.html.erb +3 -0
  80. data/app/components/railsboot/progress_component.rb +34 -0
  81. data/app/components/railsboot/spinner_component.html.erb +3 -0
  82. data/app/components/railsboot/spinner_component.rb +23 -0
  83. data/app/components/railsboot/table/body_component.html.erb +9 -0
  84. data/app/components/railsboot/table/body_component.rb +7 -0
  85. data/app/components/railsboot/table/cell_component.rb +13 -0
  86. data/app/components/railsboot/table/head_component.html.erb +9 -0
  87. data/app/components/railsboot/table/head_component.rb +7 -0
  88. data/app/components/railsboot/table/row_component.html.erb +9 -0
  89. data/app/components/railsboot/table/row_component.rb +7 -0
  90. data/app/components/railsboot/table_component.html.erb +9 -0
  91. data/app/components/railsboot/table_component.rb +14 -0
  92. data/app/components/railsboot/toast/body_component.rb +15 -0
  93. data/app/components/railsboot/toast/header_component.rb +17 -0
  94. data/app/components/railsboot/toast_component.html.erb +4 -0
  95. data/app/components/railsboot/toast_component.rb +21 -0
  96. data/app/helpers/railsboot/view_components_helper.rb +34 -0
  97. data/config/routes.rb +2 -0
  98. data/lib/railsboot/engine.rb +20 -0
  99. data/lib/railsboot/version.rb +3 -0
  100. data/lib/railsboot.rb +9 -0
  101. data/lib/tasks/railsboot_tasks.rake +4 -0
  102. metadata +196 -0
@@ -0,0 +1,3 @@
1
+ <%= content_tag :li, **@html_attributes do %>
2
+ <h6><%= @text %></h6>
3
+ <% end %>
@@ -0,0 +1,11 @@
1
+ class Railsboot::Dropdown::HeaderComponent < Railsboot::Component
2
+ def initialize(text: "", **html_attributes)
3
+ @text = text
4
+ @html_attributes = html_attributes
5
+
6
+ @html_attributes[:class] = class_names(
7
+ "dropdown-header",
8
+ html_attributes.delete(:class)
9
+ )
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ <%= content_tag :li do %>
2
+ <%= link_to @text, @href, **@html_attributes %>
3
+ <% end %>
@@ -0,0 +1,23 @@
1
+ class Railsboot::Dropdown::LinkComponent < Railsboot::Component
2
+ def initialize(text: "", href: "", active: false, disabled: false, **html_attributes)
3
+ @text = text
4
+ @href = href
5
+ @active = active
6
+ @disabled = disabled
7
+ @html_attributes = html_attributes
8
+
9
+ @html_attributes[:class] = class_names(
10
+ "dropdown-item",
11
+ {"active" => @active},
12
+ {"disabled" => @disabled},
13
+ html_attributes.delete(:class)
14
+ )
15
+ end
16
+
17
+ private
18
+
19
+ def before_render
20
+ @html_attributes["aria-current"] = "true" if @active
21
+ @html_attributes["aria-disabled"] = "true" if @disabled
22
+ end
23
+ end
@@ -0,0 +1,9 @@
1
+ <%= content_tag :div, **@html_attributes do %>
2
+ <%= action %>
3
+
4
+ <ul class="dropdown-menu">
5
+ <% items.each do |item| %>
6
+ <%= item %>
7
+ <% end %>
8
+ </ul>
9
+ <% end %>
@@ -0,0 +1,18 @@
1
+ class Railsboot::DropdownComponent < Railsboot::Component
2
+ renders_one :action, Railsboot::Dropdown::ActionComponent
3
+
4
+ renders_many :items, types: {
5
+ link: {renders: Railsboot::Dropdown::LinkComponent, as: :link},
6
+ divider: {renders: Railsboot::Dropdown::DividerComponent, as: :divider},
7
+ header: {renders: Railsboot::Dropdown::HeaderComponent, as: :header}
8
+ }
9
+
10
+ def initialize(**html_attributes)
11
+ @html_attributes = html_attributes
12
+
13
+ @html_attributes[:class] = class_names(
14
+ "dropdown",
15
+ html_attributes.delete(:class)
16
+ )
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ <%= render Railsboot::BaseComponent.new(**@html_attributes) do %>
2
+ <%= content %>
3
+ <% end %>
@@ -0,0 +1,21 @@
1
+ class Railsboot::HeadingComponent < Railsboot::Component
2
+ TAGS = ["h1", "h2", "h3", "h4", "h5", "h6", "div", "span"].freeze
3
+ DEFAULT_TAG = "h1".freeze
4
+
5
+ SIZES = ["h1", "h2", "h3", "h4", "h5", "h6"].freeze
6
+ DISPLAYS = ["1", "2", "3", "4", "5", "6"].freeze
7
+
8
+ def initialize(tag: DEFAULT_TAG, size: nil, display: nil, **html_attributes)
9
+ @tag = fetch_or_raise(tag, TAGS)
10
+ @size = size.to_s if size.present? && SIZES.include?(size.to_s)
11
+ @display = display.to_s if display.present? && DISPLAYS.include?(display.to_s)
12
+ @html_attributes = html_attributes
13
+
14
+ @html_attributes[:tag] = @tag
15
+ @html_attributes[:class] = class_names(
16
+ {@size => @size.present?},
17
+ {"display-#{@display}" => @display.present?},
18
+ html_attributes.delete(:class)
19
+ ).presence
20
+ end
21
+ end
@@ -0,0 +1,28 @@
1
+ class Railsboot::ListGroup::ItemComponent < Railsboot::Component
2
+ def initialize(tag: "li", active: false, disabled: false, color: nil, **html_attributes)
3
+ @tag = tag
4
+ @active = active
5
+ @disabled = disabled
6
+ @color = fetch_or_fallback(color, COLORS, "")
7
+ @html_attributes = html_attributes
8
+
9
+ @html_attributes[:tag] = @tag
10
+ @html_attributes[:class] = class_names(
11
+ "list-group-item",
12
+ {"list-group-item-#{color}" => @color.present?},
13
+ {"active" => @active},
14
+ {"disabled" => @disabled},
15
+ html_attributes.delete(:class)
16
+ )
17
+ end
18
+
19
+ def call
20
+ render(Railsboot::BaseComponent.new(tag: "li", **@html_attributes)) { content }
21
+ end
22
+
23
+ private
24
+
25
+ def before_render
26
+ @html_attributes["aria-current"] = "true" if @active
27
+ end
28
+ end
@@ -0,0 +1,5 @@
1
+ <%= content_tag :ul, **@html_attributes do %>
2
+ <% items.each do |item| %>
3
+ <%= item %>
4
+ <% end %>
5
+ <% end %>
@@ -0,0 +1,14 @@
1
+ class Railsboot::ListGroupComponent < Railsboot::Component
2
+ renders_many :items, Railsboot::ListGroup::ItemComponent
3
+
4
+ def initialize(flush: false, **html_attributes)
5
+ @flush = flush
6
+ @html_attributes = html_attributes
7
+
8
+ @html_attributes[:class] = class_names(
9
+ "list-group",
10
+ {"list-group-flush" => @flush},
11
+ html_attributes.delete(:class)
12
+ )
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ class Railsboot::Modal::BodyComponent < Railsboot::Component
2
+ def initialize(**html_attributes)
3
+ @html_attributes = html_attributes
4
+
5
+ @html_attributes[:class] = class_names(
6
+ "modal-body",
7
+ html_attributes.delete(:class)
8
+ )
9
+ end
10
+
11
+ def call
12
+ render(Railsboot::BaseComponent.new(tag: "div", **@html_attributes)) { content }
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ class Railsboot::Modal::FooterComponent < Railsboot::Component
2
+ def initialize(**html_attributes)
3
+ @html_attributes = html_attributes
4
+
5
+ @html_attributes[:class] = class_names(
6
+ "modal-footer",
7
+ html_attributes.delete(:class)
8
+ )
9
+ end
10
+
11
+ def call
12
+ render(Railsboot::BaseComponent.new(tag: "div", **@html_attributes)) { content }
13
+ end
14
+ end
@@ -0,0 +1,4 @@
1
+ <%= content_tag :div, **@html_attributes do %>
2
+ <%= content %>
3
+ <%= render Railsboot::CloseButtonComponent.new(data: {bs_dismiss: "modal"}) %>
4
+ <% end %>
@@ -0,0 +1,10 @@
1
+ class Railsboot::Modal::HeaderComponent < Railsboot::Component
2
+ def initialize(**html_attributes)
3
+ @html_attributes = html_attributes
4
+
5
+ @html_attributes[:class] = class_names(
6
+ "modal-header",
7
+ html_attributes.delete(:class)
8
+ )
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ <%= content_tag :div, **@html_attributes do %>
2
+ <%= content_tag :div, class: class_names("modal-dialog", "modal-#{@size}" => @size.present?) do %>
3
+ <%= content_tag :div, class: "modal-content" do %>
4
+ <%= header if header? %>
5
+ <%= body if body? %>
6
+ <%= footer if footer? %>
7
+ <% end %>
8
+ <% end %>
9
+ <% end %>
@@ -0,0 +1,27 @@
1
+ class Railsboot::ModalComponent < Railsboot::Component
2
+ SIZES = ["", "xl", "lg", "sm"].freeze
3
+ DEFAULT_SIZE = "".freeze
4
+
5
+ renders_one :header, Railsboot::Modal::HeaderComponent
6
+ renders_one :body, Railsboot::Modal::BodyComponent
7
+ renders_one :footer, Railsboot::Modal::FooterComponent
8
+
9
+ def initialize(size: DEFAULT_SIZE, fade: true, **html_attributes)
10
+ @size = fetch_or_fallback(size, SIZES, DEFAULT_SIZE)
11
+ @fade = fade
12
+ @html_attributes = html_attributes
13
+
14
+ @html_attributes[:class] = class_names(
15
+ "modal",
16
+ {"fade" => @fade.present?},
17
+ html_attributes.delete(:class)
18
+ )
19
+ end
20
+
21
+ private
22
+
23
+ def before_render
24
+ @html_attributes["tabindex"] = "-1"
25
+ @html_attributes["aria-hidden"] = "true"
26
+ end
27
+ end
@@ -0,0 +1,19 @@
1
+ <% if @wrapper_item %>
2
+
3
+ <%= content_tag @wrapper_tag, **adjusted_wrapper_html_attributes do %>
4
+ <% if content? %>
5
+ <%= content %>
6
+ <% else %>
7
+ <%= link_to @text, @href, **@html_attributes %>
8
+ <% end %>
9
+ <% end %>
10
+
11
+ <% else %>
12
+
13
+ <% if content? %>
14
+ <%= content %>
15
+ <% else %>
16
+ <%= link_to @text, @href, **@html_attributes %>
17
+ <% end %>
18
+
19
+ <% end %>
@@ -0,0 +1,32 @@
1
+ class Railsboot::Nav::ItemComponent < Railsboot::Component
2
+ def initialize(text: "", href: "", active: false, disabled: false, wrapper_item: false, wrapper_tag: "li", wrapper_html_attributes: {}, **html_attributes)
3
+ @text = text
4
+ @href = href
5
+ @active = active
6
+ @disabled = disabled
7
+ @html_attributes = html_attributes
8
+
9
+ @wrapper_item = wrapper_item
10
+ @wrapper_tag = wrapper_tag
11
+ @wrapper_html_attributes = wrapper_html_attributes
12
+
13
+ @html_attributes[:class] = class_names(
14
+ "nav-link",
15
+ {"active" => @active},
16
+ {"disabled" => @disabled},
17
+ html_attributes.delete(:class)
18
+ )
19
+ end
20
+
21
+ def adjusted_wrapper_html_attributes
22
+ @wrapper_html_attributes["class"] = ["nav-item", @wrapper_html_attributes.delete(:class)].compact_blank.uniq.join(" ")
23
+ @wrapper_html_attributes
24
+ end
25
+
26
+ private
27
+
28
+ def before_render
29
+ @html_attributes["aria-current"] = "page" if @active
30
+ @html_attributes["aria-disabled"] = "true" if @disabled
31
+ end
32
+ end
@@ -0,0 +1,5 @@
1
+ <%= content_tag @tag, **@html_attributes do %>
2
+ <% items.each do |item| %>
3
+ <%= item %>
4
+ <% end %>
5
+ <% end %>
@@ -0,0 +1,23 @@
1
+ class Railsboot::NavComponent < Railsboot::Component
2
+ STYLES = ["", "tabs", "pills", "underline"].freeze
3
+ DEFAULT_STYLE = "".freeze
4
+
5
+ WIDTHS = ["", "fill", "justified"].freeze
6
+ DEFAULT_WIDTH = "".freeze
7
+
8
+ renders_many :items, Railsboot::Nav::ItemComponent
9
+
10
+ def initialize(tag: "nav", style: DEFAULT_STYLE, width: DEFAULT_WIDTH, **html_attributes)
11
+ @tag = tag
12
+ @style = fetch_or_fallback(style, STYLES, DEFAULT_STYLE)
13
+ @width = fetch_or_fallback(width, WIDTHS, DEFAULT_WIDTH)
14
+ @html_attributes = html_attributes
15
+
16
+ @html_attributes[:class] = class_names(
17
+ "nav",
18
+ {"nav-#{@style}" => @style.present?},
19
+ {"nav-#{@width}" => @width.present?},
20
+ html_attributes.delete(:class)
21
+ )
22
+ end
23
+ end
@@ -0,0 +1,16 @@
1
+ class Railsboot::Navbar::BrandComponent < Railsboot::Component
2
+ def initialize(tag: "a", **html_attributes)
3
+ @tag = tag
4
+ @html_attributes = html_attributes
5
+
6
+ @html_attributes[:tag] = @tag
7
+ @html_attributes[:class] = class_names(
8
+ "navbar-brand",
9
+ html_attributes.delete(:class)
10
+ )
11
+ end
12
+
13
+ def call
14
+ render(Railsboot::BaseComponent.new(**@html_attributes)) { content }
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ <%= render Railsboot::BaseComponent.new(**@html_attributes) do %>
2
+ <% items.each do |item| %>
3
+ <%= item %>
4
+ <% end %>
5
+ <% end %>
@@ -0,0 +1,14 @@
1
+ class Railsboot::Navbar::NavComponent < Railsboot::Component
2
+ renders_many :items, Railsboot::Nav::ItemComponent
3
+
4
+ def initialize(tag: "nav", **html_attributes)
5
+ @tag = tag
6
+ @html_attributes = html_attributes
7
+
8
+ @html_attributes[:tag] = @tag
9
+ @html_attributes[:class] = class_names(
10
+ "navbar-nav",
11
+ html_attributes.delete(:class)
12
+ )
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ <%= content_tag :button, **@html_attributes do %>
2
+ <span class="navbar-toggler-icon"></span>
3
+ <% end %>
@@ -0,0 +1,22 @@
1
+ class Railsboot::Navbar::TogglerComponent < Railsboot::Component
2
+ def initialize(id:, **html_attributes)
3
+ @id = id
4
+ @html_attributes = html_attributes
5
+
6
+ @html_attributes[:class] = class_names(
7
+ "navbar-toggler",
8
+ html_attributes.delete(:class)
9
+ )
10
+ end
11
+
12
+ private
13
+
14
+ def before_render
15
+ @html_attributes["type"] = "button"
16
+ @html_attributes["data-bs-toggle"] = "collapse"
17
+ @html_attributes["data-bs-target"] = "##{@id}"
18
+ @html_attributes["aria-controls"] = @id.to_s
19
+ @html_attributes["aria-expanded"] = "false"
20
+ @html_attributes["aria-label"] = "Toggle navigation"
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ <%= content_tag :nav, **@html_attributes do %>
2
+ <% content %>
3
+ <% end %>
@@ -0,0 +1,15 @@
1
+ class Railsboot::NavbarComponent < Railsboot::Component
2
+ EXPANDS = ["sm", "md", "lg", "xl", "xxl"].freeze
3
+ DEFAULT_EXPAND = "".freeze
4
+
5
+ def initialize(expand: DEFAULT_EXPAND, **html_attributes)
6
+ @expand = fetch_or_fallback(expand, EXPANDS, DEFAULT_EXPAND)
7
+ @html_attributes = html_attributes
8
+
9
+ @html_attributes[:class] = class_names(
10
+ "navbar",
11
+ {"navbar-expand-#{@expand}" => @expand.present?},
12
+ html_attributes.delete(:class)
13
+ )
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ class Railsboot::Offcanvas::BodyComponent < Railsboot::Component
2
+ def initialize(**html_attributes)
3
+ @html_attributes = html_attributes
4
+
5
+ @html_attributes[:tag] = "div"
6
+ @html_attributes[:class] = class_names(
7
+ "offcanvas-body",
8
+ html_attributes.delete(:class)
9
+ )
10
+ end
11
+
12
+ def call
13
+ render(Railsboot::BaseComponent.new(**@html_attributes)) { content }
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ <%= content_tag :div, **@html_attributes do %>
2
+ <%= content_tag :h5, @text, class: "offcanvas-title" if @text.present? %>
3
+ <%= content %>
4
+ <%= render Railsboot::CloseButtonComponent.new(data: {bs_dismiss: "offcanvas"}) %>
5
+ <% end %>
@@ -0,0 +1,11 @@
1
+ class Railsboot::Offcanvas::HeaderComponent < Railsboot::Component
2
+ def initialize(text: "", **html_attributes)
3
+ @text = text
4
+ @html_attributes = html_attributes
5
+
6
+ @html_attributes[:class] = class_names(
7
+ "offcanvas-header",
8
+ html_attributes.delete(:class)
9
+ )
10
+ end
11
+ end
@@ -0,0 +1,4 @@
1
+ <%= render Railsboot::BaseComponent.new(**@html_attributes) do %>
2
+ <%= header if header? %>
3
+ <%= body if body? %>
4
+ <% end %>
@@ -0,0 +1,25 @@
1
+ class Railsboot::OffcanvasComponent < Railsboot::Component
2
+ PLACEMENTS = ["start", "end", "top", "bottom"].freeze
3
+ DEFAULT_PLACEMENT = "start".freeze
4
+
5
+ renders_one :header, Railsboot::Offcanvas::HeaderComponent
6
+ renders_one :body, Railsboot::Offcanvas::BodyComponent
7
+
8
+ def initialize(placement: DEFAULT_PLACEMENT, **html_attributes)
9
+ @placement = fetch_or_fallback(placement, PLACEMENTS, DEFAULT_PLACEMENT)
10
+ @html_attributes = html_attributes
11
+
12
+ @html_attributes[:tag] = "div"
13
+ @html_attributes[:class] = class_names(
14
+ "offcanvas",
15
+ "offcanvas-#{@placement}",
16
+ html_attributes.delete(:class)
17
+ )
18
+ end
19
+
20
+ private
21
+
22
+ def before_render
23
+ @html_attributes["tabindex"] = "-1"
24
+ end
25
+ end
@@ -0,0 +1 @@
1
+ <%== helpers.pagy_bootstrap_nav(@pagy) %>
@@ -0,0 +1,9 @@
1
+ class Railsboot::PaginationComponent < Railsboot::Component
2
+ def initialize(pagy:)
3
+ @pagy = pagy
4
+ end
5
+
6
+ def render?
7
+ @pagy.present? && @pagy.pages.to_i > 1
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ <%= render Railsboot::BaseComponent.new(**@html_attributes) do %>
2
+ <%= content_tag :div, @label, class: inner_classes, style: "width: #{@value}%" %>
3
+ <% end %>
@@ -0,0 +1,34 @@
1
+ class Railsboot::ProgressComponent < Railsboot::Component
2
+ def initialize(value: 0, min: 0, max: 100, label: "", aria_label: nil, color: DEFAULT_COLOR, **html_attributes)
3
+ @value = value
4
+ @min = min
5
+ @max = max
6
+ @label = label
7
+ @aria_label = aria_label
8
+ @color = fetch_or_raise(color, COLORS)
9
+ @html_attributes = html_attributes
10
+
11
+ @html_attributes[:tag] = "div"
12
+ @html_attributes[:class] = class_names(
13
+ "progress",
14
+ html_attributes.delete(:class)
15
+ )
16
+ end
17
+
18
+ def inner_classes
19
+ class_names(
20
+ "progress-bar",
21
+ {"bg-#{@color}" => @color.present?}
22
+ )
23
+ end
24
+
25
+ protected
26
+
27
+ def before_render
28
+ @html_attributes["role"] = "progressbar"
29
+ @html_attributes["aria-valuenow"] = @value
30
+ @html_attributes["aria-valuemin"] = @min
31
+ @html_attributes["aria-valuemax"] = @max
32
+ @html_attributes["aria-label"] = @aria_label if @aria_label.present?
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ <%= render Railsboot::BaseComponent.new(**@html_attributes) do %>
2
+ <span class="visually-hidden">Loading...</span>
3
+ <% end %>
@@ -0,0 +1,23 @@
1
+ class Railsboot::SpinnerComponent < Railsboot::Component
2
+ STYLES = ["border", "grow"].freeze
3
+ DEFAULT_STYLE = "border".freeze
4
+
5
+ def initialize(style: DEFAULT_STYLE, color: DEFAULT_COLOR, **html_attributes)
6
+ @style = fetch_or_raise(style, STYLES)
7
+ @color = fetch_or_raise(color, COLORS)
8
+ @html_attributes = html_attributes
9
+
10
+ @html_attributes[:tag] = "div"
11
+ @html_attributes[:class] = class_names(
12
+ "spinner-#{@style}",
13
+ "text-#{@color}",
14
+ html_attributes.delete(:class)
15
+ )
16
+ end
17
+
18
+ private
19
+
20
+ def before_render
21
+ @html_attributes["role"] = "status"
22
+ end
23
+ end
@@ -0,0 +1,9 @@
1
+ <%= content_tag :tbody, **@html_attributes do %>
2
+ <% if rows? %>
3
+ <% rows.each do |row| %>
4
+ <%= row %>
5
+ <% end %>
6
+ <% else %>
7
+ <% content %>
8
+ <% end %>
9
+ <% end %>
@@ -0,0 +1,7 @@
1
+ class Railsboot::Table::BodyComponent < Railsboot::Component
2
+ renders_many :rows, Railsboot::Table::RowComponent
3
+
4
+ def initialize(**html_attributes)
5
+ @html_attributes = html_attributes
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ class Railsboot::Table::CellComponent < Railsboot::Component
2
+ TAGS = ["th", "td"].freeze
3
+ DEFAULT_TAG = "td".freeze
4
+
5
+ def initialize(tag: DEFAULT_TAG, **html_attributes)
6
+ @tag = fetch_or_raise(tag, TAGS)
7
+ @html_attributes = html_attributes
8
+ end
9
+
10
+ def call
11
+ content_tag @tag, content, **@html_attributes
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ <%= content_tag :thead, **@html_attributes do %>
2
+ <% if rows? %>
3
+ <% rows.each do |row| %>
4
+ <%= row %>
5
+ <% end %>
6
+ <% else %>
7
+ <% content %>
8
+ <% end %>
9
+ <% end %>
@@ -0,0 +1,7 @@
1
+ class Railsboot::Table::HeadComponent < Railsboot::Component
2
+ renders_many :rows, Railsboot::Table::RowComponent
3
+
4
+ def initialize(**html_attributes)
5
+ @html_attributes = html_attributes
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ <%= content_tag :tr, **@html_attributes do %>
2
+ <% if cells? %>
3
+ <% cells.each do |cell| %>
4
+ <%= cell %>
5
+ <% end %>
6
+ <% else %>
7
+ <% content %>
8
+ <% end %>
9
+ <% end %>
@@ -0,0 +1,7 @@
1
+ class Railsboot::Table::RowComponent < Railsboot::Component
2
+ renders_many :cells, Railsboot::Table::CellComponent
3
+
4
+ def initialize(**html_attributes)
5
+ @html_attributes = html_attributes
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ <%= render Railsboot::BaseComponent.new(**@html_attributes) do %>
2
+ <%= head if head.present? %>
3
+ <%= body if body.present? %>
4
+
5
+ <%# Fallback if slots are not set %>
6
+ <% if head.blank? && body.blank? %>
7
+ <%= content %>
8
+ <% end %>
9
+ <% end %>