From 63cf4598e3484ea1e3ee706d85e075eddfeb184e Mon Sep 17 00:00:00 2001 From: Seth Horsley Date: Mon, 7 Oct 2024 02:11:27 +0200 Subject: [PATCH 01/14] =?UTF-8?q?got=20thangs=20working=20=F0=9F=98=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile.lock | 8 +++---- lib/rbui/alert/alert.rb | 2 +- lib/rbui/alert_dialog/alert_dialog_content.rb | 2 +- lib/rbui/avatar/avatar.rb | 2 +- lib/rbui/badge/badge.rb | 2 +- lib/rbui/button/button.rb | 24 +++++++++---------- lib/rbui/calendar/calendar_days.rb | 18 +++++++------- lib/rbui/calendar/calendar_weekdays.rb | 2 +- lib/rbui/codeblock/codeblock.rb | 4 +--- lib/rbui/command/command_dialog_content.rb | 6 ++--- lib/rbui/command/command_dialog_trigger.rb | 2 +- lib/rbui/context_menu/context_menu_content.rb | 2 +- lib/rbui/context_menu/context_menu_label.rb | 2 +- lib/rbui/dialog/dialog_content.rb | 6 ++--- lib/rbui/hover_card/hover_card_content.rb | 2 +- lib/rbui/link/link.rb | 24 +++++++++---------- lib/rbui/pagination/pagination_item.rb | 4 ++-- lib/rbui/sheet/sheet_content.rb | 6 ++--- lib/rbui/typography/typography_list.rb | 4 ++-- lib/rbui/version.rb | 2 +- package.json | 2 +- rbui.gemspec | 2 +- test/test_helper.rb | 20 +++++++++++++++- 23 files changed, 82 insertions(+), 66 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index c0309834e..1073acde1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,8 +1,8 @@ PATH remote: . specs: - rbui (1.0.0.pre.alpha.3) - phlex (~> 1.10) + rbui (1.0.0.pre.alpha.4) + phlex (~> 2.0.0.beta2) rouge (~> 4.2.0) tailwind_merge (>= 0.12) @@ -19,7 +19,7 @@ GEM parser (3.3.3.0) ast (~> 2.4.1) racc - phlex (1.11.0) + phlex (2.0.0.beta2) racc (1.8.0) rainbow (3.1.1) rake (13.2.1) @@ -57,7 +57,7 @@ GEM lint_roller (~> 1.1) rubocop-performance (~> 1.21.0) strscan (3.1.0) - tailwind_merge (0.13.0) + tailwind_merge (0.13.1) lru_redux (~> 1.1) unicode-display_width (2.5.0) diff --git a/lib/rbui/alert/alert.rb b/lib/rbui/alert/alert.rb index e9074d0f0..fdc428e38 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/alert_dialog/alert_dialog_content.rb b/lib/rbui/alert_dialog/alert_dialog_content.rb index 3120c95e3..f1e06e576 100644 --- a/lib/rbui/alert_dialog/alert_dialog_content.rb +++ b/lib/rbui/alert_dialog/alert_dialog_content.rb @@ -3,7 +3,7 @@ module RBUI class AlertDialogContent < Base def view_template(&block) - template_tag(**attrs) do + template(**attrs) do div(data: {controller: "rbui--alert-dialog"}) do background container(&block) diff --git a/lib/rbui/avatar/avatar.rb b/lib/rbui/avatar/avatar.rb index 8895ed8f2..28bd2bf55 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 a8dde0378..18afd91f9 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 5cd345be0..7cc679120 100644 --- a/lib/rbui/button/button.rb +++ b/lib/rbui/button/button.rb @@ -35,45 +35,45 @@ 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", 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", 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", 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", 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", 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", size_classes - ) + ] end def default_classes diff --git a/lib/rbui/calendar/calendar_days.rb b/lib/rbui/calendar/calendar_days.rb index b809de6b2..bf74d409d 100644 --- a/lib/rbui/calendar/calendar_days.rb +++ b/lib/rbui/calendar/calendar_days.rb @@ -20,10 +20,10 @@ def render_selected_date_template 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" - ), + ], role: "gridcell", tabindex: "0", type: "button", @@ -39,10 +39,10 @@ def render_today_date_template 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" - ), + ], role: "gridcell", tabindex: "-1", type: "button" @@ -57,10 +57,10 @@ def render_current_month_date_template 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" - ), + ], role: "gridcell", tabindex: "-1", type: "button" @@ -75,10 +75,10 @@ def render_other_month_date_template 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" - ), + ], role: "gridcell", tabindex: "-1", type: "button" @@ -87,7 +87,7 @@ def render_other_month_date_template end def date_template(target, &block) - template_tag(data: {rbui__calendar_target: target}) do + template(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", diff --git a/lib/rbui/calendar/calendar_weekdays.rb b/lib/rbui/calendar/calendar_weekdays.rb index 6487036e4..c93600566 100644 --- a/lib/rbui/calendar/calendar_weekdays.rb +++ b/lib/rbui/calendar/calendar_weekdays.rb @@ -5,7 +5,7 @@ class CalendarWeekdays < Base DAYS = %w[Monday Tuesday Wednesday Thursday Friday Saturday Sunday].freeze def view_template - template_tag(data: {rbui__calendar_target: "weekdaysTemplate"}) do + template(data: {rbui__calendar_target: "weekdaysTemplate"}) do thead(**attrs) do tr(class: "flex") do DAYS.each do |day| diff --git a/lib/rbui/codeblock/codeblock.rb b/lib/rbui/codeblock/codeblock.rb index f53f0aba7..29e6a010a 100644 --- a/lib/rbui/codeblock/codeblock.rb +++ b/lib/rbui/codeblock/codeblock.rb @@ -55,9 +55,7 @@ def codeblock div(**attrs) do div(class: "after:content-none") do pre do - unsafe_raw FORMATTER.format( - lexer.lex(@code) - ) + raw(safe(FORMATTER.format(lexer.lex(@code)))) end end end diff --git a/lib/rbui/command/command_dialog_content.rb b/lib/rbui/command/command_dialog_content.rb index 12cefcd33..576157352 100644 --- a/lib/rbui/command/command_dialog_content.rb +++ b/lib/rbui/command/command_dialog_content.rb @@ -17,7 +17,7 @@ def initialize(size: :md, **attrs) end def view_template(&block) - template_tag(data: {rbui__command_target: "content"}) do + template(data: {rbui__command_target: "content"}) do div(data: {controller: "rbui--command"}) do backdrop div(**attrs, &block) @@ -30,10 +30,10 @@ def view_template(&block) 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 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 c30adbc95..7d4d0f177 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_content.rb b/lib/rbui/context_menu/context_menu_content.rb index c65b2d961..39a3014bc 100644 --- a/lib/rbui/context_menu/context_menu_content.rb +++ b/lib/rbui/context_menu/context_menu_content.rb @@ -3,7 +3,7 @@ module RBUI class ContextMenuContent < Base def view_template(&block) - template_tag(data: {rbui__context_menu_target: "content"}) do + template(data: {rbui__context_menu_target: "content"}) do div(**attrs, &block) end end diff --git a/lib/rbui/context_menu/context_menu_label.rb b/lib/rbui/context_menu/context_menu_label.rb index d7bf6434c..46e779f7a 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 29c1f9391..c05d4b277 100644 --- a/lib/rbui/dialog/dialog_content.rb +++ b/lib/rbui/dialog/dialog_content.rb @@ -17,7 +17,7 @@ def initialize(size: :md, **attrs) end def view_template - template_tag(data: {rbui__dialog_target: "content"}) do + template(data: {rbui__dialog_target: "content"}) do div(data_controller: "rbui--dialog") do backdrop div(**attrs) do @@ -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/hover_card/hover_card_content.rb b/lib/rbui/hover_card/hover_card_content.rb index c0de0b5bd..3fff27114 100644 --- a/lib/rbui/hover_card/hover_card_content.rb +++ b/lib/rbui/hover_card/hover_card_content.rb @@ -3,7 +3,7 @@ module RBUI class HoverCardContent < Base def view_template(&block) - template_tag(data: {rbui__hover_card_target: "content"}) do + template(data: {rbui__hover_card_target: "content"}) do div(**attrs, &block) end end diff --git a/lib/rbui/link/link.rb b/lib/rbui/link/link.rb index b3dc37556..083c316ce 100644 --- a/lib/rbui/link/link.rb +++ b/lib/rbui/link/link.rb @@ -35,45 +35,45 @@ 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", 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", 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", 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", 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", 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", size_classes - ) + ] end def default_classes diff --git a/lib/rbui/pagination/pagination_item.rb b/lib/rbui/pagination/pagination_item.rb index 4035f884a..3a211d1d8 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 dc50931af..bb1c5cbbb 100644 --- a/lib/rbui/sheet/sheet_content.rb +++ b/lib/rbui/sheet/sheet_content.rb @@ -16,7 +16,7 @@ def initialize(side: :right, **attrs) end def view_template(&block) - template_tag(data: {rbui__sheet_target: "content"}) do + template(data: {rbui__sheet_target: "content"}) do div(data: {controller: "rbui--sheet-content"}) do backdrop div(**attrs) do @@ -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 22b11c57d..8769328a0 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/lib/rbui/version.rb b/lib/rbui/version.rb index 1e3692e4c..ce71ba2bc 100644 --- a/lib/rbui/version.rb +++ b/lib/rbui/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module RBUI - VERSION = "1.0.0-alpha.3" + VERSION = "1.0.0-alpha.4" end diff --git a/package.json b/package.json index bfdaeb69b..02547f63b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rbui-js", - "version": "1.0.0-alpha.3", + "version": "1.0.0-alpha.4", "main": "lib/rbui/index.js", "description": "Stimulus controllers for RbUI Component Library", "homepage": "https://rbui.dev", diff --git a/rbui.gemspec b/rbui.gemspec index 8ad97662b..400e4dcdb 100644 --- a/rbui.gemspec +++ b/rbui.gemspec @@ -15,7 +15,7 @@ Gem::Specification.new do |s| s.required_ruby_version = ">= 3.2" - s.add_dependency "phlex", "~> 1.10" + s.add_dependency "phlex", "~> 2.0.0.beta2" s.add_dependency "rouge", "~> 4.2.0" s.add_dependency "tailwind_merge", ">= 0.12" diff --git a/test/test_helper.rb b/test/test_helper.rb index d516fc7cb..87803a866 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,24 @@ def phlex_context(&) render TestContext.new, & end +# this is a monkey patch for https://github.com/phlex-ruby/phlex/pull/809 +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 + # 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") From 6e693017ad960125f3138c2ab761650c1641f0c9 Mon Sep 17 00:00:00 2001 From: Seth Horsley Date: Mon, 7 Oct 2024 02:19:40 +0200 Subject: [PATCH 02/14] fix ruby version --- .github/workflows/ci.yml | 22 +++++++++------------- .ruby-version | 1 - .tool-versions | 2 ++ 3 files changed, 11 insertions(+), 14 deletions(-) delete mode 100644 .ruby-version create mode 100644 .tool-versions diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 911cbd579..2b516433e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,21 +13,17 @@ jobs: name: StandardRB Check Action runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.3 - bundler-cache: true # runs 'bundle install' and caches installed gems automatically - - run: bundle exec standardrb --format progress + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + - run: bundle exec standardrb --format progress tests: strategy: - fail-fast: false - matrix: - os: ["ubuntu-latest"] - ruby-version: - - "3.2" - - "3.3" - - "head" + fail-fast: false + matrix: + os: ["ubuntu-latest"] + name: Running minitest runs-on: ubuntu-latest steps: diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index 619b53766..000000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -3.3.3 diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 000000000..a289dce10 --- /dev/null +++ b/.tool-versions @@ -0,0 +1,2 @@ +ruby 3.3.4 + From 0931121239e553437e2ffe0e1d97472b22f8a43d Mon Sep 17 00:00:00 2001 From: Seth Horsley Date: Mon, 7 Oct 2024 02:21:05 +0200 Subject: [PATCH 03/14] allow people to use phlex 1 too --- Gemfile.lock | 2 +- rbui.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1073acde1..c8d504ebf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,7 +2,7 @@ PATH remote: . specs: rbui (1.0.0.pre.alpha.4) - phlex (~> 2.0.0.beta2) + phlex (>= 1.10) rouge (~> 4.2.0) tailwind_merge (>= 0.12) diff --git a/rbui.gemspec b/rbui.gemspec index 400e4dcdb..d524b1f0e 100644 --- a/rbui.gemspec +++ b/rbui.gemspec @@ -15,7 +15,7 @@ Gem::Specification.new do |s| s.required_ruby_version = ">= 3.2" - s.add_dependency "phlex", "~> 2.0.0.beta2" + s.add_dependency "phlex", ">= 1.10" s.add_dependency "rouge", "~> 4.2.0" s.add_dependency "tailwind_merge", ">= 0.12" From b9f846b142464c4c3a64511547f51f58bde1eb6f Mon Sep 17 00:00:00 2001 From: Seth Horsley Date: Mon, 7 Oct 2024 02:28:30 +0200 Subject: [PATCH 04/14] update ruby --- .tool-versions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tool-versions b/.tool-versions index a289dce10..3f7cdb287 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -ruby 3.3.4 +ruby 3.3.5 From 9ae80703d3c0a49e619657f78d42ac0feaf5d880 Mon Sep 17 00:00:00 2001 From: Seth Horsley Date: Mon, 14 Oct 2024 19:13:52 +0200 Subject: [PATCH 05/14] add ruby versions and phlex --- .github/workflows/ci.yml | 42 +++++++++++++++++++++++++++++++--------- gemfiles/phlex1.gemfile | 5 +++++ gemfiles/phlex2.gemfile | 5 +++++ 3 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 gemfiles/phlex1.gemfile create mode 100644 gemfiles/phlex2.gemfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b516433e..db9c94556 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,22 +16,46 @@ jobs: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - bundler-cache: true # runs 'bundle install' and caches installed gems automatically + ruby-version: 3.3 # Use the latest stable Ruby version for StandardRB + bundler-cache: true - run: bundle exec standardrb --format progress + tests: + name: Tests (Ruby ${{ matrix.ruby }} - ${{ matrix.gemfile }}) strategy: - fail-fast: false matrix: - os: ["ubuntu-latest"] + include: + # Latest Ruby with latest Phlex + - ruby: 3.3 + gemfile: Gemfile + + # Ruby 3.2 with Phlex 1 + - ruby: 3.2 + gemfile: gemfiles/phlex1.gemfile + + # Ruby 3.1 with Phlex 1 + - ruby: 3.1 + gemfile: gemfiles/phlex1.gemfile - name: Running minitest + # Ruby 3.0 with Phlex 1 + - ruby: "3.0" + gemfile: gemfiles/phlex1.gemfile + + # Ruby 2.7 with Phlex 1 + - ruby: 2.7 + gemfile: gemfiles/phlex1.gemfile + + fail-fast: false runs-on: ubuntu-latest + env: + BUNDLE_GEMFILE: ${{ matrix.gemfile }} steps: - uses: actions/checkout@v4 - - uses: ruby/setup-ruby@v1 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 with: - ruby-version: ${{ matrix.ruby-version }} - bundler-cache: false + ruby-version: ${{ matrix.ruby }} + bundler-cache: true - - run: bundle install - - run: bundle exec rake test + - name: Run tests + run: bundle exec rake test diff --git a/gemfiles/phlex1.gemfile b/gemfiles/phlex1.gemfile new file mode 100644 index 000000000..7d45c61eb --- /dev/null +++ b/gemfiles/phlex1.gemfile @@ -0,0 +1,5 @@ +source "https://rubygems.org" + +gemspec path: ".." + +gem "phlex", "~> 1.0" diff --git a/gemfiles/phlex2.gemfile b/gemfiles/phlex2.gemfile new file mode 100644 index 000000000..687406182 --- /dev/null +++ b/gemfiles/phlex2.gemfile @@ -0,0 +1,5 @@ +source "https://rubygems.org" + +gemspec path: ".." + +gem "phlex", "~> 2.0" From c99ce5899a4f0268704aa82b3db45dc7f9c01193 Mon Sep 17 00:00:00 2001 From: Seth Horsley Date: Mon, 14 Oct 2024 19:15:04 +0200 Subject: [PATCH 06/14] update min ruby version --- rbui.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rbui.gemspec b/rbui.gemspec index d524b1f0e..37301d95f 100644 --- a/rbui.gemspec +++ b/rbui.gemspec @@ -13,7 +13,7 @@ Gem::Specification.new do |s| "https://rubygems.org/gems/rbui" s.license = "MIT" - s.required_ruby_version = ">= 3.2" + s.required_ruby_version = ">= 2.7" s.add_dependency "phlex", ">= 1.10" s.add_dependency "rouge", "~> 4.2.0" From 8d3ab1b1e2c59cb6240058eb18a63e7473f5e4bc Mon Sep 17 00:00:00 2001 From: Seth Horsley Date: Mon, 14 Oct 2024 19:43:49 +0200 Subject: [PATCH 07/14] update ci ruby versions --- .github/workflows/ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db9c94556..ffd378fc1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,10 +41,6 @@ jobs: - ruby: "3.0" gemfile: gemfiles/phlex1.gemfile - # Ruby 2.7 with Phlex 1 - - ruby: 2.7 - gemfile: gemfiles/phlex1.gemfile - fail-fast: false runs-on: ubuntu-latest env: From 8de93085eb7153fca798cbe1330eca804ebef483 Mon Sep 17 00:00:00 2001 From: Seth Horsley Date: Wed, 30 Oct 2024 01:39:31 +0100 Subject: [PATCH 08/14] fix merge from main --- Gemfile.lock | 8 +------- gemfiles/phlex1.gemfile | 5 ----- gemfiles/phlex2.gemfile | 5 ----- rbui.gemspec | 25 ------------------------- 4 files changed, 1 insertion(+), 42 deletions(-) delete mode 100644 gemfiles/phlex1.gemfile delete mode 100644 gemfiles/phlex2.gemfile delete mode 100644 rbui.gemspec diff --git a/Gemfile.lock b/Gemfile.lock index 66e388e72..348f04d08 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,10 +1,6 @@ PATH remote: . specs: - rbui (1.0.0.pre.alpha.4) - phlex (>= 1.10) - rbui (1.0.0.pre.alpha.3) - phlex (~> 1.10) ruby_ui (1.0.0.pre.alpha.4) phlex (~> 1.10) rouge (~> 4.2.0) @@ -23,7 +19,7 @@ GEM parser (3.3.3.0) ast (~> 2.4.1) racc - phlex (2.0.0.beta2) + phlex (1.11.0) racc (1.8.0) rainbow (3.1.1) rake (13.2.1) @@ -61,8 +57,6 @@ GEM lint_roller (~> 1.1) rubocop-performance (~> 1.21.0) strscan (3.1.0) - tailwind_merge (0.13.1) - tailwind_merge (0.13.0) tailwind_merge (0.13.2) lru_redux (~> 1.1) unicode-display_width (2.5.0) diff --git a/gemfiles/phlex1.gemfile b/gemfiles/phlex1.gemfile deleted file mode 100644 index 7d45c61eb..000000000 --- a/gemfiles/phlex1.gemfile +++ /dev/null @@ -1,5 +0,0 @@ -source "https://rubygems.org" - -gemspec path: ".." - -gem "phlex", "~> 1.0" diff --git a/gemfiles/phlex2.gemfile b/gemfiles/phlex2.gemfile deleted file mode 100644 index 687406182..000000000 --- a/gemfiles/phlex2.gemfile +++ /dev/null @@ -1,5 +0,0 @@ -source "https://rubygems.org" - -gemspec path: ".." - -gem "phlex", "~> 2.0" diff --git a/rbui.gemspec b/rbui.gemspec deleted file mode 100644 index 37301d95f..000000000 --- a/rbui.gemspec +++ /dev/null @@ -1,25 +0,0 @@ -require_relative "lib/rbui/version" - -Gem::Specification.new do |s| - s.name = "rbui" - s.version = RBUI::VERSION - s.summary = "RbUI is a UI Component Library for Ruby developers." - s.description = "RbUI is a UI Component Library for Ruby developers. Built on top of the Phlex Framework." - s.authors = ["George Kettle"] - s.email = "george.kettle@icloud.com" - s.files = Dir["lib/**/*.rb", "tasks/**/*.rake"] - s.require_path = "lib" - s.homepage = - "https://rubygems.org/gems/rbui" - s.license = "MIT" - - s.required_ruby_version = ">= 2.7" - - s.add_dependency "phlex", ">= 1.10" - s.add_dependency "rouge", "~> 4.2.0" - s.add_dependency "tailwind_merge", ">= 0.12" - - s.add_development_dependency "rake" - s.add_development_dependency "standard" - s.add_development_dependency "minitest" -end From d1b10b2ef45a5a9843f33bb0416906977707d23c Mon Sep 17 00:00:00 2001 From: Seth Horsley Date: Wed, 30 Oct 2024 16:15:18 +0100 Subject: [PATCH 09/14] WIP --- gemfiles/phlex1.gemfile | 5 +++++ gemfiles/phlex2.gemfile | 5 +++++ lib/rbui/codeblock/codeblock.rb | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 gemfiles/phlex1.gemfile create mode 100644 gemfiles/phlex2.gemfile diff --git a/gemfiles/phlex1.gemfile b/gemfiles/phlex1.gemfile new file mode 100644 index 000000000..7d45c61eb --- /dev/null +++ b/gemfiles/phlex1.gemfile @@ -0,0 +1,5 @@ +source "https://rubygems.org" + +gemspec path: ".." + +gem "phlex", "~> 1.0" diff --git a/gemfiles/phlex2.gemfile b/gemfiles/phlex2.gemfile new file mode 100644 index 000000000..687406182 --- /dev/null +++ b/gemfiles/phlex2.gemfile @@ -0,0 +1,5 @@ +source "https://rubygems.org" + +gemspec path: ".." + +gem "phlex", "~> 2.0" diff --git a/lib/rbui/codeblock/codeblock.rb b/lib/rbui/codeblock/codeblock.rb index 29e6a010a..d8a3f4121 100644 --- a/lib/rbui/codeblock/codeblock.rb +++ b/lib/rbui/codeblock/codeblock.rb @@ -55,7 +55,13 @@ def codeblock div(**attrs) do div(class: "after:content-none") do pre do - raw(safe(FORMATTER.format(lexer.lex(@code)))) + if Gem::Version.new(Gem.loaded_specs["phlex"].version) < Gem::Version.new("2.0.0") + unsafe_raw FORMATTER.format( + lexer.lex(@code) + ) + else + raw(safe(FORMATTER.format(lexer.lex(@code)))) + end end end end From 7b0515f81a5f16ef878055e4d13203d9a997e3eb Mon Sep 17 00:00:00 2001 From: Seth Horsley Date: Sun, 3 Nov 2024 00:46:39 +0100 Subject: [PATCH 10/14] tests should be passing --- lib/rbui/alert_dialog/alert_dialog_content.rb | 9 ++++++++- lib/rbui/calendar/calendar_days.rb | 9 ++++++++- lib/rbui/calendar/calendar_weekdays.rb | 10 +++++++++- lib/rbui/codeblock/codeblock.rb | 10 +++++++--- lib/rbui/command/command_dialog_content.rb | 9 ++++++++- lib/rbui/context_menu/context_menu_content.rb | 9 ++++++++- lib/rbui/dialog/dialog_content.rb | 10 +++++++++- lib/rbui/hover_card/hover_card_content.rb | 9 ++++++++- lib/rbui/sheet/sheet_content.rb | 9 ++++++++- 9 files changed, 73 insertions(+), 11 deletions(-) diff --git a/lib/rbui/alert_dialog/alert_dialog_content.rb b/lib/rbui/alert_dialog/alert_dialog_content.rb index f1e06e576..40760eaf9 100644 --- a/lib/rbui/alert_dialog/alert_dialog_content.rb +++ b/lib/rbui/alert_dialog/alert_dialog_content.rb @@ -3,7 +3,14 @@ module RBUI class AlertDialogContent < Base def view_template(&block) - template(**attrs) do + current_version = Gem.loaded_specs["phlex"].version + _template_tag = if current_version.segments[0] >= 2 + template + else + template_tag + end + + _template_tag(**attrs) do div(data: {controller: "rbui--alert-dialog"}) do background container(&block) diff --git a/lib/rbui/calendar/calendar_days.rb b/lib/rbui/calendar/calendar_days.rb index bf74d409d..6aabd045a 100644 --- a/lib/rbui/calendar/calendar_days.rb +++ b/lib/rbui/calendar/calendar_days.rb @@ -87,7 +87,14 @@ def render_other_month_date_template end def date_template(target, &block) - template(data: {rbui__calendar_target: target}) do + current_version = Gem.loaded_specs["phlex"].version + _template_tag = if current_version.segments[0] >= 2 + template + else + template_tag + end + + _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", diff --git a/lib/rbui/calendar/calendar_weekdays.rb b/lib/rbui/calendar/calendar_weekdays.rb index c93600566..042266fdf 100644 --- a/lib/rbui/calendar/calendar_weekdays.rb +++ b/lib/rbui/calendar/calendar_weekdays.rb @@ -5,7 +5,15 @@ class CalendarWeekdays < Base DAYS = %w[Monday Tuesday Wednesday Thursday Friday Saturday Sunday].freeze def view_template - template(data: {rbui__calendar_target: "weekdaysTemplate"}) do + current_version = Gem.loaded_specs["phlex"].version + + _template_tag = if current_version.segments[0] >= 2 + template + else + template_tag + end + + _template_tag(data: {rbui__calendar_target: "weekdaysTemplate"}) do thead(**attrs) do tr(class: "flex") do DAYS.each do |day| diff --git a/lib/rbui/codeblock/codeblock.rb b/lib/rbui/codeblock/codeblock.rb index d8a3f4121..2a360c88e 100644 --- a/lib/rbui/codeblock/codeblock.rb +++ b/lib/rbui/codeblock/codeblock.rb @@ -55,12 +55,16 @@ def codeblock div(**attrs) do div(class: "after:content-none") do pre do - if Gem::Version.new(Gem.loaded_specs["phlex"].version) < Gem::Version.new("2.0.0") + current_version = Gem.loaded_specs["phlex"].version + + if current_version.segments[0] >= 2 + # Any 2.x version (including betas) + raw(safe(FORMATTER.format(lexer.lex(@code)))) + else + # Any 1.x version unsafe_raw FORMATTER.format( lexer.lex(@code) ) - else - raw(safe(FORMATTER.format(lexer.lex(@code)))) end end end diff --git a/lib/rbui/command/command_dialog_content.rb b/lib/rbui/command/command_dialog_content.rb index 576157352..83c8fb5f8 100644 --- a/lib/rbui/command/command_dialog_content.rb +++ b/lib/rbui/command/command_dialog_content.rb @@ -17,7 +17,14 @@ def initialize(size: :md, **attrs) end def view_template(&block) - template(data: {rbui__command_target: "content"}) do + current_version = Gem.loaded_specs["phlex"].version + _template_tag = if current_version.segments[0] >= 2 + template + else + template_tag + end + + _template_tag(data: {rbui__command_target: "content"}) do div(data: {controller: "rbui--command"}) do backdrop div(**attrs, &block) diff --git a/lib/rbui/context_menu/context_menu_content.rb b/lib/rbui/context_menu/context_menu_content.rb index 39a3014bc..c48181de3 100644 --- a/lib/rbui/context_menu/context_menu_content.rb +++ b/lib/rbui/context_menu/context_menu_content.rb @@ -3,7 +3,14 @@ module RBUI class ContextMenuContent < Base def view_template(&block) - template(data: {rbui__context_menu_target: "content"}) do + current_version = Gem.loaded_specs["phlex"].version + _template_tag = if current_version.segments[0] >= 2 + template + else + template_tag + end + + _template_tag(data: {rbui__context_menu_target: "content"}) do div(**attrs, &block) end end diff --git a/lib/rbui/dialog/dialog_content.rb b/lib/rbui/dialog/dialog_content.rb index c05d4b277..a0ff2b276 100644 --- a/lib/rbui/dialog/dialog_content.rb +++ b/lib/rbui/dialog/dialog_content.rb @@ -17,7 +17,15 @@ def initialize(size: :md, **attrs) end def view_template - template(data: {rbui__dialog_target: "content"}) do + current_version = Gem.loaded_specs["phlex"].version + + _template_tag = if current_version.segments[0] >= 2 + template + else + template_tag + end + + _template_tag(data: {rbui__dialog_target: "content"}) do div(data_controller: "rbui--dialog") do backdrop div(**attrs) do diff --git a/lib/rbui/hover_card/hover_card_content.rb b/lib/rbui/hover_card/hover_card_content.rb index 3fff27114..ad0930f7e 100644 --- a/lib/rbui/hover_card/hover_card_content.rb +++ b/lib/rbui/hover_card/hover_card_content.rb @@ -3,7 +3,14 @@ module RBUI class HoverCardContent < Base def view_template(&block) - template(data: {rbui__hover_card_target: "content"}) do + current_version = Gem.loaded_specs["phlex"].version + + _template_tag = if current_version.segments[0] >= 2 + template + else + template_tag + end + _template_tag(data: {rbui__hover_card_target: "content"}) do div(**attrs, &block) end end diff --git a/lib/rbui/sheet/sheet_content.rb b/lib/rbui/sheet/sheet_content.rb index bb1c5cbbb..649677e99 100644 --- a/lib/rbui/sheet/sheet_content.rb +++ b/lib/rbui/sheet/sheet_content.rb @@ -16,7 +16,14 @@ def initialize(side: :right, **attrs) end def view_template(&block) - template(data: {rbui__sheet_target: "content"}) do + current_version = Gem.loaded_specs["phlex"].version + _template_tag = if current_version.segments[0] >= 2 + template + else + template_tag + end + + _template_tag(data: {rbui__sheet_target: "content"}) do div(data: {controller: "rbui--sheet-content"}) do backdrop div(**attrs) do From df0cf37ce6d72cdbd0761820d7420bc388b89ecd Mon Sep 17 00:00:00 2001 From: Seth Horsley Date: Sun, 3 Nov 2024 03:15:22 +0100 Subject: [PATCH 11/14] update gemspec --- Gemfile.lock | 2 +- ruby_ui.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 348f04d08..f1b0bea55 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,7 +2,7 @@ PATH remote: . specs: ruby_ui (1.0.0.pre.alpha.4) - phlex (~> 1.10) + phlex (~> 1.10, < 3) rouge (~> 4.2.0) tailwind_merge (~> 0.12) diff --git a/ruby_ui.gemspec b/ruby_ui.gemspec index 15395e7c7..c86153338 100644 --- a/ruby_ui.gemspec +++ b/ruby_ui.gemspec @@ -15,7 +15,7 @@ Gem::Specification.new do |s| s.required_ruby_version = ">= 3.2" - s.add_dependency "phlex", "~> 1.10" + s.add_dependency "phlex", "~> 1.10", "< 3" s.add_dependency "rouge", "~> 4.2.0" s.add_dependency "tailwind_merge", "~> 0.12" From 253cdf1a331624205bbf6a48a0eeecc0de085520 Mon Sep 17 00:00:00 2001 From: Seth Horsley Date: Sun, 3 Nov 2024 04:11:19 +0100 Subject: [PATCH 12/14] update min ruby version --- ruby_ui.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruby_ui.gemspec b/ruby_ui.gemspec index c86153338..2510a207d 100644 --- a/ruby_ui.gemspec +++ b/ruby_ui.gemspec @@ -13,7 +13,7 @@ Gem::Specification.new do |s| "https://rubygems.org/gems/ruby_ui" s.license = "MIT" - s.required_ruby_version = ">= 3.2" + s.required_ruby_version = ">= 3.0" s.add_dependency "phlex", "~> 1.10", "< 3" s.add_dependency "rouge", "~> 4.2.0" From 78676104dc083e11ec0cc468d09e005ac154b71d Mon Sep 17 00:00:00 2001 From: Seth Horsley Date: Sun, 3 Nov 2024 16:28:56 +0100 Subject: [PATCH 13/14] phlex kit only works with ruby 3.2 and above --- .github/workflows/ci.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ffd378fc1..3e168a3f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,14 +33,6 @@ jobs: - ruby: 3.2 gemfile: gemfiles/phlex1.gemfile - # Ruby 3.1 with Phlex 1 - - ruby: 3.1 - gemfile: gemfiles/phlex1.gemfile - - # Ruby 3.0 with Phlex 1 - - ruby: "3.0" - gemfile: gemfiles/phlex1.gemfile - fail-fast: false runs-on: ubuntu-latest env: From 7423b174cc5b974366224a9319007ecafbcba975 Mon Sep 17 00:00:00 2001 From: Seth Horsley Date: Sun, 3 Nov 2024 17:22:25 +0100 Subject: [PATCH 14/14] clean up files and add back ruby-version file --- .ruby-version | 2 ++ gemfiles/phlex2.gemfile | 2 +- lib/rbui/typography/typography_list.rb | 47 -------------------------- 3 files changed, 3 insertions(+), 48 deletions(-) create mode 100644 .ruby-version delete mode 100644 lib/rbui/typography/typography_list.rb diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 000000000..92fd9f951 --- /dev/null +++ b/.ruby-version @@ -0,0 +1,2 @@ +3.3.3 + diff --git a/gemfiles/phlex2.gemfile b/gemfiles/phlex2.gemfile index 687406182..197772403 100644 --- a/gemfiles/phlex2.gemfile +++ b/gemfiles/phlex2.gemfile @@ -2,4 +2,4 @@ source "https://rubygems.org" gemspec path: ".." -gem "phlex", "~> 2.0" +gem "phlex", "~> 2.0.0.beta2" diff --git a/lib/rbui/typography/typography_list.rb b/lib/rbui/typography/typography_list.rb deleted file mode 100644 index 8769328a0..000000000 --- a/lib/rbui/typography/typography_list.rb +++ /dev/null @@ -1,47 +0,0 @@ -# frozen_string_literal: true - -module RBUI - class TypographyList < Base - def initialize(items: [], numbered: false, **attrs) - @items = items - @numbered = numbered - super(**attrs) - end - - def view_template(&) - if @items.empty? - list(**attrs, &) - else - list(**attrs) do - @items.each do |item| - TypographyListItem { item } - end - end - end - end - - private - - def list(**attrs, &) - if numbered? - ol(**attrs, &) - else - ul(**attrs, &) - end - end - - def numbered? = @numbered - - def not_numbered? = !numbered? - - def default_attrs - { - class: [ - "my-6 ml-6 [&>li]:mt-2 [&>li]:pl-2", - numbered?: "list-decimal marker:font-medium", - not_numbered?: "list-disc" - ] - } - end - end -end