Sha256: 01256c7a416e05725e5d7f1a05b2ba0f276c481b41e8aa3fd3b368782980051e

Contents?: true

Size: 1.14 KB

Versions: 6

Compression:

Stored size: 1.14 KB

Contents

module Coco
  module App
    module Layouts
      class Page < Coco::Component
        include Concerns::AcceptsOptions

        component_name :page_layout

        accepts_option :width, from: [:full, :constrained], default: :constrained

        renders_one :header
        renders_many :hidden_sections

        renders_one :previous_link, ->(**kwargs) do
          Coco::PagerLink.new(**kwargs, direction: :previous, class: "page-control-previous")
        end

        renders_one :next_link, ->(**kwargs) do
          Coco::PagerLink.new(**kwargs, direction: :next, class: "page-control-next")
        end

        renders_one :poll_controller, ->(interval) do
          Coco::PollController.new(interval: interval)
        end

        before_render do
          with_poll_controller(@poll) unless poll_controller? || @poll.nil?
          with_next_link(href: @next_page) if @next_page
          with_previous_link(href: @previous_page) if @previous_page
        end

        def initialize(poll: nil, **kwargs)
          @poll = poll
          @previous_page = kwargs[:previous]
          @next_page = kwargs[:next]
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
coveragebook_components-0.9.1 app/components/coco/app/layouts/page/page.rb
coveragebook_components-0.9.0 app/components/coco/app/layouts/page/page.rb
coveragebook_components-0.8.9 app/components/coco/app/layouts/page/page.rb
coveragebook_components-0.8.8 app/components/coco/app/layouts/page/page.rb
coveragebook_components-0.8.7 app/components/coco/app/layouts/page/page.rb
coveragebook_components-0.8.6 app/components/coco/app/layouts/page/page.rb