diff --git a/Gemfile.lock b/Gemfile.lock index aa6a9e6529..b337bf3f07 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -107,7 +107,7 @@ GIT PATH remote: . specs: - avo (3.13.6) + avo (3.13.7) actionview (>= 6.1) active_link_to activerecord (>= 6.1) @@ -508,7 +508,7 @@ GEM railties (>= 5.2) reverse_markdown (2.1.1) nokogiri - rexml (3.3.7) + rexml (3.3.9) ripper-tags (1.0.2) rspec-core (3.13.1) rspec-support (~> 3.13.0) @@ -643,7 +643,7 @@ GEM unicode-display_width (2.6.0) uri (0.13.1) useragent (0.16.10) - view_component (3.15.1) + view_component (3.17.0) activesupport (>= 5.2.0, < 8.0) concurrent-ruby (~> 1.0) method_source (~> 1.0) diff --git a/README.md b/README.md index 44eb7fa35d..b74ea91125 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ Please read the [RELEASE.MD](./RELEASE.MD) -[Become a sponsor ](https://github.com/sponsors/adrianthedev) +[Become a sponsor](mailto:hi@avohq.io) ![Alt](https://repobeats.axiom.co/api/embed/1481a6a259064f02a7936470d12a50802a9c98a4.svg "Repobeats analytics image") @@ -120,3 +120,10 @@ Please read the [RELEASE.MD](./RELEASE.MD) [Get a box of waffles and some of the best app monitoring from Appsignal](https://appsignal.com/r/93dbe69bfb) 🧇 [Get $100 in credits from Digital Ocean](https://www.digitalocean.com/?refcode=efc1fe881d74&utm_campaign=Referral_Invite&utm_medium=Referral_Program&utm_source=badge) 💸 + +## Other Open Source Work + + - [`active_storage-blurhash`](https://github.com/avo-hq/active_storage-blurhash) - A plug-n-play [blurhash](https://blurha.sh/) integration for images stored in ActiveStorage + - [`class_variants`](https://github.com/avo-hq/class_variants) - Easily configure styles and apply them as classes. Very useful when you're implementing Tailwind CSS components and call them with different states. + - [`prop_initializer`](https://github.com/avo-hq/prop_initializer) - A flexible tool for defining properties on Ruby classes. + - [`stimulus-confetti`](https://github.com/avo-hq/stimulus-confetti) - The easiest way to add confetti to your StimulusJS app diff --git a/app/components/avo/actions_component.rb b/app/components/avo/actions_component.rb index 0829acb8b3..59754068e3 100644 --- a/app/components/avo/actions_component.rb +++ b/app/components/avo/actions_component.rb @@ -34,6 +34,13 @@ class Avo::ActionsComponent < Avo::BaseComponent def after_initialize filter_actions unless @custom_list + + # Hydrate each action action with the record when rendering a list on row controls + if @as_row_control + @actions.each do |action| + action.hydrate(resource: @resource, record: @resource.record) if action.respond_to?(:hydrate) + end + end end def render? @@ -52,23 +59,8 @@ def filter_actions end end - # How should the action be displayed by default - def is_disabled?(action) - return false if action.standalone || @as_row_control - - on_index_page? - end - private - def on_record_page? - @view.in?(["show", "edit", "new"]) - end - - def on_index_page? - !on_record_page? - end - def icon(icon) svg icon, class: "h-5 shrink-0 mr-1 inline pointer-events-none" end @@ -112,15 +104,17 @@ def action_data_attributes(action) "turbo-frame": Avo::MODAL_FRAME_ID, action: "click->actions-picker#visitAction", "actions-picker-target": action.standalone ? "standaloneAction" : "resourceAction", - disabled: is_disabled?(action), + disabled: action.disabled?, turbo_prefetch: false, + enabled_classes: "text-black", + disabled_classes: "text-gray-500" } end def action_css_class(action) helpers.class_names("flex items-center px-4 py-3 w-full font-semibold text-sm hover:bg-primary-100", { - "text-gray-500": is_disabled?(action), - "text-black": !is_disabled?(action), + "text-gray-500": action.disabled?, + "text-black": action.enabled?, }) end end diff --git a/app/components/avo/fields/common/boolean_check_component.html.erb b/app/components/avo/fields/common/boolean_check_component.html.erb index 3bef51608b..6db564030f 100644 --- a/app/components/avo/fields/common/boolean_check_component.html.erb +++ b/app/components/avo/fields/common/boolean_check_component.html.erb @@ -1 +1 @@ -<%= helpers.svg "#{@icon}.svg", class: @classes %> +<%= helpers.svg "#{@icon}.svg", class: classes %> diff --git a/app/components/avo/fields/common/boolean_check_component.rb b/app/components/avo/fields/common/boolean_check_component.rb index a6d69071ed..70dcc6ce75 100644 --- a/app/components/avo/fields/common/boolean_check_component.rb +++ b/app/components/avo/fields/common/boolean_check_component.rb @@ -2,10 +2,17 @@ class Avo::Fields::Common::BooleanCheckComponent < Avo::BaseComponent prop :checked, default: false + prop :size, default: :md prop :icon do |value| @checked ? "heroicons/outline/check-circle" : "heroicons/outline/x-circle" end - prop :classes do |value| - "h-6 #{@checked ? "text-green-600" : "text-red-500"}" + + def classes + helpers.class_names({ + "h-5": @size == :sm, + "h-6": @size == :md, + "text-green-600": @checked, + "text-red-600": !@checked, + }) end end diff --git a/app/components/avo/fields/common/boolean_group_component.html.erb b/app/components/avo/fields/common/boolean_group_component.html.erb index 79e2d1302a..5bbb3e968c 100644 --- a/app/components/avo/fields/common/boolean_group_component.html.erb +++ b/app/components/avo/fields/common/boolean_group_component.html.erb @@ -1,11 +1,11 @@
<%= link_to t("avo.view").humanize, "javascript:void(0);", data: {"tippy-target": :source} %>