Sha256: ffbe53b7d3229afad41034e7875c1e1bd325e24d8519e0d9c152a844c06344d2

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

module ZuoraConnectUi
  # General helpers for application level
  module ApplicationHelper
    def zuo_parameterize(string)
      if Rails::VERSION::STRING.start_with? '5'
        string.parameterize(separator: '_')
      else
        string.parameterize('_')
      end
    end

    def zuo_include_tag
      script_tag(type: 'module', src: anjuna(ANJUNA_VERSION, true)) +
        script_tag(nomodule: '', src: anjuna(ANJUNA_VERSION, false)) +
        link_tag(href: theme(THEME_VERSION, 'application'), rel: 'stylesheet') +
        link_tag(href: theme(THEME_VERSION, 'theme'), rel: 'stylesheet') +
        link_tag(href: theme(THEME_VERSION, 'icons'), rel: 'stylesheet')
    end

    def script_tag(attrs)
      attr_map = attrs.map { |key, value| " #{key}=\"#{value}\"" }

      "<script#{attr_map.join('')}></script>".html_safe
    end

    def anjuna(version, esm)
      "https://cdn.zuora.com/anjuna/#{version}" \
        "/core/anjuna-core/anjuna-core#{'.esm' if esm}.js"
    end

    def link_tag(attrs)
      attr_map = attrs.map { |key, value| " #{key}=\"#{value}\"" }

      "<link#{attr_map.join('')}>".html_safe
    end

    def theme(version, file)
      "https://cdn.zuora.com/theme/#{version}/css/#{file}.css"
    end

    ANJUNA_VERSION = '1.0.0-rc.7'
    THEME_VERSION = '1.0.0-rc.4'
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
zuora_connect_ui-0.9.1 app/helpers/zuora_connect_ui/application_helper.rb
zuora_connect_ui-0.9.0 app/helpers/zuora_connect_ui/application_helper.rb
zuora_connect_ui-0.8.3 app/helpers/zuora_connect_ui/application_helper.rb