Sha256: b9dcc544480a838928c39734a755896accc78536a7862729332646c67439871d

Contents?: true

Size: 1.01 KB

Versions: 29

Compression:

Stored size: 1.01 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
        @site_title_image ||= @namespace.site_title_image(helpers)
      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.present?
          title_image
        else
          title_text
        end
      end

      def title_text
        @title_text ||= @namespace.site_title(helpers)
      end

      def title_image
        helpers.image_tag(site_title_image, id: "site_title_image", alt: title_text)
      end

    end

  end
end

Version data entries

29 entries across 29 versions & 3 rubygems

Version Path
activeadmin-rb-1.6.0 lib/active_admin/views/components/site_title.rb
activeadmin-rb-1.5.2 lib/active_admin/views/components/site_title.rb
activeadmin-2.8.0 lib/active_admin/views/components/site_title.rb
activeadmin-rb-1.5.1 lib/active_admin/views/components/site_title.rb
activeadmin-2.7.0 lib/active_admin/views/components/site_title.rb
activeadmin-2.6.1 lib/active_admin/views/components/site_title.rb
activeadmin-2.6.0 lib/active_admin/views/components/site_title.rb
activeadmin-2.5.0 lib/active_admin/views/components/site_title.rb
activeadmin-2.4.0 lib/active_admin/views/components/site_title.rb
activeadmin-2.3.1 lib/active_admin/views/components/site_title.rb
activeadmin-2.3.0 lib/active_admin/views/components/site_title.rb
activeadmin-2.2.0 lib/active_admin/views/components/site_title.rb
activeadmin-2.1.0 lib/active_admin/views/components/site_title.rb
activeadmin-2.0.0 lib/active_admin/views/components/site_title.rb
activeadmin-rb-1.5.0 lib/active_admin/views/components/site_title.rb
activeadmin-2.0.0.rc2 lib/active_admin/views/components/site_title.rb
activeadmin_addons-1.7.1 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/lib/active_admin/views/components/site_title.rb
activeadmin-2.0.0.rc1 lib/active_admin/views/components/site_title.rb
activeadmin-rb-1.4.0 lib/active_admin/views/components/site_title.rb
activeadmin_addons-1.7.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/lib/active_admin/views/components/site_title.rb