Sha256: 59ee3195465519b20318cd9f62a3415136494f026f108525883562014eafb3c7

Contents?: true

Size: 1.08 KB

Versions: 7

Compression:

Stored size: 1.08 KB

Contents

module ActiveAdmin
  module Views

    class SiteTitle < Component

      def tag_name
        'h1'
      end

      def build(namespace)
        super(id: "site_title")
        @namespace = namespace

        if site_title_link?
          text_node site_title_with_link
        else
          text_node site_title_content
        end
      end

      def site_title_link?
        @namespace.site_title_link.present?
      end

      def site_title_image?
        @namespace.site_title_image.present?
      end

      private

      def site_title_with_link
        helpers.link_to(site_title_content, @namespace.site_title_link)
      end

      def site_title_content
        if site_title_image?
          title_image
        else
          title_text
        end
      end

      def title_text
        helpers.render_or_call_method_or_proc_on(helpers, @namespace.site_title)
      end

      def title_image
        path = helpers.render_or_call_method_or_proc_on(helpers, @namespace.site_title_image)
        helpers.image_tag(path, id: "site_title_image", alt: title_text)
      end

    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
activeadmin-1.3.1 lib/active_admin/views/components/site_title.rb
activeadmin-1.3.0 lib/active_admin/views/components/site_title.rb
activeadmin-1.2.1 lib/active_admin/views/components/site_title.rb
activeadmin-1.2.0 lib/active_admin/views/components/site_title.rb
activeadmin-1.1.0 lib/active_admin/views/components/site_title.rb
activeadmin-1.0.0 lib/active_admin/views/components/site_title.rb
activeadmin-1.0.0.pre5 lib/active_admin/views/components/site_title.rb