From 0ddd80d23e687205d5a3a62e062ee961d76f7b74 Mon Sep 17 00:00:00 2001 From: Seth Horsley Date: Mon, 7 Oct 2024 01:51:18 +0200 Subject: [PATCH] WIP --- Gemfile.lock | 26 +++++++ lib/rbui/alert/alert.rb | 2 +- lib/rbui/avatar/avatar.rb | 2 +- lib/rbui/badge/badge.rb | 2 +- lib/rbui/button/button.rb | 51 +++++++++----- lib/rbui/calendar/calendar_days.rb | 65 ++++++++++------- .../calendar/calendar_input_controller.js | 7 +- lib/rbui/command/command_dialog_content.rb | 11 ++- lib/rbui/command/command_dialog_trigger.rb | 2 +- lib/rbui/context_menu/context_menu_label.rb | 2 +- lib/rbui/dialog/dialog_content.rb | 4 +- lib/rbui/link/link.rb | 70 ++++++++++++++----- lib/rbui/pagination/pagination_item.rb | 4 +- lib/rbui/sheet/sheet_content.rb | 4 +- lib/rbui/typography/typography_list.rb | 4 +- test/rbui/accordion_test.rb | 2 - test/rbui/alert_dialog_test.rb | 2 - test/rbui/alert_test.rb | 2 - test/rbui/aspect_ratio_test.rb | 2 - test/rbui/avatar_test.rb | 2 - test/rbui/badge_test.rb | 2 - test/rbui/button_test.rb | 2 - test/rbui/calendar_test.rb | 2 - test/rbui/card_test.rb | 2 - test/rbui/chart_test.rb | 2 - test/rbui/checkbox_test.rb | 2 - test/rbui/clipboard_test.rb | 2 - test/rbui/codeblock_test.rb | 2 - test/rbui/collapsible_test.rb | 2 - test/rbui/combobox_test.rb | 2 - test/rbui/command_test.rb | 2 - test/rbui/context_menu_test.rb | 2 - test/rbui/dialog_test.rb | 2 - test/rbui/dropdown_menu_test.rb | 2 - test/rbui/form_test.rb | 2 - test/rbui/hover_card_test.rb | 2 - test/rbui/input_test.rb | 2 - test/rbui/link_test.rb | 15 ---- test/rbui/pagination_test.rb | 2 - test/rbui/popover_test.rb | 2 - test/rbui/select_test.rb | 2 - test/rbui/sheet_test.rb | 2 - test/rbui/shortcut_key_test.rb | 2 - test/rbui/table_test.rb | 2 - test/rbui/tabs_test.rb | 2 - test/rbui/textarea_test.rb | 2 - test/rbui/theme_toggle_test.rb | 2 - test/rbui/tooltip_test.rb | 2 - test/rbui/typography_test.rb | 2 - test/test_helper.rb | 24 ++++++- 50 files changed, 201 insertions(+), 160 deletions(-) delete mode 100644 test/rbui/link_test.rb diff --git a/Gemfile.lock b/Gemfile.lock index eb7ff5d..23c495c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,18 +9,41 @@ PATH GEM remote: https://rubygems.org/ specs: + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) ast (2.4.2) + capybara (3.40.0) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.11) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) json (2.7.2) language_server-protocol (3.17.0.3) lint_roller (1.1.0) lru_redux (1.1.0) + matrix (0.4.2) + mini_mime (1.1.5) + mini_portile2 (2.8.7) minitest (5.25.1) + nokogiri (1.16.7) + mini_portile2 (~> 2.8.2) + racc (~> 1.4) + nokogiri (1.16.7-arm64-darwin) + racc (~> 1.4) parallel (1.25.1) parser (3.3.3.0) ast (~> 2.4.1) racc phlex (2.0.0.beta2) + public_suffix (6.0.1) racc (1.8.0) + rack (3.1.7) + rack-test (2.1.0) + rack (>= 1.3) rainbow (3.1.1) rake (13.2.1) regexp_parser (2.9.2) @@ -60,12 +83,15 @@ GEM tailwind_merge (0.13.0) lru_redux (~> 1.1) unicode-display_width (2.5.0) + xpath (3.2.0) + nokogiri (~> 1.8) PLATFORMS arm64-darwin-23 ruby DEPENDENCIES + capybara minitest rake rbui! diff --git a/lib/rbui/alert/alert.rb b/lib/rbui/alert/alert.rb index e9074d0..fdc428e 100644 --- a/lib/rbui/alert/alert.rb +++ b/lib/rbui/alert/alert.rb @@ -29,7 +29,7 @@ def colors def default_attrs base_classes = "backdrop-blur relative w-full ring-1 ring-inset rounded-lg px-4 py-4 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg~*]:pl-8" { - class: tokens(base_classes, colors) + class: [base_classes, colors] } end end diff --git a/lib/rbui/avatar/avatar.rb b/lib/rbui/avatar/avatar.rb index 8895ed8..28bd2bf 100644 --- a/lib/rbui/avatar/avatar.rb +++ b/lib/rbui/avatar/avatar.rb @@ -24,7 +24,7 @@ def view_template(&) def default_attrs { - class: tokens("relative flex shrink-0 overflow-hidden rounded-full", @size_classes) + class: ["relative flex shrink-0 overflow-hidden rounded-full", @size_classes] } end end diff --git a/lib/rbui/badge/badge.rb b/lib/rbui/badge/badge.rb index a8dde03..18afd91 100644 --- a/lib/rbui/badge/badge.rb +++ b/lib/rbui/badge/badge.rb @@ -53,7 +53,7 @@ def view_template(&) def default_attrs { - class: tokens("inline-flex items-center rounded-md font-medium ring-1 ring-inset", SIZES[@size], COLORS[@variant]) + class: ["inline-flex items-center rounded-md font-medium ring-1 ring-inset", SIZES[@size], COLORS[@variant]] } end end diff --git a/lib/rbui/button/button.rb b/lib/rbui/button/button.rb index 5cd345b..93e595e 100644 --- a/lib/rbui/button/button.rb +++ b/lib/rbui/button/button.rb @@ -35,45 +35,60 @@ def size_classes end def primary_classes - tokens( - "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 bg-primary text-primary-foreground shadow hover:bg-primary/90", + [ + "whitespace-nowrap inline-flex items-center justify-center rounded-md", + "font-medium transition-colors focus-visible:outline-none focus-visible:ring-1", + "focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50", + "bg-primary text-primary-foreground shadow hover:bg-primary/90", size_classes - ) + ] end def link_classes - tokens( - "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 text-primary underline-offset-4 hover:underline", + [ + "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium", + "transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", + "disabled:pointer-events-none disabled:opacity-50 text-primary underline-offset-4 hover:underline", size_classes - ) + ] end def secondary_classes - tokens( - "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 bg-secondary text-secondary-foreground hover:bg-opacity-80", + [ + "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium", + "transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", + "disabled:pointer-events-none disabled:opacity-50 bg-secondary text-secondary-foreground hover:bg-opacity-80", size_classes - ) + ] end def destructive_classes - tokens( - "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90", + [ + "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium", + "transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", + "disabled:pointer-events-none disabled:opacity-50 bg-destructive text-destructive-foreground", + "shadow-sm hover:bg-destructive/90", size_classes - ) + ] end def outline_classes - tokens( - "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground", + [ + "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium", + "transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", + "disabled:pointer-events-none disabled:opacity-50 border border-input bg-background shadow-sm", + "hover:bg-accent hover:text-accent-foreground", size_classes - ) + ] end def ghost_classes - tokens( - "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 hover:bg-accent hover:text-accent-foreground", + [ + "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors", + "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none", + "disabled:opacity-50 hover:bg-accent hover:text-accent-foreground", size_classes - ) + ] end def default_classes diff --git a/lib/rbui/calendar/calendar_days.rb b/lib/rbui/calendar/calendar_days.rb index b809de6..18c54fe 100644 --- a/lib/rbui/calendar/calendar_days.rb +++ b/lib/rbui/calendar/calendar_days.rb @@ -2,7 +2,16 @@ module RBUI class CalendarDays < Base - BASE_CLASS = "inline-flex items-center justify-center rounded-md text-sm ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 h-8 w-8 p-0 font-normal aria-selected:opacity-100" + BASE_CLASS = [ + "inline-flex items-center justify-center", + "rounded-md text-sm", + "ring-offset-background transition-colors", + "focus-visible:outline-none focus-visible:ring-2", + "focus-visible:ring-ring focus-visible:ring-offset-2", + "disabled:pointer-events-none disabled:opacity-50", + "h-8 w-8 p-0 font-normal", + "aria-selected:opacity-100" + ] def view_template render_selected_date_template @@ -19,11 +28,12 @@ def render_selected_date_template data_day: "{{day}}", data_action: "click->rbui--calendar#selectDay", name: "day", - class: - tokens( - BASE_CLASS, - "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground" - ), + class: [ + *BASE_CLASS, + "bg-primary text-primary-foreground", + "hover:bg-primary hover:text-primary-foreground", + "focus:bg-primary focus:text-primary-foreground" + ], role: "gridcell", tabindex: "0", type: "button", @@ -38,11 +48,12 @@ def render_today_date_template data_day: "{{day}}", data_action: "click->rbui--calendar#selectDay", name: "day", - class: - tokens( - BASE_CLASS, - "bg-accent text-accent-foreground hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground" - ), + class: [ + *BASE_CLASS, + "bg-accent text-accent-foreground", + "hover:bg-accent hover:text-accent-foreground", + "focus:bg-accent focus:text-accent-foreground" + ], role: "gridcell", tabindex: "-1", type: "button" @@ -56,11 +67,12 @@ def render_current_month_date_template data_day: "{{day}}", data_action: "click->rbui--calendar#selectDay", name: "day", - class: - tokens( - BASE_CLASS, - "bg-background text-foreground hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground" - ), + class: [ + *BASE_CLASS, + "bg-background text-foreground", + "hover:bg-accent hover:text-accent-foreground", + "focus:bg-accent focus:text-accent-foreground" + ], role: "gridcell", tabindex: "-1", type: "button" @@ -72,13 +84,14 @@ def render_other_month_date_template date_template("otherMonthDateTemplate") do button( data_day: "{{day}}", - data_action: " click->rbui--calendar#selectDay", + data_action: "click->rbui--calendar#selectDay", name: "day", - class: - tokens( - BASE_CLASS, - "bg-background text-muted-foreground hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground" - ), + class: [ + *BASE_CLASS, + "bg-background text-muted-foreground", + "hover:bg-accent hover:text-accent-foreground", + "focus:bg-accent focus:text-accent-foreground" + ], role: "gridcell", tabindex: "-1", type: "button" @@ -89,8 +102,12 @@ def render_other_month_date_template def date_template(target, &block) template_tag(data: {rbui__calendar_target: target}) do td( - class: - "relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected])]:rounded-md", + class: [ + "relative p-0 text-center text-sm", + "focus-within:relative focus-within:z-20", + "[&:has([aria-selected])]:bg-accent", + "[&:has([aria-selected])]:rounded-md" + ], role: "presentation", &block ) diff --git a/lib/rbui/calendar/calendar_input_controller.js b/lib/rbui/calendar/calendar_input_controller.js index 17b48ad..86bbd60 100644 --- a/lib/rbui/calendar/calendar_input_controller.js +++ b/lib/rbui/calendar/calendar_input_controller.js @@ -1,8 +1,11 @@ -import { Controller } from "@hotwired/stimulus" +import { Controller } from "@hotwired/stimulus"; // Connects to data-controller="input" export default class extends Controller { + connect() { + console.log("Connected to input"); + } setValue(value) { - this.element.value = value + this.element.value = value; } } diff --git a/lib/rbui/command/command_dialog_content.rb b/lib/rbui/command/command_dialog_content.rb index 12cefcd..bc5a8f9 100644 --- a/lib/rbui/command/command_dialog_content.rb +++ b/lib/rbui/command/command_dialog_content.rb @@ -30,10 +30,15 @@ def view_template(&block) def default_attrs { data_state: "open", - class: tokens( - "fixed pointer-events-auto left-[50%] top-[50%] z-50 grid w-full translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg md:w-full", + class: [ + "fixed pointer-events-auto left-[50%] top-[50%] z-50 grid w-full translate-x-[-50%]", + "translate-y-[-50%] gap-4 border bg-background shadow-lg duration-200 data-[state=open]:animate-in", + "data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", + "data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2", + "data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2", + "data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg md:w-full", SIZES[@size] - ) + ] } end diff --git a/lib/rbui/command/command_dialog_trigger.rb b/lib/rbui/command/command_dialog_trigger.rb index c30adbc..7d4d0f1 100644 --- a/lib/rbui/command/command_dialog_trigger.rb +++ b/lib/rbui/command/command_dialog_trigger.rb @@ -21,7 +21,7 @@ def view_template(&) def default_attrs { data: { - action: tokens("click->rbui--command#open", @keybindings.join(" ")) + action: ["click->rbui--command#open", @keybindings.join(" ")] } } end diff --git a/lib/rbui/context_menu/context_menu_label.rb b/lib/rbui/context_menu/context_menu_label.rb index d7bf643..46e779f 100644 --- a/lib/rbui/context_menu/context_menu_label.rb +++ b/lib/rbui/context_menu/context_menu_label.rb @@ -17,7 +17,7 @@ def inset? = @inset def default_attrs { - class: tokens("px-2 py-1.5 text-sm font-semibold text-foreground", inset?: "pl-8") + class: ["px-2 py-1.5 text-sm font-semibold text-foreground", inset?: "pl-8"] } end end diff --git a/lib/rbui/dialog/dialog_content.rb b/lib/rbui/dialog/dialog_content.rb index 29c1f93..4792be1 100644 --- a/lib/rbui/dialog/dialog_content.rb +++ b/lib/rbui/dialog/dialog_content.rb @@ -33,10 +33,10 @@ def view_template def default_attrs { data_state: "open", - class: tokens( + class: [ "fixed pointer-events-auto left-[50%] top-[50%] z-50 grid w-full translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg md:w-full", SIZES[@size] - ) + ] } end diff --git a/lib/rbui/link/link.rb b/lib/rbui/link/link.rb index b3dc375..bd755f7 100644 --- a/lib/rbui/link/link.rb +++ b/lib/rbui/link/link.rb @@ -35,45 +35,79 @@ def size_classes end def primary_classes - tokens( - "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 bg-primary text-primary-foreground shadow hover:bg-primary/90", + [ + "whitespace-nowrap", + "inline-flex items-center justify-center", + "rounded-md font-medium transition-colors", + "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", + "disabled:pointer-events-none disabled:opacity-50", + "bg-primary text-primary-foreground shadow", + "hover:bg-primary/90", size_classes - ) + ] end def link_classes - tokens( - "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 text-primary underline-offset-4 hover:underline", + [ + "whitespace-nowrap", + "inline-flex items-center justify-center", + "rounded-md font-medium transition-colors", + "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", + "disabled:pointer-events-none disabled:opacity-50", + "text-primary underline-offset-4 hover:underline", size_classes - ) + ] end def secondary_classes - tokens( - "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 bg-secondary text-secondary-foreground hover:bg-opacity-80", + [ + "whitespace-nowrap", + "inline-flex items-center justify-center", + "rounded-md font-medium transition-colors", + "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", + "disabled:pointer-events-none disabled:opacity-50", + "bg-secondary text-secondary-foreground", + "hover:bg-opacity-80", size_classes - ) + ] end def destructive_classes - tokens( - "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90", + [ + "whitespace-nowrap", + "inline-flex items-center justify-center", + "rounded-md font-medium transition-colors", + "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", + "disabled:pointer-events-none disabled:opacity-50", + "bg-destructive text-destructive-foreground shadow-sm", + "hover:bg-destructive/90", size_classes - ) + ] end def outline_classes - tokens( - "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground", + [ + "whitespace-nowrap", + "inline-flex items-center justify-center", + "rounded-md font-medium transition-colors", + "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", + "disabled:pointer-events-none disabled:opacity-50", + "border border-input bg-background shadow-sm", + "hover:bg-accent hover:text-accent-foreground", size_classes - ) + ] end def ghost_classes - tokens( - "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 hover:bg-accent hover:text-accent-foreground", + [ + "whitespace-nowrap", + "inline-flex items-center justify-center", + "rounded-md font-medium transition-colors", + "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", + "disabled:pointer-events-none disabled:opacity-50", + "hover:bg-accent hover:text-accent-foreground", size_classes - ) + ] end def default_classes diff --git a/lib/rbui/pagination/pagination_item.rb b/lib/rbui/pagination/pagination_item.rb index 4035f88..3a211d1 100644 --- a/lib/rbui/pagination/pagination_item.rb +++ b/lib/rbui/pagination/pagination_item.rb @@ -19,9 +19,9 @@ def view_template(&block) def default_attrs { aria: {current: @active ? "page" : nil}, - class: tokens( + class: [ RBUI::Button.new(variant: @active ? :outline : :ghost).attrs[:class] - ) + ] } end end diff --git a/lib/rbui/sheet/sheet_content.rb b/lib/rbui/sheet/sheet_content.rb index dc50931..4c91907 100644 --- a/lib/rbui/sheet/sheet_content.rb +++ b/lib/rbui/sheet/sheet_content.rb @@ -32,10 +32,10 @@ def view_template(&block) def default_attrs { data_state: "open", # For animate in - class: tokens( + class: [ "fixed pointer-events-auto z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500", @side_classes - ) + ] } end diff --git a/lib/rbui/typography/typography_list.rb b/lib/rbui/typography/typography_list.rb index 22b11c5..8769328 100644 --- a/lib/rbui/typography/typography_list.rb +++ b/lib/rbui/typography/typography_list.rb @@ -36,11 +36,11 @@ def not_numbered? = !numbered? def default_attrs { - class: tokens( + class: [ "my-6 ml-6 [&>li]:mt-2 [&>li]:pl-2", numbered?: "list-decimal marker:font-medium", not_numbered?: "list-disc" - ) + ] } end end diff --git a/test/rbui/accordion_test.rb b/test/rbui/accordion_test.rb index 464caf6..1ca5637 100644 --- a/test/rbui/accordion_test.rb +++ b/test/rbui/accordion_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::AccordionTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_default_items output = phlex_context do RBUI.Accordion do diff --git a/test/rbui/alert_dialog_test.rb b/test/rbui/alert_dialog_test.rb index 485ff02..75e71b3 100644 --- a/test/rbui/alert_dialog_test.rb +++ b/test/rbui/alert_dialog_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::AlertDialogTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.AlertDialog do diff --git a/test/rbui/alert_test.rb b/test/rbui/alert_test.rb index 4f317e2..d1d80f2 100644 --- a/test/rbui/alert_test.rb +++ b/test/rbui/alert_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::AlertTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.Alert do diff --git a/test/rbui/aspect_ratio_test.rb b/test/rbui/aspect_ratio_test.rb index 9be3cfe..df980ef 100644 --- a/test/rbui/aspect_ratio_test.rb +++ b/test/rbui/aspect_ratio_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::AspectRatioTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.AspectRatio(aspect_ratio: "16/9") do |aspect| diff --git a/test/rbui/avatar_test.rb b/test/rbui/avatar_test.rb index 52fcd98..39c4ec9 100644 --- a/test/rbui/avatar_test.rb +++ b/test/rbui/avatar_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::AvatarTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.Avatar do diff --git a/test/rbui/badge_test.rb b/test/rbui/badge_test.rb index 8797375..6832759 100644 --- a/test/rbui/badge_test.rb +++ b/test/rbui/badge_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::BadgeTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.Badge { "Badge" } diff --git a/test/rbui/button_test.rb b/test/rbui/button_test.rb index 305845c..f7dc3ce 100644 --- a/test/rbui/button_test.rb +++ b/test/rbui/button_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::ButtonTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.Button(variant: :primary) { "Primary" } diff --git a/test/rbui/calendar_test.rb b/test/rbui/calendar_test.rb index c5927ff..1471b3f 100644 --- a/test/rbui/calendar_test.rb +++ b/test/rbui/calendar_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::CalendarTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.Input(type: "string", placeholder: "Select a date", class: "rounded-md border shadow", id: "date", data_controller: "rbui--input") diff --git a/test/rbui/card_test.rb b/test/rbui/card_test.rb index 74e31b6..9ff4233 100644 --- a/test/rbui/card_test.rb +++ b/test/rbui/card_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::CardTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.Card(class: "w-96") do diff --git a/test/rbui/chart_test.rb b/test/rbui/chart_test.rb index a7c884b..6fdedda 100644 --- a/test/rbui/chart_test.rb +++ b/test/rbui/chart_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::ChartTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do options = { diff --git a/test/rbui/checkbox_test.rb b/test/rbui/checkbox_test.rb index cb57d26..b895ae2 100644 --- a/test/rbui/checkbox_test.rb +++ b/test/rbui/checkbox_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::CheckboxTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.Checkbox(id: "terms") diff --git a/test/rbui/clipboard_test.rb b/test/rbui/clipboard_test.rb index 20455f4..bccb986 100644 --- a/test/rbui/clipboard_test.rb +++ b/test/rbui/clipboard_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::ClipboardTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.Clipboard(success: "Copied!", error: "Copy Failed!") diff --git a/test/rbui/codeblock_test.rb b/test/rbui/codeblock_test.rb index 93f9db0..5cc7a2b 100644 --- a/test/rbui/codeblock_test.rb +++ b/test/rbui/codeblock_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::CodeblockTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items code = <<~CODE def hello_world diff --git a/test/rbui/collapsible_test.rb b/test/rbui/collapsible_test.rb index 2a2b27f..296bc1c 100644 --- a/test/rbui/collapsible_test.rb +++ b/test/rbui/collapsible_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::CollapsibleTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.Collapsible(open: true) do diff --git a/test/rbui/combobox_test.rb b/test/rbui/combobox_test.rb index d516c26..f01ecad 100644 --- a/test/rbui/combobox_test.rb +++ b/test/rbui/combobox_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::ComboboxTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.Combobox do diff --git a/test/rbui/command_test.rb b/test/rbui/command_test.rb index 9b92e26..bcdd890 100644 --- a/test/rbui/command_test.rb +++ b/test/rbui/command_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::CommandTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items components_list = [ {name: "Accordion", path: "#"}, diff --git a/test/rbui/context_menu_test.rb b/test/rbui/context_menu_test.rb index c510d4c..d4b65fa 100644 --- a/test/rbui/context_menu_test.rb +++ b/test/rbui/context_menu_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::ContextMenuTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.ContextMenu do diff --git a/test/rbui/dialog_test.rb b/test/rbui/dialog_test.rb index 85cf8b7..e8fb532 100644 --- a/test/rbui/dialog_test.rb +++ b/test/rbui/dialog_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::DialogTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.Dialog do diff --git a/test/rbui/dropdown_menu_test.rb b/test/rbui/dropdown_menu_test.rb index 3eda792..b697f96 100644 --- a/test/rbui/dropdown_menu_test.rb +++ b/test/rbui/dropdown_menu_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::DropdownMenuTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.DropdownMenu do diff --git a/test/rbui/form_test.rb b/test/rbui/form_test.rb index 572f88e..4c6d460 100644 --- a/test/rbui/form_test.rb +++ b/test/rbui/form_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::FormTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.Form do diff --git a/test/rbui/hover_card_test.rb b/test/rbui/hover_card_test.rb index 455bfc0..899f7eb 100644 --- a/test/rbui/hover_card_test.rb +++ b/test/rbui/hover_card_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::HoverCardTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.HoverCard do diff --git a/test/rbui/input_test.rb b/test/rbui/input_test.rb index 3380e9b..9956a09 100644 --- a/test/rbui/input_test.rb +++ b/test/rbui/input_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::InputTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.Input(type: "email", placeholder: "Email") diff --git a/test/rbui/link_test.rb b/test/rbui/link_test.rb deleted file mode 100644 index 53faa88..0000000 --- a/test/rbui/link_test.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -require "test_helper" - -class RBUI::LinkTest < Minitest::Test - include Phlex::Testing::ViewHelper - - def test_render_with_all_items - output = phlex_context do - RBUI.Link(href: "#") { "Link" } - end - - assert_match(/Link/, output) - end -end diff --git a/test/rbui/pagination_test.rb b/test/rbui/pagination_test.rb index 68974e5..40edc1a 100644 --- a/test/rbui/pagination_test.rb +++ b/test/rbui/pagination_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::PaginationTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.Pagination do diff --git a/test/rbui/popover_test.rb b/test/rbui/popover_test.rb index 610a1c3..06d5d78 100644 --- a/test/rbui/popover_test.rb +++ b/test/rbui/popover_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::PopoverTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.Popover do diff --git a/test/rbui/select_test.rb b/test/rbui/select_test.rb index 6ebbf5a..e2f9810 100644 --- a/test/rbui/select_test.rb +++ b/test/rbui/select_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::SelectTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items people = [ ["John Doe", 1], diff --git a/test/rbui/sheet_test.rb b/test/rbui/sheet_test.rb index 17a3e78..8cb9515 100644 --- a/test/rbui/sheet_test.rb +++ b/test/rbui/sheet_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::SheetTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.Sheet do diff --git a/test/rbui/shortcut_key_test.rb b/test/rbui/shortcut_key_test.rb index ffbafbf..ae22604 100644 --- a/test/rbui/shortcut_key_test.rb +++ b/test/rbui/shortcut_key_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::ShortcutKeyTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.ShortcutKey do |shortcut| diff --git a/test/rbui/table_test.rb b/test/rbui/table_test.rb index a9f9b7a..fd05c65 100644 --- a/test/rbui/table_test.rb +++ b/test/rbui/table_test.rb @@ -3,8 +3,6 @@ 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}, diff --git a/test/rbui/tabs_test.rb b/test/rbui/tabs_test.rb index d16eec1..749e588 100644 --- a/test/rbui/tabs_test.rb +++ b/test/rbui/tabs_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::TabsTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.Tabs(default_value: "account", class: "w-96") do diff --git a/test/rbui/textarea_test.rb b/test/rbui/textarea_test.rb index 9174e70..5b239f4 100644 --- a/test/rbui/textarea_test.rb +++ b/test/rbui/textarea_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::TextareaTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.Textarea(rows: 4, placeholder: "Comment") diff --git a/test/rbui/theme_toggle_test.rb b/test/rbui/theme_toggle_test.rb index 31e06e0..1891660 100644 --- a/test/rbui/theme_toggle_test.rb +++ b/test/rbui/theme_toggle_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::ThemeToggleTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.ThemeToggle do |toggle| diff --git a/test/rbui/tooltip_test.rb b/test/rbui/tooltip_test.rb index d7f107c..7cf3d22 100644 --- a/test/rbui/tooltip_test.rb +++ b/test/rbui/tooltip_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::TooltipTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_render_with_all_items output = phlex_context do RBUI.Tooltip do diff --git a/test/rbui/typography_test.rb b/test/rbui/typography_test.rb index ea2c4de..d847a97 100644 --- a/test/rbui/typography_test.rb +++ b/test/rbui/typography_test.rb @@ -3,8 +3,6 @@ require "test_helper" class RBUI::TypographyTest < Minitest::Test - include Phlex::Testing::ViewHelper - def test_h1 output = phlex_context do RBUI.TypographyH1 { "This is an H1 title" } diff --git a/test/test_helper.rb b/test/test_helper.rb index d516fc7..dfecc49 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -5,7 +5,7 @@ Bundler.require(:default) require "phlex" -require "phlex/testing/view_helper" +# require "phlex/testing/view_helper" require "minitest/autorun" class TestContext < Phlex::HTML @@ -18,6 +18,28 @@ def phlex_context(&) render TestContext.new, & end +module Phlex::Testing + module Basic + def render(view, &) + if view.is_a?(Class) && view < Phlex::SGML + view = view.new + end + + view.call(view_context:, &) + end + + def view_context + nil + end + end + ViewHelper = Basic +end + +# Include Phlex::Testing::ViewHelper in Minitest::Test +class Minitest::Test + include Phlex::Testing::ViewHelper +end + # this is a tracepoint that will output the path of all files loaded that contain the string "phlex" # trace = TracePoint.new(:class) do |tp| # puts "Loaded: #{tp.path}" if tp.path.include?("phlex")