Sha256: e824eafe4a8b925501da794bf21de32b35a531d3c9385949702416bf2dd04531

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Decidim
  # This cell renders the button to follow the given resource.
  class FollowButtonCell < Decidim::ViewModel
    include LayoutHelper

    def show
      return if model == current_user
      render
    end

    private

    def button_classes
      return "card__button secondary text-uppercase follow-button mb-none" if inline?
      return "button secondary hollow expanded button--icon button--sc" if large?
      "button secondary hollow expanded small button--icon follow-button"
    end

    def icon_options
      return { class: "icon--small" } if inline?
      {}
    end

    # Checks whether the button will be shown inline or not. Inline buttons will
    # not have any border, and the icon will be small. This is mostly intended
    # to be used from cards.
    def inline?
      options[:inline]
    end

    # Checks whether the button will be shown large or not.
    def large?
      options[:large]
    end

    def decidim
      Decidim::Core::Engine.routes.url_helpers
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-core-0.18.1 app/cells/decidim/follow_button_cell.rb
decidim-core-0.17.2 app/cells/decidim/follow_button_cell.rb
decidim-core-0.18.0 app/cells/decidim/follow_button_cell.rb
decidim-core-0.17.1 app/cells/decidim/follow_button_cell.rb
decidim-core-0.17.0 app/cells/decidim/follow_button_cell.rb