Sha256: d79c542eb4ebe06eb671d2da78883880c0b4e4b9df22670c47b7b5f88c7af119

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module Avo
  module Concerns
    module RowControlsConfiguration
      extend ActiveSupport::Concern

      included do
        class_attribute :row_controls_config, default: {}
      end

      def controls_placement
        @controls_placement ||= row_controls_configurations[:placement]
      end

      def render_row_controls_on_the_right?
        controls_placement.in? [:right, :both]
      end

      def render_row_controls_on_the_left?
        controls_placement.in? [:left, :both]
      end

      def row_controls_configurations
        @row_controls_configurations ||= Avo.configuration.resource_row_controls_config.merge(row_controls_config)
      end

      def row_controls_classes
        classes = "text-right whitespace-nowrap px-3"

        if render_row_controls_on_the_left?
          classes += " w-px"
        end

        if row_controls_configurations[:show_on_hover]
          classes += " opacity-0 group-hover:opacity-100"
        end

        if row_controls_configurations[:float]
          classes += " floating-row-controls sticky group-hover:bg-gray-50 bg-white inset-auto right-0"
        end

        classes
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
avo-3.16.4 lib/avo/concerns/row_controls_configuration.rb
avo-3.16.3 lib/avo/concerns/row_controls_configuration.rb