Sha256: 52f47693c633c70905d59944277a9f82b66c690dc06f008442140ea234c1266d

Contents?: true

Size: 606 Bytes

Versions: 25

Compression:

Stored size: 606 Bytes

Contents

module Coco
  class PagerButton < Coco::Component
    include Concerns::AcceptsOptions

    tag_name :a
    tag_attr :href, :target

    accepts_option :direction, from: %i[previous next], required: true

    renders_one :icon, ->(name, **kwargs) do
      Coco::Icon.new(**kwargs, name: name, size: :xxl)
    end

    before_render do
      unless icon?
        with_icon(next? ? :chevron_right : :chevron_left)
      end
    end

    def direction
      get_option_value(:direction)
    end

    def next?
      direction == :next
    end

    def previous?
      direction == :previous
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
coveragebook_components-0.16.0 app/components/coco/navigation/pager_button/pager_button.rb
coveragebook_components-0.15.0 app/components/coco/navigation/pager_button/pager_button.rb
coveragebook_components-0.14.0 app/components/coco/navigation/pager_button/pager_button.rb
coveragebook_components-0.13.1 app/components/coco/navigation/pager_button/pager_button.rb
coveragebook_components-0.13.0 app/components/coco/navigation/pager_button/pager_button.rb