diff --git a/lib/phlex_ui/table.rb b/lib/rbui/table/table.rb similarity index 95% rename from lib/phlex_ui/table.rb rename to lib/rbui/table/table.rb index e4465f4..aa1cbbd 100644 --- a/lib/phlex_ui/table.rb +++ b/lib/rbui/table/table.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module PhlexUI +module RBUI class Table < Base def view_template(&block) div(class: "relative w-full overflow-auto") do diff --git a/lib/phlex_ui/table/table_body.rb b/lib/rbui/table/table_body.rb similarity index 93% rename from lib/phlex_ui/table/table_body.rb rename to lib/rbui/table/table_body.rb index 2376f97..eb67515 100644 --- a/lib/phlex_ui/table/table_body.rb +++ b/lib/rbui/table/table_body.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module PhlexUI +module RBUI class TableBody < Base def view_template(&) tbody(**attrs, &) diff --git a/lib/phlex_ui/table/table_caption.rb b/lib/rbui/table/table_caption.rb similarity index 94% rename from lib/phlex_ui/table/table_caption.rb rename to lib/rbui/table/table_caption.rb index 99b0705..538b4b1 100644 --- a/lib/phlex_ui/table/table_caption.rb +++ b/lib/rbui/table/table_caption.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module PhlexUI +module RBUI class TableCaption < Base def view_template(&) caption(**attrs, &) diff --git a/lib/phlex_ui/table/table_cell.rb b/lib/rbui/table/table_cell.rb similarity index 94% rename from lib/phlex_ui/table/table_cell.rb rename to lib/rbui/table/table_cell.rb index b8d3f86..a51877e 100644 --- a/lib/phlex_ui/table/table_cell.rb +++ b/lib/rbui/table/table_cell.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module PhlexUI +module RBUI class TableCell < Base def view_template(&) td(**attrs, &) diff --git a/lib/phlex_ui/table/table_footer.rb b/lib/rbui/table/table_footer.rb similarity index 94% rename from lib/phlex_ui/table/table_footer.rb rename to lib/rbui/table/table_footer.rb index ce631d6..8f7cd1f 100644 --- a/lib/phlex_ui/table/table_footer.rb +++ b/lib/rbui/table/table_footer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module PhlexUI +module RBUI class TableFooter < Base def view_template(&) tfoot(**attrs, &) diff --git a/lib/phlex_ui/table/table_head.rb b/lib/rbui/table/table_head.rb similarity index 95% rename from lib/phlex_ui/table/table_head.rb rename to lib/rbui/table/table_head.rb index dc652bc..83b9ae1 100644 --- a/lib/phlex_ui/table/table_head.rb +++ b/lib/rbui/table/table_head.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module PhlexUI +module RBUI class TableHead < Base def view_template(&) th(**attrs, &) diff --git a/lib/phlex_ui/table/table_header.rb b/lib/rbui/table/table_header.rb similarity index 93% rename from lib/phlex_ui/table/table_header.rb rename to lib/rbui/table/table_header.rb index d19fe21..32b868c 100644 --- a/lib/phlex_ui/table/table_header.rb +++ b/lib/rbui/table/table_header.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module PhlexUI +module RBUI class TableHeader < Base def view_template(&) thead(**attrs, &) diff --git a/lib/phlex_ui/table/table_row.rb b/lib/rbui/table/table_row.rb similarity index 95% rename from lib/phlex_ui/table/table_row.rb rename to lib/rbui/table/table_row.rb index 9a3c46b..c50dfcb 100644 --- a/lib/phlex_ui/table/table_row.rb +++ b/lib/rbui/table/table_row.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module PhlexUI +module RBUI class TableRow < Base def view_template(&) tr(**attrs, &) diff --git a/test/phlex_ui/table_test.rb b/test/phlex_ui/table_test.rb deleted file mode 100644 index 6d1f529..0000000 --- a/test/phlex_ui/table_test.rb +++ /dev/null @@ -1,48 +0,0 @@ -# frozen_string_literal: true - -require "test_helper" - -class PhlexUI::TableTest < Minitest::Test - include Phlex::Testing::ViewHelper - - def test_render_with_all_items - invoices = [ - {identifier: "INV-0001", status: "Active", method: "Credit Card", amount: 100}, - {identifier: "INV-0002", status: "Active", method: "Bank Transfer", amount: 230}, - {identifier: "INV-0003", status: "Pending", method: "PayPal", amount: 350}, - {identifier: "INV-0004", status: "Inactive", method: "Credit Card", amount: 100} - ] - - output = phlex_context do - PhlexUI.Table do - PhlexUI.TableCaption { "Employees at Acme inc." } - PhlexUI.TableHeader do - PhlexUI.TableRow do - PhlexUI.TableHead { "Name" } - PhlexUI.TableHead { "Email" } - PhlexUI.TableHead { "Status" } - PhlexUI.TableHead(class: "text-right") { "Role" } - end - end - PhlexUI.TableBody do - invoices.each do |invoice| - PhlexUI.TableRow do - PhlexUI.TableCell(class: "font-medium") { invoice[:identifier] } - PhlexUI.TableCell { invoice[:status] } - PhlexUI.TableCell { invoice[:method] } - PhlexUI.TableCell(class: "text-right") { invoice[:amount] } - end - end - end - PhlexUI.TableFooter do - PhlexUI.TableRow do - PhlexUI.TableHead(class: "font-medium", colspan: 3) { "Total" } - PhlexUI.TableHead(class: "font-medium text-right") { invoices.sum { |invoice| invoice[:amount] } } - end - end - end - end - - assert_match(/Total/, output) - end -end diff --git a/test/rbui/table_test.rb b/test/rbui/table_test.rb new file mode 100644 index 0000000..a9f9b7a --- /dev/null +++ b/test/rbui/table_test.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +require "test_helper" + +class RBUI::TableTest < Minitest::Test + include Phlex::Testing::ViewHelper + + def test_render_with_all_items + invoices = [ + {identifier: "INV-0001", status: "Active", method: "Credit Card", amount: 100}, + {identifier: "INV-0002", status: "Active", method: "Bank Transfer", amount: 230}, + {identifier: "INV-0003", status: "Pending", method: "PayPal", amount: 350}, + {identifier: "INV-0004", status: "Inactive", method: "Credit Card", amount: 100} + ] + + output = phlex_context do + RBUI.Table do + RBUI.TableCaption { "Employees at Acme inc." } + RBUI.TableHeader do + RBUI.TableRow do + RBUI.TableHead { "Name" } + RBUI.TableHead { "Email" } + RBUI.TableHead { "Status" } + RBUI.TableHead(class: "text-right") { "Role" } + end + end + RBUI.TableBody do + invoices.each do |invoice| + RBUI.TableRow do + RBUI.TableCell(class: "font-medium") { invoice[:identifier] } + RBUI.TableCell { invoice[:status] } + RBUI.TableCell { invoice[:method] } + RBUI.TableCell(class: "text-right") { invoice[:amount] } + end + end + end + RBUI.TableFooter do + RBUI.TableRow do + RBUI.TableHead(class: "font-medium", colspan: 3) { "Total" } + RBUI.TableHead(class: "font-medium text-right") { invoices.sum { |invoice| invoice[:amount] } } + end + end + end + end + + assert_match(/Total/, output) + end +end