Sha256: a7a4460656f8bc1c1410a8ddbd3cf7322ed7aa6ba2f832d1ce45cb126756172d

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 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 current_user
      context[:current_user]
    end

    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

2 entries across 2 versions & 1 rubygems

Version Path
decidim-core-0.16.1 app/cells/decidim/follow_button_cell.rb
decidim-core-0.16.0 app/cells/decidim/follow_button_cell.rb